Patch

Created Diff never expires
8 removals
Words removed17
Total words2032
Words removed (%)0.84
689 lines
9 additions
Words added13
Total words2028
Words added (%)0.64
690 lines
using System;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Text;
using System.Text;
using System.Reflection;
using System.Reflection;
using Oxide.Core;
using Oxide.Core;
using Oxide.Core.Database;
using Oxide.Core.Database;
using Oxide.Core.Plugins;
using Oxide.Core.Plugins;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Libraries.Covalence;
using Oxide.Game.Rust.Cui;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using UnityEngine;


namespace Oxide.Plugins
namespace Oxide.Plugins
{
{
[Info("ZLevels Remastered", "Default", "2.9.10")]
[Info("ZLevels Remastered", "Default", "2.9.10")]
[Description("Lets players level up as they harvest different resources and when crafting")]
[Description("Lets players level up as they harvest different resources and when crafting")]
class ZLevelsRemastered : RustPlugin
class ZLevelsRemastered : RustPlugin
{
{
#region Variables
#region Variables


[PluginReference]
[PluginReference]
Plugin EventManager;
Plugin EventManager;


bool Changed = false;
bool Changed = false;
bool initialized;
bool initialized;
bool bonusOn = false;
bool bonusOn = false;
static ZLevelsRemastered zLevels = null;
static ZLevelsRemastered zLevels = null;


Dictionary<string, ItemDefinition> CraftItems;
Dictionary<string, ItemDefinition> CraftItems;
CraftData _craftData;
CraftData _craftData;
PlayerData playerPrefs = new PlayerData();
PlayerData playerPrefs = new PlayerData();
bool newSaveDetected = false;
bool newSaveDetected = false;


private long[] levelAnnounce =
private long[] levelAnnounce =
{10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200};
{10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200};


int MaxB = 999;
int MaxB = 10001;
int MinB = 10;
int MinB = 10;


#endregion Variables
#endregion Variables


#region Config
#region Config


int gameProtocol;
int gameProtocol;
int penaltyMinutes;
int penaltyMinutes;
bool penaltyOnDeath;
bool penaltyOnDeath;
bool wipeDataOnNewSave;
bool wipeDataOnNewSave;
bool enablePermission;
bool enablePermission;
bool enableNightBonus;
bool enableNightBonus;
bool logEnabledBonusConsole;
bool logEnabledBonusConsole;
bool broadcastEnabledBonus;
bool broadcastEnabledBonus;
bool enableLevelupBroadcast;
bool enableLevelupBroadcast;
string permissionName;
string permissionName;
string permissionNameXP;
string permissionNameXP;
string pluginPrefix;
string pluginPrefix;
bool playerCuiDefaultEnabled;
bool playerCuiDefaultEnabled;
bool playerPluginDefaultEnabled;
bool playerPluginDefaultEnabled;
bool excludeWeaponsOnGather;
bool excludeWeaponsOnGather;
bool excludeJackhammerOnGather;
bool excludeJackhammerOnGather;
bool excludeChainsawOnGather;
bool excludeChainsawOnGather;
bool enableDispenserGather;
bool enableDispenserGather;
bool enableCollectiblePickup;
bool enableCollectiblePickup;
bool enableCropGather;
bool enableCropGather;


Dictionary<string, object> enabledCollectibleEntity;
Dictionary<string, object> enabledCollectibleEntity;
Dictionary<string, object> defaultMultipliers;
Dictionary<string, object> defaultMultipliers;
Dictionary<string, object> resourceMultipliers;
Dictionary<string, object> resourceMultipliers;
Dictionary<string, object> resourceMultipliersAtNight;
Dictionary<string, object> resourceMultipliersAtNight;
Dictionary<string, object> resourceMultipliersCurrent;
Dictionary<string, object> resourceMultipliersCurrent;
Dictionary<string, object> levelCaps;
Dictionary<string, object> levelCaps;
Dictionary<string, object> pointsPerHit;
Dictionary<string, object> pointsPerHit;
Dictionary<string, object> pointsPerHitAtNight;
Dictionary<string, object> pointsPerHitAtNight;
Dictionary<string, object> pointsPerHitCurrent;
Dictionary<string, object> pointsPerHitCurrent;
Dictionary<string, object> craftingDetails;
Dictionary<string, object> craftingDetails;
Dictionary<string, object> percentLostOnDeath;
Dictionary<string, object> percentLostOnDeath;
Dictionary<string, object> colors;
Dictionary<string, object> colors;


Dictionary<string, int> skillIndex;
Dictionary<string, int> skillIndex;
Dictionary<string, object> cuiColors;
Dictionary<string, object> cuiColors;
bool cuiEnabled;
bool cuiEnabled;
int cuiFontSizeLvl;
int cuiFontSizeLvl;
int cuiFontSizeBar;
int cuiFontSizeBar;
int cuiFontSizePercent;
int cuiFontSizePercent;
string cuiFontColor;
string cuiFontColor;
bool cuiTextShadow;
bool cuiTextShadow;
string cuiXpBarBackground;
string cuiXpBarBackground;
string cuiBoundsBackground;
string cuiBoundsBackground;
Dictionary<string, object> cuiPositioning;
Dictionary<string, object> cuiPositioning;


protected override void LoadDefaultConfig()
protected override void LoadDefaultConfig()
{
{
Config.Clear();
Config.Clear();
LoadVariables();
LoadVariables();
}
}


object GetConfig(string menu, string datavalue, object defaultValue)
object GetConfig(string menu, string datavalue, object defaultValue)
{
{
var data = Config[menu] as Dictionary<string, object>;
var data = Config[menu] as Dictionary<string, object>;
if (data == null)
if (data == null)
{
{
data = new Dictionary<string, object>();
data = new Dictionary<string, object>();
Config[menu] = data;
Config[menu] = data;
Changed = true;
Changed = true;
}
}
object value;
object value;
if (!data.TryGetValue(datavalue, out value))
if (!data.TryGetValue(datavalue, out value))
{
{
value = defaultValue;
value = defaultValue;
data[datavalue] = value;
data[datavalue] = value;
Changed = true;
Changed = true;
}
}
return value;
return value;
}
}


void LoadVariables()
void LoadVariables()
{
{
gameProtocol = Convert.ToInt32(GetConfig("Generic", "gameProtocol", Rust.Protocol.network));
gameProtocol = Convert.ToInt32(GetConfig("Generic", "gameProtocol", Rust.Protocol.network));
penaltyMinutes = Convert.ToInt32(GetConfig("Generic", "penaltyMinutes", 10));
penaltyMinutes = Convert.ToInt32(GetConfig("Generic", "penaltyMinutes", 10));
penaltyOnDeath = Convert.ToBoolean(GetConfig("Generic", "penaltyOnDeath", true));
penaltyOnDeath = Convert.ToBoolean(GetConfig("Generic", "penaltyOnDeath", true));
wipeDataOnNewSave = Convert.ToBoolean(GetConfig("Generic", "wipeDataOnNewSave", false));
wipeDataOnNewSave = Convert.ToBoolean(GetConfig("Generic", "wipeDataOnNewSave", false));
enablePermission = Convert.ToBoolean(GetConfig("Generic", "enablePermission", false));
enablePermission = Convert.ToBoolean(GetConfig("Generic", "enablePermission", false));
permissionName = Convert.ToString(GetConfig("Generic", "permissionName", "zlevelsremastered.use"));
permissionName = Convert.ToString(GetConfig("Generic", "permissionName", "zlevelsremastered.use"));
permissionNameXP = Convert.ToString(GetConfig("Generic", "permissionNameXP", "zlevelsremastered.noxploss"));
permissionNameXP = Convert.ToString(GetConfig("Generic", "permissionNameXP", "zlevelsremastered.noxploss"));
pluginPrefix = Convert.ToString(GetConfig("Generic", "pluginPrefix", "<color=orange>ZLevels</color>:"));
pluginPrefix = Convert.ToString(GetConfig("Generic", "pluginPrefix", "<color=orange>ZLevels</color>:"));
enableLevelupBroadcast = Convert.ToBoolean(GetConfig("Generic", "enableLevelupBroadcast", false));
enableLevelupBroadcast = Convert.ToBoolean(GetConfig("Generic", "enableLevelupBroadcast", false));
playerCuiDefaultEnabled = Convert.ToBoolean(GetConfig("Generic", "playerCuiDefaultEnabled", true));
playerCuiDefaultEnabled = Convert.ToBoolean(GetConfig("Generic", "playerCuiDefaultEnabled", true));
playerPluginDefaultEnabled = Convert.ToBoolean(GetConfig("Generic", "playerPluginDefaultEnabled", true));
playerPluginDefaultEnabled = Convert.ToBoolean(GetConfig("Generic", "playerPluginDefaultEnabled", true));
excludeWeaponsOnGather = Convert.ToBoolean(GetConfig("Generic", "exludeWeaponsOnGather", false));
excludeWeaponsOnGather = Convert.ToBoolean(GetConfig("Generic", "exludeWeaponsOnGather", false));
excludeJackhammerOnGather = Convert.ToBoolean(GetConfig("Generic", "excludeJackhammerOnGather", true));
excludeJackhammerOnGather = Convert.ToBoolean(GetConfig("Generic", "excludeJackhammerOnGather", true));
excludeChainsawOnGather = Convert.ToBoolean(GetConfig("Generic", "excludeChainsawOnGather", true));
excludeChainsawOnGather = Convert.ToBoolean(GetConfig("Generic", "excludeChainsawOnGather", true));


enableDispenserGather = Convert.ToBoolean(GetConfig("Functions", "enableDispenserGather", true));
enableDispenserGather = Convert.ToBoolean(GetConfig("Functions", "enableDispenserGather", true));
enableCollectiblePickup = Convert.ToBoolean(GetConfig("Functions", "enableCollectiblePickup", true));
enableCollectiblePickup = Convert.ToBoolean(GetConfig("Functions", "enableCollectiblePickup", true));
enableCropGather = Convert.ToBoolean(GetConfig("Functions", "enableCropGather", true));
enableCropGather = Convert.ToBoolean(GetConfig("Functions", "enableCropGather", true));


enabledCollectibleEntity = (Dictionary<string, object>)GetConfig("Functions", "CollectibleEntitys", new Dictionary<string, object>());
enabledCollectibleEntity = (Dictionary<string, object>)GetConfig("Functions", "CollectibleEntitys", new Dictionary<string, object>());


defaultMultipliers = (Dictionary<string, object>)GetConfig("Settings", "DefaultResourceMultiplier", new Dictionary<string, object>{
defaultMultipliers = (Dictionary<string, object>)GetConfig("Settings", "DefaultResourceMultiplier", new Dictionary<string, object>{
{Skills.WOODCUTTING, 1},
{Skills.WOODCUTTING, 1},
{Skills.MINING, 1},
{Skills.MINING, 1},
{Skills.SKINNING, 1},
{Skills.SKINNING, 1},
{Skills.ACQUIRE, 1}
{Skills.ACQUIRE, 1}
});
});


resourceMultipliers = (Dictionary<string, object>)GetConfig("Settings", "ResourcePerLevelMultiplier", new Dictionary<string, object>{
resourceMultipliers = (Dictionary<string, object>)GetConfig("Settings", "ResourcePerLevelMultiplier", new Dictionary<string, object>{
{Skills.WOODCUTTING, 2},
{Skills.WOODCUTTING, 2},
{Skills.MINING, 2},
{Skills.MINING, 2},
{Skills.SKINNING, 2},
{Skills.SKINNING, 2},
{Skills.ACQUIRE, 2}
{Skills.ACQUIRE, 2}
});
});
levelCaps = (Dictionary<string, object>)GetConfig("Settings", "LevelCaps", new Dictionary<string, object>{
levelCaps = (Dictionary<string, object>)GetConfig("Settings", "LevelCaps", new Dictionary<string, object>{
{Skills.WOODCUTTING, 200},
{Skills.WOODCUTTING, 200},
{Skills.MINING, 200},
{Skills.MINING, 200},
{Skills.SKINNING, 200},
{Skills.SKINNING, 200},
{Skills.ACQUIRE, 200},
{Skills.ACQUIRE, 200},
{Skills.CRAFTING, -1}
{Skills.CRAFTING, -1}


});
});
pointsPerHit = (Dictionary<string, object>)GetConfig("Settings", "PointsPerHit", new Dictionary<string, object>{
pointsPerHit = (Dictionary<string, object>)GetConfig("Settings", "PointsPerHit", new Dictionary<string, object>{
{Skills.WOODCUTTING, 30},
{Skills.WOODCUTTING, 30},
{Skills.MINING, 30},
{Skills.MINING, 30},
{Skills.SKINNING, 30},
{Skills.SKINNING, 30},
{Skills.ACQUIRE, 30}
{Skills.ACQUIRE, 30}
});
});
craftingDetails = (Dictionary<string, object>)GetConfig("Settings", "CraftingDetails", new Dictionary<string, object>{
craftingDetails = (Dictionary<string, object>)GetConfig("Settings", "CraftingDetails", new Dictionary<string, object>{
{ "TimeSpent", 1},
{ "TimeSpent", 1},
{ "XPPerTimeSpent", 3},
{ "XPPerTimeSpent", 3},
{ "PercentFasterPerLevel", 5 }
{ "PercentFasterPerLevel", 5 }
});
});
percentLostOnDeath = (Dictionary<string, object>)GetConfig("Settings", "PercentLostOnDeath", new Dictionary<string, object>{
percentLostOnDeath = (Dictionary<string, object>)GetConfig("Settings", "PercentLostOnDeath", new Dictionary<string, object>{
{Skills.WOODCUTTING, 50},
{Skills.WOODCUTTING, 50},
{Skills.MINING, 50},
{Skills.MINING, 50},
{Skills.SKINNING, 50},
{Skills.SKINNING, 50},
{Skills.ACQUIRE, 50},
{Skills.ACQUIRE, 50},
{Skills.CRAFTING, 50}
{Skills.CRAFTING, 50}
});
});
colors = (Dictionary<string, object>)GetConfig("Settings", "SkillColors", new Dictionary<string, object>()
colors = (Dictionary<string, object>)GetConfig("Settings", "SkillColors", new Dictionary<string, object>()
{
{
{Skills.WOODCUTTING, "#FFDDAA"},
{Skills.WOODCUTTING, "#FFDDAA"},
{Skills.MINING, "#DDDDDD"},
{Skills.MINING, "#DDDDDD"},
{Skills.SKINNING, "#FFDDDD"},
{Skills.SKINNING, "#FFDDDD"},
{Skills.ACQUIRE, "#ADD8E6"},
{Skills.ACQUIRE, "#ADD8E6"},
{Skills.CRAFTING, "#CCFF99"}
{Skills.CRAFTING, "#CCFF99"}
});
});
cuiColors = (Dictionary<string, object>)GetConfig("CUI", "XpBarColors", new Dictionary<string, object>()
cuiColors = (Dictionary<string, object>)GetConfig("CUI", "XpBarColors", new Dictionary<string, object>()
{
{
{Skills.WOODCUTTING, "0.8 0.4 0 0.5"},
{Skills.WOODCUTTING, "0.8 0.4 0 0.5"},
{Skills.MINING, "0.1 0.5 0.8 0.5"},
{Skills.MINING, "0.1 0.5 0.8 0.5"},
{Skills.SKINNING, "0.8 0.1 0 0.5"},
{Skills.SKINNING, "0.8 0.1 0 0.5"},
{Skills.ACQUIRE, "0 0.8 0 0.5"},
{Skills.ACQUIRE, "0 0.8 0 0.5"},
{Skills.CRAFTING, "0.2 0.72 0.5 0.5"}
{Skills.CRAFTING, "0.2 0.72 0.5 0.5"}
});
});
cuiEnabled = Convert.ToBoolean(GetConfig("CUI", "cuiEnabled", true));
cuiEnabled = Convert.ToBoolean(GetConfig("CUI", "cuiEnabled", true));
cuiFontSizeLvl = Convert.ToInt32(GetConfig("CUI", "FontSizeLevel", 11));
cuiFontSizeLvl = Convert.ToInt32(GetConfig("CUI", "FontSizeLevel", 11));
cuiFontSizeBar = Convert.ToInt32(GetConfig("CUI", "FontSizeBar", 11));
cuiFontSizeBar = Convert.ToInt32(GetConfig("CUI", "FontSizeBar", 11));
cuiFontSizePercent = Convert.ToInt32(GetConfig("CUI", "FontSizePercent", 11));
cuiFontSizePercent = Convert.ToInt32(GetConfig("CUI", "FontSizePercent", 11));
cuiTextShadow = Convert.ToBoolean(GetConfig("CUI", "TextShadowEnabled", true));
cuiTextShadow = Convert.ToBoolean(GetConfig("CUI", "TextShadowEnabled", true));
cuiFontColor = Convert.ToString(GetConfig("CUI", "FontColor", "0.74 0.76 0.78 1"));
cuiFontColor = Convert.ToString(GetConfig("CUI", "FontColor", "0.74 0.76 0.78 1"));
cuiXpBarBackground = Convert.ToString(GetConfig("CUI", "XpBarBackground", "0.2 0.2 0.2 0.2"));
cuiXpBarBackground = Convert.ToString(GetConfig("CUI", "XpBarBackground", "0.2 0.2 0.2 0.2"));
cuiBoundsBackground = Convert.ToString(GetConfig("CUI", "BoundsBackground", "0.1 0.1 0.1 0.1"));
cuiBoundsBackground = Convert.ToString(GetConfig("CUI", "BoundsBackground", "0.1 0.1 0.1 0.1"));
cuiPositioning = (Dictionary<string, object>)GetConfig("CUI", "Bounds", new Dictionary<string, object>()
cuiPositioning = (Dictionary<string, object>)GetConfig("CUI", "Bounds", new Dictionary<string, object>()
{
{
{"WidthLeft", "0.725"},
{"WidthLeft", "0.725"},
{"WidthRight", "0.83"},
{"WidthRight", "0.83"},
{"HeightLower", "0.02"},
{"HeightLower", "0.02"},
{"HeightUpper", "0.1225"}
{"HeightUpper", "0.1225"}
});
});


pointsPerHitAtNight = (Dictionary<string, object>)GetConfig("NightBonus", "PointsPerHitAtNight", new Dictionary<string, object>{
pointsPerHitAtNight = (Dictionary<string, object>)GetConfig("NightBonus", "PointsPerHitAtNight", new Dictionary<string, object>{
{Skills.WOODCUTTING, 60},
{Skills.WOODCUTTING, 60},
{Skills.MINING, 60},
{Skills.MINING, 60},
{Skills.SKINNING, 60},
{Skills.SKINNING, 60},
{Skills.ACQUIRE, 60}
{Skills.ACQUIRE, 60}
});
});
resourceMultipliersAtNight = (Dictionary<string, object>)GetConfig("NightBonus", "ResourcePerLevelMultiplierAtNight", new Dictionary<string, object>{
resourceMultipliersAtNight = (Dictionary<string, object>)GetConfig("NightBonus", "ResourcePerLevelMultiplierAtNight", new Dictionary<string, object>{
{Skills.WOODCUTTING, 2},
{Skills.WOODCUTTING, 2},
{Skills.MINING, 2},
{Skills.MINING, 2},
{Skills.SKINNING, 2},
{Skills.SKINNING, 2},
{Skills.ACQUIRE, 2}
{Skills.ACQUIRE, 2}
});
});
enableNightBonus = Convert.ToBoolean(GetConfig("NightBonus", "enableNightBonus", false));
enableNightBonus = Convert.ToBoolean(GetConfig("NightBonus", "enableNightBonus", false));
logEnabledBonusConsole = Convert.ToBoolean(GetConfig("NightBonus", "logEnabledBonusConsole", false));
logEnabledBonusConsole = Convert.ToBoolean(GetConfig("NightBonus", "logEnabledBonusConsole", false));
broadcastEnabledBonus = Convert.ToBoolean(GetConfig("NightBonus", "broadcastEnabledBonus", true));
broadcastEnabledBonus = Convert.ToBoolean(GetConfig("NightBonus", "broadcastEnabledBonus", true));


if (!Changed) return;
if (!Changed) return;
SaveConfig();
SaveConfig();
Changed = false;
Changed = false;
}
}


protected override void LoadDefaultMessages()
protected override void LoadDefaultMessages()
{
{
lang.RegisterMessages(new Dictionary<string, string>
lang.RegisterMessages(new Dictionary<string, string>
{
{
{"StatsHeadline", "Level stats (/statinfo - To get more information about skills)"},
{"StatsHeadline", "Level stats (/statinfo - To get more information about skills)"},
{"StatsText", "-{0}\nLevel: {1} (+{4}% bonus) \nXP: {2}/{3} [{5}].\n<color=red>-{6} XP loose on death.</color>"},
{"StatsText", "-{0}\nLevel: {1} (+{4}% bonus) \nXP: {2}/{3} [{5}].\n<color=red>-{6} XP loose on death.</color>"},
{"LevelUpText", "{0} Level up\nLevel: {1} (+{4}% bonus) \nXP: {2}/{3}"},
{"LevelUpText", "{0} Level up\nLevel: {1} (+{4}% bonus) \nXP: {2}/{3}"},
{"LevelUpTextBroadcast", "<color=#5af>{0}</color> has reached level <color=#5af>{1}</color> in <color={2}>{3}</color>"},
{"LevelUpTextBroadcast", "<color=#5af>{0}</color> has reached level <color=#5af>{1}</color> in <color={2}>{3}</color>"},
{"PenaltyText", "<color=orange>You have lost XP for dying:{0}</color>"},
{"PenaltyText", "<color=orange>You have lost XP for dying:{0}</color>"},
{"NoPermission", "You don't have permission to use this command"},
{"NoPermission", "You don't have permission to use this command"},
{"WCSkill", "Woodcutting"},
{"WCSkill", "Woodcutting"},
{"MSkill", "Mining"},
{"MSkill", "Mining"},
{"SSkill", "Skinning"},
{"SSkill", "Skinning"},
{"CSkill", "Crafting" },
{"CSkill", "Crafting" },
{"ASkill", "Acquire" },
{"ASkill", "Acquire" },
{"NightBonusOn", "Nightbonus for points per hit enabled"},
{"NightBonusOn", "Nightbonus for points per hit enabled"},
{"NightBonusOff", "Nightbonus for points per hit disabled"},
{"NightBonusOff", "Nightbonus for points per hit disabled"},
{"PluginPlayerOn", "The plugin functions are now enabled again"},
{"PluginPlayerOn", "The plugin functions are now enabled again"},
{"PluginPlayerOff", "The plugin functions are now disabled for your character"},
{"PluginPlayerOff", "The plugin functions are now disabled for your character"},
},this);
},this);
}
}


#endregion Config
#endregion Config


#region Main
#region Main


void Init()
void Init()
{
{
LoadVariables();
LoadVariables();
LoadDefaultMessages();
LoadDefaultMessages();
initialized = false;
initialized = false;
try {
try {
if ((int)levelCaps[Skills.CRAFTING] > 20)
if ((int)levelCaps[Skills.CRAFTING] > 20)
levelCaps[Skills.CRAFTING] = 20;
levelCaps[Skills.CRAFTING] = 20;
}
}
catch
catch
{
{
// ignored
// ignored
}
}


if (!permission.PermissionExists(permissionName)) permission.RegisterPermission(permissionName, this);
if (!permission.PermissionExists(permissionName)) permission.RegisterPermission(permissionName, this);
if (!permission.PermissionExists(permissionNameXP)) permission.RegisterPermission(permissionNameXP, this);
if (!permission.PermissionExists(permissionNameXP)) permission.RegisterPermission(permissionNameXP, this);
if ((_craftData = Interface.GetMod().DataFileSystem.ReadObject<CraftData>("ZLevelsCraftDetails")) == null)
if ((_craftData = Interface.GetMod().DataFileSystem.ReadObject<CraftData>("ZLevelsCraftDetails")) == null || !_craftData.CraftList.Any())
_craftData = new CraftData();
{
GenerateItems(true);
_craftData = Interface.GetMod().DataFileSystem.ReadObject<CraftData>("ZLevelsCraftDetails");
}
var index = 0;
var index = 0;
skillIndex = new Dictionary<string,int>();
skillIndex = new Dictionary<string,int>();
foreach (var skill in Skills.ALL)
foreach (var skill in Skills.ALL)
if (IsSkillEnabled(skill))
if (IsSkillEnabled(skill))
skillIndex.Add(skill, ++index);
skillIndex.Add(skill, ++index);
}
}


void Loaded() => zLevels = this;
void Loaded() => zLevels = this;


void OnServerSave()
void OnServerSave()
{
{
if (initialized)
if (initialized)
SaveData();
SaveData();
}
}


void Unload()
void Unload()
{
{
if (!initialized)
if (!initialized)
return;
return;
SaveData();
SaveData();
foreach (var player in BasePlayer.activePlayerList)
foreach (var player in BasePlayer.activePlayerList)
DestroyGUI(player);
DestroyGUI(player);
}
}


void OnNewSave(string strFilename)
void OnNewSave(string strFilename)
{
{
if (wipeDataOnNewSave)
if (wipeDataOnNewSave)
newSaveDetected = true;
newSaveDetected = true;
}
}


void SaveData() => Interface.Oxide.DataFileSystem.WriteObject(this.Name, playerPrefs);
void SaveData() => Interface.Oxide.DataFileSystem.WriteObject(this.Name, playerPrefs);


void OnServerInitialized()
void OnServerInitialized()
{
{
CheckCollectible();
CheckCollectible();
playerPrefs = Interface.GetMod().DataFileSystem.ReadObject<PlayerData>(this.Name) ?? new PlayerData();
playerPrefs = Interface.GetMod().DataFileSystem.ReadObject<PlayerData>(this.Name) ?? new PlayerData();
if (newSaveDetected || (playerPrefs == null || playerPrefs.PlayerInfo == null || playerPrefs.PlayerInfo.Count == 0))
if (newSaveDetected || (playerPrefs == null || playerPrefs.PlayerInfo == null || playerPrefs.PlayerInfo.Count == 0))
{
{
playerPrefs = new PlayerData();
playerPrefs = new PlayerData();
SaveData();
SaveData();
}
}
pointsPerHitCurrent = pointsPerHit;
pointsPerHitCurrent = pointsPerHit;
resourceMultipliersCurrent = resourceMultipliers;
resourceMultipliersCurrent = resourceMultipliers;
if (enableNightBonus && TOD_Sky.Instance.IsNight)
if (enableNightBonus && TOD_Sky.Instance.IsNight)
{
{
pointsPerHitCurrent = pointsPerHitAtNight;
pointsPerHitCurrent = pointsPerHitAtNight;
resourceMultipliersCurrent = resourceMultipliersAtNight;
resourceMultipliersCurrent = resourceMultipliersAtNight;
bonusOn = true;
bonusOn = true;
}
}
initialized = true;
initialized = true;
foreach (var player in BasePlayer.activePlayerList)
foreach (var player in BasePlayer.activePlayerList)
{
{
if (player != null)
if (player != null)
{
{
UpdatePlayer(player);
UpdatePlayer(player);
if (cuiEnabled)
if (cuiEnabled)
CreateGUI(player);
CreateGUI(player);
}
}
}
}
foreach (var player in BasePlayer.sleepingPlayerList)
foreach (var player in BasePlayer.sleepingPlayerList)
{
{
if (player != null)
if (player != null)
UpdatePlayer(player);
UpdatePlayer(player);
}
}
SaveData();
SaveData();
Puts("Stats can be reset by > zl.reset <");
Puts("Stats can be reset by > zl.reset <");
}
}


void CheckCollectible()
void CheckCollectible()
{
{
var collectList = Resources.FindObjectsOfTypeAll<CollectibleEntity>().Select(c => c.ShortPrefabName).Distinct().ToList();
var collectList = Resources.FindObjectsOfTypeAll<CollectibleEntity>().Select(c => c.ShortPrefabName).Distinct().ToList();
if (collectList == null || collectList.Count == 0)
if (collectList == null || collectList.Count == 0)
return;
return;
if (enabledCollectibleEntity == null)
if (enabledCollectibleEntity == null)
enabledCollectibleEntity = new Dictionary<string, object>();
enabledCollectibleEntity = new Dictionary<string, object>();
bool updated = false;
bool updated = false;
foreach (var collect in collectList)
foreach (var collect in collectList)
{
{
if (!enabledCollectibleEntity.ContainsKey(collect))
if (!enabledCollectibleEntity.ContainsKey(collect))
{
{
enabledCollectibleEntity.Add(collect, true);
enabledCollectibleEntity.Add(collect, true);
updated = true;
updated = true;
}
}
}
}
if (updated)
if (updated)
{
{
Config["Functions", "CollectibleEntitys"] = enabledCollectibleEntity;
Config["Functions", "CollectibleEntitys"] = enabledCollectibleEntity;
Config.Save();
Config.Save();
}
}
}
}


#endregion Main
#endregion Main


#region Classes
#region Classes


class Skills
class Skills
{
{
public static string CRAFTING = "C";
public static string CRAFTING = "C";
public static string WOODCUTTING = "WC";
public static string WOODCUTTING = "WC";
public static string SKINNING = "S";
public static string SKINNING = "S";
public static string MINING = "M";
public static string MINING = "M";
public static string ACQUIRE = "A";
public static string ACQUIRE = "A";
public static string[] ALL = { WOODCUTTING, MINING, SKINNING, ACQUIRE, CRAFTING };
public static string[] ALL = { WOODCUTTING, MINING, SKINNING, ACQUIRE, CRAFTING };
}
}


class CraftData
class CraftData
{
{
public Dictionary<string, CraftInfo> CraftList = new Dictionary<string, CraftInfo>();
public Dictionary<string, CraftInfo> CraftList = new Dictionary<string, CraftInfo>();
}
}


class CraftInfo
class CraftInfo
{
{
public int MaxBulkCraft;
public int MaxBulkCraft;
public int MinBulkCraft;
public int MinBulkCraft;
public string shortName;
public string shortName;
public bool Enabled;
public bool Enabled;
}
}


class PlayerData
class PlayerData
{
{
public Dictionary<ulong, PlayerInfo> PlayerInfo = new Dictionary<ulong, PlayerInfo>();
public Dictionary<ulong, PlayerInfo> PlayerInfo = new Dictionary<ulong, PlayerInfo>();
public PlayerData(){}
public PlayerData(){}
}
}


class PlayerInfo
class PlayerInfo
{
{
public long WCL = 1;
public long WCL = 1;
public long WCP = 10;
public long WCP = 10;
public long ML = 1;
public long ML = 1;
public long MP = 10;
public long MP = 10;
public long SL = 1;
public long SL = 1;
public long SP = 10;
public long SP = 10;
public long AL = 1;
public long AL = 1;
public long AP = 10;
public long AP = 10;
public long CL = 1;
public long CL = 1;
public long CP = 10;
public long CP = 10;
public long LD;
public long LD;
public long LLD;
public long LLD;
public long XPM = 100;
public long XPM = 100;
public bool CUI = true;
public bool CUI = true;
public bool ONOFF = true;
public bool ONOFF = true;
}
}


#endregion Classes
#endregion Classes


#region Serverhooks
#region Serverhooks


void OnPlayerConnected(BasePlayer player)
void OnPlayerConnected(BasePlayer player)
{
{
if (!initialized || player == null || !IsValid(player)) return;
if (!initialized || player == null || !IsValid(player)) return;
UpdatePlayer(player);
UpdatePlayer(player);
CreateGUI(player);
CreateGUI(player);
/*
/*
long multiplier = 100;
long multiplier = 100;
var playerPermissions = permission.GetUserPermissions(player.UserIDString);
var playerPermissions = permission.GetUserPermissions(player.UserIDString);
if (playerPermissions.Any(x => x.ToLower().StartsWith("zlvlboost")))
if (playerPermissions.Any(x => x.ToLower().StartsWith("zlvlboost")))
{
{
var perm = playerPermissions.First(x => x.ToLower().StartsWith("zlvlboost"));
var perm = playerPermissions.First(x => x.ToLower().StartsWith("zlvlboost"));
if (!long.TryParse(perm.ToLower().Replace("zlvlboost", ""), out multiplier))
if (!long.TryParse(perm.ToLower().Replace("zlvlboost", ""), out multiplier))
multiplier = 100;
multiplier = 100;
}
}
editMultiplierForPlayer(multiplier, player.userID);
editMultiplierForPlayer(multiplier, player.userID);
*/
*/
}
}


void OnPlayerDisconnected(BasePlayer player)
void OnPlayerDisconnected(BasePlayer player)
{
{
if (initialized && player != null)
if (initialized && player != null)
UpdatePlayer(player);
UpdatePlayer(player);
}
}


void UpdatePlayer(BasePlayer player)
void UpdatePlayer(BasePlayer player)
{
{
PlayerInfo p = null;
PlayerInfo p = null;
if (!playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
if (!playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
{
{
var info = new PlayerInfo();
var info = new PlayerInfo();
info.LD = ToEpochTime(DateTime.UtcNow);
info.LD = ToEpochTime(DateTime.UtcNow);
info.LLD = ToEpochTime(DateTime.UtcNow);
info.LLD = ToEpochTime(DateTime.UtcNow);
info.CUI = playerCuiDefaultEnabled;
info.CUI = playerCuiDefaultEnabled;
info.ONOFF = playerPluginDefaultEnabled;
info.ONOFF = playerPluginDefaultEnabled;
playerPrefs.PlayerInfo.Add(player.userID, info);
playerPrefs.PlayerInfo.Add(player.userID, info);
return;
return;
}
}
else
else
p.LLD = ToEpochTime(DateTime.UtcNow);
p.LLD = ToEpochTime(DateTime.UtcNow);
}
}


void CheckPlayer(BasePlayer player)
void CheckPlayer(BasePlayer player)
{
{
PlayerInfo p = null;
PlayerInfo p = null;
if (!playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
if (!playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
UpdatePlayer(player);
UpdatePlayer(player);
}
}


void OnPlayerSleepEnded(BasePlayer player)
void OnPlayerSleepEnded(BasePlayer player)
{
{
if (!initialized || player == null) return;
if (!initialized || player == null) return;
PlayerInfo p = null;
PlayerInfo p = null;
if (playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
if (playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
CreateGUI(player);
CreateGUI(player);
else
else
{
{
UpdatePlayer(player);
UpdatePlayer(player);
CreateGUI(player);
CreateGUI(player);
}
}
}
}


void OnPlayerSleep(BasePlayer player)
void OnPlayerSleep(BasePlayer player)
{
{
if (!initialized || player == null) return;
if (!initialized || player == null) return;
PlayerInfo p = null;
PlayerInfo p = null;
if (playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
if (playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
DestroyGUI(player);
DestroyGUI(player);
}
}


void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
{
if (!initialized || entity == null || !(entity is BasePlayer) || !IsValid((BasePlayer) entity)) return;
if (!initialized || entity == null || !(entity is BasePlayer) || !IsValid((BasePlayer) entity)) return;
NextTick(()=>{
NextTick(()=>{
if (entity != null && entity.health <= 0f) DestroyGUI(entity as BasePlayer);
if (entity != null && entity.health <= 0f) DestroyGUI(entity as BasePlayer);
});
});
}
}


void OnEntityDeath(BaseCombatEntity entity, HitInfo hitInfo)
void OnEntityDeath(BaseCombatEntity entity, HitInfo hitInfo)
{
{
if (!initialized || !penaltyOnDeath || entity == null || !(entity is BasePlayer) || !IsValid(entity as BasePlayer))
if (!initialized || !penaltyOnDeath || entity == null || !(entity is BasePlayer) || !IsValid(entity as BasePlayer))
return;
return;
var player = entity as BasePlayer;
var player = entity as BasePlayer;
CheckPlayer(player);
CheckPlayer(player);
if (!playerPrefs.PlayerInfo[player.userID].ONOFF)
if (!playerPrefs.PlayerInfo[player.userID].ONOFF)
return;
return;
if (Interface.CallHook("CanBePenalized", player) != null)
if (Interface.CallHook("CanBePenalized", player) != null)
return;
return;
PlayerInfo p = null;
PlayerInfo p = null;
if (!hasRights(player.UserIDString) || !playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
if (!hasRights(player.UserIDString) || !playerPrefs.PlayerInfo.TryGetValue(player.userID, out p))
return;
return;
if (EventManager?.Call("isPlaying", player) != null && (bool)EventManager?.Call("isPlaying", player))
if (EventManager?.Call("isPlaying", player) != null && (bool)EventManager?.Call("isPlaying", player))
return;
return;
if (hitInfo != null && hitInfo.damageTypes != null && hitInfo.damageTypes.Has(Rust.DamageType.Suicide))
if (hitInfo != null && hitInfo.damageTypes != null && hitInfo.damageTypes.Has(Rust.DamageType.Suicide))
return;
return;
if (permission.UserHasPermission(player.UserIDString, permissionNameXP))
if (permission.UserHasPermission(player.UserIDString, permissionNameXP))
return;
return;
var penaltyText = string.Empty;
var penaltyText = string.Empty;
var penaltyExist = false;
var penaltyExist = false;
foreach (var skill in Skills.ALL)
foreach (var skill in Skills.ALL)
if (IsSkillEnabled(skill))
if (IsSkillEnabled(skill))
{
{
var penalty = GetPenalty(player, skill);
var penalty = GetPenalty(player, skill);
if (penalty > 0)
if (penalty > 0)
{
{
penaltyText += "\n* -" + penalty + " " + msg(skill + "Skill") + " XP.";
penaltyText += "\n* -" + penalty + " " + msg(skill + "Skill") + " XP.";
removePoints(player.userID, skill, penalty);
removePoints(player.userID, skill, penalty);
penaltyExist = true;
penaltyExist = true;
}
}
}
}
if (penaltyExist)
if (penaltyExist)
PrintToChat(player, string.Format(msg("PenaltyText", player.UserIDString), penaltyText));
PrintToChat(player, string.Format(msg("PenaltyText", player.UserIDString), penaltyText));
playerPrefs.PlayerInfo[player.userID].LD = ToEpochTime(DateTime.UtcNow);
playerPrefs.PlayerInfo[player.userID].LD = ToEpochTime(DateTime.UtcNow);
}
}


void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
{
{
if (!initialized || !enableDispenserGather || entity == null || !(entity is BasePlayer) || item == null || dispenser == null)
if (!initialized || !enableDispenserGather || entity == null || !(entity is BasePlayer) || item == null || dispenser == null)
return;
return;
var player = entity as BasePlayer;
var player = entity as BasePlayer;
CheckPlayer(player);
CheckPlayer(player);
if (!playerPrefs.PlayerInfo[player.userID].ONOFF || excludeWeaponsOnGather && player.GetActiveItem()?.info?.category == ItemCategory.Weapon)
if (!playerPrefs.PlayerInfo[player.userID].ONOFF || excludeWeaponsOnGather && player.GetActiveItem()?.info?.category == ItemCategory.Weapon)
return;
return;
if (!hasRights(player.UserIDString))
if (!hasRights(player.UserIDString))
return;
return;
if (excludeJackhammerOnGather && player.GetHeldEntity() is Jackhammer || excludeChainsawOnGather && player.GetHeldEntity() is Chainsaw)
if (excludeJackhammerOnGather && player.GetHeldEntity() is Jackhammer || excludeChainsawOnGather && player.GetHeldEntity() is Chainsaw)
return;
return;
if (IsSkillEnabled(Skills.WOODCUTTING) &&(int)dispenser.gatherType == 0) levelHandler(player, item, Skills.WOODCUTTING);
if (IsSkillEnabled(Skills.WOODCUTTING) &&(int)dispenser.gatherType == 0) levelHandler(player, item, Skills.WOODCUTTING);
if (IsSkillEnabled(Skills.MINING) && (int)dispenser.gatherType == 1) levelHandler(player, item, Skills.MINING);
if (IsSkillEnabled(Skills.MINING) && (int)dispenser.gatherType == 1) levelHandler(player, item, Skills.MINING);
if (IsSkillEnabled(Skills.SKINNING) && (int)dispenser.gatherType == 2) levelHandler(player, item, Skills.SKINNING);
if (IsSkillEnabled(Skills.SKINNING) && (int)dispenser.gatherType == 2) levelHandler(player, item, Skills.SKINNING);
}
}


void OnDispenserBonus(ResourceDispenser dispenser, BaseEntity entity, Item item) => OnDispenserGather(dispenser, entity, item);
void OnDispenserBonus(ResourceDispenser dispenser, BaseEntity entity, Item item) => OnDispenserGather(dispenser, entity, item);


void OnCollectiblePickup(Item item, BasePlayer player, CollectibleEntity entity)
void OnCollectiblePickup(Item item, BasePlayer player, CollectibleEntity entity)
{
{
if (!initialized || !enableCollectiblePickup || item == null || player == null || !hasRights(player.UserIDString))
if (!initialized || !enableCollectiblePickup || item == null || player == null || !hasRights(player.UserIDString))
return;
return;
CheckPlayer(player);
CheckPlayer(player);
if (!playerPrefs.PlayerInfo[player.userID].ONOFF)
if (!playerPrefs.PlayerInfo[player.userID].ONOFF)
return;
return;
if (enabledCollectibleEntity.ContainsKey(entity.ShortPrefabName) && (bool)enabledCollectibleEntity[entity.ShortPrefabName] == false)
if (enabledCollectibleEntity.ContainsKey(entity.ShortPrefabName) && (bool)enabledCollectibleEntity[entity.ShortPrefabName] == false)
return;
return;
var skillName = string.Empty;
var skillName = string.Empty;


if (IsSkillDisabled(Skills.ACQUIRE))
if (IsSkillDisabled(Skills.ACQUIRE))
{
{
switch (item.info.shortname)
switch (item.info.shortname)
{
{
case "wood":
case "wood":
skillName = Skills.WOODCUTTING;
skillName = Skills.WOODCUTTING;
break;
break;
case "cloth":
case "cloth":
case "mushroom":
case "mushroom":
case "corn":
case "corn":
case "pumpkin":
case "pumpkin":
case "seed.hemp":
case "seed.hemp":
case "seed.pumpkin":
case "seed.pumpkin":
case "seed.corn":
case "seed.corn":
skillName = Skills.SKINNING;
skillName = Skills.SKINNING;
break;
break;
case "metal.ore":
case "metal.ore":
case "sulfur.ore":
case "sulfur.ore":
case "stones":
case "stones":
skillName = Skills.MINING;
skillName = Skills.MINING;
break;
break;
}
}
}
}
else
else
skillName = Skills.ACQUIRE;
skillName = Skills.ACQUIRE;


if (!string.IsNullOrEmpty(skillName))
if (!string.IsNullOrEmpty(skillName))
levelHandler(player, item, skillName);
levelHandler(player, item, skillName);
}
}


void OnTimeSunset()
void OnTimeSunset()
{
{
if (!enableNightBonus || bonusOn) return;
if (!enableNightBonus || bonusOn) return;
bonusOn = true;
bonusOn = true;
pointsPerHitCurrent = pointsPerHitAtNight;
pointsPerHitCurrent = pointsPerHitAtNight;
resourceMultipliersCurrent = resourceMultipliersAtNight;
resourceMultipliersCurrent = resourceMultipliersAtNight;
if (broadcastEnabledBonus)
if (broadcastEnabledBonus)
Server.Broadcast(pluginPrefix + " "+ msg("NightBonusOn"));
Server.Broadcast(pluginPrefix + " "+ msg("NightBonusOn"));
if (logEnabledBonusConsole)
if (logEnabledBonusConsole)
Puts("Nightbonus points enabled");
Puts("Nightbonus points enabled");
}
}


void OnTimeSunrise()
void OnTimeSunrise()
{
{
if (!enableNightBonus || !bonusOn) return;
if (!enableNightBonus || !bonusOn) return;
bonusOn = false;
bonusOn = false;
pointsPerHitCurrent = pointsPerHit;
pointsPerHitCurrent = pointsPerHit;
resourceMultipliersCurrent = resourceMultipliers;
resourceMultipliersCurrent = resourceMultipliers;
if (broadcastEnabledBonus)
if (broadcastEnabledBonus)
Server.Broadcast(pluginPrefix + " "+ msg("NightBonusOff"));
Server.Broadcast(pluginPrefix + " "+ msg("NightBonusOff"));
if (logEnabledBonusConsole)
if (logEnabledBonusConsole)
Puts("Nightbonus points disabled");
Puts("Nightbonus points disabled");
}
}


void OnGrowableGathered(GrowableEntity growable, Item item, BasePlayer player)
void OnGrowableGathered(GrowableEntity growable, Item item, BasePlayer player)
{
{
if (!initialized || !enableCropGather || item == null || player == null || !hasRights(player.UserIDString) || !playerPrefs.PlayerInfo[player.userID].ONOFF) return;
if (!initialized || !enableCropGather || item == null || player == null || !hasRights(player.UserIDString) || !playerPrefs.PlayerInfo[player.userID].ONOFF) return;
var skillName = string.Empty;
var skillName = string.Empty;
if (IsSkillDisabled(Skills.ACQUIRE))
if (IsSkillDisabled(Skills.ACQUIRE))
skillName = Skills.SKINNING;
skillName = Skills.SKINNING;
else
else
skillName = Skills.ACQUIRE;
skillName = Skills.ACQUIRE;
levelHandler(player, item, skillName);
levelHandler(player, item, skillName);
}
}


object OnItemCraft(ItemCraftTask task, BasePlayer crafter)
object OnItemCraft(ItemCraftTask task, BasePlayer crafter)
{
{
if (!initialized || IsSkillDisabled(Skills.CRAFTING) || !hasRights(crafter.UserIDString) || !playerPrefs.PlayerInfo[crafter.userID].ONOFF) return null;
if (!initialized || IsSkillDisabled(Skills.CRAFTING) || !hasRights(crafter.UserIDString) || !playerPrefs.PlayerInfo[crafter.userID].ONOFF) return null;
var Level = getLevel(crafter.userID, Skills.CRAFTING);
var Level = getLevel(crafter.userID, Skills.CRAFTING);
var craftingTime = task.blueprint.time;
var craftingTime = task.blueprint.time;
var amountToReduce = task.blueprint.time * ((float)(Level * (int)craftingDetails["PercentFasterPerLevel"]) / 100);
var amountToReduce = task.blueprint.time * ((float)(Level * (int)craftingDetails["PercentFasterPerLevel"]) / 100);
craftingTime -= amountToReduce;
craftingTime -= amountToReduce;
if (craftingTime < 0)
if (craftingTime < 0)
craftingTime = 0;
craftingTime = 0;
if (craftingTime == 0)
if (craftingTime == 0)
{
{
try
try
{
{
foreach (var entry in _craftData.CraftList)
foreach (var entry in _craftData.CraftList)
{
{
var itemname = task.blueprint.targetItem.shortname;
var itemname = task.blueprint.targetItem.shortname;
if (entry.Value.shortName == itemname && entry.Value.Enabled)
if (entry.Value.shortName == itemname && entry.Value.Enabled)
{
{
var amount = task.amount;
var amount = task.amount;
if (amount >= entry.Value.MinBulkCraft && amount <= entry.Value.MaxBulkCraft)
if (amount >= entry.Value.MinBulkCraft && amount <= entry.Value.MaxBulkCraft)
{
{
var item = GetItem(itemname);
var item = GetItem(itemname);
var final_amount = task.blueprint.amountToCreate * amount;
var final_amount = task.blueprint.amountToCreate * amount;
var newItem = ItemManager.CreateByItemID(item.itemid, (int)final_amount);
var newItem = ItemManager.CreateByItemID(item.itemid, (int)final_amount);
crafter.inventory.GiveItem(newItem);
crafter.inventory.GiveItem(newItem);


var returnstring = "You have crafted <color=#66FF66>" + amount + "</color> <color=#66FFFF>" + item.displayName.english + "</color>\n[Batch Amount: <color=#66FF66>" + final_amount + "</color>]";
/*var returnstring = "You have crafted <color=#66FF66>" + amount + "</color> <color=#66FFFF>" + item.displayName.english + "</color>\n[Batch Amount: <color=#66FF66>" + final_amount + "</color>]";
PrintToChat(crafter, returnstring);
PrintToChat(crafter, returnstring);*/
return false;
return false;
}
}
}
}
}
}
}
}
catch
catch
{
{
GenerateItems();
GenerateItems();
}
}
}
}


if (!task.blueprint.name.Contains("(Clone)"))
if (!task.blueprint.name.Contains("(Clone)"))
task.blueprint = UnityEngine.Object.Instantiate(task.blueprint);
task.blueprint = UnityEngine.Object.Instantiate(task.blueprint);
task.blueprint.time = craftingTime;
task.blueprint.time = craftingTime;
return null;
return null;
}
}


object OnItemCraftFinished(ItemCraftTask task, Item item)
object OnItemCraftFinished(ItemCraftTask task, Item item)
{
{
if (!initialized || IsSkillDisabled(Skills.CRAFTING)) return null;
if (!initialized || IsSkillDisabled(Skills.CRAFTING)) return null;
var crafter = task.owner;
var crafter = task.owner;
if (crafter == null || !hasRights(crafter.UserIDString)) return null;
if (crafter == null || !hasRights(crafter.UserIDString)) return null;
var xpPercentBefore = getExperiencePercent(crafter, Skills.CRAFTING);
var xpPercentBefore = getExperiencePercent(crafter, Skills.CRAFTING);
if (task.blueprint == null)
if (task.blueprint == null)
{
{
Puts("There is problem obtaining task.blueprint on 'OnItemCraftFinished' hook! This is usually caused by some incompatable plugins.");
Puts("There is problem obtaining task.blueprint on 'OnItemCraftFinished' hook! This is usually caused by some incompatable plugins.");
return null;
return null;
}
}
var experienceGain = Convert.ToInt32(Math.Floor((task.blueprint.time + 0.99f) / (int)craftingDetails["TimeSpent"]));//(int)task.blueprint.time / 10;
var experienceGain = Convert.ToInt32(Math.Floor((task.blueprint.time + 0.99f
if (experienceGain == 0)