Example #1
0
        public bool TryDoCommand(Players.Player causedBy, string chattext)
        {
            var matched = Regex.Match(chattext, @"/spawnprotect (?<access>.+) (?<steamid>.+)");

            if (!matched.Success)
            {
                Chat.Send(causedBy, "Command didn't match, use /spawnprotect [spawn|nospawn|banner|deny] steamid");
                return(true);
            }
            string access = matched.Groups ["access"].Value;
            ulong  steamid;

            if (!ulong.TryParse(matched.Groups ["steamid"].Value, out steamid))
            {
                Chat.Send(causedBy, "Failed parsing steamid");
                return(true);
            }
            Steamworks.CSteamID csteamid = new Steamworks.CSteamID(steamid);
            if (!csteamid.IsValid())
            {
                Chat.Send(causedBy, "steamid is not valid");
                return(true);
            }
            NetworkID networkId = new NetworkID(csteamid);

            Players.Player targetPlayer;
            if (!Players.TryGetPlayer(networkId, out targetPlayer))
            {
                Chat.Send(causedBy, "Player not found or offline");
                return(true);
            }
            if (access.Equals("spawn"))
            {
                if (!PermissionsManager.CheckAndWarnPermission(causedBy, SpawnProtectModEntries.PERMISSION_SUPER))
                {
                    return(true);
                }
                PermissionsManager.AddPermissionToUser(causedBy, targetPlayer, SpawnProtectModEntries.PERMISSION_SPAWN_CHANGE);
            }
            else if (access.Equals("nospawn"))
            {
                if (PermissionsManager.HasPermission(causedBy, SpawnProtectModEntries.PERMISSION_SUPER))
                {
                    PermissionsManager.RemovePermissionOfUser(causedBy, targetPlayer, SpawnProtectModEntries.PERMISSION_SPAWN_CHANGE);
                }
            }
            else if (access.Equals("banner"))
            {
                PermissionsManager.AddPermissionToUser(causedBy, targetPlayer, SpawnProtectModEntries.PERMISSION_BANNER_PREFIX + causedBy.ID.steamID);
            }
            else if (access.Equals("deny"))
            {
                PermissionsManager.RemovePermissionOfUser(causedBy, targetPlayer, SpawnProtectModEntries.PERMISSION_BANNER_PREFIX + causedBy.ID.steamID);
            }
            else
            {
                Chat.Send(causedBy, "Unknown access level, use /spawnprotect [spawn|nospawn|banner|deny] steamid");
            }
            return(true);
        }
