Forráskód Böngészése

Reorganizing code.

cerevisiae 14 éve
szülő
commit
86702dfc6a
3 módosított fájl, 472 hozzáadás és 372 törlés
  1. 17 16
      vMinecraftChat.java
  2. 426 354
      vMinecraftCommands.java
  3. 29 2
      vMinecraftUsers.java

+ 17 - 16
vMinecraftChat.java

@@ -19,17 +19,18 @@ public class vMinecraftChat {
 	//=====================================================================
     public static void gmsg(Player sender, String msg){
         for (Player receiver : etc.getServer().getPlayerList()) {
-            if (receiver != null) {
-            	if(vMinecraftUsers.players.findProfile(receiver) == null)
-            		return;
-            	//Check if the person has the sender ignored
-            	if(!vMinecraftUsers.players.findProfile(receiver).isIgnored(sender))
-        		{
-        	    	String[] message = applyColors(wordWrap(msg));
-        	    	for(String out : message)
-        	    		receiver.sendMessage(out);
-        		}
-            }
+        	
+            if (receiver == null) {return;}
+            
+        	if(vMinecraftUsers.getProfile(receiver) == null)
+        		return;
+        	//Check if the person has the sender ignored
+        	if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender))
+    		{
+    	    	String[] message = applyColors(wordWrap(msg));
+    	    	for(String out : message)
+    	    		receiver.sendMessage(out);
+    		}
         }
     }
 
@@ -41,17 +42,17 @@ public class vMinecraftChat {
 	//=====================================================================
     public static void sendMessage(Player sender, Player receiver, String msg){
     	//Check if the receiver has the sender ignored
-    	if(vMinecraftUsers.players.findProfile(receiver) == null)
+    	if(vMinecraftUsers.getProfile(receiver) == null)
     		return;
-		if(!vMinecraftUsers.players.findProfile(receiver).isIgnored(sender))
+		if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender))
 		{
 	    	String[] message = applyColors(wordWrap(msg));
 	    	for(String out : message)
 	    		receiver.sendMessage(out);
 	    //Tell them if they are
 		} else
-    		sendMessage(sender, sender, Colors.Rose + receiver.getName() + " has you " +
-    				"on their ignore list.");
+    		sendMessage(sender, sender, Colors.Rose + receiver.getName()
+    				+ " has you on their ignore list.");
     }
 
 	//=====================================================================
@@ -220,7 +221,7 @@ public class vMinecraftChat {
     	//Add the color if there is one
     	if(player.getColor() != null && player.getColor() != "")
     		output = player.getColor().substring(0,2) + output;
-    	//Add the prefix if there is one
+    	//Add the tag if there is one
     	if(playerPrefix != null && !playerPrefix.isEmpty())
     		output = applyColors(playerPrefix.substring(1)) + output;
     	

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 426 - 354
vMinecraftCommands.java


+ 29 - 2
vMinecraftUsers.java

@@ -44,7 +44,7 @@ public class vMinecraftUsers {
 			}
 		}
     }
-        public boolean doesPlayerExist(String player) {
+    public boolean doesPlayerExist(String player) {
         try {
             Scanner scanner = new Scanner(new File(location));
             while (scanner.hasNextLine()) {
@@ -64,10 +64,26 @@ public class vMinecraftUsers {
         }
         return false;
     }
-        
+
+	//=====================================================================
+	//Function:	addUser
+	//Input:	Player player: The player to create a profile for
+	//Output:	none
+	//Use:		Creates the player profile
+	//=====================================================================
     public static void addUser(Player player){
     	players.addPlayer(player);
     }
+
+	//=====================================================================
+	//Function:	getProfile
+	//Input:	Player player: The player to find the profile for
+	//Output:	PlayerList.PlayerProfile: The profile
+	//Use:		Gets the player profile
+	//=====================================================================
+    public static PlayerList.PlayerProfile getProfile(Player player){
+    	return players.findProfile(player);
+    }
     
     public static vMinecraftUsers getInstance() {
 		if (instance == null) {
@@ -319,6 +335,17 @@ class PlayerList
 			return false;
 		}
 
+		//=====================================================================
+		//Function:	removeIgnore
+		//Input:	Player name: The player to unignore
+		//Output:	boolean: If the player was successfully unignored
+		//Use:		Stops ignoring a player.
+		//=====================================================================
+		public String[] listIgnore()
+		{
+			return ignoreList.toArray(new String[ignoreList.size()]);
+		}
+
 		//=====================================================================
 		//Function:	addAlias
 		//Input:	String command: The command to try to call

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott