예제 #1
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);
        }
예제 #2
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;
     }
 }
예제 #3
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);
         }
     }
 }
예제 #4
0
 public static void BlockDeleted(Player p, int x, int y, int z, byte type)
 {
     p.world.SetTile(x, y, z, Blocks.air);
     int index = p.world.CoordsToIndex((short)x, (short)y, (short)z);
     if (p.world.teleportBlocks.ContainsKey(index))
     {
         int index2 = p.world.teleportBlocks[index];
         if (p.world.teleportBlocks.ContainsKey(index2))
         {
             short[] coords2 = p.world.IndexToCoords(index2);
             p.world.SetTile(coords2[0], coords2[1], coords2[2], Blocks.air);
             p.world.teleportBlocks.Remove(index2);
             p.SendMessage(0xFF, "Unlinked.");
         }
         else
         {
             p.SendMessage(0xFF, "Teleport block link could not be found");
         }
         p.world.teleportBlocks.Remove(index);
         p.world.Save();
         p.SendMessage(0xFF, "Removed teleport block");
     }
     else
     {
         p.SendMessage(0xFF, "That is not a teleport block!");
     }
     p.OnBlockchange -= new Player.BlockHandler(BlockDeleted);
 }
예제 #5
0
        public static void Cuboid(Player p, string message)
        {
            byte type = 0;
            if (p.cParams.cuboidLock)
            {
                p.SendMessage(0xFF, "Another cuboid is already in progress.  Please wait for it to finish.");
                return;
            }

            if (message.Trim().Equals(""))
            {
                type = 0xFF;
            }
            else
            {
                if (Blocks.blockNames.ContainsKey(message.Trim()))
                {
                    type = Blocks.blockNames[message.Trim()];
                }
                else
                {
                    p.SendMessage(0xFF, "No such blocktype \"" + message.Trim() + "\"");
                    return;
                }
            }
            p.cParams.replace = false;
            p.cParams.replacenot = false;
            p.cParams.type = type;
            p.SendMessage(0xFF, "Change the block of the first corner");
            p.cuboiding = true;
            p.OnBlockchange += new Player.BlockHandler(OnFirstCorner);
        }
예제 #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) + "&e(" + pl.rank + ")");
                msg.Append("&e and is connected from IP &b" + pl.ip);
                p.SendMessage(0x00, msg.ToString());
                Account a = Program.server.accounts[pl.username.ToLower()];
                p.SendMessage(0xFF, "Visit count: &c" + a.visitcount);
                p.SendMessage(0xFF, "Blocks Created: &c" + a.blocksCreated + "&e Destroyed: &c" + a.blocksDestroyed + "&e Ratio: &c" + Math.Round(a.blockRatio, 3));
                p.SendMessage(0xFF, "Message count: &c" + a.messagesSent);

            }
            else if (Program.server.accounts.ContainsKey(message.Trim()) && Program.server.playerRanksDict.ContainsKey(message.Trim()))
            {
                StringBuilder msg = new StringBuilder();
                msg.Append(message.Trim().ToLower());
                msg.Append("&e is ranked " + Rank.GetColor(Program.server.playerRanksDict[message.Trim().ToLower()]) + Rank.RankName(Program.server.playerRanksDict[message.Trim().ToLower()]));
                msg.Append("&e last connected from IP &b" + Program.server.accounts[message.Trim().ToLower()].lastseenip);
                p.SendMessage(0x00, msg.ToString());
                Account a = Program.server.accounts[message.Trim().ToLower()];
                p.SendMessage(0xFF, "Visit count: &c" + a.visitcount);
                p.SendMessage(0xFF, "Blocks Created: &c" + a.blocksCreated + "&e Destroyed: &c" + a.blocksDestroyed + "&e Ratio: &c" + Math.Round(a.blockRatio, 3));
                p.SendMessage(0xFF, "Message count: &c" + a.messagesSent);
            }
            else
            {
                p.SendMessage(0xFF, "Command failed (could not find player)");
            }
        }
예제 #7
0
 public static void Help(Player p)
 {
     p.SendMessage(0xFF, "/place binding - Binds stone to binding");
     p.SendMessage(0xFF, "-> Bindings in () are alternatives that do the same thing");
     string available = "&9safewater(sw)&e, &csafelava(sl)&e, &fnone(off)&e, &agrass, &7doublestair(dstair)&e, &6door&e, &fair";
     if (p.rank >= Rank.RankLevel("operator"))
     {
         available += "&e, &0admin(adminium, admincrete)&e, &1activewater(aw)&e, &4activelava(al)&e, &funflood(deflood, air_flood)";
     }
     p.SendMessage(0xFF, "-> Available bindings: " + available);
 }
예제 #8
0
 public static void Help(Player p, string cmd)
 {
     switch (cmd)
     {
         case "tpblock":
             p.SendMessage(0xFF, "/tpblock - Create a set of teleport blocks");
             break;
         case "tpdel":
             p.SendMessage(0xFF, "/tpdel - Remove a teleport block");
             break;
         default:
             break;
     }
 }
예제 #9
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;
     }
 }
예제 #10
0
 public static void Help(Player p, string cmd)
 {
     switch (cmd)
     {
         case "tp":
             p.SendMessage(0xFF, "/tp player - Teleports you to player's location");
             break;
         case "fetch":
             p.SendMessage(0xFF, "/fetch player - Fetches player to your location");
             break;
         default:
             break;
     }
 }
예제 #11
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!");
         }
     }
 }
예제 #12
0
        public static void Tp(Player p, string message)
        {
            if (message.Trim().Equals(""))
            {
                p.SendMessage(0xFF, "No username specified");
                return;
            }

            Player pl = Player.FindPlayer(p, message, true);
            if (pl != null)
            {
                p.SendSpawn(new short[3] { pl.x, pl.y, pl.z }, new byte[2] { 0, 0 });
                p.SendMessage(0xFF, "Teleported to " + pl.GetFormattedName());
                return;
            }
        }
예제 #13
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 #");
 }
예제 #14
0
 public static void AddMsgBlock(Player p, string message)
 {
     message = Player.ParseColors(message);
     if (message.Contains("MB_END"))
     {
         p.OnBlockchange += new Player.BlockHandler(BlockPlaced);
         p.messageBlockText = message.Substring(0, message.IndexOf("MB_END"));
         p.SendMessage(0xFF, "Place a block to finalize the message block");
     }
     else
     {
         p.OnChat += new Player.ChatHandler(ChatReceived);
         p.messageBlockText = message;
         p.SendMessage(0xFF, "Message entry will continue until a message contains MB_END");
     }
 }
예제 #15
0
 public static void BlockRemoved(Player p, int x, int y, int z, byte type)
 {
     p.SendBlock((short)x, (short)y, (short)z, p.world.GetTile(x, y, z));
     p.world.messageBlocks.Remove(p.world.CoordsToIndex((short)x, (short)y, (short)z));
     p.world.Save();
     p.SendMessage(0xFF, "Message block deleted");
     p.OnBlockchange -= new Player.BlockHandler(BlockRemoved);
 }
예제 #16
0
        public static void BlockPlaced(Player p, int x, int y, int z, byte type)
        {
            if(type == 0) type = p.world.GetTile(x, y, z);
            if (p.world.messageBlocks.ContainsKey(p.world.CoordsToIndex((short)x, (short)y, (short)z)))
            {
                p.SendMessage(0xFF, "A message block already exists there!");
            }
            else
            {
                p.world.messageBlocks.Add(p.world.CoordsToIndex((short)x, (short)y, (short)z), p.messageBlockText);
                p.SendMessage(0xFF, "Message block created");
            }
            p.world.SetTile(x, y, z, type);
            p.world.Save();

            p.OnBlockchange -= new Player.BlockHandler(BlockPlaced);
        }