Example #2
0
            public bool TryDoCommand(Players.Player id, string chatItem, List <string> splits)
            {
                if (splits.Count >= 1 && splits[0] == "/speed")
                {
                    if (!PermissionsManager.CheckAndWarnPermission(id, (PermissionsManager.Permission) "FastGlider.speed"))
                    {
                        return(true);
                    }

                    if (splits.Count == 1)
                    {
                        Chat.Send(id, "Set the speed using /speed [speed]");
                        return(true);
                    }
                    else if (splits.Count == 2 && splits[0] == "/speed")
                    {
                        int result;
                        if (!int.TryParse(splits[1], out result))
                        {
                            Chat.Send(id, "Could not parse [" + splits[1] + "] as a number.", EChatSendOptions.Default);
                            return(true);
                        }
                        if (result <= 0)
                        {
                            Chat.Send(id, "Speed cannot be 0 or lower. Use 2 to reset glider to default speed", EChatSendOptions.Default);
                            return(true);
                        }
                        FastGlider.SetSpeed(result);
                        Chat.Send(id, "Set Speed to " + result);
                        return(true);
                    }
                }
                return(false);
            }
 public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
 {
     if (!splits[0].Equals("/noflight"))
     {
         return(false);
     }
     if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "noflight"))
     {
         return(true);
     }
     foreach (var player in Players.PlayerDatabase.Values)
     {
         var flightState = player.GetTempValues(false).GetOrDefault("pipliz.setflight", false);
         if (!PermissionsManager.HasPermission(player, "setflight") && flightState)
         {
             player.GetTempValues(true).Set("pipliz.setflight", false);
             // player.ShouldSave = true;
             if (player.ConnectionState == Players.EConnectionState.Connected)
             {
                 Chat.Send(player, "Please don't fly");
                 Players.Disconnect(player);
             }
             else
             {
                 Log.Write($"Removed flight state from offline player {player.ID.ToStringReadable()}");
             }
         }
     }
     return(true);
 }
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/travelthere"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "travelpaths"))
            {
                return(true);
            }
            Vector3Int StartWaypoint;

            if (WaypointManager.startWaypoints.TryGetValue(causedBy, out StartWaypoint))
            {
                WaypointManager.travelPaths.Add(StartWaypoint, causedBy.VoxelPosition);
                WaypointManager.startWaypoints.Remove(causedBy);
                WaypointManager.Save();
                Chat.Send(causedBy, $"Saved travel path from {StartWaypoint} to {causedBy.VoxelPosition}");
            }
            else
            {
                Chat.Send(causedBy, "You have no start waypoint set, use /travelhere at start point");
            }
            return(true);
        }
        public void MoveCommand(Players.Player causedBy, string param)
        {
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "announcements.move"))
            {
                return;
            }
            var m = Regex.Match(param, @"A?(?<index>\d+) A?(?<newindex>\d+)");

            if (!m.Success)
            {
                Chat.Send(causedBy, $"Params didn't match, use {EDIT_PREFIX} A[index] [newindex]");
                return;
            }
            string StrIndex = m.Groups ["index"].Value;
            int    Index;

            if (!int.TryParse(StrIndex, out Index))
            {
                Chat.Send(causedBy, $"Could not parse given parameter '{StrIndex}' as index number");
                return;
            }
            string StrNewIndex = m.Groups ["newindex"].Value;
            int    NewIndex;

            if (!int.TryParse(StrNewIndex, out NewIndex))
            {
                Chat.Send(causedBy, $"Could not parse given parameter '{StrNewIndex}' as index number");
                return;
            }
            Announcements.MoveAnnouncement(Index, NewIndex);
            Chat.Send(causedBy, $"Moved announcement {Index} to index {NewIndex}");
        }
        private bool ProcessUnclaimChunk(Players.Player id, string chatItem)
        {
            if (PermissionsManager.CheckAndWarnPermission(id, "chunk.claim"))
            {
                // get the current chunk
                Players.Player p = id;

                int playerX = Pipliz.Math.RoundToInt(p.Position.x);
                int playerY = Pipliz.Math.RoundToInt(p.Position.y);
                int playerZ = Pipliz.Math.RoundToInt(p.Position.z);

                Vector3Int position = new Vector3Int(playerX, playerY, playerZ);

                if (Managers.WorldManager.unclaimChunk(position, p.ID))
                {
                    Vector3Int chunkPos = position.ToChunk();
                    int        owned    = Managers.WorldManager.getOwnedChunkCount(p.ID);

                    Chat.send(id, String.Format("Unclaimed chunk: {0}, {1}, {2}", chunkPos.x, chunkPos.y, chunkPos.z), Chat.ChatColour.lime, Chat.ChatStyle.bold);
                    Chat.send(id, String.Format("You now own {0} chunks.", owned), Chat.ChatColour.lime, Chat.ChatStyle.bold);
                }
                else
                {
                    // chunk already owned
                    Chat.send(id, "Unable to unclaim chunk", Chat.ChatColour.red, Chat.ChatStyle.bold);
                }
            }


            return(true);
        }
