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.");
                }
            });
        }
Example #2
0
        public void CommandTime(MiNET.Player player, string timeString)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            int time;

            switch (timeString.ToLower())
            {
            case "day":
                time = 6000;
                break;

            case "night":
                time = 12000;
                break;

            default:
                player.SendMessage("Unknown time string.");
                return;
            }

            //player.Level.CurrentWorldTime = time;
            player.Level.WorldTime = time;
        }
Example #3
0
        public void MoveToLobby(MiNET.Player player, int hub = 0)
        {
            if (_skyCoreApi.GameType.Equals("hub"))
            {
                if (hub == 0)
                {
                    player.SendMessage("§c§l(!)§r §cYou are already connected to a hub.");
                    return;
                }

                string hubNum = hub.ToString();

                GameController gameController = _skyCoreApi.GameModes["hub"];
                foreach (GameLevel hubLevel in gameController.GameLevels.Values)
                {
                    if (hubLevel.GameId.Replace("hub", "").Equals(hubNum))
                    {
                        hubLevel.AddPlayer((SkyPlayer)player);
                        return;
                    }
                }

                player.SendMessage($"§c§l(!)§r §cHub{hubNum} does not exist.");
                return;
            }

            player.SendMessage("§e§l(!)§r §eMoving to Hub...");

            ExternalGameHandler.AddPlayer((SkyPlayer)player, "hub");
        }
Example #4
0
        public void CommandScale(MiNET.Player player, string scaleString, string targetName = "")
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            MiNET.Player targetPlayer;
            if (String.IsNullOrEmpty(targetName))
            {
                targetPlayer = player;
            }
            else
            {
                targetPlayer = _skyCoreApi.GetPlayer(targetName);
                if (targetPlayer == null)
                {
                    player.SendMessage($"§c§l(!) §r§c{targetName} is not online.");
                    return;
                }
            }

            try
            {
                targetPlayer.Scale = Double.Parse(scaleString);
                player.SendMessage($"§e§l(!) §r§eUpdated {targetPlayer.Username}'s scale to {targetPlayer.Scale}");
            }
            catch (Exception e)
            {
                player.SendMessage($"§c§l(!) §r§cUnable to parse scale {scaleString}");
                Console.WriteLine(e);
                throw;
            }
        }
        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}\"");
            });
        }
Example #6
0
        public void CommandStop(MiNET.Player player, params string[] args)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            if (args.Length > 0)
            {
                if (args[0].Equals("now"))
                {
                    player.SendMessage("§cRebooting Server...");
                    RestartHandler.TriggerReboot(true);
                    return;
                }
                if (args[0].Equals("queue"))
                {
                    player.SendMessage("§cQueueing reboot...");
                    player.SendMessage("§7* Server should reboot after all games have finished their games.");
                    RestartHandler.TriggerReboot(false);
                    return;
                }
            }

            player.SendMessage("§c/stop now (Immediately stops the server)");
            player.SendMessage("§c/stop queue (Queues a reboot once all games are free to reboot)");
        }
Example #7
0
 public void OnInteract(MiNET.Player player)
 {
     if (_action != null)
     {
         //SkyUtil.log($"(2) Processing NPC Interact as {player.Username}");
         _action((SkyPlayer)player);
     }
 }
        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));
                }
            }
        }
Example #9
0
        public void CommandGetPos(MiNET.Player player)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            PlayerLocation knownLocation = player.KnownPosition;

            player.SendMessage(
                $"Pos: {player.Level.LevelId}:{knownLocation.X},{knownLocation.Y},{knownLocation.Z}:{knownLocation.HeadYaw}:{knownLocation.Pitch}");
        }
        public void CommandMute(MiNET.Player player, string playerName, params string[] args)
        {
            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(() =>
            {
                RunPunishmentCommand(player, PunishmentType.Mute, playerName, args);
            });
        }
Example #11
0
        public void CommandSpeed(MiNET.Player player, float speed = 0.1f)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            player.MovementSpeed = speed;
            player.SendAdventureSettings();

            player.SendMessage($"§eUpdated movement speed to {speed}");
        }
