Exemple #1
0
        public void Invoke(ShPlayer player, string arg1 = "")
        {
            player.SendChatMessage($"BP Essentials v{Core.Version}.");
            var info = Core.Instance.Info;

            switch (arg1)
            {
            case "web":
                player.SendChatMessage($"Website: {info.Website}");
                break;

            case "info":
                player.SendChatMessage(info.ToString());
                player.SendChatMessage($"Authors: {string.Join(", ", Core.Authors.Select(x => x.ToString()))}");
                player.SendChatMessage($"Version: {(Core.IsDevelopmentBuild() ? "[DEVELOPMENT-BUILD] " : "")}v{Core.Version}");
                break;

            case "reload":
                if (!player.HasPermission(info.GroupNamespace + ".reload"))
                {
                    player.SendChatMessage($"No permission! Requires the '{info.GroupNamespace}.reload' permission.");
                    return;
                }
                player.SendChatMessage("Reloading..");
                Core.Instance.OnReloadRequestAsync();
                player.SendChatMessage("Reloaded.");
                break;

            default:
                player.SendChatMessage("Missing argument: reload/help/info/web");
                break;
            }
        }
Exemple #2
0
        public void Invoke(ShPlayer player, ShPlayer target = null)
        {
            if (target != null && !player.HasPermission($"{Core.Instance.Info.GroupNamespace}.{nameof(WarnList)}.viewotherplayers"))
            {
                player.TS("warns_noPermission_viewOtherPlayers");
                return;
            }
            target = target ?? player;
            var           warns         = target.GetWarns().Select(warn => warn.ToString(player)).ToArray();
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(player.T("warns_for", target.username.CleanerMessage()));
            if (warns.Length == 0)
            {
                stringBuilder.AppendLine(player.T("none"));
            }
            else
            {
                stringBuilder.AppendLine(player.T("warns_count", warns.Length.ToString()));
                stringBuilder.AppendLine();
                for (int i = 0; i < warns.Length; i++)
                {
                    stringBuilder.AppendLine($"{i + 1} - {warns[i]}");
                }
            }
            player.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, stringBuilder.ToString());
        }
Exemple #3
0
        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()) : ""));
        }
Exemple #4
0
        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.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.T(Core.Instance.KitHandler.Name + "_received", obj.Name) +
                (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()) : ""));
        }
Exemple #5
0
        public void Invoke(ShPlayer player)
        {
            var kits = Core.Instance.KitHandler.List.Where(x => !x.Disabled && player.HasPermission($"{Core.Instance.Info.GroupNamespace}.{Core.Instance.KitHandler.Name}.{x.Name}")).Select(n => n.Name + $"{(n.Price != 0 ? $" ({n.Price})" : "")}").ToArray();

            player.TS("kits", kits.Length.ToString(), (kits.Length == 0 ? "none" : string.Join(", ", kits)));
        }