Merge branch 'master' of github.com:nossr50/vminecraft-plugin

Conflicts:
	vMinecraftListener.java
This commit is contained in:
nossr50 2010-12-13 16:19:10 -08:00
commit b6396b9dc5
3 changed files with 86 additions and 49 deletions

View File

@ -38,19 +38,20 @@ public class vMinecraftChat {
for (Player receiver : etc.getServer().getPlayerList()) { for (Player receiver : etc.getServer().getPlayerList()) {
if (receiver == null) {return;} if (receiver == null) return;
if(vMinecraftUsers.getProfile(receiver) == null) return;
if(vMinecraftUsers.getProfile(receiver) == null)
return;
//Check if the person has the sender ignored //Check if the person has the sender ignored
if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender)) if(sender != null)
{ if(vMinecraftUsers.getProfile(receiver).isIgnored(sender))
return;
String[] message = applyColors(wordWrap(msg)); String[] message = applyColors(wordWrap(msg));
for(String out : message) for(String out : message)
receiver.sendMessage(out); receiver.sendMessage(out);
} }
} }
}
//===================================================================== //=====================================================================
//Function: gmsg //Function: gmsg
@ -75,15 +76,19 @@ public class vMinecraftChat {
//Check if the receiver has the sender ignored //Check if the receiver has the sender ignored
if(vMinecraftUsers.getProfile(receiver) == null) if(vMinecraftUsers.getProfile(receiver) == null)
return; return;
if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender))
if(sender != null)
if(vMinecraftUsers.getProfile(receiver).isIgnored(sender))
{ {
sendMessage(sender, sender, Colors.Rose + receiver.getName()
+ " has you on their ignore list.");
return;
}
String[] message = applyColors(wordWrap(msg)); String[] message = applyColors(wordWrap(msg));
for(String out : message) for(String out : message)
receiver.sendMessage(out); receiver.sendMessage(out);
//Tell them if they are //Tell them if they are
} else
sendMessage(sender, sender, Colors.Rose + receiver.getName()
+ " has you on their ignore list.");
} }
//===================================================================== //=====================================================================

View File

@ -6,9 +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;
public String deadplayer;
public boolean senddeath;
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
//===================================================================== //=====================================================================
@ -83,32 +80,8 @@ public class vMinecraftListener extends PluginListener {
//Use: Checks for exploits and runs the commands //Use: Checks for exploits and runs the commands
//===================================================================== //=====================================================================
public boolean onHealthChange(Player player,int oldValue,int newValue){ public boolean onHealthChange(Player player,int oldValue,int newValue){
if (vMinecraftSettings.getInstance().isEzModo(player.getName())) { if (player.getHealth() > 1){
return oldValue > newValue; vMinecraftUsers.getProfile(player).isDead(false);
}
if (player.getHealth() < 1){
senddeath = true;
deadplayer = player.getName();
vMinecraftChat.gmsg(deadplayer + " " + Colors.Red + vMinecraftSettings.randomDeathMsg());
/* These messages need to be in onHealth because onDamage is only called when a player is hurt, other than
* that I'm a bit clueless on how we should go about trying to fix this. I'll set it to at least show random death messages for now.
if (type == type.CREEPER_EXPLOSION) {
vMinecraftChat.gmsg(deadplayer + Colors.Rose + " was blown to bits by a creeper");
} else if(type == type.FALL){
vMinecraftChat.gmsg(deadplayer + Colors.Rose + " fell to death!");
} else if(type == type.FIRE){
vMinecraftChat.gmsg(deadplayer + Colors.Rose + " was incinerated");
} else if (type == type.FIRE_TICK){
vMinecraftChat.gmsg(deadplayer + Colors.Rose + " Stop drop and roll, not scream, run, and burn ");
} else if (type == type.LAVA){
vMinecraftChat.gmsg(deadplayer + Colors.Rose + " drowned in lava");
} else if (type == type.WATER){
vMinecraftChat.gmsg(deadplayer + Colors.Rose + " should've attended that swimming class");
} else {
vMinecraftChat.gmsg(Colors.Gray + deadplayer + " " + vMinecraftSettings.randomDeathMsg());
}
*
*/
} }
return false; return false;
} }
@ -133,8 +106,48 @@ public class vMinecraftListener extends PluginListener {
} }
return false; return false;
} }
public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) { public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
Player defend = null;
if(defender != null && defender.isPlayer())
{
defend = defender.getPlayer();
if (vMinecraftSettings.getInstance().isEzModo(defend.getName())) {
return true;
}
if (defend.getHealth() > 0)
return false; return false;
if (vMinecraftUsers.getProfile(defend).isDead())
return false;
vMinecraftUsers.getProfile(defend).isDead(true);
Player attack = null;
if(attacker != null && attacker.isPlayer())
attack = attacker.getPlayer();
if(attack != null)
{
vMinecraftChat.gmsg(defend.getName() + " was slain by " + attack.getName());
}
if (type == type.CREEPER_EXPLOSION) {
vMinecraftChat.gmsg(defend.getName() + Colors.Rose + " was blown to bits by a creeper");
} else if(type == type.FALL){
vMinecraftChat.gmsg(defend.getName() + Colors.Rose + " fell to death!");
} else if(type == type.FIRE){
vMinecraftChat.gmsg(defend.getName() + Colors.Rose + " was incinerated");
} else if (type == type.FIRE_TICK){
vMinecraftChat.gmsg(defend.getName() + Colors.Rose + " Stop drop and roll, not scream, run, and burn ");
} else if (type == type.LAVA){
vMinecraftChat.gmsg(defend.getName() + Colors.Rose + " drowned in lava");
} else if (type == type.WATER){
log.log(Level.INFO, "Water");
vMinecraftChat.gmsg(defend.getName() + Colors.Rose + " should've attended that swimming class");
} else {
vMinecraftChat.gmsg(Colors.Gray + defend.getName() + " " + vMinecraftSettings.randomDeathMsg());
} }
} }
return false;
}
}

View File

@ -154,6 +154,8 @@ class PlayerList
tag, tag,
suffix; suffix;
private boolean dead;
char defaultColor; char defaultColor;
String location = "vminecraft.users"; String location = "vminecraft.users";
@ -182,6 +184,7 @@ class PlayerList
defaultColor = 'f'; defaultColor = 'f';
ignoreList = new ArrayList<String>(); ignoreList = new ArrayList<String>();
aliasList = new commandList(); aliasList = new commandList();
dead = false;
//Try to load the player and if they aren't found, append them //Try to load the player and if they aren't found, append them
if(!load()) if(!load())
@ -544,6 +547,22 @@ class PlayerList
return etc.getServer().matchPlayer(lastMessage); return etc.getServer().matchPlayer(lastMessage);
return null; return null;
} }
//=====================================================================
//Function: isDead
//Input: None
//Output: boolean: If the player is dead or not
//Use: Gets the player is dead or not.
//=====================================================================
public boolean isDead() {return dead;}
//=====================================================================
//Function: isDead
//Input: boolean isded: if the player is dead or not.
//Output: None
//Use: Sets if the player is dead or not
//=====================================================================
public void isDead(boolean isded){dead = isded;}
} }
} }