Example #7
0
        protected override bool RunCommand(Players.Player ply, string[] args, NetworkID target)
        {
            if (PermissionsManager.CheckAndWarnPermission(ply, "chunk.claim"))
            {
                // get the current chunk
                int playerX = Pipliz.Math.RoundToInt(ply.Position.x);
                int playerY = Pipliz.Math.RoundToInt(ply.Position.y);
                int playerZ = Pipliz.Math.RoundToInt(ply.Position.z);

                Vector3Int position = new Vector3Int(playerX, playerY, playerZ);

                if (Managers.WorldManager.unclaimChunk(position, ply.ID))
                {
                    Vector3Int chunkPos = position.ToChunk();
                    int        owned    = Managers.WorldManager.getOwnedChunkCount(ply.ID);

                    ColonyAPI.Helpers.Chat.sendSilent(ply, string.Format("Unclaimed chunk: {0}, {1}, {2}", chunkPos.x, chunkPos.y, chunkPos.z), ColonyAPI.Helpers.Chat.ChatColour.lime, ColonyAPI.Helpers.Chat.ChatStyle.bold);
                    ColonyAPI.Helpers.Chat.sendSilent(ply, string.Format("You now own {0} chunks.", owned), ColonyAPI.Helpers.Chat.ChatColour.lime, ColonyAPI.Helpers.Chat.ChatStyle.bold);
                }
                else
                {
                    // chunk not owned
                    ColonyAPI.Helpers.Chat.sendSilent(ply, "Unable to unclaim chunk", ColonyAPI.Helpers.Chat.ChatColour.red, ColonyAPI.Helpers.Chat.ChatStyle.bold);
                }
            }
            ColonyAPI.Helpers.Utilities.WriteLog("ColonyPlusPlus-Utilities", ply.Name + " attempted to use /chunk unclaim!");
            return(true);
        }
Example #8
0
        protected override bool RunCommand(Players.Player ply, string[] args, NetworkID[] targets)
        {
            if (PermissionsManager.CheckAndWarnPermission(ply, "chunk.delete"))
            {
                // get the current chunk
                int playerX = Pipliz.Math.RoundToInt(ply.Position.x);
                int playerY = Pipliz.Math.RoundToInt(ply.Position.y);
                int playerZ = Pipliz.Math.RoundToInt(ply.Position.z);

                Vector3Int position = new Vector3Int(playerX, playerY, playerZ);

                if (Managers.WorldManager.unclaimChunk(position, ply.ID, true))
                {
                    Vector3Int chunkPos = position.ToChunk();

                    Chat.send(ply, string.Format("Chunk Owner Deleted ({0}, {1}, {2})", chunkPos.x, chunkPos.y, chunkPos.z), Chat.ChatColour.lime, Chat.ChatStyle.bold);
                }
                else
                {
                    // chunk not owned
                    Chat.sendSilent(ply, "Unable to unclaim chunk", Chat.ChatColour.red, Chat.ChatStyle.bold);
                }
            }
            Utilities.WriteLog(ply.Name + " attempted to use /chunk delete!");
            return(true);
        }
Example #9
0
 public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
 {
     if (!splits[0].Equals("/eventend"))
     {
         return(false);
     }
     if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "events"))
     {
         return(true);
     }
     if (Events.currentLocation == Vector3Int.invalidPos)
     {
         Chat.Send(causedBy, "There is currently no event ongoing");
         return(true);
     }
     Events.currentLocation = Vector3Int.invalidPos;
     foreach (var participantEntry in Events.originPositions)
     {
         Teleport.TeleportTo(participantEntry.Key, participantEntry.Value);
         if (!string.IsNullOrEmpty(Events.msgPrivStopped))
         {
             Chat.Send(causedBy, Events.msgPrivStopped.Replace("{stoppername}", causedBy.Name));
         }
     }
     Events.originPositions.Clear();
     if (!string.IsNullOrEmpty(Events.msgAllStopped))
     {
         Chat.SendToConnected(Events.msgAllStopped.Replace("{stoppername}", causedBy.Name));
     }
     return(true);
 }
Example #10
0
        protected override bool RunCommand(Players.Player ply, string[] args, NetworkID target)
        {
            if (PermissionsManager.CheckAndWarnPermission(ply, "chunk.list") && ColonyAPI.Managers.ConfigManager.getConfigBoolean("ColonyPlusPlus-Utilities", "chunks.enabled"))
            {
                if (Managers.WorldManager.getOwnedChunkCount(ply.ID) > 0)
                {
                    string ownedChunks = "You own " + Managers.WorldManager.getOwnedChunkCount(ply.ID) + " chunks: ";

                    foreach (Data.ChunkData c in Managers.WorldManager.ChunkDataList.Values)
                    {
                        if (c.getOwner() == ply.ID)
                        {
                            ownedChunks += "[" + ColonyAPI.Managers.WorldManager.XZPositionToString(c.location.ToChunk()) + "], ";
                        }
                    }

                    ColonyAPI.Helpers.Chat.sendSilent(ply, ownedChunks, ColonyAPI.Helpers.Chat.ChatColour.cyan, ColonyAPI.Helpers.Chat.ChatStyle.bold);
                }
                else
                {
                    ColonyAPI.Helpers.Chat.sendSilent(ply, "You own no chunks", ColonyAPI.Helpers.Chat.ChatColour.red, ColonyAPI.Helpers.Chat.ChatStyle.bold);
                }
            }
            else
            {
                ColonyAPI.Helpers.Chat.sendSilent(ply, "You cannot claim chunks", ColonyAPI.Helpers.Chat.ChatColour.red, ColonyAPI.Helpers.Chat.ChatStyle.bold);
            }

            return(true);
        }
        public void EditCommand(Players.Player causedBy, string param)
        {
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "announcements.edit"))
            {
                return;
            }
            var m = Regex.Match(param, @"A?(?<index>\d+) (?<text>.+)");

            if (!m.Success)
            {
                Chat.Send(causedBy, $"Params didn't match, use {EDIT_PREFIX} A[index] [text]");
                return;
            }
            string StrIndex = m.Groups ["index"].Value;
            int    Index;

            if (!int.TryParse(StrIndex, out Index))
            {
                Chat.Send(causedBy, $"Could not parse given parameter '{StrIndex}' as index number");
                return;
            }
            string Text = m.Groups ["text"].Value;

            Announcements.ChangeAnnouncement(Index, Text);
            Chat.Send(causedBy, $"Changed announcement {Index}");
        }
Example #12
0
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/ban"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "ban"))
            {
                return(true);
            }
            var m = Regex.Match(chattext, @"/ban (?<targetplayername>['].+[']|[^ ]+)");

            if (!m.Success)
            {
                Chat.Send(causedBy, "Command didn't match, use /ban [targetplayername]");
                return(true);
            }
            var targetPlayerName = m.Groups ["targetplayername"].Value;

            Players.Player targetPlayer;
            string         error;

            if (!PlayerHelper.TryGetPlayer(targetPlayerName, out targetPlayer, out error))
            {
                Chat.Send(causedBy, $"Could not find target player '{targetPlayerName}'; {error}");
                return(true);
            }
            Chat.Send(targetPlayer, "<color=red>You were banned from the server</color>");
            Chat.SendToConnected($"{targetPlayer.Name} is banned by {causedBy.Name}");
            BlackAndWhitelisting.AddBlackList(targetPlayer.ID.steamID.m_SteamID);
            BlackAndWhitelisting.Reload();
            Players.Disconnect(targetPlayer);
            return(true);
        }
Example #13
0
        public bool TryDoCommand(Players.Player player, string chat, List <string> splits)
        {
            if (!chat.Trim().ToLower().Equals("/sign_owner"))
            {
                return(false);
            }

            if (!PermissionsManager.CheckAndWarnPermission(player, "khanx.signowner"))
            {
                return(true);
            }

            foreach (var singPosition in SignManager.signs.Keys)
            {
                if (Math.ManhattanDistance(new Vector3Int(player.Position), singPosition) < SignManager.markerDistance)
                {
                    Sign sign = SignManager.signs[singPosition];

                    if (Players.TryGetPlayer(sign.owner, out Players.Player plOwner))
                    {
                        Chat.Send(player, string.Format("{0} is the owner of the sign located in ({1}, {2}, {3})", plOwner.Name, singPosition.x, singPosition.y, singPosition.z));
                    }
                    else
                    {
                        Chat.Send(player, string.Format("<color=red>The owner has not been identified</color> of the sign located in ({0}, {1}, {2})", singPosition.x, singPosition.y, singPosition.z));
                    }
                }
            }

            return(true);
        }
