public static void Me(Player p, string message) { if (!message.Trim().Equals("")) { Player.GlobalMessage("* " + p.GetFormattedName() + "&e " + message); } }
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)"); } }
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); } } }
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); }
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; } }
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; } }
public static void Spawn(Player p, string message) { short x = (short)(Program.server.world.spawnx << 5); short y = (short)(Program.server.world.spawny << 5); short z = (short)(Program.server.world.spawnz << 5); p.SendSpawn(new short[] { x, y, z }, new byte[] { Program.server.world.srotx, Program.server.world.sroty }); }
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); }
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); }
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 }
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); }
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) + ")"); }
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); }
public static void FreezePlayer(Player p, short[] oldPos, byte[] oldRot, short[] newPos, byte[] newRot) { int dx = newPos[0] - oldPos[0]; int dy = newPos[1] - oldPos[1]; int dz = newPos[2] - oldPos[2]; if ((int)(Math.Sqrt((double)(dx*dx + dz*dz))) > 4) { p.SendSpawn(oldPos, newRot); } }
public Account(Player p) { this.name = p.username; this.lastseenip = p.ip; this.lastjoined = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); this.visitcount = 1; this.blocksCreated = 0; this.blocksDestroyed = 0; this.messagesSent = 0; this.blockRatio = 0.0d; }
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); }
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"); }
public static void FlyMove(Player p, short[] oldPos, byte[] oldRot, short[] newPos, byte[] newRot) { if (p.flyBlocks == null) { p.flyBlocks = new List<Block>(); } if (Math.Abs((newPos[0] >> 5) - p.lastFlyPos[0]) >= 1 || Math.Abs((newPos[2] >> 5) - p.lastFlyPos[2]) >= 1 || Math.Abs(p.lastFlyPos[1] - ((newPos[1] >> 5) - 2)) >= 1) { int oy = (p.lastFlyPos[1] < p.world.height ? p.lastFlyPos[1] : p.world.height - 1); int ny = ((newPos[1] >> 5) - 2 < p.world.height ? (newPos[1] >> 5) - 2 : p.world.height - 1); List<Block> newPlatform = new List<Block>(); for (int x = ((newPos[0] >> 5) - 3); x < ((newPos[0] >> 5) + 3); x++) { for (int z = ((newPos[2] >> 5) - 3); z < ((newPos[2] >> 5) + 3); z++) { newPlatform.Add(new Block((short)x, (short)ny, (short)z, Blocks.glass)); } } List<Block> pNewBlocks = new List<Block>(p.flyBlocks); foreach (Block b in p.flyBlocks) { if (!newPlatform.Contains(b)) { pNewBlocks.Remove(b); p.SendBlock(b.x, b.y, b.z, p.world.GetTile(b.x, b.y, b.z)); } } foreach (Block b in newPlatform) { if (!pNewBlocks.Contains(b)) { pNewBlocks.Add(b); p.SendBlock(b.x, b.y, b.z, Blocks.glass); } } p.flyBlocks = pNewBlocks; /*for (int x = p.lastFlyPos[0] - 3; x < p.lastFlyPos[0] + 3; x++) { for (int z = p.lastFlyPos[2] - 3; z < p.lastFlyPos[2] + 3; z++) { p.SendBlock((short)x, (short)oy, (short)z, p.world.GetTile(x, oy, z)); } } */ p.lastFlyPos = new int[] { newPos[0] >> 5, (newPos[1] >> 5) - 2, newPos[2] >> 5 }; } }
public static void Help(Player p, string cmd) { switch (cmd) { case "mb": p.SendMessage(0xFF, "/mb message - Create a message block. Message must end with MB_END, or will keep intercepting chat until it gets MB_END"); break; case "mbdel": p.SendMessage(0xFF, "/mbdel - Delete a message block"); break; default: break; } }
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)); } }
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; } }
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)]); } }
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; } }
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; } }
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."); } }
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()); }
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!"); } } }
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"); } }
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"); }
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 #"); }