Exemplo n.º 1
0
        public void CommandUnban(MiNET.Player player, string playerName)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Mod))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            RunnableTask.RunTask(() =>
            {
                string targetXuid = StatisticsCore.GetXuidForPlayername(playerName);
                if (targetXuid == null)
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §cis not a Skytonia user.");
                    return;
                }

                if (PunishCore.GetPunishmentsFor(targetXuid).RemoveActive(PunishmentType.Ban))
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §chas been unbanned.");
                }
                else
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §cis not currently banned.");
                }
            });
        }
Exemplo n.º 2
0
        public void CommandKick(MiNET.Player player, string playerName, string[] reason)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Helper))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            RunnableTask.RunTask(() =>
            {
                string targetXuid = StatisticsCore.GetXuidForPlayername(playerName);
                if (targetXuid == null)
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §cis not a Skytonia user.");
                    return;
                }

                string punishReason = GetReasonFromArgs(reason);

                PunishCore.AddKick(targetXuid, punishReason, player.CertificateData.ExtraData.Xuid);

                SkyPlayer target = SkyCoreAPI.Instance.GetPlayer(playerName);
                target?.Disconnect($"§cYou have been kicked from the server.\n" +
                                   $"§6Reason: {punishReason}");

                player.SendMessage($"§f[PUNISH] §7{playerName} §chas been kicked for: §f\"{punishReason}\"");
            });
        }
Exemplo n.º 3
0
        private static void RunPunishmentCommand(MiNET.Player player, PunishmentType punishmentType, String playerName, string[] args)
        {
            string targetXuid = StatisticsCore.GetXuidForPlayername(playerName);

            if (targetXuid == null)
            {
                player.SendMessage($"§f[PUNISH] §7{playerName} §cis not a Skytonia user.");
                return;
            }

            args = ParseExpiryTime(player, args, out DurationUnit durationUnit, out int durationAmount);
            if (args == null)
            {
                return;                 //Message printed to player
            }

            string punishReason = GetReasonFromArgs(args);

            DateTime expiry = UpdateExpiryTime(durationUnit, durationAmount);

            Punishment punishment = new Punishment(punishReason, player.CertificateData.ExtraData.Xuid, true, durationAmount, durationUnit, expiry);

            PunishCore.AddPunishment(targetXuid, punishmentType, punishment);

            if (punishmentType == PunishmentType.Ban)
            {
                SkyPlayer target = SkyCoreAPI.Instance.GetPlayer(playerName);
                if (durationUnit == DurationUnit.Permanent)
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §chas been banned permanently for: \"{punishReason}\"");

                    target?.Disconnect(PunishmentMessages.GetPunishmentMessage(target, punishmentType, punishment));
                }
                else
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §chas been banned for: §f{GetNeatDuration(durationAmount, durationUnit)} \"{punishReason}\"");

                    target?.Disconnect(PunishmentMessages.GetPunishmentMessage(target, punishmentType, punishment));
                }
            }
            else if (punishmentType == PunishmentType.Mute)
            {
                SkyPlayer target = SkyCoreAPI.Instance.GetPlayer(playerName);
                if (durationUnit == DurationUnit.Permanent)
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §chas been muted permanently for: \"{punishReason}\"");

                    target?.SendMessage(PunishmentMessages.GetPunishmentMessage(target, PunishmentType.Mute, punishment));
                }
                else
                {
                    player.SendMessage($"§f[PUNISH] §7{playerName} §chas been muted for: §f{GetNeatDuration(durationAmount, durationUnit)} \"{punishReason}\"");

                    target?.SendMessage(PunishmentMessages.GetPunishmentMessage(target, PunishmentType.Mute, punishment));
                }
            }
        }