예제 #17
0
 public static void LoginMessage(Player p)
 {
     p.SendMessage(0xFF, "Welcome to my uBuilder server!");
     p.OnBlockchange += new Player.BlockHandler(NoBuildMode);
     //p.ResetLoginHandler();  //Resets the BlockHandler and therefore undoes the above line
     p.OnMovement += new Player.PositionChangeHandler(FreezePlayer);
     //p.ResetPositionChangeHandler(); //Resets the PositionChangeHandler and therefore undoes the above line
 }
예제 #18
0
 public static void Help(Player p, string cmd)
 {
     switch (cmd)
     {
         case "copy":
             p.SendMessage(0xFF, "/copy - Copies the selected cuboid into your clipboard");
             break;
         case "paste":
             p.SendMessage(0xFF, "/paste - Pastes your clipboard");
             break;
         case "save":
             p.SendMessage(0xFF, "/save name - Saves a copied cuboid to your folder");
             p.SendMessage(0xFF, "/save $GLOBAL/name - Saves a cuboid to the global folder");
             break;
         case "load":
             p.SendMessage(0xFF, "/load username/save - Loads save from username's folder");
             p.SendMessage(0xFF, "/load save - Loads save from the Global folder");
             break;
         case "rotate":
             p.SendMessage(0xFF, "/rotate - Rotates your copy clipboard 90deg CCW");
             break;
         default:
             break;
     }
 }
예제 #19
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;
     }
 }
예제 #20
0
        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);
            }
        }
예제 #21
0
 public static void Fly(Player p, string message)
 {
     if (!p.flying)
     {
         p.SendMessage(0xFF, "Fly mode is now &aenabled");
         p.flying = true;
         p.OnMovement += new Player.PositionChangeHandler(FlyMove);
     }
     else
     {
         p.SendMessage(0xFF, "Fly mode is now &cdisabled");
         p.flying = false;
         p.OnMovement -= new Player.PositionChangeHandler(FlyMove);
         foreach(Block b in p.flyBlocks)
         {
             p.SendBlock(b.x, b.y, b.z, p.world.GetTile(b.x, b.y, b.z));
         }
     }
 }
예제 #22
0
 public static void OnFirstBlock(Player p, int x, int y, int z, byte type)
 {
     p.world.SetTile(x, y, z, Blocks.teleportBlock);
     p.SendMessage(0xFF, "Change a block to make the link");
     p.tParams.x1 = x;
     p.tParams.y1 = y;
     p.tParams.z1 = z;
     p.OnBlockchange -= new Player.BlockHandler(OnFirstBlock);
     p.OnBlockchange += new Player.BlockHandler(OnSecondBlock);
 }
예제 #23
0
 public static void Abort(Player p, string message)
 {
     if (p.cParams.cuboidLock)
     {
         if (!DrawThreadManager.Terminate_Draw(p, 0))
         {
             p.SendMessage(0xFF, "Abort attempt failed.");
         }
     }
     else if (p.sArgs.shapeLock)
     {
         if (!DrawThreadManager.Terminate_Draw(p, 1))
         {
             p.SendMessage(0xFF, "Abort attempt failed.");
         }
     }
     else
     {
         p.SendMessage(0xFF, "No active draw threads.");
     }
 }
예제 #24
0
        public static bool Terminate_Draw(Player p, byte type)
        {
            if (type == 0) // Cuboid
            {
                if (cuboid_threads.ContainsKey(p))
                {
                    cuboid_threads[p].Abort();
                    cuboid_threads.Remove(p);
                    p.cParams.cuboidLock = false;
                    p.SendMessage(0xFF, "Cuboid aborted.");
                    return true;
                }
                else
                {
                    return false;
                }
            }

            else if (type == 1) // ShapeCommand
            {
                if (shape_threads.ContainsKey(p))
                {
                    shape_threads[p].Abort();
                    shape_threads.Remove(p);
                    p.sArgs.shapeLock = false;
                    p.SendMessage(0xFF, "Shape aborted.");
                    return true;
                }
                else
                {
                    return false;
                }
            }

            else
            {
                return false;
            }
        }
예제 #25
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");
        }
예제 #26
0
 public static void ChatReceived(Player p, string message)
 {
     if (message.Contains("MB_END"))
     {
         p.OnChat -= new Player.ChatHandler(ChatReceived);
         p.OnBlockchange += new Player.BlockHandler(BlockPlaced);
         p.messageBlockText += message.Substring(0, message.IndexOf("MB_END"));
         p.SendMessage(0xFF, "Place a block to finalize the message block");
     }
     else
     {
         p.messageBlockText += Player.ParseColors(Player.ParseSpecialChar(message));
     }
 }
예제 #27
0
 public static void Help(Player p, string message)
 {
     if (!message.Trim().Equals(""))
     {
         Command.HelpMessage(p, message.Trim());
         return;
     }
     p.SendMessage(0xFF, "Running uBuilder 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/uBuilder&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");
 }
예제 #28
0
        public static void Check(Player p, short[] oldPos, byte[] oldRot, short[] newPos, byte[] newRot)
        {
            short x = (short)(newPos[0] >> 5);
            short y = (short)((newPos[1] >> 5) - 2);
            short z = (short)(newPos[2] >> 5);

            //Don't spam them if they haven't moved
            if (oldPos[0] >> 5 == x && (oldPos[1] >> 5) - 2 == y && oldPos[2] >> 5 == z) return;

            if (p.world.messageBlocks.ContainsKey(p.world.CoordsToIndex(x, y, z)))
            {
                p.SendMessage(0x0, "&e" + p.world.messageBlocks[p.world.CoordsToIndex(x, y, z)]);
            }
        }
예제 #29
0
 public static void Ranks(Player p, string message)
 {
     p.SendMessage(0xFF, "Ranks: ");
     p.SendMessage(0, "&4@owner &e(" + Rank.RankLevel("owner") + "-" + Rank.MAX_RANK + ")");
     p.SendMessage(0, "&9+operator &e(" + Rank.RankLevel("operator") + "-" + (Rank.RankLevel("owner") - 1) + ")");
     p.SendMessage(0, "player &e(" + Rank.RankLevel("player") + "-" + (Rank.RankLevel("operator") - 1) + ")");
     p.SendMessage(0, "&7guest &e(" + Rank.RankLevel("guest") + "-" + (Rank.RankLevel("player") - 1) + ")");
     p.SendMessage(0, "&0[:(]banned &e(" + Rank.RankLevel("none") + "-" + (Rank.RankLevel("guest") - 1) + ")");
 }
예제 #30
0
        public static void Load(Player p, string message)
        {
            message = message.Trim().ToLower();
            if (!File.Exists("save/" + message))
            {
                p.SendMessage(0xFF, "That file doesn't exist!");
                return;
            }

            try
            {
                FileStream fIn = new FileStream("save/" + message, FileMode.Open);

                byte[] signature = new byte[4];
                fIn.Read(signature, 0, 4);
                if (!Encoding.UTF8.GetString(signature).Equals("SAVE"))
                {
                    p.SendMessage(0xFF, "Save file is corrupt.");
                    fIn.Close();
                    return;
                }

                byte[] length = new byte[4];
                fIn.Read(length, 0, 4);
                int number = BitConverter.ToInt32(length, 0);
                p.copyClipboard = new Block[number];

                for (int i = 0; i < number; i++)
                {
                    byte[] blockBytes = new byte[7];
                    fIn.Read(blockBytes, 0, 7);

                    short x = BitConverter.ToInt16(blockBytes, 0);
                    short y = BitConverter.ToInt16(blockBytes, 2);
                    short z = BitConverter.ToInt16(blockBytes, 4);
                    byte type = blockBytes[6];

                    p.copyClipboard[i] = new Block(x, y, z, type);
                }

                fIn.Close();
                p.SendMessage(0xFF, "Loaded save.  Use /paste to put it somewhere");
            }
            catch (Exception e)
            {
                Program.server.logger.log(e);
                p.SendMessage(0xFF, "Something went wrong.  I don't think your save loaded right.");
            }
        }