Browse Source

Fixed /msg and /ignore

cerevisiae 14 years ago
parent
commit
263a5701d7
3 changed files with 15 additions and 14 deletions
  1. 7 5
      vMinecraftCommands.java
  2. 1 0
      vMinecraftListener.java
  3. 7 9
      vMinecraftUsers.java

+ 7 - 5
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);

+ 1 - 0
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);
     }
     

+ 7 - 9
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<String> ignoreList;
 		private commandList aliasList;
@@ -190,7 +191,6 @@ class PlayerList
             suffix = new String();
 			ignoreList = new ArrayList<String>();
             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);
 	        }
 		}