예제 #1
0
 public static void Help(Player p, string cmd)
 {
     switch (cmd)
     {
         case "ban":
             p.SendMessage(0xFF, "/ban player - Removes player's priveleges");
             p.SendMessage(0xFF, "/ban player reason - Bans player with reason");
             break;
         case "unban":
             p.SendMessage(0xFF, "/unban player - Removes the ban on player");
             break;
         case "ipban":
             p.SendMessage(0xFF, "/ipban player - Bans player's ip");
             p.SendMessage(0xFF, "/ipban player reason - Bans player's ip with reason");
             break;
         case "unipban":
             p.SendMessage(0xFF, "/unipban ip - Removes the ipban on ip");
             break;
         case "kick":
             p.SendMessage(0xFF, "/kick player - Disconnects a player");
             p.SendMessage(0xFF, "/kick player reason - Disconnects a player with reason");
             break;
         default:
             break;
     }
 }
예제 #2
0
 public static void Where(Player p, string message)
 {
     if (message.Equals(""))
     {
         p.SendMessage(0xFF, String.Format("X: {0}, Y: {1}, Z: {2}", p.x/32, p.y/32, p.z/32));
     }
     else
     {
         bool found = false;
         foreach (Player pl in Program.server.playerlist)
         {
             if (pl != null && pl.loggedIn && !pl.disconnected && pl.username.ToLower().Equals(message.Trim().ToLower()))
             {
                 p.SendMessage(0xFF, String.Format("-> " + pl.GetFormattedName() + "&e X: {0}, Y: {1}, Z: {2}", pl.x/32, pl.y/32, pl.z/32));
                 return;
             }
             else if (pl != null && pl.loggedIn && !pl.disconnected && pl.username.Substring(0, message.Length).ToLower().Equals(message.ToLower().Trim()))
             {
                 p.SendMessage(0xFF, String.Format("-> " + pl.GetFormattedName() + "&e X: {0}, Y: {1}, Z: {2}", pl.x / 32, pl.y / 32, pl.z / 32));
                 found = true;
             }
         }
         if (!found)
         {
             p.SendMessage(0xFF, "Could not find player " + message);
         }
     }
 }
예제 #3
0
        public static void NewWorld(Player p, string message)
        {
            if (message.Trim().Equals(""))
            {
                Help(p, "newworld");
                return;
            }

            string[] args = message.Trim().Split(' ');
            if (args.Length != 4)
            {
                Help(p, "newworld");
                return;
            }

            string worldname = args[0];
            short w = Int16.Parse(args[1]);
            short h = Int16.Parse(args[2]);
            short d = Int16.Parse(args[3]);
            worldname += ".umw";

            if (System.IO.File.Exists("maps/" + worldname))
            {
                p.SendMessage(0xFF, "That filename already exists!");
                return;
            }

            World newworld = new World(worldname, w, h, d);
            newworld.Save();

            p.SendMessage(0xFF, "Created new world: " + worldname);
        }
예제 #4
0
 public static void Help(Player p, string cmd)
 {
     switch (cmd)
     {
         case "colors":
             p.SendMessage(0xFF, "/colors - displays information about color codes");
             break;
         case "chars":
             p.SendMessage(0xFF, "/chars - displays information about special characters");
             break;
         default:
             break;
     }
 }
예제 #5
0
 public static void Ban(Player p, string message)
 {
     if (!message.Trim().Contains(" "))
     {
         if (p.username.ToLower().Equals(message.Trim().ToLower()))
         {
             p.SendMessage(0xFF, "You can't ban yourself!");
             return;
         }
         Player pl = Player.FindPlayer(p, message.Trim(), false);
         if (pl != null && (pl.rank < p.rank || p.username.Equals("[console]")))
         {
             ChangeRankCommand.Base(p, pl.username, Rank.RankLevel("none"));
             Player.GlobalMessage(p.GetFormattedName() + "&e banned " + pl.username);
             return;
         }
         else if (pl != null && pl.rank >= p.rank)
         {
             p.SendMessage(0xFF, "You can't ban that person!");
         }
         else if (pl == null && Program.server.playerRanksDict.ContainsKey(message.Trim().ToLower()))
         {
             Program.server.playerRanksDict[message.Trim().ToLower()] = Rank.RankLevel("none");
             Program.server.saveRanks();
             Player.GlobalMessage(p.GetFormattedName() + "&e banned " + message.Trim() + "&f(offline)&e");
         }
     }
     else
     {
         string ply = message.Trim().Substring(0, message.IndexOf(" "));
         string reason = message.Trim().Substring(message.IndexOf(" ") + 1);
         if (p.username.ToLower().Equals(ply.Trim().ToLower()))
         {
             p.SendMessage(0xFF, "You can't ban yourself!");
             return;
         }
         Player pl = Player.FindPlayer(p, ply, false);
         if (pl != null && (pl.rank < p.rank || p.username.Equals("[console]")))
         {
             ChangeRankCommand.Base(p, pl.username, Rank.RankLevel("none"));
             Player.GlobalMessage(p.GetFormattedName() + "&e banned " + pl.username + " (" + reason + ")");
         }
         else if (pl.rank >= p.rank)
         {
             p.SendMessage(0xFF, "You can't ban that person!");
         }
     }
 }
예제 #6
0
 public static void Who(Player p, string message)
 {
     Player pl = Player.FindPlayer(p, message.Trim(), true);
     if (pl != null)
     {
         StringBuilder msg = new StringBuilder();
         msg.Append(pl.GetFormattedName());
         msg.Append("&e is ranked " + Rank.GetColor(pl.rank) + Rank.RankName(pl.rank));
         msg.Append("&e and is connected from IP &b" + pl.ip);
         p.SendMessage(0x00, msg.ToString());
     }
     else
     {
         p.SendMessage(0xFF, "Command failed (could not find player)");
     }
 }
예제 #7
0
 public static void Chars(Player p, string message)
 {
     p.SendMessage(0xFF, "Character Codes: ");
     string temp = String.Empty;
     foreach (KeyValuePair<string, char> rule in Player.specialChars)
     {
         temp += (("&c" + rule.Key + "&e ").PadRight(8) + rule.Value).PadRight(15);
         if (temp.Length >= 60)
         {
             p.SendMessage(0x0, temp);
             temp = String.Empty;
         }
     }
     p.SendMessage(0x0, temp);
     //p.SendMessage(0x0, @"&c\# &e Displays the character with byte id #");
 }
예제 #8
0
 public static void Help(Player p, string cmd)
 {
     switch (cmd)
     {
         case "newworld":
             p.SendMessage(0xFF, "/newworld name x y z - Creates a x*y*z size map with the specified name");
             //p.SendMessage(0xFF, "Available modes: normal, image");
             break;
         case "setspawn":
             p.SendMessage(0xFF, "/setspawn - Sets the map's spawnpoint to your location");
             break;
         case "spawn":
             p.SendMessage(0xFF, "/spawn - Returns you to the map's spawnpoint");
             break;
         default:
             break;
     }
 }
예제 #9
0
파일: Command.cs 프로젝트: roy12345/uMiner
        public static void HandleCommand(Player p, string cmd, string msg)
        {
            if(commands.ContainsKey(cmd))
            {
                if(p.rank < commands[cmd].minRank)
                {
                    p.SendMessage(0xFF, "You can't use that command!");
                    return;
                }
                Program.server.logger.log(p.username + " uses /" + cmd);
                commands[cmd].handler(p, msg);

            }
            else
            {
                p.SendMessage(0xFF, "No such command &c/" + cmd);
            }
        }
예제 #10
0
        public static void SetSpawn(Player p, string message)
        {
            Program.server.world.spawnx = (short)(p.x >> 5);
            Program.server.world.spawny = (short)(p.y >> 5);
            Program.server.world.spawnz = (short)(p.z >> 5);

            Program.server.world.srotx = p.rotx;
            Program.server.world.sroty = p.roty;

            Program.server.world.Save();

            p.SendMessage(0xFF, "Spawnpoint saved");
        }
