From 43c933ebb7805c90409a33191e68abfa68a23bed Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 29 Nov 2010 22:58:27 -0800 Subject: [PATCH] Added /heal and /suicide. Corrected some things in the settings file. Signed-off-by: nossr50 --- vminecraftCommands.java | 44 +++++++++++++++++++++++++++++++++++++++-- vminecraftSettings.java | 15 ++++++++++---- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/vminecraftCommands.java b/vminecraftCommands.java index aa37744a9..46acf3cfb 100644 --- a/vminecraftCommands.java +++ b/vminecraftCommands.java @@ -35,10 +35,50 @@ 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.registerAlias("/playerlist", "/who"); + cl.registerAlias("/suicide", "/wrists"); + } + + //Heal + public static boolean heal(Player player, String[] args) + { + if(vminecraftSettings.getInstance().cmdHeal) + { + if (args[1] == null){ + if (player.getHealth() < 20){ + vminecraftChat.gmsg("Your health is restored"); + return true; + } + else if (args[1] != null){ + Player playerTarget = etc.getServer().matchPlayer(args[1]); + if (playerTarget != null){ + playerTarget.setHealth(20); + vminecraftChat.gmsg(Colors.Blue + "You have healed " + playerTarget.getColor() + playerTarget.getName()); + vminecraftChat.gmsg(Colors.Blue + "You have been healed by " + player.getColor() + player.getName()); + return true; + } + else if (playerTarget == null){ + vminecraftChat.gmsg(Colors.Rose + "Couldn't find that player"); + return false; + } + + } + } + } + return false; + } + //Suicide + public static boolean suicide(Player player, String[] args) + { + if(vminecraftSettings.getInstance().cmdSuicide) + { + player.setHealth(0); + return true; + } + return false; } - - //===================================================================== //Function: teleport (/tp) //Input: Player player: The player using the command diff --git a/vminecraftSettings.java b/vminecraftSettings.java index fc2e1d26c..4d764cede 100644 --- a/vminecraftSettings.java +++ b/vminecraftSettings.java @@ -33,6 +33,8 @@ public class vminecraftSettings { cmdWho = false, stopFire = false, stopTnt = false, + cmdHeal = false, + cmdSuicide = false, cmdEzModo = false; //An array of players currently in ezmodo static ArrayList ezModo = new ArrayList(); @@ -74,6 +76,7 @@ public class vminecraftSettings { writer.write("cmdSay=true\r\n"); writer.write("cmdTp=true\r\n"); writer.write("cmdRules=true\r\n"); + writer.write("cmdSuicide=true\r\n"); writer.write("globalmessages=true\r\n"); writer.write("FFF=true\r\n"); writer.write("adminchat=true\r\n"); @@ -82,11 +85,11 @@ public class vminecraftSettings { writer.write("ezModo=\r\n"); 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("stopFire=false\r\n"); + writer.write("stopTnt=false\r\n"); 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"); + writer.write("#Death messages, seperate them by comma. All death messages start with the player name and a space.\r\n"); + writer.write("deathMessages=is no more,died horribly,went peacefully\r\n"); } catch (Exception e) { log.log(Level.SEVERE, "Exception while creating " + location, e); } finally { @@ -122,6 +125,8 @@ public class vminecraftSettings { cmdTp = properties.getBoolean("cmdTp",true); cmdMasstp = properties.getBoolean("cmdMasstp",true); cmdTphere = properties.getBoolean("cmdTphere",true); + cmdSuicide = properties.getBoolean("cmdSuicide", true); + cmdHeal = properties.getBoolean("cmdHeal",true); globalmessages = properties.getBoolean("globalmessages",true); cmdSay = properties.getBoolean("cmdSay",true); cmdEzModo = properties.getBoolean("cmdEzModo",true); @@ -171,6 +176,8 @@ public class vminecraftSettings { public boolean cmdWho() {return cmdWho;} public boolean stopFire() {return stopFire;} public boolean stopTnt() {return stopTnt;} + public boolean cmdSuicide() {return cmdSuicide;} + public boolean cmdHeal() {return cmdHeal;} //EzModo methods public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}