Example #14
0
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/help"))
            {
                return(false);
            }
            var    m = Regex.Match(chattext, @"/help (?<section>.+)");
            string cmdList;

            // without filter basic command list
            if (!m.Success)
            {
                cmdList = string.Join(", ", basicList);
                Chat.Send(causedBy, "Type /help warp|event|jail... to filter.");
                Chat.Send(causedBy, $"Commands: {cmdList}");
                return(true);
            }

            // all admin commands - only if permission
            string filter = m.Groups["section"].Value;

            if (filter.Equals("admin"))
            {
                if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "adminhelp"))
                {
                    return(true);
                }
                cmdList = string.Join(", ", adminList);
                Chat.Send(causedBy, $"Admin commands: {cmdList}");
                return(true);
            }

            // filter by matching
            List <string> matching = new List <string>();

            foreach (string elem in basicList)
            {
                if (elem.Contains(filter))
                {
                    matching.Add(elem);
                }
            }
            // search admin command only if permission ok
            if (PermissionsManager.HasPermission(causedBy, AntiGrief.MOD_PREFIX + "adminhelp"))
            {
                foreach (string elem in adminList)
                {
                    if (elem.Contains(filter))
                    {
                        matching.Add(elem);
                    }
                }
            }
            cmdList = string.Join(", ", matching.ToArray());
            Chat.Send(causedBy, $"Matching commands: {cmdList}");

            return(true);
        }
 public void AddCommand(Players.Player causedBy, string param)
 {
     if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "announcements.add"))
     {
         return;
     }
     Announcements.AddAnnouncement(param);
     Chat.Send(causedBy, "New announcement placed next");
 }
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/jail"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "jail"))
            {
                return(true);
            }

            var m = Regex.Match(chattext, @"/jail (?<player>['].+[']|[^ ]+) (?<jailtime>[0-9]+)? ?(?<reason>.+)$");

            if (!m.Success)
            {
                Chat.Send(causedBy, "Syntax error, use /jail <player> [time] <reason>");
                return(true);
            }

            Players.Player target;
            string         targetName = m.Groups["player"].Value;
            string         error;

            if (!PlayerHelper.TryGetPlayer(targetName, out target, out error, true))
            {
                Chat.Send(causedBy, $"Could not find player {targetName}: {error}");
                return(true);
            }

            uint jailtime = 0;
            var  timeval  = m.Groups["jailtime"].Value;

            if (timeval.Equals(""))
            {
                jailtime = JailManager.DEFAULT_JAIL_TIME;
            }
            else
            {
                if (!uint.TryParse(timeval, out jailtime))
                {
                    Chat.Send(causedBy, $"Could not identify time value {timeval}");
                }
            }
            string reason = m.Groups["reason"].Value;

            if (JailManager.IsPlayerJailed(target))
            {
                Chat.Send(causedBy, $"{target.Name} is already in jail.");
                return(true);
            }

            JailManager.jailPlayer(target, causedBy, reason, jailtime);
            Chat.Send(causedBy, $"Threw {target.Name} into the jail for {jailtime} minutes");

            return(true);
        }
Example #17
0
 protected override bool RunCommand(Players.Player ply, string[] args, NetworkID target)
 {
     if (PermissionsManager.CheckAndWarnPermission(ply, "kick"))
     {
         var targetPlayer = Players.GetPlayer(target);
         ServerManager.Disconnect(targetPlayer);
         ColonyAPI.Helpers.Chat.send(ply, $"Kicked {targetPlayer.Name}", ColonyAPI.Helpers.Chat.ChatColour.magenta);
     }
     return(true);
 }
Example #18
0
 public bool TryDoCommand(Players.Player causedBy, string chattext)
 {
     if (causedBy != null)
     {
         foreach (string permission in new string[] { "mods.scarabol.sphere.create" })
         {
             if (PermissionsManager.CheckAndWarnPermission(causedBy, permission))
             {
                 var m = Regex.Match(chattext, @"/sphere (?<px>-?\d+) (?<py>-?\d+) (?<pz>-?\d+) (?<r>\d+) (?<mat>.+)");
                 if (m.Success)
                 {
                     int    px  = Int32.Parse(m.Groups["px"].Value);
                     int    py  = Int32.Parse(m.Groups["py"].Value);
                     int    pz  = Int32.Parse(m.Groups["pz"].Value);
                     int    r   = Int32.Parse(m.Groups["r"].Value);
                     string mat = m.Groups["mat"].Value;
                     if (mat.Equals("water"))
                     {
                         Chat.Send(causedBy, "just don't ...");
                         return(true);
                     }
                     Vector3Int position = new Vector3Int(px, py, pz);
                     Chat.Send(causedBy, string.Format("Generating sphere centered at {0} with radius {1}", position, r));
                     ushort typeIndex = ItemTypes.IndexLookup.GetIndex(mat);
                     ThreadManager.InvokeOnMainThread(delegate()
                     {
                         for (int x = -r + 1; x < r; x++)
                         {
                             for (int y = -r + 1; y < r; y++)
                             {
                                 for (int z = -r + 1; z < r; z++)
                                 {
                                     Vector3Int p = new Vector3Int(px, py, pz).Add(x, y, z);
                                     int d        = (int)System.Math.Round(System.Math.Sqrt(x * x + y * y + z * z));
                                     if (d < r)
                                     {
                                         ServerManager.TryChangeBlock(p, typeIndex);
                                     }
                                 }
                             }
                         }
                     }, 1.0);
                 }
                 else
                 {
                     Chat.Send(causedBy, "Command didn't match, use /sphere x y z r materialname");
                 }
                 return(true);
             }
         }
         Chat.Send(causedBy, "Permission denied!");
     }
     return(true);
 }