예제 #11
0
 public static void Help(Player p, string message)
 {
     if (!message.Trim().Equals(""))
     {
         Command.HelpMessage(p, message.Trim());
         return;
     }
     p.SendMessage(0xFF, "Running uMiner Rev. &a" + Program.revision.ToString() + "&e " + (char)1 + ".");
     p.SendMessage(0xFF, "---------------------");
     p.SendMessage(0xFF, "Global messages are enclosed in brackets [ ]");
     p.SendMessage(0xFF, "Visit &fhttp://github.com/calzoneman/uMiner&e for downloads and source code.");
     p.SendMessage(0xFF, "---------------------");
     p.SendMessage(0xFF, "Type &5/help commands&e for information about available commands");
     p.SendMessage(0xFF, "Type &5/help commandname&e for information about a specific command");
     p.SendMessage(0xFF, "Type &5/ranks&e for information on ranks");
 }
예제 #12
0
 public static void Ranks(Player p, string message)
 {
     p.SendMessage(0xFF, "Ranks: ");
     p.SendMessage(0, "&4@owner &e(" + Rank.RankLevel("owner") + ")");
     p.SendMessage(0, "&9+operator &e(" + Rank.RankLevel("operator") + ")");
     p.SendMessage(0, "player &e(" + Rank.RankLevel("player") + ")");
     p.SendMessage(0, "&7guest &e(" + Rank.RankLevel("guest") + ")");
     p.SendMessage(0, "&0[:(]banned &e(" + Rank.RankLevel("none") + ")");
 }
예제 #13
0
 public static void Commands(Player p, string message)
 {
     StringBuilder availableCmds = new StringBuilder();
     availableCmds.Append("Available commands:");
     foreach (KeyValuePair<string, Command> cmd in Command.commands)
     {
         if (cmd.Value.minRank <= p.rank)
         {
             availableCmds.Append(" ");
             availableCmds.Append(Rank.GetColor(cmd.Value.minRank));
             availableCmds.Append(cmd.Key);
         }
     }
     p.SendMessage(0xFF, availableCmds.ToString());
 }
예제 #14
0
 public static void Kick(Player p, string message)
 {
     if (!message.Trim().Contains(" "))
     {
         Player pl = Player.FindPlayer(p, message.Trim(), false);
         if (pl != null && (pl.rank <= p.rank || p.username.Equals("[console]")))
         {
             pl.Kick("Kicked by " + p.username + "&e", false);
         }
         else if(pl != null && pl.rank > p.rank)
         {
             p.SendMessage(0xFF, "You can't kick that person!");
         }
         return;
     }
     else
     {
         string ply = message.Trim().Substring(0, message.Trim().IndexOf(" "));
         string reason = message.Trim().Substring(message.Trim().IndexOf(" ") + 1);
         Player pl = Player.FindPlayer(p, ply, false);
         if (pl != null && (pl.rank <= p.rank || p.username.Equals("[console]")))
         {
             pl.Kick(reason, false);
         }
         else if(pl.rank > p.rank)
         {
             p.SendMessage(0xFF, "You can't kick that person!");
         }
         return;
     }
 }
예제 #15
0
 public static void Colors(Player p, string message)
 {
     p.SendMessage(0xFF, "Color codes: ");
     p.SendMessage(0, "&0%0 &1%1 &2%2 &3%3 &4%4 &5%5 &6%6 &7%7");
     p.SendMessage(0, "&8%8 &9%9 &a%a &b%b &c%c &d%d &e%e &f%f");
 }
예제 #16
0
        public static void UnbanIp(Player p, string message)
        {
            message = message.Trim();
            if (!Program.server.ipbanned.Contains(message))
            {
                p.SendMessage(0xFF, "Cannot find ip " + message);
                return;
            }

            Program.server.ipbanned.Remove(message);
            Program.server.saveIpBans();

            foreach (Player pl in Program.server.playerlist)
            {
                if (pl != null && pl != p && pl.ip.Equals(message))
                {
                    ChangeRankCommand.Base(p, pl.username, Rank.RankLevel("guest"));
                    break;
                }
            }

            Player.GlobalMessage(p.GetFormattedName() + "&e unipbanned " + message);
        }
예제 #17
0
파일: Command.cs 프로젝트: roy12345/uMiner
 public static void HelpMessage(Player p, string cmd)
 {
     switch (cmd)
     {
         case "chars":
         case "colors":
             ColorCommand.Help(p, cmd);
             break;
         case "commands":
             HelpCommand.Commands(p, cmd);
             break;
         case "fetch":
         case "tp":
             TeleportCommand.Help(p, cmd);
             break;
         case "guest":
         case "player":
         case "operator":
             ChangeRankCommand.Help(p, cmd);
             break;
         case "help":
             p.SendMessage(0xFF, "/help - Displays a help menu");
             break;
         case "ranks":
             p.SendMessage(0xFF, "/ranks - Displays information regarding ranks");
             break;
         case "kick":
         case "ban":
         case "ipban":
         case "unban":
         case "unipban":
             DisconnectCommand.Help(p, cmd);
             break;
         case "newworld":
         case "setspawn":
         case "spawn":
             WorldCommand.Help(p, "newworld");
             break;
         case "place":
             PlaceCommand.Help(p);
             break;
         case "say":
             SayCommand.Help(p);
             break;
         case "where":
             WhereCommand.Help(p);
             break;
         case "who":
             WhoCommand.Help(p);
             break;
         default:
             break;
     }
 }
예제 #18
0
 public static void IpBan(Player p, string message)
 {
     if (!message.Trim().Contains(" "))
     {
         if (p.username.ToLower().Equals(message.Trim().ToLower()))
         {
             p.SendMessage(0xFF, "You can't ipban yourself!");
             return;
         }
         Player pl = Player.FindPlayer(p, message.Trim(), false);
         if (pl != null && (pl.rank < p.rank || p.username.Equals("[console]")))
         {
             ChangeRankCommand.Base(p, pl.username, Rank.RankLevel("none"));
             Program.server.ipbanned.Add(pl.ip);
             Program.server.saveIpBans();
             Player.GlobalMessage(p.GetFormattedName() + "&e ipbanned " + pl.username);
             return;
         }
         else if (pl != null && pl.rank >= p.rank)
         {
             p.SendMessage(0xFF, "You can't IPBan that person!");
         }
     }
     else
     {
         string ply = message.Trim().Substring(0, message.IndexOf(" "));
         string reason = message.Trim().Substring(message.IndexOf(" ") + 1);
         if (p.username.ToLower().Equals(message.Trim().ToLower()))
         {
             p.SendMessage(0xFF, "You can't ipban yourself!");
             return;
         }
         Player pl = Player.FindPlayer(p, ply, false);
         if (pl != null && (pl.rank < p.rank || p.username.Equals("[console]")) && !pl.ip.Equals("127.0.0.1"))
         {
             ChangeRankCommand.Base(p, pl.username, Rank.RankLevel("none"));
             Program.server.ipbanned.Add(pl.ip);
             Program.server.saveIpBans();
             Player.GlobalMessage(p.GetFormattedName() + "&e ipbanned " + pl.username + " (" + reason + ")");
             return;
         }
         else if (pl.rank >= p.rank || pl.ip.Equals("127.0.0.1"))
         {
             p.SendMessage(0xFF, "You can't IPBan that person!");
         }
     }
 }
예제 #19
0
 public static void Help(Player p)
 {
     p.SendMessage(0xFF, "/who player - Displays information about player");
 }
예제 #20
0
 public static void Help(Player p, string cmd)
 {
     p.SendMessage(0xFF, "/" + cmd + " player - set player's rank to " + cmd);
 }
예제 #21
0
        public static void Base(Player p, string message, byte newrank)
        {
            if (message.Trim().Equals(""))
            {
                p.SendMessage(0xFF, "No player specified");
                return;
            }

            Player pl = uMiner.Player.FindPlayer(p, message, false);
            if (pl != null)
            {
                if (pl.username.Equals(p.username))
                {
                    p.SendMessage(0xFF, "You can't change your own rank!");
                }
                if (pl.rank < newrank || p.rank > pl.rank || p.username.Equals("[console]"))
                {
                    byte oldRank = pl.rank;
                    pl.rank = newrank;
                    Program.server.playerRanksDict[pl.username.ToLower()] = pl.rank;
                    Program.server.saveRanks();

                    if (newrank == 0)
                    {
                        pl.prefix = "[:(]";
                    }
                    else if (newrank < Rank.RankLevel("operator"))
                    {
                        pl.prefix = "";
                    }
                    else if (newrank == Rank.RankLevel("operator"))
                    {
                        pl.prefix = "+";
                    }
                    else if (newrank == Rank.RankLevel("owner"))
                    {
                        pl.prefix = "@";
                    }

                    //Clear the player's binding as a safeguard
                    pl.binding = Bindings.None;

                    //If the person was OP before, disable adminium editing
                    //Vice versa as well
                    if (oldRank >= Rank.RankLevel("operator") && newrank < Rank.RankLevel("operator"))
                    {
                        Packet deop = new Packet(2);
                        deop.Append((byte)ServerPacket.RankUpdate);
                        deop.Append((byte)0x0);
                        pl.SendPacket(deop);
                    }
                    else if (oldRank < Rank.RankLevel("operator") && newrank >= Rank.RankLevel("operator"))
                    {
                        Packet deop = new Packet(2);
                        deop.Append((byte)ServerPacket.RankUpdate);
                        deop.Append((byte)0x64);
                        pl.SendPacket(deop);
                    }

                    //Despawn and respawn player
                    Packet despawn = new Packet(2);
                    despawn.Append((byte)ServerPacket.PlayerDie);
                    despawn.Append(pl.id);
                    foreach (Player ply in Program.server.playerlist)
                    {
                        if (ply != null && ply != pl && ply.loggedIn && !ply.disconnected)
                        {
                            ply.SendPacket(despawn);
                        }
                    }
                    uMiner.Player.GlobalSpawnPlayer(pl);
                    uMiner.Player.GlobalMessage(p.GetFormattedName() + "&e set " + pl.GetFormattedName() + "&e's rank to " + Rank.GetColor(newrank) + Rank.RankName(newrank) + "&e");
                }
                else
                {
                    p.SendMessage(0xFF, "Player " + pl.GetFormattedName() + "&e cannot have rank set to " + Rank.GetColor(newrank) + Rank.RankName(newrank));
                }
                return;
            }
        }
예제 #22
0
 public static void Help(Player p)
 {
     p.SendMessage(0xFF, "/me action - Displays a roleplaying action");
 }
예제 #23
0
 public static void Help(Player p)
 {
     p.SendMessage(0xFF, "/where - Tells your location");
     p.SendMessage(0xFF, "/where player - Tells you player's location");
 }
예제 #24
0
        public static void Unban(Player p, string message)
        {
            message = message.Trim().ToLower();

            Player pl = Player.FindPlayer(p, message.Trim().ToLower(), false);
            if(pl != null)
            {
                ChangeRankCommand.Base(p, message, Rank.RankLevel("guest"));
            }

            else
            {
                if (!Program.server.playerRanksDict.ContainsKey(message))
                {
                    p.SendMessage(0xFF, "Cannot find player " + message);
                    return;
                }
                Program.server.playerRanksDict[message] = Rank.RankLevel("guest");
                Program.server.saveRanks();
            }

            Player.GlobalMessage(p.GetFormattedName() + "&e unbanned " + message);
        }