mirror of
https://github.com/kaboomserver/icontrolu.git
synced 2024-11-25 00:47:55 -05:00
Don't try to modify max health if less than 0
This commit is contained in:
parent
f00208d706
commit
145cfcb0c7
3 changed files with 6 additions and 10 deletions
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
|
@ -1,8 +1,6 @@
|
||||||
package pw.kaboom.icontrolu;
|
package pw.kaboom.icontrolu;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -25,7 +23,7 @@ import org.bukkit.scoreboard.Team;
|
||||||
import pw.kaboom.icontrolu.utilities.PlayerList;
|
import pw.kaboom.icontrolu.utilities.PlayerList;
|
||||||
|
|
||||||
class Tick extends BukkitRunnable {
|
class Tick extends BukkitRunnable {
|
||||||
@Override
|
@SuppressWarnings("deprecation")
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Player target: Bukkit.getOnlinePlayers()) {
|
for (Player target: Bukkit.getOnlinePlayers()) {
|
||||||
final Player controller = PlayerList.getController(target.getUniqueId());
|
final Player controller = PlayerList.getController(target.getUniqueId());
|
||||||
|
@ -45,14 +43,15 @@ class Tick extends BukkitRunnable {
|
||||||
target.teleportAsync(controller.getLocation());
|
target.teleportAsync(controller.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeInstance controllerMaxHealth = target.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
|
||||||
AttributeInstance targetMaxHealth = target.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
|
||||||
targetMaxHealth.setBaseValue(controllerMaxHealth.getBaseValue());
|
|
||||||
|
|
||||||
target.setAllowFlight(controller.getAllowFlight());
|
target.setAllowFlight(controller.getAllowFlight());
|
||||||
target.setExhaustion(controller.getExhaustion());
|
target.setExhaustion(controller.getExhaustion());
|
||||||
target.setFlying(controller.isFlying());
|
target.setFlying(controller.isFlying());
|
||||||
target.setFoodLevel(controller.getFoodLevel());
|
target.setFoodLevel(controller.getFoodLevel());
|
||||||
|
|
||||||
|
if (controller.getMaxHealth() > 0) {
|
||||||
|
target.setMaxHealth(controller.getMaxHealth());
|
||||||
|
}
|
||||||
|
|
||||||
target.setHealth(controller.getHealth());
|
target.setHealth(controller.getHealth());
|
||||||
target.setLevel(controller.getLevel());
|
target.setLevel(controller.getLevel());
|
||||||
target.setSneaking(controller.isSneaking());
|
target.setSneaking(controller.isSneaking());
|
||||||
|
@ -172,7 +171,6 @@ class ControlPlayer implements Listener {
|
||||||
final int tickDelay = 200;
|
final int tickDelay = 200;
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Player allPlayers: Bukkit.getOnlinePlayers()) {
|
for (Player allPlayers: Bukkit.getOnlinePlayers()) {
|
||||||
allPlayers.showPlayer(JavaPlugin.getPlugin(Main.class), controller);
|
allPlayers.showPlayer(JavaPlugin.getPlugin(Main.class), controller);
|
||||||
|
|
|
@ -60,7 +60,6 @@ public final class CommandIcu implements CommandExecutor {
|
||||||
final int tickDelay = 200;
|
final int tickDelay = 200;
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Player player: Bukkit.getOnlinePlayers()) {
|
for (Player player: Bukkit.getOnlinePlayers()) {
|
||||||
player.showPlayer(JavaPlugin.getPlugin(Main.class), controller);
|
player.showPlayer(JavaPlugin.getPlugin(Main.class), controller);
|
||||||
|
@ -85,7 +84,6 @@ public final class CommandIcu implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
|
|
Loading…
Reference in a new issue