diff --git a/other.java b/other.java deleted file mode 100644 index 859127dea..000000000 --- a/other.java +++ /dev/null @@ -1,134 +0,0 @@ -//Contains all the java methods for vminecraft -public class other { - public static other gmsg; - public static other gmsg(String msg){ - for (Player p : etc.getServer().getPlayerList()) { - if (p != null) { - p.sendMessage(msg); - } - } - return gmsg; - } - - public static boolean lengthCheck(String str) - { - int length = 0; - for(int x = 0; x\"*()".indexOf(str.charAt(x)) != -1) - { - length+=5; - } - else if("hequcbrownxjmpsvazydgTHEQUCKBROWNFXJMPSVLAZYDG1234567890#\\/?$%-=_+&".indexOf(str.charAt(x)) != -1) - { - length+=6; - } - else if("@~".indexOf(str.charAt(x)) != -1) - { - length+=7; - } - else if(str.charAt(x)==' ') - { - length+=4; - } - } - if(length<=316) - { - return true; - } else { return false; } - - } - - public static String colorChange(char colour) - { - String color = ""; - switch(colour) - { - case '0': - color = Colors.Black; - break; - case '1': - color = Colors.Navy; - break; - case '2': - color = Colors.Green; - break; - case '3': - color = Colors.Blue; - break; - case '4': - color = Colors.Red; - break; - case '5': - color = Colors.Purple; - break; - case '6': - color = Colors.Gold; - break; - case '7': - color = Colors.LightGray; - break; - case '8': - color = Colors.Gray; - break; - case '9': - color = Colors.DarkPurple; - break; - case 'a': - color = Colors.LightGreen; - break; - case 'b': - color = Colors.LightBlue; - break; - case 'c': - color = Colors.Rose; - break; - case 'd': - color = Colors.LightPurple; - break; - case 'e': - color = Colors.Yellow; - break; - case 'f': - color = Colors.White; - break; - case 'A': - color = Colors.LightGreen; - break; - case 'B': - color = Colors.LightBlue; - break; - case 'C': - color = Colors.Rose; - break; - case 'D': - color = Colors.LightPurple; - break; - case 'E': - color = Colors.Yellow; - break; - case 'F': - color = Colors.White; - break; - default: - color = Colors.White; - break; - } - - return color; - } - - - } \ No newline at end of file diff --git a/settings.java b/settings.java deleted file mode 100644 index 3bd99a48d..000000000 --- a/settings.java +++ /dev/null @@ -1,126 +0,0 @@ -import java.io.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class settings { - private final static Object syncLock = new Object(); - protected static final Logger log = Logger.getLogger("Minecraft"); - private static volatile settings instance; - static boolean toggle = true; - private boolean adminChat = false; - private boolean greentext = false; - private boolean FFF = false; - private boolean quakeColors = false; - private boolean cmdFabulous = false; - private boolean cmdPromote = false; - private boolean cmdDemote = false; - private boolean cmdWhoIs = false; - private boolean cmdRules = false; - private boolean cmdMasstp = false; - private boolean cmdTp = false; - private boolean cmdTphere = false; - private boolean globalmessages = false; - private boolean cmdSay = false; - private PropertiesFile properties; - String file = "vminecraft.properties"; - public String rules[] = null; - - public void loadSettings() - { - File theDir = new File("vminecraft.properties"); - if(!theDir.exists()) - { - String location = "vminecraft.properties"; - properties = new PropertiesFile("vminecraft.properties"); - FileWriter writer = null; - try { - writer = new FileWriter(location); - writer.write("#This plugin is modular\r\n"); - writer.write("#Turn any features you don't want to false and they won't be running\r\n"); - writer.write("#If you edit this file and save it, then use /reload it will reload the settings\r\n"); - writer.write("greentext=true\r\n"); - writer.write("quakeColors=true\r\n"); - writer.write("cmdTphere=true\r\n"); - writer.write("cmdFabulous=true\r\n"); - writer.write("cmdWhoIs=true\r\n"); - writer.write("cmdPromote=true\r\n"); - writer.write("cmdDemote=true\r\n"); - writer.write("cmdMasstp=true\r\n"); - writer.write("cmdSay=true\r\n"); - writer.write("cmdTp=true\r\n"); - writer.write("cmdRules=true\r\n"); - writer.write("globalmessages=true\r\n"); - writer.write("FFF=true\r\n"); - writer.write("adminchat=true\r\n"); - writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n"); - } catch (Exception e) { - log.log(Level.SEVERE, "Exception while creating " + location, e); - } finally { - try { - if (writer != null) { - writer.close(); - } - } catch (IOException e) { - log.log(Level.SEVERE, "Exception while closing writer for " + location, e); - } - } - - - } else { - properties = new PropertiesFile("vminecraft.properties"); - properties.load(); - } - - try { - adminChat = properties.getBoolean("adminchat",true); - greentext = properties.getBoolean("greentext",true); - FFF = properties.getBoolean("FFF",true); - quakeColors = properties.getBoolean("quakeColors",true); - cmdFabulous = properties.getBoolean("cmdFabulous",true); - cmdPromote = properties.getBoolean("cmdPromote",true); - cmdDemote = properties.getBoolean("cmdDemote",true); - cmdWhoIs = properties.getBoolean("cmdWhoIs",true); - cmdRules = properties.getBoolean("cmdRules",true); - cmdTp = properties.getBoolean("cmdTp",true); - cmdMasstp = properties.getBoolean("cmdMasstp",true); - cmdTphere = properties.getBoolean("cmdTphere",true); - globalmessages = properties.getBoolean("globalmessages",true); - cmdSay = properties.getBoolean("cmdSay",true); - rules = properties.getString("rules", "").split("@"); - log.log(Level.INFO, "vminecraft plugin successfully loaded"); - - } - catch (Exception e) - { - log.log(Level.SEVERE, "vminecraft Error: ERROR LOADING PROPERTIES FILE"); - } - } - - public boolean adminchat() {return adminChat;} - public boolean greentext() {return greentext;} - public boolean FFF() {return FFF;} - public boolean quakeColors() {return quakeColors;} - public boolean cmdFabulous() {return cmdFabulous;} - public boolean cmdPromote() {return cmdPromote;} - public boolean cmdDemote() {return cmdDemote;} - public boolean cmdWhoIs() {return cmdWhoIs;} - public boolean cmdTp() {return cmdTp;} - public boolean cmdTphere() {return cmdTphere;} - public boolean cmdSay() {return cmdSay;} - public boolean cmdRules() {return cmdRules;} - public boolean globalmessages() {return globalmessages;} - public boolean cmdMasstp() {return cmdMasstp;} - - public static settings getInstance() { - if (instance == null) { - instance = new settings(); - } - - return instance; - } - //Will return the rules - public String[] getRules() { - return rules; - } - -} \ No newline at end of file diff --git a/vMinecraftChat.java b/vMinecraftChat.java index 541d26184..c0dab6a04 100644 --- a/vMinecraftChat.java +++ b/vMinecraftChat.java @@ -9,6 +9,7 @@ import java.util.logging.Logger; //===================================================================== public class vMinecraftChat { protected static final Logger log = Logger.getLogger("Minecraft"); + protected static final int lineLength = 312; //===================================================================== //Function: gmsg @@ -60,12 +61,12 @@ public class vMinecraftChat { //Loop through the words finding their length and increasing //j, the end point for the sub string - while(len <= 316 && !split.isEmpty()) + while(split.get(0) != null && len <= lineLength && !split.isEmpty()) { int wordLength = msgLength(split.get(0)) + 4; //If a word is too long for a line - if(wordLength > 316) + if(wordLength > lineLength) { String[] tempArray = wordCut(len, split.remove(0)); words.add(tempArray[0]); @@ -74,7 +75,7 @@ public class vMinecraftChat { //If the word is not too long to fit len += wordLength; - if( len < 316) + if( len < lineLength) words.add(split.remove(0)); } //Merge them and add them to the output array. @@ -118,7 +119,7 @@ public class vMinecraftChat { //and their following color codes String[] output = new String[2]; int x = 0; - while(length < 316 && x < str.length()) + while(length < lineLength && x < str.length()) { int len = charLength(str.charAt(x)); if( len > 0) @@ -140,15 +141,15 @@ public class vMinecraftChat { //===================================================================== private static int charLength(char x) { - if("i;,.:|!".indexOf(x) != -1) + if("i.:,;|!".indexOf(x) != -1) return 2; else if("l'".indexOf(x) != -1) return 3; else if("tI[]".indexOf(x) != -1) return 4; - else if("kf{}<>\"*()".indexOf(x) != -1) + else if("fk{}<>\"*()".indexOf(x) != -1) return 5; - else if("hequcbrownxjmpsvazydgTHEQUCKBROWNFXJMPSVLAZYDG1234567890#\\/?$%-=_+&".indexOf(x) != -1) + else if("abcdeghjmnopqrsuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890\\/#?$%-=_+&^".indexOf(x) != -1) return 6; else if("@~".indexOf(x) != -1) return 7; diff --git a/vMinecraftCommands.java b/vMinecraftCommands.java index dcb09d7ca..b218cca64 100644 --- a/vMinecraftCommands.java +++ b/vMinecraftCommands.java @@ -44,10 +44,15 @@ public class vMinecraftCommands{ cl.register("/a", "adminChatToggle", "toggle admin chat for every message"); cl.register("/modify", "modifySplit"); cl.register("/me", "me"); + cl.register("/msg", "message"); + cl.register("/reply", "reply"); cl.registerAlias("/playerlist", "/who"); + cl.registerAlias("/r", "/reply"); + cl.registerAlias("/w", "/msg"); cl.registerAlias("/wrists", "/suicide"); cl.registerAlias("/ci", "/clearinventory"); } + //===================================================================== //Function: me (/me) //Input: Player player: The player using the command @@ -61,6 +66,65 @@ public class vMinecraftCommands{ vMinecraftChat.emote(player, str); return EXIT_SUCCESS; } + + //===================================================================== + //Function: message (/msg, /w, /whisper) + //Input: Player player: The player using the command + //Output: int: Exit Code + //Use: Send a message to a player + //===================================================================== + public static int message(Player player, String[] args) + { + String msg = etc.combineSplit(1, args, " "); + Player toPlayer = etc.getServer().matchPlayer(args[0]); + if (args.length < 1) { + return EXIT_FAIL; + } else if (toPlayer != null) { + //Send the message to the targeted player and the sender + vMinecraftChat.sendMessage(player, toPlayer, + Colors.LightGreen + "[" + Colors.White + "From:" + + vMinecraftChat.getName(player) + Colors.LightGreen + "]" + msg); + vMinecraftChat.sendMessage(player, player, + Colors.LightGreen + "[" + Colors.White + "To:" + + vMinecraftChat.getName(toPlayer) + Colors.LightGreen + "]" + msg); + //Set the last massager for each player + vMinecraftUsers.players.findProfile(player).setMessage(toPlayer); + vMinecraftUsers.players.findProfile(toPlayer).setMessage(player); + } else { + vMinecraftChat.sendMessage(player, player, Colors.Red + + "No player by the name of " + args[0] + " could be found."); + } + return EXIT_SUCCESS; + } + + //===================================================================== + //Function: reply (/r, /reply) + //Input: Player player: The player using the command + //Output: int: Exit Code + //Use: Send a message to a player + //===================================================================== + public static int reply(Player player, String[] args) + { + Player toPlayer = vMinecraftUsers.players.findProfile(player).getMessage(); + if (toPlayer != null) { + String msg = etc.combineSplit(1, args, " "); + //Send the message to the targeted player and the sender + vMinecraftChat.sendMessage(player, toPlayer, + Colors.LightGreen + "[" + Colors.White + "From:" + + vMinecraftChat.getName(player) + Colors.LightGreen + "] " + msg); + vMinecraftChat.sendMessage(player, player, + Colors.LightGreen + "[" + Colors.White + "To:" + + vMinecraftChat.getName(toPlayer) + Colors.LightGreen + "] " + msg); + + //Set the last messager for each player + vMinecraftUsers.players.findProfile(player).setMessage(toPlayer); + vMinecraftUsers.players.findProfile(toPlayer).setMessage(player); + } else { + vMinecraftChat.sendMessage(player, player, + Colors.Red + "That person is no longer logged in."); + } + return EXIT_SUCCESS; + } //===================================================================== //Function: adminChatToggle (/a) @@ -522,7 +586,7 @@ public class vMinecraftCommands{ { //Exploit fix for people giving themselves commands if(args[1].equals("commands")) - return EXIT_FAIL; + return EXIT_SUCCESS; return EXIT_CONTINUE; } diff --git a/vMinecraftListener.java b/vMinecraftListener.java new file mode 100644 index 000000000..25965391f --- /dev/null +++ b/vMinecraftListener.java @@ -0,0 +1,150 @@ +import java.util.logging.Level; +import java.util.logging.Logger; +//===================================================================== +//Class: vMinecraftListener +//Use: The listener to catch incoming chat and commands +//Author: nossr50, TrapAlice, cerevisiae +//===================================================================== +public class vMinecraftListener extends PluginListener { + public int damagetype; + protected static final Logger log = Logger.getLogger("Minecraft"); + + //===================================================================== + //Function: disable + //Input: None + //Output: None + //Use: Disables vMinecraft, but why would you want to do that? ;) + //===================================================================== + public void disable() { + log.log(Level.INFO, "vMinecraft disabled"); + } + + //===================================================================== + //Function: onChat + //Input: Player player: The player calling the command + // String message: The message to color + //Output: boolean: If the user has access to the command + // and it is enabled + //Use: Checks for quote, rage, and colors + //===================================================================== + public boolean onChat(Player player, String message){ + + //Quote (Greentext) + if (message.startsWith("@") || + vMinecraftSettings.getInstance().isAdminToggled(player.getName())) + return vMinecraftChat.adminChat(player, message); + + else if (message.startsWith(">")) + return vMinecraftChat.quote(player, message); + + //Rage (FFF) + else if (message.startsWith("FFF")) + return vMinecraftChat.rage(player, message); + + //Send through quakeColors otherwise + else + return vMinecraftChat.quakeColors(player, message); + } + + //===================================================================== + //Function: onCommand + //Input: Player player: The player calling the command + // String[] split: The arguments + //Output: boolean: If the user has access to the command + // and it is enabled + //Use: Checks for exploits and runs the commands + //===================================================================== + public boolean onCommand(Player player, String[] split) { + + //Copy the arguments into their own array. + String[] args = new String[split.length - 1]; + System.arraycopy(split, 1, args, 0, args.length); + + //Return the results of the command + int exitCode = vMinecraftCommands.cl.call(split[0], player, args); + if(exitCode == 0) + return false; + else if(exitCode == 1) + return true; + else + return false; + + } + + //===================================================================== + //Function: onHealthChange + //Input: Player player: The player calling the command + // int oldValue: The old health value; + // int newValue: The new health value + //Output: boolean: If the user has access to the command + // and it is enabled + //Use: Checks for exploits and runs the commands + //===================================================================== + public boolean onHealthChange(Player player,int oldValue,int newValue){ + if (vMinecraftSettings.getInstance().isEzModo(player.getName())) { + return oldValue > newValue; + } + return false; + } + + public void onLogin(Player player){ + vMinecraftUsers.addUser(player); + } + public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) { + if(defender.isPlayer()){ + Player player = (Player)defender; + if (attacker.isPlayer()) { + Player pAttacker = (Player)attacker; + if(player.getHealth() < 1){ + vMinecraftChat.gmsg(player, pAttacker.getName() + " has murdered " + player.getName()); + } + } + if (player.getHealth() < 1 && !attacker.isPlayer()) { + if (type == type.CREEPER_EXPLOSION) { + damagetype = 1; //Creeper + } else if(type == type.FALL){ + damagetype = 2; //Fall + } else if(type == type.FIRE){ + damagetype = 3; //Fire going to make it share with firetick since its similar + } else if (type == type.FIRE_TICK){ + damagetype = 4; //Firetick + } else if (type == type.LAVA){ + damagetype = 5; //Lava + } else if (type == type.WATER){ + damagetype = 6; //Water + } + //This should trigger the player death message + } else if (player.getHealth() < 1 && attacker.isPlayer()){ + damagetype = 7; //Player + } + if(damagetype == 1){ + vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " was blown to bits by a creeper"); + damagetype = 0; + } else if (damagetype == 2) { + vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " fell to death!"); + damagetype = 0; + } else if (damagetype ==3){ + vMinecraftChat.gmsg(player, player.getName() + Colors.Red + " was incinerated"); + damagetype = 0; + } else if (damagetype == 4){ + vMinecraftChat.gmsg(player, Colors.Red + " Stop drop and roll, not scream, run, and burn " + player.getName()); + damagetype = 0; + } else if (damagetype == 5){ + vMinecraftChat.gmsg(player, Colors.Red + player.getName() + " drowned in lava"); + damagetype = 0; + } else if (damagetype == 6){ + vMinecraftChat.gmsg(player, Colors.Blue + player.getName() + " should've attended that swimming class"); + damagetype = 0; + } else if (damagetype == 7){ + Player pAttacker = (Player)attacker; + vMinecraftChat.gmsg(player, pAttacker.getName() + " has murdered " + player.getName()); + damagetype = 0; + } + else { + vMinecraftChat.gmsg(player, Colors.Gray + player.getName() + " " + vMinecraftSettings.randomDeathMsg()); + } + } + return false; + } + +} \ No newline at end of file diff --git a/vMinecraftUsers.java b/vMinecraftUsers.java index 40b383376..9b12ab477 100644 --- a/vMinecraftUsers.java +++ b/vMinecraftUsers.java @@ -11,7 +11,7 @@ public class vMinecraftUsers { private PropertiesFile properties; String location = "vminecraftusers.txt"; - ArrayList players = new ArrayList(); + public static PlayerList players = new PlayerList(); public void loadUsers(){ @@ -143,11 +143,11 @@ class PlayerList //Output: PlayerProfile: The profile of the specified player //Use: Get the profile for the specified player //===================================================================== - private PlayerProfile findProfile(Player player) + public PlayerProfile findProfile(Player player) { for(PlayerProfile ply : players) { - if(ply.getPlayer().equals(player)) + if(ply.isPlayer(player)) return ply; } return null; @@ -161,10 +161,11 @@ class PlayerList class PlayerProfile { protected final Logger log = Logger.getLogger("Minecraft"); - private Player playerName; - private String nickName; - private String tag; - private String suffix; + private String playerName, + lastMessage, + nickName, + tag, + suffix; private ArrayList ignoreList; private commandList aliasList; @@ -181,13 +182,14 @@ class PlayerList //===================================================================== public PlayerProfile(Player player) { - //Declare things - ignoreList = new ArrayList(); - aliasList = new commandList(); + //Declare things nickName = new String(); tag = new String(); suffix = new String(); + ignoreList = new ArrayList(); + aliasList = new commandList(); String location = "vminecraftusers.txt"; + //Try to apply what we can try { Scanner scanner = new Scanner(new File(location)); @@ -197,43 +199,55 @@ class PlayerList continue; } String[] split = line.split(":"); - if (!split[0].equalsIgnoreCase(player.getName())) { - continue; - } - nickName = (split[1].split(",").toString()); - - if (split.length >= 4) { - tag = (split[3]); - } - - //Add all the ignored people to the player's ignore list - if (split.length >= 5) { - for(String name : split[4].split(",")) - ignoreList.add(etc.getServer().getPlayer(name)); - } - if (split.length >= 6) { - //Loop through all the aliases - for(String alias : split[5].split(",")) - { - //Break apart the two parts of the alias - String[] parts = alias.split("@"); - if(parts.length > 1) - { - //Get the arguments for the alias if there are any - String[] command = parts[1].split(" "); - String[] args = null; - if(command.length > 1) - System.arraycopy(command, 1, args, 0, command.length - 2); - - //Register the alias to the player's aliasList - aliasList.registerAlias(parts[0], command[0], args); - } - } + + //If the player name is equal to the name in the list + if (split.length > 0 && split[0].equalsIgnoreCase(player.getName())) { + + //Get the tag from the 1st split + nickName = (split[1].split(",").toString()); + + //Get the tag from the 2nd split + suffix = split[2]; + + //Get the tag from the 3rd split + if (split.length >= 4) { + tag = (split[3]); + } + + //Add all the ignored people to the player's ignore list + if (split.length >= 5) { + for(String name : split[4].split(",")) + ignoreList.add(etc.getServer().getPlayer(name)); + } + + //Get the alias list, from the 5th split + if (split.length >= 6) { + //Loop through all the aliases + for(String alias : split[5].split(",")) + { + //Break apart the two parts of the alias + String[] parts = alias.split("@"); + if(parts.length > 1) + { + //Get the arguments for the alias if there are any + String[] command = parts[1].split(" "); + String[] args = null; + if(command.length > 1) + System.arraycopy(command, 1, args, + 0, command.length - 2); + + //Register the alias to the player's aliasList + aliasList.registerAlias(parts[0], command[0], args); + } + } + } + break; } } scanner.close(); } catch (Exception e) { - log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e); + log.log(Level.SEVERE, "Exception while reading " + + location + " (Are you sure you formatted it correctly?)", e); } } @@ -255,7 +269,7 @@ class PlayerList continue; } String[] split = line.split(":"); - if (!split[0].equalsIgnoreCase(playerName.toString())) { + if (!split[0].equalsIgnoreCase(playerName)) { continue; } bw.write(playerName + ":" + nickName + ":" + suffix + ":" + tag + ":" + ignoreList + ":" + aliasList); @@ -267,14 +281,16 @@ class PlayerList } } - //===================================================================== - //Function: getPlayer + //Function: isPlayer //Input: None //Output: Player: The player this profile belongs to - //Use: Finds if the specified player is in the ignore list + //Use: Finds if this profile belongs to a specified player //===================================================================== - public Player getPlayer(){return playerName;} + public boolean isPlayer(Player player) + { + return player.getName().equals(playerName); + } //===================================================================== //Function: isIgnored @@ -369,6 +385,28 @@ class PlayerList //Use: Gets a player tag //===================================================================== public String getTag() { return tag; } + + //===================================================================== + //Function: setMessage + //Input: String newName: The name of the player they last messaged + // or recieved a message from. + //Output: None + //Use: Sets a player tag + //===================================================================== + public void setMessage(Player newName){ lastMessage = newName.getName(); } + + //===================================================================== + //Function: getMessage + //Input: None + //Output: String: The player name + //Use: Gets the name of the player they last messaged or recieved + // a message from. + //===================================================================== + public Player getMessage() + { + + return etc.getServer().matchPlayer(lastMessage); + } } } diff --git a/vminecraftListener.java b/vminecraftListener.java deleted file mode 100644 index f1dc12b58..000000000 --- a/vminecraftListener.java +++ /dev/null @@ -1,418 +0,0 @@ -//Vminecraft plugin by nossr50 & TrapAlice -import java.util.logging.Level; -import java.util.logging.Logger; - - public class vminecraftListener extends PluginListener { - protected static final Logger log = Logger.getLogger("Minecraft"); - public void disable() { - log.log(Level.INFO, "vminecraft disabled"); - } - private ArrayList ezmodo = new ArrayList(); //An array of players currently in ezmodo - - public void enable() { - settings.getInstance().loadSettings(); //Load the settings files - log.log(Level.INFO, "vminecraft enabled"); - } - public void onPlayerMove () { - if (ezmodo.contains(player.getName())){ - if (player.getHealth() < 30) - { - player.setHealth(30); - } - } - } - public boolean onChat(Player player, String message){ - String temp2 = "<" + player.getColor() + player.getName() + Colors.White +"> "; //Copies the formatting of id.java - String adminchat = Colors.DarkPurple + "{" + player.getColor() + player.getName() + Colors.DarkPurple +"}" + Colors.White + " "; //Special formatting for adminchat - String message2 = ""; //Used for greentext and FFF - String check = temp2+message; //Calculates how long your message will be including your name in the equation, this prevents minecraft clients from crashing when a color code is inserted after a linebreak - if (settings.getInstance().adminchat()&&message.startsWith("@") && (player.isAdmin() || player.canUseCommand("/adminchat"))) { - for (Player p : etc.getServer().getPlayerList()) { - String blaa = ""; - if (p != null) { - if (p.isAdmin() || (p.canUseCommand("/adminchat"))) { - for ( int x = 1; x< message.length(); x++) { - blaa+=message.charAt(x); - } - if (p.isAdmin() || (p.canUseCommand("/adminchat"))){ - if (p != null) { - p.sendMessage(adminchat+blaa); - } - } - } - } - } - log.log(Level.INFO, "@"+temp2+message); //So you can read adminchat from the server console - return true; - - } - //Greentext - if (settings.getInstance().greentext()&&message.startsWith(">")) { - log.log(Level.INFO, "<"+player.getName()+"> "+message); - message = Colors.LightGreen + message; - message2 = temp2 + message; - other.gmsg(message2); - return true; - } - //FFF - if (settings.getInstance().FFF()&&message.startsWith("FFF")) { - log.log(Level.INFO, "<"+player.getName()+"> "+message); - message = Colors.Red + message; - message2 = temp2 + message; - other.gmsg(message2); - return true; - } - //QuakeColors - if(settings.getInstance().quakeColors()&&message.length()>2 && other.lengthCheck(check)) { - String temp = ""; - for(int x = 0; x< message.length(); x++) - { - if(message.charAt(x)=='^'&&x!=message.length()-1) - { - temp+=other.colorChange(message.charAt(x+1)); - x+=1; - } - else{ - temp+=message.charAt(x); - } - } - log.log(Level.INFO, "<"+player.getName()+"> "+message); - message = temp2 + temp + " "; - for (Player p : etc.getServer().getPlayerList()) { - if (p != null) { - other.gmsg(message); - return true; - } - } - } - return false; - } - - public boolean onCommand(Player player, String[] split) { - if(!player.canUseCommand(split[0])) { - return false; - } - if(settings.getInstance().cmdMasstp() && split[0].equalsIgnoreCase("/masstp")) { - for (Player p : etc.getServer().getPlayerList()) { - if (!p.hasControlOver(player)) { - p.teleportTo(player); - } - - } - player.sendMessage(Colors.Blue+"Summoning successful."); - } - //ezmodo - if (split[0].equals("/ezmodo")) { - if (ezmodo.contains(player.getName())) { - player.sendMessage(Colors.Red + "ezmodo = off"); - ezmodo.remove(ezmodo.indexOf(player.getName())); - } else { - player.sendMessage(Colors.LightBlue + "eh- maji? ezmodo!?"); - player.sendMessage(Colors.Rose + "kimo-i"); - player.sendMessage(Colors.LightBlue + "Easy Mode ga yurusareru no wa shougakusei made dayo ne"); - player.sendMessage(Colors.Red + "**Laughter**"); - ezmodo.add(player.getName()); - player.setHealth(30); - } - return true; - } - //Replacement for /tp - if(settings.getInstance().cmdTp() && split[0].equalsIgnoreCase("/tp")) { - { - if (split.length < 2) { - player.sendMessage(Colors.Rose + "Correct usage is: /tp [player]"); - return true; - } - - Player playerTarget = etc.getServer().matchPlayer(split[1]); - - if (player.getName().equalsIgnoreCase(split[1])) { - player.sendMessage(Colors.Rose + "You're already here!"); - return true; - } - - if (!player.hasControlOver(playerTarget)) { - player.sendMessage(Colors.Red + "That player has higher permissions than you."); - return true; - } - - if (playerTarget != null) { - log.log(Level.INFO, player.getName() + " teleported to " + playerTarget.getName()); - player.teleportTo(playerTarget); - return true; - } else { - player.sendMessage(Colors.Rose + "Can't find user " + split[1] + "."); - return true; - } - } - } - //Replacement for /tphere - if (settings.getInstance().cmdTphere() && (split[0].equalsIgnoreCase("/tphere") || split[0].equalsIgnoreCase("/s"))) { - if (split.length < 2) { - player.sendMessage(Colors.Rose + "Correct usage is: /tphere [player]"); - return true; - } - - Player playerTarget = etc.getServer().matchPlayer(split[1]); - - if (!player.hasControlOver(playerTarget)) { - player.sendMessage(Colors.Red + "That player has higher permissions than you."); - return true; - } - if (player.getName().equalsIgnoreCase(split[1])) { - player.sendMessage(Colors.Rose + "Wow look at that! You teleported yourself to yourself!"); - return true; - } - - if (playerTarget != null) { - log.log(Level.INFO, player.getName() + " teleported " + player.getName() + " to their self."); - playerTarget.teleportTo(player); - } else { - player.sendMessage(Colors.Rose + "Can't find user " + split[1] + "."); - } - } - //Global messages that should only parse when a command can be successful - if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/kick")) { - Player playerTarget = etc.getServer().matchPlayer(split[1]); - if (playerTarget != null && !playerTarget.hasControlOver(player)) { - other.gmsg(player.getColor()+player.getName()+Colors.Blue+" has kicked "+Colors.Red+playerTarget.getColor()+playerTarget.getName()); - } - } - if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/ban")) { - Player playerTarget = etc.getServer().matchPlayer(split[1]); - if (playerTarget != null && !playerTarget.hasControlOver(player)) { - other.gmsg(player.getColor()+player.getName()+Colors.Blue+" has banned "+Colors.Red+playerTarget.getColor()+playerTarget.getName()); - } - } - if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/ipban")) { - Player playerTarget = etc.getServer().matchPlayer(split[1]); - if (playerTarget != null && !playerTarget.hasControlOver(player)) { - other.gmsg(player.getColor()+player.getName()+Colors.Blue+" has IP banned "+Colors.Red+playerTarget.getColor()+playerTarget.getName()); - } - } - if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/time")) { - if (split.length <= 2) { - other.gmsg(Colors.Blue+"Time changes thanks to "+player.getColor()+player.getName()); - return false; - } - } - //Should only reload vminecraft settings if the player is able to use /reload - if(split[0].equalsIgnoreCase("/reload") && player.canUseCommand("/reload")) { - settings.getInstance().loadSettings(); - return false; - } - //Rules - if(settings.getInstance().cmdRules() && split[0].equalsIgnoreCase("/rules")) { - for (String str : settings.getInstance().getRules()) { - player.sendMessage(Colors.Blue+str); - } - return true; - } - //Fabulous - if(split[0].equalsIgnoreCase("/fabulous") && settings.getInstance().cmdFabulous()) { - if (split.length == 1) {return false;} - String temp = ""; - String str = ""; - str = etc.combineSplit(1, split, " "); - String temp2 = "<" + player.getName() + "> "+str; - String[] rainbow = new String[] {Colors.Red, Colors.Rose, Colors.Yellow, Colors.Green, Colors.Blue, Colors.LightPurple, Colors.Purple}; - int counter=0; - if(other.lengthCheck(temp2)) - { - log.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\""); - for(int x=0; x " + str; - - other.gmsg(message); - return true; - } else { - player.sendMessage(Colors.Rose + "Message is too long"); - } - return true; - } - /* - //Promote - if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote")) { - if(split.length != 2) - { - player.sendMessage(Colors.Rose + "Usage is /promote [Player]"); - - } - - Player playerTarget = null; - if(split.length==2){ - for( Player p : etc.getServer().getPlayerList()) - { - if (p.getName().equalsIgnoreCase(split[1])) - { - playerTarget = p; - } - } - - if( playerTarget!=null) - { - String playerTargetGroup[] = playerTarget.getGroups(); - String playerGroup[] = player.getGroups(); - player.sendMessage("Debug data:"); - player.sendMessage("PlayerTarget: "+playerTargetGroup[0]); - player.sendMessage("Player: "+playerGroup[0]); - if(playerTargetGroup[0].equals("admins")) - { - player.sendMessage(Colors.Rose + "You can not promote " + split[1] + " any higher."); - } - if(playerTargetGroup[0].equals("mods") && (playerGroup[0].equals("owner"))) - { - playerTarget.setGroups(ranks.Admins); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin"; - other.gmsg(message); - } - else if (playerTargetGroup[0].equals("trusted") && (playerGroup[0].equals("admins") || playerGroup[0].equals("owner"))) - { - playerTarget.setGroups(ranks.Mods); - playerTargetGroup[0]="Mods"; - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mod"; - other.gmsg(message); - } - else if (playerTargetGroup[0].equals("default") && (playerGroup[0].equals("mods") || playerGroup[0].equals("admins") || player.isInGroup("owner"))) - { - playerTarget.setGroups(ranks.Trusted); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted"; - other.gmsg(message); - } - return true; - } - else{ - player.sendMessage(Colors.Rose + "Player not found"); - } - log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" "); -} - } - //Demote - if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote")) -{ - if(split.length != 2) - { - player.sendMessage(Colors.Rose + "Usage is /demote [Player]"); - } - - Player playerTarget = null; - - for( Player p : etc.getServer().getPlayerList()) - { - if (p.getName().equalsIgnoreCase(split[1])) - { - playerTarget = p; - } - } - - if( playerTarget!=null) - { - if(playerTarget.isInGroup("admins") && (player.isInGroup("superadmins"))) - { - playerTarget.setGroups(ranks.Mods); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod"; - other.gmsg(message); - } - if(playerTarget.isInGroup("mods") && (player.isInGroup("admins") || player.isInGroup("superadmins"))) - { - playerTarget.setGroups(ranks.Trusted); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted"; - other.gmsg(message); - } - else if (playerTarget.isInGroup("trusted") && (player.isInGroup("mods") || player.isInGroup("superadmins") || player.isInGroup("admins"))) - { - playerTarget.setGroups(ranks.Def); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default"; - other.gmsg(message); - } - else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins"))) - { - player.sendMessage(Colors.Rose + "You can not demote " + split[1] + " any lower."); - } - } - else{ - player.sendMessage(Colors.Rose + "Player not found"); - } - log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" "); - return true; -} - * - */ - //Whois will display info about a player - if (settings.getInstance().cmdWhoIs() && split[0].equalsIgnoreCase("/whois")) { - if (split.length < 2) { - player.sendMessage(Colors.Rose + "Usage is /whois [player]"); - } - String admin =""; - String ignore =""; - String IP = ""; - Player playerTarget = null; - for( Player p : etc.getServer().getPlayerList()) - { - if (p.getName().equalsIgnoreCase(split[1])) - { - playerTarget = p; - } - } - if (playerTarget != null){ - - IP = playerTarget.getIP(); - if (playerTarget.canIgnoreRestrictions()) { - ignore = "True"; - } else { - ignore ="False"; - } - if (playerTarget.canIgnoreRestrictions()) { - admin = "True"; - } else { - admin = "False"; - } - - - //Displaying the information - player.sendMessage(Colors.Blue + "Whois results for "+split[1]+"."); - //Group - for (String group : playerTarget.getGroups()) { - player.sendMessage(Colors.Blue + "Groups: "+group); - } - //Admin - player.sendMessage(Colors.Blue+"Admin: "+admin); - //IP - player.sendMessage(Colors.Blue+"IP: "+IP); - //Restrictions - player.sendMessage(Colors.Blue+"Can ignore restrictions: "+ignore); - - - } else { - player.sendMessage(Colors.Rose+"Player not found."); - } - return true; - } - //Say - if (settings.getInstance().cmdSay() && (split[0].equalsIgnoreCase("/say"))) { - String sayan; - sayan = etc.combineSplit(1, split, " "); - other.gmsg(Colors.Yellow+sayan); - } - //Should this be included? - else { - return false; - } - //Needs to be included - return true; - } - } diff --git a/vminecraftPlugin.java b/vminecraftPlugin.java deleted file mode 100644 index adfe72a6d..000000000 --- a/vminecraftPlugin.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * vminecraft Plugin - * @author Robert, TrapAlice - */ -//This is how we setup the listener -public class vminecraftPlugin extends Plugin { - static final vminecraftListener listener = new vminecraftListener(); - - public void enable() { - //If we had commands we would add them here. - etc.getInstance().addCommand("/masstp", "Teleports those with lower permissions to you"); - etc.getInstance().addCommand("/rules", "Displays the rules"); - etc.getInstance().addCommand("/fabulous", "makes text SUUUPER"); - etc.getInstance().addCommand("/whois", "/whois [user]"); - settings.getInstance().loadSettings(); //Hopefully this will make the plugin load right away - } - - public void disable() { - //And remove the commands here. - } - - public void initialize() { - //Here we add the hook we're going to use. In this case it's the arm swing event. - etc.getLoader().addListener(PluginLoader.Hook.CHAT, listener, this, PluginListener.Priority.MEDIUM); - etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.HIGH); - } -}