From 02ecadbf3c8b172fbaaa25bc9278fd7d779f4cc8 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 29 Nov 2010 18:51:30 -0800 Subject: [PATCH] Commands - Fixed whois Listener - Added random death messages Plugin - Added hooks for damage Settings - Added random death messages Signed-off-by: nossr50 --- vminecraftCommands.java | 2 +- vminecraftListener.java | 8 +++++++- vminecraftPlugin.java | 1 + vminecraftSettings.java | 20 ++++++++++++++------ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/vminecraftCommands.java b/vminecraftCommands.java index 8d9ef4792..f36cfe938 100644 --- a/vminecraftCommands.java +++ b/vminecraftCommands.java @@ -265,7 +265,7 @@ public class vminecraftCommands{ player.sendMessage(Colors.Blue + "Groups: " + group); //Admin player.sendMessage(Colors.Blue+"Admin: " + - String.valueOf(playerTarget.canIgnoreRestrictions())); + String.valueOf(playerTarget.isAdmin())); //IP player.sendMessage(Colors.Blue+"IP: " + playerTarget.getIP()); //Restrictions diff --git a/vminecraftListener.java b/vminecraftListener.java index c910eae42..7bc1081a6 100644 --- a/vminecraftListener.java +++ b/vminecraftListener.java @@ -83,9 +83,15 @@ public class vminecraftListener extends PluginListener { } else if (vminecraftSettings.getInstance().globalmessages() && player.getHealth() < 1) { - vminecraftChat.gmsg(Colors.Gray + player.getName() + " is no more"); + vminecraftChat.gmsg(Colors.Gray + player.getName() + " " + vminecraftSettings.randomDeathMsg()); } return false; } + /** Not working yet, I posted the issue to hMod on github though + public boolean onDamage(DamageType type, BaseEntity attacker, BaseEntity defender, int amount) { + + return false; + } + **/ } \ No newline at end of file diff --git a/vminecraftPlugin.java b/vminecraftPlugin.java index 37176ff38..160418483 100644 --- a/vminecraftPlugin.java +++ b/vminecraftPlugin.java @@ -23,6 +23,7 @@ public class vminecraftPlugin extends Plugin { etc.getLoader().addListener(PluginLoader.Hook.CHAT, listener, this, PluginListener.Priority.MEDIUM); etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.HIGH); etc.getLoader().addListener(PluginLoader.Hook.IGNITE, listener, this, PluginListener.Priority.HIGH); + etc.getLoader().addListener(PluginLoader.Hook.DAMAGE, listener, this, PluginListener.Priority.MEDIUM); etc.getLoader().addListener(PluginLoader.Hook.EXPLODE, listener, this, PluginListener.Priority.HIGH); if(etc.getInstance().isHealthEnabled()){ etc.getLoader().addListener(PluginLoader.Hook.HEALTH_CHANGE, listener, this, PluginListener.Priority.MEDIUM); diff --git a/vminecraftSettings.java b/vminecraftSettings.java index 8ff4917b3..fc2e1d26c 100644 --- a/vminecraftSettings.java +++ b/vminecraftSettings.java @@ -2,6 +2,7 @@ import java.io.*; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.Random; //===================================================================== //Class: vminecraftSettings //Use: Controls the settings for vminecraft @@ -11,7 +12,6 @@ public class vminecraftSettings { //private final static Object syncLock = new Object(); protected static final Logger log = Logger.getLogger("Minecraft"); private static volatile vminecraftSettings instance; - //Invulnerability List //The feature settings @@ -34,7 +34,6 @@ public class vminecraftSettings { stopFire = false, stopTnt = false, cmdEzModo = false; - //An array of players currently in ezmodo static ArrayList ezModo = new ArrayList(); //The max health for ezModo @@ -43,6 +42,7 @@ public class vminecraftSettings { private PropertiesFile properties; String file = "vminecraft.properties"; public String rules[] = new String[0]; + public static String deathMessages[] = new String[0]; //===================================================================== //Function: loadSettings @@ -83,8 +83,10 @@ public class vminecraftSettings { writer.write("#The health ezmodo people will have while in ezmodo. Don't set to 0\r\n"); writer.write("ezHealth=30\r\n"); writer.write("stopFire=false"); - writer.write("stopTnt=false"); + writer.write("stopTnt=false"); writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n"); + writer.write("#Death messages, seperate them by comma. All death messages start with the player name and a space."); + writer.write("deathMessages=is no more,died horribly,went peacefully"); } catch (Exception e) { log.log(Level.SEVERE, "Exception while creating " + location, e); } finally { @@ -126,7 +128,7 @@ public class vminecraftSettings { stopFire = properties.getBoolean("stopFire",true); stopTnt = properties.getBoolean("stopTNT",true); rules = properties.getString("rules", "").split("@"); - + deathMessages = properties.getString("deathmessages", "").split(","); String[] tempEz = properties.getString("ezModo").split(","); ezModo = new ArrayList(); for(int i = 0; i < tempEz.length; i++) @@ -170,13 +172,19 @@ public class vminecraftSettings { public boolean stopFire() {return stopFire;} public boolean stopTnt() {return stopTnt;} - //EzModo functions + //EzModo methods public boolean isEzModo(String playerName) {return ezModo.contains(playerName);} public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));} public void addEzModo(String playerName) {ezModo.add(playerName);} public int ezModoHealth() {return ezHealth;} public String ezModoList() {return ezModo.toString();} - + //Random death message method + public static String randomDeathMsg() { + if (deathMessages == null) { + return "died"; + } + return deathMessages[ (int) (Math.random() * deathMessages.length)]; + } //===================================================================== //Function: getInstance