mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-21 23:01:24 +01:00
Null check enderdragon bossbar again, set blank hologram names to hover
This commit is contained in:
parent
cd12fefe73
commit
2c8b1864d8
@ -1408,13 +1408,13 @@ public class NPCCommands {
|
||||
permission = "citizens.npc.name")
|
||||
@Requirements(selected = true, ownership = true)
|
||||
public void name(CommandContext args, CommandSender sender, NPC npc) {
|
||||
String old = npc.data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
|
||||
String old = npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString();
|
||||
if (args.hasFlag('h')) {
|
||||
old = "hover";
|
||||
} else {
|
||||
old = old.equals("hover") ? "true" : "" + !Boolean.parseBoolean(old);
|
||||
}
|
||||
npc.data().setPersistent(NPC.NAMEPLATE_VISIBLE_METADATA, old);
|
||||
npc.data().setPersistent(NPC.Metadata.NAMEPLATE_VISIBLE, old);
|
||||
Messaging.sendTr(sender, Messages.NAMEPLATE_VISIBILITY_TOGGLED);
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ public class HologramTrait extends Trait {
|
||||
if (!npc.isSpawned())
|
||||
return;
|
||||
lastNameplateVisible = Boolean
|
||||
.parseBoolean(npc.data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString());
|
||||
.parseBoolean(npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString());
|
||||
currentLoc = npc.getStoredLocation();
|
||||
if (npc.requiresNameHologram() && lastNameplateVisible) {
|
||||
nameNPC = createHologram(npc.getFullName(), 0);
|
||||
@ -205,7 +205,7 @@ public class HologramTrait extends Trait {
|
||||
currentLoc = npc.getStoredLocation();
|
||||
}
|
||||
boolean nameplateVisible = Boolean
|
||||
.parseBoolean(npc.data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString());
|
||||
.parseBoolean(npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString());
|
||||
if (npc.requiresNameHologram()) {
|
||||
if (nameNPC != null && !nameplateVisible) {
|
||||
nameNPC.destroy();
|
||||
@ -245,10 +245,10 @@ public class HologramTrait extends Trait {
|
||||
}
|
||||
if (text != null && !ChatColor.stripColor(Colorizer.parseColors(text)).isEmpty()) {
|
||||
hologramNPC.setName(Placeholders.replace(text, null, npc));
|
||||
hologramNPC.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, true);
|
||||
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, true);
|
||||
} else {
|
||||
hologramNPC.setName("");
|
||||
hologramNPC.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, "hover");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class Util {
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()
|
||||
|| npc.data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString().equals("false")) {
|
||||
|| npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString().equals("false")) {
|
||||
NMS.setTeamNameTagVisible(team, false);
|
||||
}
|
||||
mode = 0;
|
||||
|
@ -272,6 +272,7 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.dimension.end.EndDragonFight;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.level.pathfinder.Node;
|
||||
@ -448,7 +449,10 @@ public class NMSImpl implements NMSBridge {
|
||||
if (entity.getType() == EntityType.WITHER) {
|
||||
bserver = ((WitherBoss) NMSImpl.getHandle(entity)).bossEvent;
|
||||
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
|
||||
bserver = ((EnderDragon) NMSImpl.getHandle(entity)).getDragonFight().dragonEvent;
|
||||
EndDragonFight df = ((EnderDragon) NMSImpl.getHandle(entity)).getDragonFight();
|
||||
if (df != null) {
|
||||
bserver = df.dragonEvent;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -275,6 +275,7 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.dimension.end.EndDragonFight;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.level.pathfinder.Node;
|
||||
@ -453,7 +454,10 @@ public class NMSImpl implements NMSBridge {
|
||||
if (entity.getType() == EntityType.WITHER) {
|
||||
bserver = ((WitherBoss) NMSImpl.getHandle(entity)).bossEvent;
|
||||
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
|
||||
bserver = ((EnderDragon) NMSImpl.getHandle(entity)).getDragonFight().dragonEvent;
|
||||
EndDragonFight df = ((EnderDragon) NMSImpl.getHandle(entity)).getDragonFight();
|
||||
if (df != null) {
|
||||
bserver = df.dragonEvent;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.citizensnpcs.nms.v1_18_R2.util;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -128,7 +128,7 @@ public class PlayerAnimationImpl {
|
||||
NMSImpl.sendPacketNearby(player.getBukkitEntity(), player.getBukkitEntity().getLocation(), packet, radius);
|
||||
}
|
||||
|
||||
private static EnumMap<PlayerAnimation, Integer> DEFAULTS = Maps.newEnumMap(PlayerAnimation.class);
|
||||
private static Map<PlayerAnimation, Integer> DEFAULTS = Maps.newEnumMap(PlayerAnimation.class);
|
||||
static {
|
||||
DEFAULTS.put(PlayerAnimation.ARM_SWING, 0);
|
||||
DEFAULTS.put(PlayerAnimation.HURT, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user