Example #12
0
        public void CommandFly(MiNET.Player player, string targetName = "")
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            SkyPlayer targetPlayer;

            if (string.IsNullOrEmpty(targetName))
            {
                targetPlayer = (SkyPlayer)player;
            }
            else
            {
                targetPlayer = _skyCoreApi.GetPlayer(targetName);
                if (targetPlayer == null)
                {
                    player.SendMessage($"§c§l(!) §r§c{targetName} is not online.");
                    return;
                }
            }

            if (targetPlayer.GameMode == GameMode.Creative || targetPlayer.GameMode == GameMode.Spectator)
            {
                if (player.Username.Equals(targetPlayer.Username))
                {
                    player.SendMessage($"§c§l(!) §r§cFlight cannot be toggled in {targetPlayer.GameMode}");
                }
                else
                {
                    player.SendMessage(
                        $"§c§l(!) §r§cFlight cannot be toggled for {targetPlayer.Username} since they are in {targetPlayer.GameMode} mode.");
                }
                return;
            }

            if (targetPlayer.AllowFly)
            {
                targetPlayer.IsFlying = false;
                targetPlayer.SetAllowFly(false);

                player.SendMessage($"§e§l(!) §r§eFlight §c§lDISABLED §r§efor {targetPlayer.Username}");
            }
            else
            {
                targetPlayer.SetAllowFly(true);
                player.SendMessage($"§e§l(!) §r§eFlight §a§lENABLED §r§efor {targetPlayer.Username}");
            }
        }
Example #13
0
        public override void RemovePlayer(MiNET.Player player, bool removeFromWorld = false)
        {
            if (((SkyPlayer)player).GameTeam == null)
            {
                return;                 //Shouldn't be in the/any game.
            }

            CurrentState.HandleLeave(this, (SkyPlayer)player);

            PlayerTeamDict.TryGetValue(player.Username, out var gameTeam);

            if (gameTeam != null)
            {
                PlayerTeamDict.Remove(player.Username);
                TeamPlayerDict[gameTeam].Remove((SkyPlayer)player);
            }

            //Enforce removing the attached team
            ((SkyPlayer)player).GameTeam = null;
        }
Example #14
0
        public void CommandJoin(MiNET.Player player, string gameName)
        {
            try
            {
                switch (gameName.ToLower())
                {
                case "murder":
                {
                    ExternalGameHandler.AddPlayer((SkyPlayer)player, "murder");
                    break;
                }

                case "build-battle":
                {
                    ExternalGameHandler.AddPlayer((SkyPlayer)player, "build-battle");
                    break;
                }

                case "hub":
                {
                    ExternalGameHandler.AddPlayer((SkyPlayer)player, "hub");
                    break;
                }

                default:
                {
                    player.SendMessage($"§c§l(!)§r §cCould not find game '{gameName}'.");
                    return;
                }
                }

                player.SendMessage($"§e§l(!)§r §eJoining Game {gameName}...");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                player.SendMessage($"§c§l(!)§r §cUnable to Join Game '{gameName}'.");
            }
        }
Example #15
0
        public void CommandAdmin(MiNET.Player player, params string[] args)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            if (args.Length > 0)
            {
                if (args[0].Equals("players"))
                {
                    player.SendMessage("§6Retrieving Game Player Counts...");
                    foreach (var entry in ExternalGameHandler.GameRegistrations)
                    {
                        int lobbyPlayers = 0;
                        foreach (InstanceInfo instance in entry.Value.GetAllInstances())
                        {
                            foreach (GameInfo gameInfo in instance.AvailableGames)
                            {
                                lobbyPlayers += gameInfo.CurrentPlayers;
                            }
                        }

                        int gamePlayers = entry.Value.GetCurrentPlayers() - lobbyPlayers;

                        player.SendMessage($"§e({entry.Key}) - §eLobby§6(§e{lobbyPlayers}§6) §eGame§6(§e{gamePlayers}§6)");
                    }
                    return;
                }
                else if (args[0].Equals("bugtest"))
                {
                    BugSnagUtil.ReportBug(new Exception("Test Exception"), player as SkyPlayer);
                }
            }

            player.SendMessage("§c/admin players - Lists player counts for all games");
        }
Example #16
0
        public void CommandPermGet(MiNET.Player player, string targetName)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            if (string.IsNullOrEmpty(targetName))
            {
                player.SendMessage($"{ChatColors.Red}Enter a valid player name.");
                return;
            }

            SkyPlayer target = _skyCoreApi.GetPlayer(targetName);

            if (target == null || !target.IsConnected)
            {
                player.SendMessage($"{ChatColors.Red}Target player is not online.");
                return;
            }

            player.SendMessage($"{ChatColors.Yellow}{target.Username} is currently rank '{((SkyPlayer)player).PlayerGroup.GroupName}'");
        }
Example #17
0
 public void CommandGamemode(MiNET.Player player, int gamemodeId = 0)
 {
     CommandGamemode(player, player.Username, gamemodeId);
 }
Example #18
0
        public void CommandPermSet(MiNET.Player player, string targetName, string targetGroupName)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            if (String.IsNullOrEmpty(targetName))
            {
                player.SendMessage($"{ChatColors.Red}Enter a valid player name.");
                return;
            }

            SkyPlayer target = _skyCoreApi.GetPlayer(targetName);

            if (target == null || !target.IsConnected)
            {
                player.SendMessage($"{ChatColors.Red}Target player is not online.");
                return;
            }

            //Format as our Enums
            targetGroupName = targetGroupName.ToLower();
            targetGroupName = Char.ToUpper(targetGroupName.ToCharArray()[0]) + targetGroupName.Substring(1);

            if (!PlayerGroup.ValueOf(targetGroupName, out var targetGroup))
            {
                player.SendMessage($"{ChatColors.Red}Unrecognized group name '{targetGroupName}'.");
                string possibleGroups = "";
                foreach (PlayerGroup groupLoop in PlayerGroup.Values)
                {
                    possibleGroups += groupLoop.GroupName + ",";
                }

                player.SendMessage($"Possible Groups: {possibleGroups}");
                return;
            }

            target.SetPlayerGroup(targetGroup);

            RunnableTask.RunTask(() =>
            {
                new DatabaseAction().Execute(
                    "INSERT INTO `player_groups`\n" +
                    "  (`player_xuid`, `group_name`)\n" +
                    "VALUES\n" +
                    "  (@xuid, @group)\n" +
                    "ON DUPLICATE KEY UPDATE\n" +
                    "  `player_xuid`    = VALUES(`player_xuid`),\n" +
                    "  `group_name`     = VALUES(`group_name`);",
                    (command) =>
                {
                    command.Parameters.AddWithValue("@xuid", target.CertificateData.ExtraData.Xuid);
                    command.Parameters.AddWithValue("@group", targetGroup.GroupName);
                },
                    new Action(delegate
                {
                    player.SendMessage($"{ChatColors.Yellow}Updated {target.Username}'s group to {targetGroup.GroupName}");
                })
                    );
            });
        }
Example #19
0
        public void CommandGamemode(MiNET.Player player, string targetName = "", int gamemodeId = 0)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            MiNET.Player target;
            if (String.IsNullOrEmpty(targetName))
            {
                player.SendMessage($"{ChatColors.Red}Enter a valid player name.");
                return;
            }

            target = _skyCoreApi.GetPlayer(targetName);

            if (target == null || !target.IsConnected)
            {
                player.SendMessage($"{ChatColors.Red}Target player is not online.");
                return;
            }

            GameMode gamemode;

            switch (gamemodeId)
            {
            case 0:
                gamemode = GameMode.Survival;
                break;

            case 1:
                gamemode = GameMode.Creative;
                break;

            case 2:
                gamemode = GameMode.Adventure;
                break;

            case 3:
                gamemode = GameMode.Spectator;
                //Avoid having regular players noclipping
                if (((SkyPlayer)target).PlayerGroup.IsAtLeast(PlayerGroup.Youtuber))
                {
                    target.IsNoClip = true;
                }
                else
                {
                    target.IsNoClip = true;
                }
                break;

            default:
            {
                player.SendMessage($"{ChatColors.Red}Invalid gamemode id {gamemodeId}.");
                return;
            }
            }

            target.SetGameMode(gamemode);

            player.SendMessage($"{ChatColors.Yellow}Updated {target.Username}'s Gamemode to {gamemode}");
        }
