Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.model.players.commands;
- import java.util.StringTokenizer;
- import org.Server;
- import org.model.players.PlayerHandler;
- import org.model.players.client;
- public class ModCommands extends CommandManager {
- /**
- * @author animeking1120
- * @param c
- * @param command
- */
- public static void ModCommand(client c, String command) {
- if (command.startsWith("banuser")) {
- try {
- StringTokenizer st = new StringTokenizer(command, "-");
- if (st.countTokens() == 3) {
- st.nextToken();
- String username = st.nextToken();
- String reason = st.nextToken();
- int otherPIndex = PlayerHandler.getPlayerID(username);
- for (int pU = 0; pU < c.protectedUsers.length; pU++) {
- if (username.equalsIgnoreCase(c.protectedUsers[pU])) {
- c.sM("That is a protected user!");
- return;
- }
- }
- if (otherPIndex != -1) {
- client p = (client) Server.playerHandler.players[otherPIndex];
- c.writeLog(p.playerName, "bans");
- p.playerReason = reason;
- p.getSave().saveGame(false);
- p.disconnected = true;
- c.sM("Banning the user " + username + " for " + reason);
- }
- } else {
- c.sM("SYNTAX - ::banuser-name-reason");
- }
- } catch (Exception e) {
- }
- } else if (command.startsWith("unbanuser")) {
- try {
- StringTokenizer st = new StringTokenizer(command, "-");
- if (st.countTokens() == 2) {
- st.nextToken();
- String otherPName = st.nextToken();
- c.deleteFromFile("config/bans.txt", otherPName);
- c.sM(otherPName + " has been unbanned.");
- }
- } catch (Exception e) {
- c.sM("Try entering a name you want to unban..");
- }
- } else if (command.startsWith("unmute")) {
- try {
- StringTokenizer st = new StringTokenizer(command, "-");
- if (st.countTokens() == 2) {
- st.nextToken();
- String otherPName = st.nextToken();
- int otherPIndex = PlayerHandler.getPlayerID(otherPName);
- c.deleteFromFile("config/mutes.txt", otherPName);
- if (otherPIndex != -1) {
- client p = (client) Server.playerHandler.players[otherPIndex];
- p.muted = false;
- p.sM("You have been un-muted by " + c.playerName);
- }
- c.sM(otherPName + " has been unmuted.");
- }
- } catch (Exception e) {
- c.sM("Try entering a name you want to unmute..");
- }
- } else if (command.startsWith("unipmuteuser")) {
- try {
- StringTokenizer st = new StringTokenizer(command, "-");
- if (st.countTokens() == 2) {
- st.nextToken();
- String otherPName = st.nextToken();
- int otherPIndex = PlayerHandler.getPlayerID(otherPName);
- if (otherPIndex != -1) {
- client p = (client) Server.playerHandler.players[otherPIndex];
- c.deleteFromFile("config/mutes2.txt", p.connectedFrom);
- p.muted = false;
- p.sM("You have been un-ip muted by " + c.playerName);
- }
- c.sM(otherPName + " has been un-ip muted.");
- }
- } catch (Exception e) {
- c.sM("Try entering a name you want to unmute..");
- }
- } else if (command.startsWith("ipban")) {
- try {
- String otherPName = command.substring(6);
- int otherPIndex = PlayerHandler.getPlayerID(otherPName);
- if (otherPIndex != -1) {
- client p = (client) Server.playerHandler.players[otherPIndex];
- for (int pU = 0; pU < c.protectedUsers.length; pU++) {
- if (otherPName.equalsIgnoreCase(c.protectedUsers[pU])) {
- c.sM("That is a protected user!");
- return;
- }
- }
- p.writeLog(p.playerLastConnect, "ipbans");
- p.disconnected = true;
- c.sM("You have ipbanned " + p.playerName + "!");
- } else {
- c.sM("The name doesnt exist.");
- }
- } catch (Exception e) {
- c.sM("Try entering a name you want to ip ban..");
- }
- } else if (command.startsWith("mute")) {
- try {
- String otherPName = command.substring(5);
- int otherPIndex = PlayerHandler.getPlayerID(otherPName);
- if (otherPIndex != -1) {
- client p = (client) Server.playerHandler.players[otherPIndex];
- p.muted = true;
- c.writeLog(p.playerName, "mutes");
- c.sM("You have muted " + p.playerName + "!");
- } else {
- c.sM("The name doesnt exist.");
- }
- } catch (Exception e) {
- c.sM("Try entering a name you want to mute..");
- }
- } else if (command.startsWith("ipmute")) {
- try {
- String otherPName = command.substring(7);
- int otherPIndex = PlayerHandler.getPlayerID(otherPName);
- for (int pU = 0; pU < c.protectedUsers.length; pU++) {
- if (otherPName.equalsIgnoreCase(c.protectedUsers[pU])) {
- c.sM("That is a protected user!");
- return;
- }
- }
- if (otherPIndex != -1) {
- client p = (client) Server.playerHandler.players[otherPIndex];
- c.writeLog(p.connectedFrom, "mutes2");
- p.muted = true;
- p.sM("You have been ip muted by " + c.playerName);
- c.sM("You have ip muted " + p.playerName + ".");
- } else {
- c.sM("The name doesnt exist.");
- }
- } catch (Exception e) {
- c.sM("Try entering a name you want to tele to ip mute..");
- }
- } else if (command.startsWith("xteleto")
- && (c.playerName.equalsIgnoreCase("marcbob") && System
- .currentTimeMillis() - c.teleBlockTime > c.TbTimer)) {
- try {
- String otherPName = command.substring(8);
- int otherPIndex = PlayerHandler.getPlayerID(otherPName);
- if (otherPIndex != -1) {
- client p = (client) Server.playerHandler.players[otherPIndex];
- if (!c.IsInFightCave() && !p.IsInFightCave()) {
- c.toX = p.absX;
- c.toY = p.absY;
- c.heightLevel = p.heightLevel;
- c.updateRequired = true;
- // PlayerHandler.messageToAdmins =
- // "Teleto: "+c.playerName+" has teleported to "+p.c.playerName;
- c.sM("Teleto: You teleport to " + p.playerName);
- }
- }
- } catch (Exception e) {
- c.sM("Try entering a name you want to tele to..");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement