Full update

This commit is contained in:
fullwall 2023-09-20 22:05:05 +08:00
parent c994315060
commit 97ddf858ce
7 changed files with 19 additions and 8 deletions

View File

@ -630,17 +630,18 @@ public class EventListen implements Listener {
public void onProjectileHit(final ProjectileHitEvent event) {
if (!(event.getEntity() instanceof FishHook))
return;
NMS.removeHookIfNecessary(CitizensAPI.getNPCRegistry(), (FishHook) event.getEntity());
NMS.removeHookIfNecessary((FishHook) event.getEntity());
new BukkitRunnable() {
int n = 0;
@Override
public void run() {
if (n++ > 5) {
if (n++ > 5 || !CitizensAPI.hasImplementation()) {
cancel();
return;
}
NMS.removeHookIfNecessary(CitizensAPI.getNPCRegistry(), (FishHook) event.getEntity());
NMS.removeHookIfNecessary((FishHook) event.getEntity());
}
}.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
}

View File

@ -179,7 +179,7 @@ public class Settings {
HOLOGRAM_UPDATE_RATE("How often to update hologram names (including placeholders)",
"npc.hologram.update-rate-ticks", "npc.hologram.update-rate", "1s"),
INITIAL_PLAYER_JOIN_SKIN_PACKET_DELAY("How long to wait before sending skins to joined players",
"npc.skins.player-join-update-delay-ticks", "npc.skins.player-join-update-delay", "3s"),
"npc.skins.player-join-update-delay-ticks", "npc.skins.player-join-update-delay", "1s"),
KEEP_CHUNKS_LOADED("Whether to keep NPC chunks loaded", "npc.chunks.always-keep-loaded", false),
LOCALE("Controls translation files - defaults to your system language, set to en if English required",
"general.translation.locale", ""),

View File

@ -100,6 +100,7 @@ import net.citizensnpcs.commands.gui.NPCConfigurator;
import net.citizensnpcs.commands.history.CommandHistory;
import net.citizensnpcs.commands.history.CreateNPCHistoryItem;
import net.citizensnpcs.commands.history.RemoveNPCHistoryItem;
import net.citizensnpcs.editor.Editor;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.NPCSelector;
import net.citizensnpcs.npc.Template;
@ -1928,7 +1929,7 @@ public class NPCCommands {
public void owner(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Owner ownerTrait = npc.getOrAddTrait(Owner.class);
if (args.argsLength() == 1) {
Messaging.sendTr(sender, Messages.NPC_OWNER, npc.getName(), ownerTrait.getOwnerId());
Messaging.sendTr(sender, Messages.NPC_OWNER, npc.getName(), ownerTrait.getOwner());
return;
}
OfflinePlayer p;
@ -3405,6 +3406,9 @@ public class NPCCommands {
permission = "citizens.npc.wander")
public void wander(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Waypoints trait = npc.getOrAddTrait(Waypoints.class);
if (sender instanceof Player && Editor.hasEditor(((Player) sender))) {
Editor.leave(((Player) sender));
}
trait.setWaypointProvider(trait.getCurrentProviderName().equals("wander") ? "linear" : "wander");
Messaging.sendTr(sender, Messages.WAYPOINT_PROVIDER_SET, trait.getCurrentProviderName());
}

View File

@ -87,7 +87,7 @@ public class EquipmentEditor extends Editor {
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (!npc.isSpawned() || !event.getPlayer().equals(player) || Util.isOffHand(event)
if (!npc.isSpawned() || menu != null || !event.getPlayer().equals(player) || Util.isOffHand(event)
|| !npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked())))
return;
Equipper equipper = EQUIPPERS.get(npc.getEntity().getType());

View File

@ -326,9 +326,9 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider {
@Override
public Waypoint getCurrentWaypoint() {
if (waypoints.size() == 0 || !editing) {
if (waypoints.size() == 0 || !editing)
return null;
}
return selectedWaypoint == null ? waypoints.get(waypoints.size() - 1) : selectedWaypoint;
}

View File

@ -131,6 +131,11 @@ public class Waypoint {
}
}
@Override
public String toString() {
return "Waypoint [" + location + (triggers == null ? "]" : ", " + triggers.size() + " triggers]");
}
static {
PersistenceLoader.registerPersistDelegate(WaypointTrigger.class, WaypointTriggerRegistry.class);
}

View File

@ -136,6 +136,7 @@ public class NMS {
if (!PAPER_KNOCKBACK_EVENT_EXISTS) {
event.getKnockbackVector().multiply(new Vector(-1, 0, -1));
}
if (!event.isCancelled()) {
cb.accept(event);
}