spawn hit stand command
hitstandcommand.js
var Bukkit = org.bukkit;
var PotionEffect = Bukkit.potion.PotionEffect;
var PotionEffectType = Bukkit.potion.PotionEffectType;
// Damage listener for "noVuln" tagged entities
registerEvent("org.bukkit.event.entity.EntityDamageEvent", {
handleEvent: function(event) {
var entity = event.getEntity();
if (entity.getScoreboardTags().contains("noVuln")) {
// Optionally restore full health
if (entity.getHealth() < entity.getMaxHealth()) {
entity.setHealth(entity.getMaxHealth());
}
}
}
});
// Command to spawn an invincible, no-AI zombie
addCommand("hitstand", {
onCommand: function(sender, args) {
args = toArray(args);
if (!sender.getLocation) {
sender.sendMessage("§cThis command can only be used by players.");
return;
}
var loc = sender.getLocation();
var zombie = sender.getWorld().spawn(loc, Bukkit.entity.Zombie.class);
zombie.setSilent(true);
zombie.setPersistent(true);
zombie.setCollidable(true);
zombie.setInvulnerable(false);
zombie.addScoreboardTag("noVuln");
// Prevent movement with slowness 255
zombie.addPotionEffect(new PotionEffect(PotionEffectType.SLOWNESS, 1000000000, 255, true, false));
sender.sendMessage("§aSpawned a zombie that appears invincible.");
}
});
Last updated