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 Me(Player p, string message) { if (!message.Trim().Equals("")) { Player.GlobalMessage("* " + p.GetFormattedName() + "&e " + message); } }
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!"); } } }
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)"); } }
public static void Fetch(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) { pl.SendSpawn(new short[3] { p.x, p.y, p.z }, new byte[2] { 0, 0 }); pl.SendMessage(0xFF, "Fetched by " + p.GetFormattedName()); return; } }
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); }
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); }
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; } }
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); }