Add debug when sending skins to players

This commit is contained in:
fullwall 2022-05-22 17:36:48 +08:00
parent 5b274ad7a7
commit 6d1e848d89
3 changed files with 12 additions and 12 deletions

View File

@ -238,7 +238,7 @@ public class EventListen implements Listener {
NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getEntity());
if (npc == null)
return;
event.setCancelled(npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
event.setCancelled(npc.isProtected());
if (event instanceof EntityCombustByEntityEvent) {
Bukkit.getPluginManager().callEvent(new NPCCombustByEntityEvent((EntityCombustByEntityEvent) event, npc));
} else if (event instanceof EntityCombustByBlockEvent) {
@ -256,13 +256,13 @@ public class EventListen implements Listener {
npc = CitizensAPI.getNPCRegistry().getNPC(((EntityDamageByEntityEvent) event).getDamager());
if (npc == null)
return;
event.setCancelled(!npc.data().get(NPC.DAMAGE_OTHERS_METADATA, true));
event.setCancelled(!npc.isProtected());
NPCDamageEntityEvent damageEvent = new NPCDamageEntityEvent(npc, (EntityDamageByEntityEvent) event);
Bukkit.getPluginManager().callEvent(damageEvent);
}
return;
}
event.setCancelled(npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
event.setCancelled(npc.isProtected());
if (event instanceof EntityDamageByEntityEvent) {
NPCDamageByEntityEvent damageEvent = new NPCDamageByEntityEvent(npc, (EntityDamageByEntityEvent) event);
Bukkit.getPluginManager().callEvent(damageEvent);
@ -341,8 +341,7 @@ public class EventListen implements Listener {
NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getTarget());
if (npc == null)
return;
event.setCancelled(
!npc.data().get(NPC.TARGETABLE_METADATA, !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)));
event.setCancelled(!npc.data().get(NPC.TARGETABLE_METADATA, !npc.isProtected()));
Bukkit.getPluginManager().callEvent(new EntityTargetNPCEvent(event, npc));
}

View File

@ -110,21 +110,17 @@ public class WaypointCommands {
@Command(
aliases = { "waypoints", "waypoint", "wp" },
usage = "provider [provider name] (-d)",
usage = "provider [provider name]",
desc = "Sets the current waypoint provider",
modifiers = { "provider" },
min = 1,
max = 2,
flags = "d",
permission = "citizens.waypoints.provider")
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Waypoints waypoints = npc.getOrAddTrait(Waypoints.class);
if (args.argsLength() == 1) {
if (args.hasFlag('d')) {
waypoints.describeProviders(sender);
} else {
Messaging.sendTr(sender, Messages.CURRENT_WAYPOINT_PROVIDER, waypoints.getCurrentProviderName());
}
waypoints.describeProviders(sender);
return;
}
if (sender instanceof Player && Editor.hasEditor(((Player) sender))) {

View File

@ -28,6 +28,7 @@ import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.util.Util;
/**
@ -328,6 +329,10 @@ public class SkinUpdateTracker {
public void run() {
List<SkinnableEntity> visible = getNearbyNPCs(player, reset, false);
for (SkinnableEntity skinnable : visible) {
if (Messaging.isDebugging()) {
Messaging.debug("Sending skin from", skinnable.getBukkitEntity(), "to", player, "(" + delay,
reset + ")");
}
skinnable.getSkinTracker().updateViewer(player);
}
}