Example #19
0
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/warpplace"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "warp.place"))
            {
                return(true);
            }
            var m = Regex.Match(chattext, @"/warpplace (?<px>-?\d+) (?<py>-?\d+)( (?<pz>-?\d+))?");

            if (!m.Success)
            {
                Chat.Send(causedBy, "Syntax: /warpplace [x] [y] [z] or /warpplace [x] [z]");
                return(true);
            }
            var   xCoord = m.Groups ["px"].Value;
            float vx;

            if (!float.TryParse(xCoord, out vx))
            {
                Chat.Send(causedBy, $"Failure parsing first coordinate '{xCoord}'");
                return(true);
            }
            var   yCoord = m.Groups ["py"].Value;
            float vy;

            if (!float.TryParse(yCoord, out vy))
            {
                Chat.Send(causedBy, $"Failure parsing second coordinate '{yCoord}'");
                return(true);
            }
            var   zCoord = m.Groups ["pz"].Value;
            float vz;

            if (zCoord.Length > 0)
            {
                if (!float.TryParse(zCoord, out vz))
                {
                    Chat.Send(causedBy, $"Failure parsing third coordinate '{zCoord}'");
                    return(true);
                }
            }
            else
            {
                TerrainGenerator gen = (TerrainGenerator)ServerManager.TerrainGenerator;
                vz = vy;
                vy = (float)(gen.QueryData((int)vx, (int)vz).Height + 1);
            }
            Helper.TeleportPlayer(causedBy, new UnityEngine.Vector3(vx, vy, vz));
            return(true);
        }
Example #20
0
 protected override bool RunCommand(Players.Player ply, string[] args, NetworkID[] targets)
 {
     if (PermissionsManager.CheckAndWarnPermission(ply, "unban"))
     {
         //TODO: Log unbans
         var targetPlayer = Players.GetPlayer(targets[0]);
         Classes.Managers.BanManager.removeBan(targetPlayer.ID);
         BlackAndWhitelisting.RemoveBlackList(targetPlayer.ID.steamID.m_SteamID);
         Chat.send(ply, $"Unbanned {targetPlayer.Name}", Chat.ChatColour.cyan);
     }
     return(true);
 }
Example #21
0
 public bool TryDoCommand(Players.Player causedBy, string chattext)
 {
     try {
         if (PermissionsManager.CheckAndWarnPermission(causedBy, KingdomsModEntries.MOD_PREFIX + "lootbox"))
         {
             Lootbox.DoGamble(causedBy);
         }
     } catch (Exception exception) {
         Log.WriteError($"Exception while parsing command; {exception.Message} - {exception.StackTrace}");
     }
     return(true);
 }
Example #22
0
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/colonycap"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "colonycap"))
            {
                return(true);
            }

            var m = Regex.Match(chattext, @"/colonycap (?<colonistslimit>-?\d+)( (?<checkintervalseconds>\d+))?");

            if (!m.Success)
            {
                Chat.Send(causedBy, "Syntax: /colonycap {colonistslimit} [checkintervalseconds]");
                return(true);
            }

            int limit;

            if (!int.TryParse(m.Groups["colonistslimit"].Value, out limit))
            {
                Chat.Send(causedBy, "Could not parse limit");
                return(true);
            }

            AntiGrief.ColonistLimit = limit;
            if (AntiGrief.ColonistLimit > 0)
            {
                Chat.SendToConnected($"Colony population limit set to {AntiGrief.ColonistLimit}");
            }
            else
            {
                Chat.SendToConnected("Colony population limit disabled");
            }

            string strInterval = m.Groups["checkintervalseconds"].Value;

            if (strInterval.Length > 0)
            {
                int interval;
                if (!int.TryParse(strInterval, out interval))
                {
                    Chat.Send(causedBy, "Could not parse interval");
                    return(true);
                }
                AntiGrief.ColonistLimitCheckSeconds = System.Math.Max(1, interval);
                Chat.Send(causedBy, $"Check interval seconds set to {AntiGrief.ColonistLimitCheckSeconds}");
            }
            return(true);
        }
Example #23
0
        protected override bool RunCommand(Players.Player ply, string[] args, NetworkID target)
        {
            if (PermissionsManager.CheckAndWarnPermission(ply, "locate"))
            {
                var player = Players.GetPlayer(target);
                var status = player.IsConnected ? "online" : "offline";

                Chat.sendSilent(ply,
                                $"{player.Name} is {status} and was last seen at x:{player.Position.x} y:{player.Position.y} z:{player.Position.z}", Chat.ChatColour.magenta);
            }

            return(true);
        }
Example #24
0
        public bool TryDoCommand(Players.Player player, string chat, List <string> splits)
        {
            if (!chat.Trim().ToLower().StartsWith("//limit"))
            {
                return(false);
            }

            //Player exists
            if (null == player || NetworkID.Server == player.ID)
            {
                return(true);
            }

            //Check permissions
            if (!PermissionsManager.CheckAndWarnPermission(player, "khanx.wand"))
            {
                return(true);
            }

            AdvancedWand wand = AdvancedWand.GetAdvancedWand(player);

            //Wand is OFF
            if (!wand.active)
            {
                Chat.Send(player, "<color=orange>Wand is OFF, use //wand to activate</color>");
                return(true);
            }

            if (1 == splits.Count)
            {
                Chat.Send(player, string.Format("<color=lime>Limit: {0}</color>", wand.limit));
                return(true);
            }

            if (2 != splits.Count)
            {
                Chat.Send(player, "<color=orange>Wrong Arguments</color>");
                return(true);
            }

            if (!int.TryParse(splits[1], out int newLimit))
            {
                Chat.Send(player, "<color=orange>Not number</color>");
                return(true);
            }

            wand.limit = newLimit;
            Chat.Send(player, string.Format("<color=lime>Limit: {0}</color>", newLimit));

            return(true);
        }
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/inactive"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "inactive"))
            {
                return(true);
            }
            int days;

            if (splits.Count == 2)
            {
                if (!int.TryParse(splits[1], out days))
                {
                    Chat.Send(causedBy, $"Could not parse days value");
                    return(true);
                }
            }
            else
            {
                Chat.Send(causedBy, "Syntax: /inactive {days}");
                return(true);
            }

            string resultMsg = "";
            int    counter   = 0;

            foreach (KeyValuePair <Players.Player, int> entry in ActivityTracker.GetInactivePlayers(days))
            {
                Players.Player player       = entry.Key;
                int            inactiveDays = entry.Value;
                if (resultMsg.Length > 0)
                {
                    resultMsg += ", ";
                }
                resultMsg += $"{player.ID.ToStringReadable()}({inactiveDays})";
                counter++;
            }
            if (counter == 0)
            {
                resultMsg = "No inactive players found";
            }
            else
            {
                resultMsg += $". In total {counter} players";
            }
            Chat.Send(causedBy, resultMsg);
            return(true);
        }
Example #26
0
 public static void OnPlaceCapsule(Vector3Int position, ushort capsuleType, Players.Player causedBy)
 {
     if (!PermissionsManager.CheckAndWarnPermission(causedBy, CapsulesModEntries.CAPSULE_PERMISSION))
     {
         ServerManager.TryChangeBlock(position, BlockTypes.Builtin.BuiltinBlocks.Air);
         return;
     }
     ThreadManager.InvokeOnMainThread(delegate()
     {
         ushort realType;
         if (World.TryGetTypeAt(position, out realType) && realType != capsuleType)
         {
             return;
         }
         ServerManager.TryChangeBlock(position, BlockTypes.Builtin.BuiltinBlocks.Air);
         string capsuleName   = ItemTypes.IndexLookup.GetName(capsuleType);
         string blueprintName = capsuleName.Substring(0, capsuleName.Length - CapsulesModEntries.CAPSULE_SUFFIX.Length - 2);
         Chat.Send(causedBy, string.Format("Starting to build '{0}' at {1}", blueprintName, position));
         List <BlueprintTodoBlock> blocks;
         if (ManagerBlueprints.blueprints.TryGetValue(blueprintName, out blocks))
         {
             int placed      = 0, removed = 0, failed = 0;
             ushort bluetype = ItemTypes.IndexLookup.GetIndex(blueprintName + capsuleName.Substring(capsuleName.Length - 2));
             foreach (BlueprintTodoBlock block in blocks)
             {
                 Vector3Int realPosition = block.GetWorldPosition(blueprintName, position, bluetype);
                 if (realPosition.y > 0 && ServerManager.TryChangeBlock(realPosition, ItemTypes.IndexLookup.GetIndex(block.typename)))
                 {
                     if (block.typename.Equals("air"))
                     {
                         removed++;
                     }
                     else
                     {
                         placed++;
                     }
                 }
                 else
                 {
                     failed++;
                 }
             }
             Chat.Send(causedBy, string.Format("Completed '{0}' at {1} with {2} placed, {3} removed and {4} failed blocks", blueprintName, position, placed, removed, failed));
         }
         else
         {
             Chat.Send(causedBy, string.Format("Blueprint '{0}' not found", blueprintName));
         }
     }, 2.0);
 }
Example #27
0
 protected override bool RunCommand(Players.Player ply, string[] args, NetworkID target)
 {
     if (PermissionsManager.CheckAndWarnPermission(ply, "tp.admin"))
     {
         Players.Player targetPly = Players.GetPlayer(target);
         ChatCommands.Implementations.Teleport.TeleportTo(ply, targetPly.Position);
         Chat.Send(ply, "Teleported you to " + targetPly.Name);
     }
     else
     {
         Chat.Send(ply, "You don't have permission to admin teleport.");
     }
     return(true);
 }
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/killnpcs"))
            {
                return(false);
            }

            Players.Player targetPlayer = causedBy;
            var            m            = Regex.Match(chattext, @"/killnpcs ?(?<targetplayername>['].+[']|[^ ]+)");

            if (m.Success)
            {
                string targetPlayerName = m.Groups["targetplayername"].Value;
                string error;
                if (!PlayerHelper.TryGetPlayer(targetPlayerName, out targetPlayer, out error, true))
                {
                    Chat.Send(causedBy, $"Could not find '{targetPlayerName}'; {error}");
                    return(true);
                }
            }

            string permission = AntiGrief.MOD_PREFIX + "killnpcs";

            if (targetPlayer == causedBy)
            {
                permission += ".self";
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, permission))
            {
                return(true);
            }

            if (targetPlayer.ActiveColony == null)
            {
                Chat.Send(targetPlayer, $"You have to be at an active colony to allow NPC killing");
                if (targetPlayer != causedBy)
                {
                    Chat.Send(causedBy, $"{targetPlayer.Name} is not at an active colony");
                }
                return(true);
            }

            List <NPCBase> cachedFollowers = new List <NPCBase>(targetPlayer.ActiveColony.Followers);

            foreach (NPCBase npc in cachedFollowers)
            {
                npc.OnDeath();
            }
            return(true);
        }
 public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
 {
     if (!splits[0].Equals("/travelhere"))
     {
         return(false);
     }
     if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "travelpaths"))
     {
         return(true);
     }
     WaypointManager.startWaypoints.Add(causedBy, causedBy.VoxelPosition);
     Chat.Send(causedBy, $"Added start waypoint at {causedBy.VoxelPosition}, use /travelthere to set the endpoint");
     return(true);
 }
        public void RemoveCommand(Players.Player causedBy, string param)
        {
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "announcements.remove"))
            {
                return;
            }
            int Index;

            if (!TryGetIndex(causedBy, param, REMOVE_PREFIX, out Index))
            {
                return;
            }
            Announcements.RemoveAnnouncement(Index);
            Chat.Send(causedBy, $"Removed announcement {Index} from queue");
        }