Example #20
0
        public void CommandGameEdit(MiNET.Player player, params string[] args)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            if (!(player.Level is GameLevel level))
            {
                player.SendMessage($"§cYou must be in a game to use this command!");
                return;
            }

            if (!(level.GameLevelInfo is GameLevelInfo gameLevelInfo))
            {
                player.SendMessage("§cThe current level's information could not be loaded.");
                return;
            }

            if (!SkyCoreAPI.Instance.GameModes.TryGetValue(level.GameType, out var gameController))
            {
                player.SendMessage($"§cCouldn't retrieve GameController for {level.GameType}");
                return;
            }

            if (args[0].Equals("timeleft"))
            {
                if (args.Length < 2)
                {
                    player.SendMessage("§c/gameedit timeleft <time>");
                    return;
                }

                if (!int.TryParse(args[1], out var timeRemaining))
                {
                    player.SendMessage($"§cInvalid time remaining ({args[1]})");
                    return;
                }

                level.Tick = 0;
                ((RunningState)level.CurrentState).EndTick = timeRemaining * 2;

                player.SendMessage($"§eReset in-game timer, and updated end-time to {timeRemaining} seconds");
            }
            else if (args[0].Equals("level"))
            {
                if (args.Length < 2)
                {
                    player.SendMessage("§c/gameedit level <levelname>");
                    return;
                }

                string    fullyQualifiedName = $"C:\\Users\\Administrator\\Desktop\\worlds\\{level.GameType}\\{args[1]}";
                GameLevel gameLevel;
                if (!gameController.LevelNames.Contains(fullyQualifiedName) || (gameLevel = gameController.InitializeNewGame(fullyQualifiedName)) == null)
                {
                    player.SendMessage($"§cInvalid level name ({args[1]})");
                    player.SendMessage($"§cBad Args: \n§c- {string.Join("\n§c- ", gameController.LevelNames.Select(x => _removeQualification(x.ToString())).ToArray())}");
                    return;
                }

                foreach (SkyPlayer gamePlayer in level.GetAllPlayers())
                {
                    gameLevel.AddPlayer(gamePlayer);
                }

                level.UpdateGameState(new VoidGameState());                 //'Close' the game eventually

                player.SendMessage($"§cUpdating game level to {args[1]}");
            }
            else if (args[0].Equals("nextstate"))
            {
                GameState nextState = level.CurrentState.GetNextGameState(level);
                if (nextState is VoidGameState)
                {
                    player.SendMessage("§cNo Next Available State Available.");
                    return;
                }

                player.SendMessage($"§cProgressing to next state ({level.CurrentState.GetType()} -> {nextState.GetType()})");
                level.UpdateGameState(nextState);
            }
            else
            {
                if (!gameController.HandleGameEditCommand(player as SkyPlayer, level, gameLevelInfo, args))
                {
                    player.SendMessage("§c/gameedit timeleft");
                    player.SendMessage("§c/gameedit tp");
                    player.SendMessage("§c/gameedit nextstate");
                    player.SendMessage("§c/gameedit level <level-name>");
                    {
                        string subCommandHelp = gameController.GetGameEditCommandHelp(player as SkyPlayer);
                        if (subCommandHelp != null)
                        {
                            player.SendMessage(subCommandHelp);
                        }
                    }
                    player.SendMessage($"§cBad Args: {string.Join(",", args.Select(x => x.ToString()).ToArray())}");
                }
            }
        }
Example #21
0
 public void CommandLobby(MiNET.Player player, int hub = 0)
 {
     MoveToLobby(player, hub);
 }
