From 263a5701d79a51bf2c8aec0ae0220eed318fab8f Mon Sep 17 00:00:00 2001 From: cerevisiae Date: Sat, 11 Dec 2010 00:28:56 -0600 Subject: [PATCH] Fixed /msg and /ignore --- vMinecraftCommands.java | 12 +++++++----- vMinecraftListener.java | 1 + vMinecraftUsers.java | 16 +++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/vMinecraftCommands.java b/vMinecraftCommands.java index 237d03b60..5c7604441 100644 --- a/vMinecraftCommands.java +++ b/vMinecraftCommands.java @@ -107,7 +107,6 @@ public class vMinecraftCommands{ cl.registerMessage("/ban", "%p has banned %0p", Colors.Blue, 1, false); cl.registerMessage("/ipban", "%p has IP banned %0p", Colors.Blue, 1, false); cl.registerMessage("/time", "Time change thanks to %p", Colors.Blue, 1, true); - cl.registerMessage("/tp", "%p has teleported to %0p", Colors.Blue, 1, true); } //===================================================================== //Function: vminecrafthelp (/vhelp or /vminecraft) @@ -582,7 +581,7 @@ public class vMinecraftCommands{ //Make sure the player exists Player toPlayer = etc.getServer().matchPlayer(args[0]); - if (toPlayer != null && args.length > 0) { + if (toPlayer == null || args.length < 1) { vMinecraftChat.sendMessage(player, player, Colors.Rose + "No player by the name of " + args[0] + " could be found."); return EXIT_SUCCESS; @@ -683,7 +682,7 @@ public class vMinecraftCommands{ return EXIT_SUCCESS; } - if(ignore.hasControlOver(player)) + if(!player.hasControlOver(ignore)) { vMinecraftChat.sendMessage(player, player, Colors.Rose + "You can't ignore someone a higher rank than you."); @@ -691,7 +690,7 @@ public class vMinecraftCommands{ } //Don't let the player ignore themselves - if(!ignore.getName().equalsIgnoreCase(player.getName())) + if(ignore.getName().equalsIgnoreCase(player.getName())) { vMinecraftChat.sendMessage(player, player, Colors.Rose + "You cannot ignore yourself"); @@ -862,7 +861,7 @@ public class vMinecraftCommands{ //Make sure the user has access to the command if(!player.canUseCommand("/suicide")) return EXIT_FAIL; - if(vMinecraftSettings.getInstance().cmdSuicide()) return EXIT_FAIL; + if(!vMinecraftSettings.getInstance().cmdSuicide()) return EXIT_FAIL; //Set your health to 0. Not much to it. player.setHealth(0); @@ -908,6 +907,9 @@ public class vMinecraftCommands{ //If the player exists transport the user to the player else { + vMinecraftChat.gmsg( player, vMinecraftChat.getName(player) + + Colors.LightBlue + "has teleported to" + + vMinecraftChat.getName(playerTarget)); log.log(Level.INFO, player.getName() + " teleported to " + playerTarget.getName()); player.teleportTo(playerTarget); diff --git a/vMinecraftListener.java b/vMinecraftListener.java index f99465876..4d6f32578 100644 --- a/vMinecraftListener.java +++ b/vMinecraftListener.java @@ -88,6 +88,7 @@ public class vMinecraftListener extends PluginListener { } public void onLogin(Player player){ + vMinecraftChat.sendMessage(player, player, Colors.Rose + "There are currently " + etc.getServer().getPlayerList().size() + " players online."); vMinecraftUsers.addUser(player); } diff --git a/vMinecraftUsers.java b/vMinecraftUsers.java index 05b7c2322..1c20df7fc 100644 --- a/vMinecraftUsers.java +++ b/vMinecraftUsers.java @@ -7,17 +7,16 @@ import java.util.Scanner; public class vMinecraftUsers { private static volatile vMinecraftUsers instance; protected static final Logger log = Logger.getLogger("Minecraft"); - String file = "vminecraftusers.txt"; private PropertiesFile properties; - String location = "vminecraftusers.txt"; + String location = "vminecraft.users"; public static PlayerList players = new PlayerList(); public void loadUsers(){ - File theDir = new File("vminecraftusers.txt"); + File theDir = new File(location); if(!theDir.exists()){ - properties = new PropertiesFile("vminecraftusers.txt"); + properties = new PropertiesFile(location); FileWriter writer = null; try { writer = new FileWriter(location); @@ -36,11 +35,11 @@ public class vMinecraftUsers { } } else { - properties = new PropertiesFile("vminecraftusers.txt"); + properties = new PropertiesFile(location); try { properties.load(); } catch (IOException e) { - log.log(Level.SEVERE, "Exception while loading vminecraftusers.txt", e); + log.log(Level.SEVERE, "Exception while loading " + location, e); } } } @@ -166,6 +165,8 @@ class PlayerList tag, suffix, defaultColor; + + String location = "vminecraft.users"; private ArrayList ignoreList; private commandList aliasList; @@ -190,7 +191,6 @@ class PlayerList suffix = new String(); ignoreList = new ArrayList(); aliasList = new commandList(); - String location = "vminecraftusers.txt"; //Try to apply what we can try { @@ -257,7 +257,6 @@ class PlayerList //===================================================================== public void save(){ try { - String location = "vminecraftusers.txt"; BufferedWriter bw = new BufferedWriter(new FileWriter(location, true)); Scanner scanner = new Scanner(new File(location)); while (scanner.hasNextLine()) { @@ -277,7 +276,6 @@ class PlayerList } scanner.close(); } catch (Exception e) { - String location = "vminecraftusers.txt"; log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); } }