浏览代码

Added in other sendMessage and gmsg that do not require a sending player. Useful for system messages.

cerevisiae 14 年之前
父节点
当前提交
e24f6570d5
共有 2 个文件被更改,包括 34 次插入11 次删除
  1. 27 4
      vMinecraftChat.java
  2. 7 7
      vMinecraftListener.java

+ 27 - 4
vMinecraftChat.java

@@ -27,12 +27,13 @@ public class vMinecraftChat {
 
 
 	//=====================================================================
 	//=====================================================================
 	//Function:	gmsg
 	//Function:	gmsg
-	//Input:	String msg: The message to be broadcast to all players
+	//Input:	Player sender: The player sending the message
+	//			String msg: The message to be broadcast to all players
 	//Output:	None 
 	//Output:	None 
 	//Use:		Outputs a message to everybody
 	//Use:		Outputs a message to everybody
 	//=====================================================================
 	//=====================================================================
     public static void gmsg(Player sender, String msg){
     public static void gmsg(Player sender, String msg){
-    	if(sender.isMuted())
+    	if(sender != null && sender.isMuted())
     		sender.sendMessage(Colors.Red + "You have been muted.");
     		sender.sendMessage(Colors.Red + "You have been muted.");
     	
     	
         for (Player receiver : etc.getServer().getPlayerList()) {
         for (Player receiver : etc.getServer().getPlayerList()) {
@@ -52,13 +53,23 @@ public class vMinecraftChat {
     }
     }
 
 
 	//=====================================================================
 	//=====================================================================
-	//Function:	sendMessage
+	//Function:	gmsg
 	//Input:	String msg: The message to be broadcast to all players
 	//Input:	String msg: The message to be broadcast to all players
 	//Output:	None 
 	//Output:	None 
 	//Use:		Outputs a message to everybody
 	//Use:		Outputs a message to everybody
 	//=====================================================================
 	//=====================================================================
+    public static void gmsg(String msg){gmsg(null, msg);}
+
+	//=====================================================================
+	//Function:	sendMessage
+	//Input:	Player sender: The player sending the message
+    //			Player receiver: The player receiving the message
+    //			String msg: The message to be broadcast to all players
+	//Output:	None 
+	//Use:		Outputs a message to everybody
+	//=====================================================================
     public static void sendMessage(Player sender, Player receiver, String msg){
     public static void sendMessage(Player sender, Player receiver, String msg){
-    	if(sender.isMuted())
+    	if(sender != null && sender.isMuted())
     		sender.sendMessage(Colors.Red + "You have been muted.");
     		sender.sendMessage(Colors.Red + "You have been muted.");
     	
     	
     	//Check if the receiver has the sender ignored
     	//Check if the receiver has the sender ignored
@@ -75,6 +86,18 @@ public class vMinecraftChat {
     				+ " has you on their ignore list.");
     				+ " has you on their ignore list.");
     }
     }
 
 
+	//=====================================================================
+	//Function:	sendMessage
+	//Input:	Player receiver: The player receiving the message
+    //			String msg: The message to be broadcast to all players
+	//Output:	None 
+	//Use:		Outputs a message to everybody
+	//=====================================================================
+    public static void sendMessage(Player receiver, String msg)
+    {
+    	sendMessage(null, receiver, msg);
+    }
+
 	//=====================================================================
 	//=====================================================================
 	//Function:	wordWrap
 	//Function:	wordWrap
 	//Input:	String msg: The message to be wrapped
 	//Input:	String msg: The message to be wrapped

+ 7 - 7
vMinecraftListener.java

@@ -117,19 +117,19 @@ public class vMinecraftListener extends PluginListener {
 
 
     	        if (senddeath == true) {
     	        if (senddeath == true) {
     	        	if (type == type.CREEPER_EXPLOSION) {
     	        	if (type == type.CREEPER_EXPLOSION) {
-    	                vMinecraftChat.gmsg(player, deadplayer + Colors.Red + " was blown to bits by a creeper");
+    	                vMinecraftChat.gmsg(deadplayer + Colors.Rose + " was blown to bits by a creeper");
     	        	} else if(type == type.FALL){
     	        	} else if(type == type.FALL){
-    	                vMinecraftChat.gmsg(player, deadplayer + Colors.Red + " fell to death!");
+    	                vMinecraftChat.gmsg(deadplayer + Colors.Rose + " fell to death!");
     	        	} else if(type == type.FIRE){
     	        	} else if(type == type.FIRE){
-    	                vMinecraftChat.gmsg(player, deadplayer + Colors.Red + " was incinerated");
+    	                vMinecraftChat.gmsg(deadplayer + Colors.Rose + " was incinerated");
     	        	} else if (type == type.FIRE_TICK){
     	        	} else if (type == type.FIRE_TICK){
-    	                vMinecraftChat.gmsg(player, deadplayer + Colors.Red + " Stop drop and roll, not scream, run, and burn " + player.getName());
+    	                vMinecraftChat.gmsg(deadplayer + Colors.Rose + " Stop drop and roll, not scream, run, and burn ");
     	        	} else if (type == type.LAVA){
     	        	} else if (type == type.LAVA){
-    	                vMinecraftChat.gmsg(player, deadplayer + Colors.Red + " drowned in lava");
+    	                vMinecraftChat.gmsg(deadplayer + Colors.Rose + " drowned in lava");
     	        	} else if (type == type.WATER){
     	        	} else if (type == type.WATER){
-    	                vMinecraftChat.gmsg(player, deadplayer + Colors.Blue + " should've attended that swimming class");
+    	                vMinecraftChat.gmsg(deadplayer + Colors.Rose + " should've attended that swimming class");
     	        	} else {
     	        	} else {
-                            vMinecraftChat.gmsg(player, Colors.Gray + deadplayer + " " + vMinecraftSettings.randomDeathMsg());
+                            vMinecraftChat.gmsg(Colors.Gray + deadplayer + " " + vMinecraftSettings.randomDeathMsg());
                         }
                         }
                         senddeath = false;
                         senddeath = false;
                 }
                 }