Example #22
0
        public void CommandSpawnMob(MiNET.Player player, string entityName, string mobName = "", string mobScale = "")
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            entityName = entityName.ToLower();
            entityName = entityName.Substring(0, 1).ToUpper() + entityName.Substring(1);

            if (!Enum.TryParse(entityName, out EntityType entityType))
            {
                player.SendMessage($"§c§l(!) §r§cUnknown EntityType '{entityName}'");
                return;
            }

            Level level = player.Level;

            Mob mob = null;

            switch (entityType)
            {
            case EntityType.Chicken:
                mob = new Chicken(level);
                break;

            case EntityType.Cow:
                mob = new Cow(level);
                break;

            case EntityType.Pig:
                mob = new Pig(level);
                break;

            case EntityType.Sheep:
                mob = new Sheep(level);
                break;

            case EntityType.Wolf:
                mob = new Wolf(level)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(level);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(level);
                break;

            case EntityType.Squid:
                mob = new Squid(level);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(level);
                break;

            case EntityType.Bat:
                mob = new Bat(level);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(level);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(level);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(level);
                break;

            case EntityType.Zombie:
                mob = new Zombie(level);
                break;

            case EntityType.Creeper:
                mob = new Creeper(level);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(level);
                break;

            case EntityType.Spider:
                mob = new Spider(level);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(level);
                break;

            case EntityType.Slime:
                mob = new MiNET.Entities.Hostile.Slime(level);
                break;

            case EntityType.Enderman:
                mob = new Enderman(level);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(level);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(level);
                break;

            case EntityType.Ghast:
                mob = new Ghast(level);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(level);
                break;

            case EntityType.Blaze:
                mob = new Blaze(level);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(level);
                break;

            case EntityType.Witch:
                mob = new Witch(level);
                break;

            case EntityType.Stray:
                mob = new Stray(level);
                break;

            case EntityType.Husk:
                mob = new Husk(level);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(level);
                break;

            case EntityType.Guardian:
                mob = new Guardian(level);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(level);
                break;

            case EntityType.Horse:
                mob = new Horse(level);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(level);
                break;

            case EntityType.Shulker:
                mob = new Shulker(level);
                break;

            case EntityType.Dragon:
                mob = new Dragon(level);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(level);
                break;

            case EntityType.Wither:
                mob = new Wither(level);
                break;

            case EntityType.Evoker:
                mob = new Evoker(level);
                break;

            case EntityType.Vindicator:
                mob = new Vindicator(level);
                break;

            case EntityType.Vex:
                mob = new Vex(level);
                break;

            case EntityType.Npc:
                mob = new PlayerMob("test", level);
                break;
            }

            if (!String.IsNullOrEmpty(mobName))
            {
                mob.NameTag          = mobName.Replace("&", "§");
                mob.HideNameTag      = false;
                mob.IsAlwaysShowName = true;
            }

            if (!String.IsNullOrEmpty(mobScale))
            {
                try
                {
                    mob.Scale = Double.Parse(mobScale);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            mob.KnownPosition = (PlayerLocation)player.KnownPosition.Clone();
            mob.SpawnEntity();

            player.SendMessage($"§e§l(!) §r§eSpawned new {entityType}");
        }
        private static string[] ParseExpiryTime(MiNET.Player player, string[] args, out DurationUnit durationUnit, out int durationAmount)
        {
            durationAmount = -1;
            durationUnit   = DurationUnit.Permanent;
            if (args.Length > 0)
            {
                string expiryString = args[0];
                if (expiryString.Length > 0)
                {
                    switch (expiryString.ToUpper())
                    {
                    case "FOREVER":
                    case "PERM":
                    case "PERMANENT":
                    {
                        durationAmount = 0;
                        //DurationUnit is already correct.
                        break;
                    }

                    default:
                    {
                        if (args[0].Any(char.IsDigit))
                        {
                            string amountString = "";
                            for (int idx = 0; idx < expiryString.Length; idx++)
                            {
                                char charAt = expiryString[idx];
                                if (durationAmount == -1 && Char.IsDigit(charAt))
                                {
                                    amountString += charAt;
                                    continue;
                                }

                                string remainingUnitString = expiryString.Substring(idx, expiryString.Length - idx);
                                if (Enum.TryParse(remainingUnitString, out durationUnit))
                                {
                                    break;
                                }
                                switch (remainingUnitString.ToLower())
                                {
                                case "m":
                                    durationUnit = DurationUnit.Minutes;
                                    break;

                                case "h":
                                    durationUnit = DurationUnit.Hours;
                                    break;

                                case "d":
                                    durationUnit = DurationUnit.Days;
                                    break;

                                case "w":
                                    durationUnit = DurationUnit.Weeks;
                                    break;

                                case "mon":
                                    durationUnit = DurationUnit.Months;
                                    break;

                                case "y":
                                    durationUnit = DurationUnit.Years;
                                    break;
                                }

                                if (durationUnit == DurationUnit.Permanent)
                                {
                                    player.SendMessage($"§cUnable to parse expiryString unit '{expiryString.Substring(idx, expiryString.Length)}' from '{expiryString}'.");
                                    return(null);
                                }
                            }

                            if (!int.TryParse(amountString, out durationAmount))
                            {
                                player.SendMessage($"§cUnable to parse expiryString amount '{amountString}' from '{expiryString}'.");
                                return(null);
                            }

                            if (durationAmount <= 0)
                            {
                                player.SendMessage($"§cInvalid duration: '{durationAmount} {durationUnit}'.");
                                return(null);
                            }
                        }
                        break;
                    }
                    }

                    if (durationAmount > 0)
                    {
                        //Update args to remove the first entry
                        if (args.Length > 1)
                        {
                            args = args.Skip(1).ToArray();                             //Skip the first entry
                        }
                        else
                        {
                            args = new string[0];                             //No more args
                        }
                    }
                }

                //Handles Perm ban amount
                if (durationAmount == -1)
                {
                    durationAmount = 0;
                }
            }

            return(args);
        }
Example #24
0
        public void CommandGameEdit(MiNET.Player player, params string[] args)
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            if (args.Length > 0)
            {
                if (args[0].Equals("add"))
                {
                    if (args.Length > 1)
                    {
                        if (AddToWhitelist(args[1]))
                        {
                            player.SendMessage($"§eAdded '{args[1]}' to the whitelist.");
                        }
                        else
                        {
                            player.SendMessage($"§e'{args[1]}' is already on the whitelist.");
                        }
                    }
                    else
                    {
                        player.SendMessage("§e/whitelist add <name>");
                    }

                    return;
                }
                else if (args[0].Equals("remove"))
                {
                    if (args.Length > 1)
                    {
                        if (RemoveFromWhitelist(args[1]))
                        {
                            player.SendMessage($"§eRemoved '{args[1]}' from the whitelist.");
                        }
                        else
                        {
                            player.SendMessage($"§e'{args[1]}' was not on the whitelist.");
                        }
                    }
                    else
                    {
                        player.SendMessage("§e/whitelist remove <name>");
                    }

                    return;
                }
                else if (args[0].Equals("list"))
                {
                    player.SendMessage($"§e§lWhitelist:\n{String.Join(",", WhitelistContent.WhitelistedNames.ToArray())}");
                    return;
                }
                else if (args[0].Equals("reload"))
                {
                    LoadWhitelist();
                    player.SendMessage("§eReloaded Whitelist.");
                    return;
                }
                else if (args[0].Equals("on"))
                {
                    LoadWhitelist();

                    if (WhitelistContent.Enabled)
                    {
                        player.SendMessage("§eWhitelist is already enabled.");
                    }
                    else
                    {
                        WhitelistContent.Enabled = true;
                        SaveWhitelist();

                        player.SendMessage("§eWhitelist enabled.");
                    }
                    return;
                }
                else if (args[0].Equals("off"))
                {
                    LoadWhitelist();

                    if (!WhitelistContent.Enabled)
                    {
                        player.SendMessage("§eWhitelist is already disabled.");
                    }
                    else
                    {
                        WhitelistContent.Enabled = false;
                        SaveWhitelist();

                        player.SendMessage("§eWhitelist disabled.");
                    }
                    return;
                }
            }

            player.SendMessage("§e/whitelist <add/remove/list/reload>");
        }
Example #25
0
        public override void AddPlayer(MiNET.Player player, bool spawn)
        {
            AddSpectator(player as SkyPlayer);

            base.AddPlayer(player, spawn);
        }