From e24f6570d5ab832544d7c25be1c4a4b3d6598175 Mon Sep 17 00:00:00 2001 From: cerevisiae Date: Mon, 13 Dec 2010 16:25:57 -0600 Subject: [PATCH] Added in other sendMessage and gmsg that do not require a sending player. Useful for system messages. --- vMinecraftChat.java | 31 +++++++++++++++++++++++++++---- vMinecraftListener.java | 14 +++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/vMinecraftChat.java b/vMinecraftChat.java index 7b975ad64..235b60224 100644 --- a/vMinecraftChat.java +++ b/vMinecraftChat.java @@ -27,12 +27,13 @@ public class vMinecraftChat { //===================================================================== //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 //Use: Outputs a message to everybody //===================================================================== public static void gmsg(Player sender, String msg){ - if(sender.isMuted()) + if(sender != null && sender.isMuted()) sender.sendMessage(Colors.Red + "You have been muted."); 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 //Output: None //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){ - if(sender.isMuted()) + if(sender != null && sender.isMuted()) sender.sendMessage(Colors.Red + "You have been muted."); //Check if the receiver has the sender ignored @@ -75,6 +86,18 @@ public class vMinecraftChat { + " 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 //Input: String msg: The message to be wrapped diff --git a/vMinecraftListener.java b/vMinecraftListener.java index 9be14b553..5a1ae76c7 100644 --- a/vMinecraftListener.java +++ b/vMinecraftListener.java @@ -117,19 +117,19 @@ public class vMinecraftListener extends PluginListener { if (senddeath == true) { 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){ - vMinecraftChat.gmsg(player, deadplayer + Colors.Red + " fell to death!"); + vMinecraftChat.gmsg(deadplayer + Colors.Rose + " fell to death!"); } 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){ - 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){ - vMinecraftChat.gmsg(player, deadplayer + Colors.Red + " drowned in lava"); + vMinecraftChat.gmsg(deadplayer + Colors.Rose + " drowned in lava"); } 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 { - vMinecraftChat.gmsg(player, Colors.Gray + deadplayer + " " + vMinecraftSettings.randomDeathMsg()); + vMinecraftChat.gmsg(Colors.Gray + deadplayer + " " + vMinecraftSettings.randomDeathMsg()); } senddeath = false; }