Fixed Heroes health bug (thanks, Drehverschluss, for helping out with the testing)

This commit is contained in:
Garbage Mule 2011-10-24 19:27:07 +02:00
parent a31aa1ce0e
commit 9161bead55
5 changed files with 28 additions and 32 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: MobArena name: MobArena
main: com.garbagemule.MobArena.MobArena main: com.garbagemule.MobArena.MobArena
version: 0.94.3.22 version: 0.94.3.23
softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells] softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells]
commands: commands:
ma: ma:

View File

@ -41,6 +41,8 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachment;
@ -59,8 +61,6 @@ import com.garbagemule.MobArena.waves.BossWave;
import com.garbagemule.MobArena.waves.Wave; import com.garbagemule.MobArena.waves.Wave;
import com.garbagemule.MobArena.waves.Wave.WaveBranch; import com.garbagemule.MobArena.waves.Wave.WaveBranch;
import com.herocraftonline.dev.heroes.hero.Hero;
public class Arena public class Arena
{ {
private MobArena plugin; private MobArena plugin;
@ -193,12 +193,7 @@ public class Arena
for (Player p : arenaPlayers) for (Player p : arenaPlayers)
{ {
p.teleport(arenaLoc); p.teleport(arenaLoc);
if (plugin.getHeroManager() != null) setHealth(p, 20);
{
Hero hero = plugin.getHeroManager().getHero(p);
hero.setHealth(hero.getMaxHealth());
}
p.setHealth(20);
p.setFoodLevel(20); p.setFoodLevel(20);
assignClassPermissions(p); assignClassPermissions(p);
arenaPlayerMap.put(p, new ArenaPlayer(p, this, plugin)); arenaPlayerMap.put(p, new ArenaPlayer(p, this, plugin));
@ -338,13 +333,7 @@ public class Arena
{ {
storePlayerData(p, loc); storePlayerData(p, loc);
MAUtils.sitPets(p); MAUtils.sitPets(p);
p.setHealth(20); setHealth(p, 20);
if (plugin.getHeroManager() != null)
{
Hero hero = plugin.getHeroManager().getHero(p);
hero.setHealth(hero.getMaxHealth());
hero.syncHealth();
}
p.setFoodLevel(20); p.setFoodLevel(20);
p.setGameMode(GameMode.SURVIVAL); p.setGameMode(GameMode.SURVIVAL);
movePlayerToLobby(p); movePlayerToLobby(p);
@ -647,13 +636,7 @@ public class Arena
if (healthMap.containsKey(p)) if (healthMap.containsKey(p))
{ {
int health = healthMap.remove(p); int health = healthMap.remove(p);
p.setHealth(health); setHealth(p, health);
if (plugin.getHeroManager() != null)
{
Hero hero = plugin.getHeroManager().getHero(p);
hero.setHealth(health * hero.getMaxHealth() / 20);
hero.syncHealth();
}
} }
if (hungerMap.containsKey(p)) if (hungerMap.containsKey(p))
@ -710,6 +693,20 @@ public class Arena
ap.setDead(true); ap.setDead(true);
} }
private void setHealth(Player p, int health)
{
// Grab the current health
int current = p.getHealth();
// If the health is 20, just leave it at that no matter what.
int regain = health == 20 ? 20 : health - current;
// Set the health, and fire off the event.
p.setHealth(health);
EntityRegainHealthEvent event = new EntityRegainHealthEvent(p, regain, RegainReason.CUSTOM);
Bukkit.getPluginManager().callEvent(event);
}
public void repairBlocks() public void repairBlocks()
{ {
while (!repairQueue.isEmpty()) while (!repairQueue.isEmpty())

View File

@ -308,6 +308,8 @@ public class MAListener implements ArenaListener
damager = ((Projectile) damager).getShooter(); damager = ((Projectile) damager).getShooter();
} }
event.setCancelled(false);
// Pet wolf // Pet wolf
if (damagee instanceof Wolf && arena.pets.contains(damagee)) if (damagee instanceof Wolf && arena.pets.contains(damagee))
onPetDamage(event, (Wolf) damagee, damager); onPetDamage(event, (Wolf) damagee, damager);

View File

@ -22,9 +22,6 @@ import com.garbagemule.MobArena.util.FileUtils;
import com.garbagemule.register.payment.Method; import com.garbagemule.register.payment.Method;
import com.garbagemule.register.payment.Methods; import com.garbagemule.register.payment.Methods;
import com.herocraftonline.dev.heroes.Heroes;
import com.herocraftonline.dev.heroes.hero.HeroManager;
/** /**
* MobArena * MobArena
* @author garbagemule * @author garbagemule
@ -41,7 +38,7 @@ public class MobArena extends JavaPlugin
public static boolean hasSpout; public static boolean hasSpout;
// Heroes stuff // Heroes stuff
private HeroManager heroManager = null; //private HeroManager heroManager = null;
// Global variables // Global variables
public static PluginDescriptionFile desc; public static PluginDescriptionFile desc;
@ -70,7 +67,7 @@ public class MobArena extends JavaPlugin
// Set up soft dependencies // Set up soft dependencies
setupRegister(); setupRegister();
setupSpout(); setupSpout();
setupHeroes(); //setupHeroes();
setupMagicSpells(); setupMagicSpells();
// Set up the ArenaMaster and the announcements // Set up the ArenaMaster and the announcements
@ -184,13 +181,13 @@ public class MobArena extends JavaPlugin
Spouty.registerEvents(this); Spouty.registerEvents(this);
} }
private void setupHeroes() /*private void setupHeroes()
{ {
Plugin heroes = this.getServer().getPluginManager().getPlugin("Heroes"); Plugin heroes = this.getServer().getPluginManager().getPlugin("Heroes");
if (heroes == null) return; if (heroes == null) return;
heroManager = ((Heroes) heroes).getHeroManager(); heroManager = ((Heroes) heroes).getHeroManager();
} }*/
private void setupMagicSpells() private void setupMagicSpells()
{ {
@ -206,10 +203,10 @@ public class MobArena extends JavaPlugin
public ArenaMaster getAM() { return am; } // More convenient. public ArenaMaster getAM() { return am; } // More convenient.
public ArenaMaster getArenaMaster() { return am; } public ArenaMaster getArenaMaster() { return am; }
public HeroManager getHeroManager() /*public HeroManager getHeroManager()
{ {
return heroManager; return heroManager;
} }*/
private String getHeader() private String getHeader()
{ {