Further revisions, moved death messages to onDamager.

This commit is contained in:
nossr50 2010-12-02 19:46:21 -08:00
parent f521bd6fe9
commit 278c24650a

View File

@ -6,7 +6,6 @@ import java.util.logging.Logger;
//Author: nossr50, TrapAlice, cerevisiae //Author: nossr50, TrapAlice, cerevisiae
//===================================================================== //=====================================================================
public class vMinecraftListener extends PluginListener { public class vMinecraftListener extends PluginListener {
public int damagetype;
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
//===================================================================== //=====================================================================
@ -84,24 +83,6 @@ public class vMinecraftListener extends PluginListener {
if (vMinecraftSettings.getInstance().isEzModo(player.getName())) { if (vMinecraftSettings.getInstance().isEzModo(player.getName())) {
return oldValue > newValue; return oldValue > newValue;
} }
//These are place holders until I make random messages for everything and also to see if these work correctly
if (vMinecraftSettings.getInstance().globalmessages() && newValue < 1) {
if (damagetype == 1){
vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " was blown to bits by a creeper");
} else if (damagetype == 2) {
vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " fell to death!");
} else if (damagetype ==3){
vMinecraftChat.gmsg(player, player.getName() + Colors.Red + " was incinerated");
} else if (damagetype == 4){
vMinecraftChat.gmsg(player, Colors.Red + " Stop drop and roll, not scream, run, and burn " + player.getName());
} else if (damagetype == 5){
vMinecraftChat.gmsg(player, Colors.Red + player.getName() + " drowned in lava");
} else if (damagetype == 6){
vMinecraftChat.gmsg(player, Colors.Blue + player.getName() + " should've attended that swimming class");
} else {
vMinecraftChat.gmsg(player, Colors.Gray + player.getName() + " " + vMinecraftSettings.randomDeathMsg());
}
}
return false; return false;
} }
@ -109,10 +90,12 @@ public class vMinecraftListener extends PluginListener {
vMinecraftUsers.addUser(player); vMinecraftUsers.addUser(player);
} }
public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) { public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
if(defender.isPlayer() && !attacker.isPlayer()){ if(defender.isPlayer()){
Player player = (Player)defender; int damagetype = 0; //Set to 0 to begin with
if(player.getHealth() < 1) { Player player = (Player)defender;
if(type == type.CREEPER_EXPLOSION){ if(defender.isPlayer() && player.getHealth() < 1 && !attacker.isPlayer())
{
if (type == type.CREEPER_EXPLOSION) {
damagetype = 1; //Creeper damagetype = 1; //Creeper
} else if(type == type.FALL){ } else if(type == type.FALL){
damagetype = 2; //Fall damagetype = 2; //Fall
@ -124,16 +107,19 @@ public class vMinecraftListener extends PluginListener {
damagetype = 5; //Lava damagetype = 5; //Lava
} else if (type == type.WATER){ } else if (type == type.WATER){
damagetype = 6; //Water damagetype = 6; //Water
} else{
damagetype = 0;
} }
}
if (defender.isPlayer() && attacker.isPlayer()) { if (defender.isPlayer() && attacker.isPlayer()) {
Player pAttacker = (Player)attacker; Player pAttacker = (Player)attacker;
Player pDefender = (Player)defender; Player pDefender = (Player)defender;
damagetype = 0; if(pDefender.getHealth() < 1){
vMinecraftChat.gmsg(player, pAttacker.getName() + " has murdered " + pDefender.getName()); damagetype =0; //Reset damagetype to 0
vMinecraftChat.gmsg(player, pAttacker.getName() + " has murdered " + pDefender.getName());
}
} }
if (damagetype == 1 && !attacker.isPlayer()){ if (player.getHealth() < 1 && !attacker.isPlayer()) {
if (damagetype == 1){
vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " was blown to bits by a creeper"); vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " was blown to bits by a creeper");
} else if (damagetype == 2) { } else if (damagetype == 2) {
vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " fell to death!"); vMinecraftChat.gmsg(player,player.getName() + Colors.Red + " fell to death!");