public void Invoke(ShPlayer player, string kit) { var obj = Core.Instance.KitHandler.List.FirstOrDefault(x => x.Name.Equals(kit, StringComparison.OrdinalIgnoreCase)); if (obj == null) { if (Core.Instance.Settings.Levenshtein.KitMode == Configuration.Models.SettingsModel.LevenshteinMode.None) { player.TS("expFileHandler_error_notFound", player.T(Core.Instance.KitHandler.Name), kit); return; } obj = Core.Instance.KitHandler.List.OrderByDescending(x => LevenshteinDistance.CalculateSimilarity(x.Name, kit)).FirstOrDefault(); if (Core.Instance.Settings.Levenshtein.KitMode == Configuration.Models.SettingsModel.LevenshteinMode.Suggest) { player.TS("expFileHandler_error_notFound", player.T(Core.Instance.KitHandler.Name), kit); player.TS("levenshteinSuggest", obj.Name); return; } } if (!player.svPlayer.HasPermission($"{Core.Instance.Info.GroupNamespace}.{Core.Instance.KitHandler.Name}.{obj.Name}")) { player.TS("expFileHandler_error_noPermission", player.T(Core.Instance.KitHandler.Name), obj.Name); return; } if (obj.Disabled) { player.TS("expFileHandler_error_disabled", player.T(Core.Instance.KitHandler.Name), obj.Name); return; } if (player.HasCooldown(Core.Instance.KitHandler.Name, obj.Name)) { player.TS("expFileHandler_error_cooldown", player.T(Core.Instance.KitHandler.Name), player.GetCooldown(Core.Instance.KitHandler.Name, obj.Name).ToString()); return; } if (obj.Price > 0) { if (player.MyMoneyCount() < obj.Price) { player.TS("expFileHandler_error_price", player.T(Core.Instance.KitHandler.Name), obj.Price.ToString(), player.MyMoneyCount().ToString()); return; } player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true); } obj.GiveItems(player); if (obj.Delay > 0) { player.AddCooldown(Core.Instance.KitHandler.Name, obj.Name, obj.Delay); } player.SendChatMessage( player.TC(Core.Instance.KitHandler.Name + "_received", obj.Name) + (obj.Price > 0 ? player.TC(Core.Instance.KitHandler.Name + "_received_Price", obj.Price.ToString()) : "") + (obj.Delay > 0 ? player.TC(Core.Instance.KitHandler.Name + "_received_Delay", obj.Delay.ToString()) : "")); }
public void Invoke(ShPlayer player, string warp) { var obj = Core.Instance.WarpHandler.List.FirstOrDefault(x => x.Name.Equals(warp, StringComparison.OrdinalIgnoreCase)); if (obj == null) { if (Core.Instance.Settings.Levenshtein.WarpMode == Configuration.Models.SettingsModel.LevenshteinMode.None) { player.TS("expFileHandler_error_notFound", player.T(Core.Instance.WarpHandler.Name), warp); return; } obj = Core.Instance.WarpHandler.List.OrderByDescending(x => LevenshteinDistance.CalculateSimilarity(x.Name, warp)).FirstOrDefault(); if (Core.Instance.Settings.Levenshtein.WarpMode == Configuration.Models.SettingsModel.LevenshteinMode.Suggest) { player.TS("expFileHandler_error_notFound", player.T(Core.Instance.WarpHandler.Name), warp); player.TS("levenshteinSuggest", obj.Name); return; } } if (!player.HasPermission($"{Core.Instance.Info.GroupNamespace}.{Core.Instance.WarpHandler.Name}.{obj.Name}")) { player.TS("expFileHandler_error_noPermission", player.T(Core.Instance.WarpHandler.Name), obj.Name); return; } if (obj.Disabled) { player.TS("expFileHandler_error_disabled", player.T(Core.Instance.WarpHandler.Name), obj.Name); return; } if (player.HasCooldown(Core.Instance.WarpHandler.Name, obj.Name)) { player.TS("expFileHandler_error_cooldown", player.T(Core.Instance.WarpHandler.Name), player.GetCooldown(Core.Instance.WarpHandler.Name, obj.Name).ToString()); return; } if (obj.Price > 0) { if (player.MyMoneyCount() < obj.Price) { player.TS("expFileHandler_error_price", player.T(Core.Instance.WarpHandler.Name), obj.Price.ToString(), player.MyMoneyCount().ToString()); return; } player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true); } player.GetExtendedPlayer().ResetAndSavePosition(obj.Position.SerializableVector3.ToVector3(), obj.SerializableQuaternion.ToQuaternion(), obj.Position.PlaceIndex); if (obj.Delay > 0) { player.AddCooldown(Core.Instance.WarpHandler.Name, obj.Name, obj.Delay); } player.SendChatMessage( player.T(Core.Instance.WarpHandler.Name + "_teleported", obj.Name) + (obj.Price > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Price", obj.Price.ToString()) : "") + (obj.Delay > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Delay", obj.Delay.ToString()) : "")); }
public void Invoke(ShPlayer player, string kit) { var obj = Core.Instance.KitHandler.List.FirstOrDefault(x => x.Name == kit); if (obj == null) { player.TS("expFileHandler_error_notFound", player.T(Core.Instance.KitHandler.Name), kit); return; } if (!player.svPlayer.HasPermission($"{Core.Instance.Info.GroupNamespace}.{Core.Instance.KitHandler.Name}.{kit}")) { player.TS("expFileHandler_error_noPermission", player.T(Core.Instance.KitHandler.Name), kit); return; } if (obj.Disabled) { player.TS("expFileHandler_error_disabled", player.T(Core.Instance.KitHandler.Name), kit); return; } if (player.HasCooldown(Core.Instance.KitHandler.Name, kit)) { player.TS("expFileHandler_error_cooldown", player.T(Core.Instance.KitHandler.Name), player.GetCooldown(Core.Instance.KitHandler.Name, kit).ToString()); return; } if (obj.Price > 0) { if (player.MyMoneyCount() < obj.Price) { player.TS("expFileHandler_error_price", player.T(Core.Instance.KitHandler.Name), obj.Price.ToString(), player.MyMoneyCount().ToString()); return; } player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true); } obj.GiveItems(player); if (obj.Delay > 0) { player.AddCooldown(Core.Instance.KitHandler.Name, kit, obj.Delay); } player.SendChatMessage( player.T(Core.Instance.KitHandler.Name + "_received", kit) + (obj.Price > 0 ? player.T(Core.Instance.KitHandler.Name + "_received_Price", obj.Price.ToString()) : "") + (obj.Delay > 0 ? player.T(Core.Instance.KitHandler.Name + "_received_Delay", obj.Delay.ToString()) : "")); }
public void Invoke(ShPlayer player, string warp) { var obj = Core.Instance.WarpHandler.List.FirstOrDefault(x => x.Name == warp); if (obj == null) { player.TS("expFileHandler_error_notFound", player.T(Core.Instance.WarpHandler.Name), warp); return; } if (!player.svPlayer.HasPermission($"{Core.Instance.Info.GroupNamespace}.{Core.Instance.WarpHandler.Name}.{warp}")) { player.TS("expFileHandler_error_noPermission", player.T(Core.Instance.WarpHandler.Name), warp); return; } if (obj.Disabled) { player.TS("expFileHandler_error_disabled", player.T(Core.Instance.WarpHandler.Name), warp); return; } if (player.HasCooldown(Core.Instance.WarpHandler.Name, warp)) { player.TS("expFileHandler_error_cooldown", player.T(Core.Instance.WarpHandler.Name), player.GetCooldown(Core.Instance.WarpHandler.Name, warp).ToString()); return; } if (obj.Price > 0) { if (player.MyMoneyCount() < obj.Price) { player.TS("expFileHandler_error_price", player.T(Core.Instance.WarpHandler.Name), obj.Price.ToString(), player.MyMoneyCount().ToString()); return; } player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true); } player.GetExtendedPlayer().ResetAndSavePosition(obj.Position.SerializableVector3.ToVector3(), obj.SerializableQuaternion.ToQuaternion(), obj.Position.PlaceIndex); if (obj.Delay > 0) { player.AddCooldown(Core.Instance.WarpHandler.Name, warp, obj.Delay); } player.SendChatMessage( player.T(Core.Instance.WarpHandler.Name + "_teleported", warp) + (obj.Price > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Price", obj.Price.ToString()) : "") + (obj.Delay > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Delay", obj.Delay.ToString()) : "")); }