Really fix the Spigot health issue (with a twist).

This commit is contained in:
garbagemule 2014-12-13 20:28:14 +01:00
parent 4f46064bcf
commit 2e397fd123
3 changed files with 18 additions and 7 deletions

View File

@ -1,7 +1,7 @@
name: MobArena
author: garbagemule
main: com.garbagemule.MobArena.MobArena
version: 0.96.8.1
version: 0.96.8.3
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
commands:
ma:

View File

@ -172,13 +172,17 @@ public class MASpawnThread implements Runnable
int health = (int) Math.max(1D, e.getMaxHealth() * mul);
try {
e.setMaxHealth(health);
e.setHealth(health);
} catch (IllegalArgumentException ex) {
// Spigot... *facepalm*
Messenger.severe("Can't set health to " + health + ", using 2000. If you are running Spigot, set 'maxHealth' higher.");
ex.printStackTrace();
health = 2000;
Messenger.severe("Can't set health to " + health + ", using default health. If you are running Spigot, set 'maxHealth' higher in your Spigot settings.");
Messenger.severe(ex.getLocalizedMessage());
if (w.getType() == WaveType.BOSS) {
((BossWave) w).setBossName("SPIGOT ERROR");
} else {
e.setCustomName("SPIGOT ERROR");
}
}
e.setHealth(health);
// Switch on the type.
switch (w.getType()){

View File

@ -1,5 +1,6 @@
package com.garbagemule.MobArena.waves;
import com.garbagemule.MobArena.Messenger;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
@ -18,8 +19,14 @@ public class MABoss
* @param maxHealth a max health value
*/
public MABoss(LivingEntity entity, double maxHealth) {
entity.setMaxHealth(maxHealth);
entity.setHealth(maxHealth);
try {
entity.setMaxHealth(maxHealth);
entity.setHealth(maxHealth);
} catch (IllegalArgumentException ex) {
// Spigot... *facepalm*
Messenger.severe("Can't set health to " + maxHealth + ", using default health. If you are running Spigot, set 'maxHealth' higher in your Spigot settings.");
Messenger.severe(ex.getLocalizedMessage());
}
this.entity = entity;
this.dead = false;
}