Răsfoiți Sursa

Added admin chat toggle, also added shortcut for clearinvetory to be /ci

nossr50 14 ani în urmă
părinte
comite
2bf3a6c1cd
4 a modificat fișierele cu 57 adăugiri și 131 ștergeri
  1. 24 5
      vminecraftChat.java
  2. 22 126
      vminecraftCommands.java
  3. 2 0
      vminecraftListener.java
  4. 9 0
      vminecraftSettings.java

+ 24 - 5
vminecraftChat.java

@@ -79,7 +79,7 @@ public class vminecraftChat {
 		//and their following color codes
 		for(int x = 0; x<str.length(); x++)
 		{
-			if(str.charAt(x) == '§')
+			if(str.charAt(x) == '�')
 				x++;
 			else if("i;,.:|!".indexOf(str.charAt(x)) != -1)
 				length+=2;
@@ -272,6 +272,25 @@ public class vminecraftChat {
 		}
 		return false;
 	}
+        public static boolean adminChatToggle(Player player, String message){
+            if(vminecraftSettings.getInstance().isAdminToggled(player.getName())) {
+                String adminchat = Colors.DarkPurple + "{" + getName(player)
+	        +  Colors.DarkPurple +"}" + Colors.White + " ";
+                String[] msg = wordWrap(adminchat + message.substring(1, message.length()));
+                for (Player p: etc.getServer().getPlayerList()) {
+                    if (p != null) {
+                        if (p.isAdmin() || p.canUseCommand("/adminchat")) {
+                            for(String str: msg)
+                                p.sendMessage(str);
+                        }
+                    }
+                }
+                log.log(Level.INFO, "@" + "<" + getName(player)
+					+  Colors.White +"> " + message);
+                return true;
+            }
+            return false;
+        }
 
 	//=====================================================================
 	//Function:	quote
@@ -381,8 +400,8 @@ public class vminecraftChat {
 				//Loop through looking for a color code
 				for(int x = 0; x< msg.length(); x++)
 				{
-					//If the char is a ^ or §
-					if(msg.charAt(x) == '^' || msg.charAt(x) == '§')
+					//If the char is a ^ or �
+					if(msg.charAt(x) == '^' || msg.charAt(x) == '�')
 					{
 						if(x != msg.length() - 1)
 						{
@@ -445,8 +464,8 @@ public class vminecraftChat {
 			//Loop through looking for a color code
 			for(int x = 0; x< message.length(); x++)
 			{
-				//If the char is a ^ or §
-				if(message.charAt(x) == '^' || message.charAt(x) == '§')
+				//If the char is a ^ or �
+				if(message.charAt(x) == '^' || message.charAt(x) == '�')
 				{
 					if(x != message.length() - 1)
 					{

+ 22 - 126
vminecraftCommands.java

@@ -38,16 +38,33 @@ public class vminecraftCommands{
         cl.register("/slay", "slay", "Kill target player");
         cl.register("/ezmodo", "invuln", "Toggle invulnerability");
         cl.register("/ezlist", "ezlist", "List invulnerable players");
-
         cl.register("/heal", "heal", "heal yourself or other players");
         cl.register("/suicide", "suicide", "kill yourself... you loser");
-
+        cl.register("/a", "adminChatToggle", "toggle admin chat for every message");
         cl.register("/modify", "modifySplit");
-
         cl.registerAlias("/playerlist", "/who");
         cl.registerAlias("/wrists", "/suicide");
+        cl.registerAlias("/ci", "/clearinventory");
     }
-
+public static int adminChatToggle(Player player, String[] args)
+{
+    if(vminecraftSettings.getInstance().adminChatToggle())
+    {
+        if (vminecraftSettings.getInstance().cmdAdminToggle) {
+			//If the player is already toggled for admin chat, remove them
+			if (vminecraftSettings.getInstance().isAdminToggled(player.getName())) {
+				player.sendMessage(Colors.Red + "Admin Chat Toggle = off");
+				vminecraftSettings.getInstance().removeAdminToggled(player.getName());
+			//Otherwise include them
+			} else {
+                                player.sendMessage(Colors.Blue + "Admin Chat Toggled on");
+				vminecraftSettings.getInstance().addAdminToggled(player.getName());
+			}
+       return EXIT_SUCCESS;
+		}
+    }
+    return EXIT_FAIL;
+}
 	//=====================================================================
 	//Function:	heal (/heal)
 	//Input:	Player player: The player using the command
@@ -516,130 +533,9 @@ public class vminecraftCommands{
 	public static int timeReverse(long tarTime)
 	{
 		long curTime = etc.getServer().getRelativeTime();
-		if(cur)
+		//if(cur)
 		return EXIT_SUCCESS;
 	}
-	
-	
-
-    //Disable using /modify to add commands (need to make a boolean settings for this)
-
-    //ezlist
-//ezmodo
-	
-	
-	 /*
-    //Promote
-    if (vminecraftSettings.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 (vminecraftSettings.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;
-}*/
 }
 
 //=====================================================================

+ 2 - 0
vminecraftListener.java

@@ -31,6 +31,8 @@ public class vminecraftListener extends PluginListener {
     	//Quote (Greentext)
     	if (message.startsWith("@"))
     		return vminecraftChat.adminChat(player, message);
+        if (vminecraftSettings.getInstance().isAdminToggled(player.getName()))
+            return vminecraftChat.adminChatToggle(player, message);
     	
     	else if (message.startsWith(">"))
     		return vminecraftChat.quote(player, message);

+ 9 - 0
vminecraftSettings.java

@@ -34,9 +34,12 @@ public class vminecraftSettings {
 				   stopTnt			= false,
                                    cmdHeal  = false,
                                    cmdSuicide = false,
+                                   cmdAdminToggle = false,
 				   cmdEzModo		= false;
 	//An array of players currently in ezmodo
 	static ArrayList<String> ezModo = new ArrayList<String>();
+        //An array of players currently toggled for admin chat
+        static ArrayList<String> adminChatList = new ArrayList<String>();
 	//The max health for ezModo
 	static int ezHealth = 30;
 	
@@ -76,6 +79,7 @@ public class vminecraftSettings {
 				writer.write("cmdTp=true\r\n");
 				writer.write("cmdRules=true\r\n");
                                 writer.write("cmdSuicide=true\r\n");
+                                writer.write("cmdAdminToggle=true\r\n");
 				writer.write("globalmessages=true\r\n");
 				writer.write("FFF=true\r\n");
 				writer.write("adminchat=true\r\n");
@@ -126,6 +130,7 @@ public class vminecraftSettings {
 			cmdTphere = properties.getBoolean("cmdTphere",true);
 			cmdSuicide = properties.getBoolean("cmdSuicide", true);
 			cmdHeal = properties.getBoolean("cmdHeal",true);
+                        cmdAdminToggle = properties.getBoolean("cmdAdminToggle", true);
 			globalmessages = properties.getBoolean("globalmessages",true);
 			cmdSay = properties.getBoolean("cmdSay",true);
 			cmdEzModo = properties.getBoolean("cmdEzModo",true);
@@ -158,6 +163,7 @@ public class vminecraftSettings {
 	//Use:		Returns if the feature is enabled
 	//=====================================================================
 	public boolean adminchat() {return adminChat;}
+        public boolean adminChatToggle() {return cmdAdminToggle;}
 	public boolean greentext() {return greentext;}
 	public boolean FFF() {return FFF;}
 	public boolean quakeColors() {return quakeColors;}
@@ -180,8 +186,11 @@ public class vminecraftSettings {
 	//EzModo methods
     public boolean cmdEzModo() {return cmdEzModo;}
 	public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
+        public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
 	public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
+        public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));}
 	public void addEzModo(String playerName) {ezModo.add(playerName);}
+        public void addAdminToggled(String playerName) {adminChatList.add(playerName);}
 	public int ezModoHealth() {return ezHealth;}
 	public String ezModoList() {return ezModo.toString();}