diff --git a/main/pom.xml b/main/pom.xml index b71f1eb6f..a79ded8e8 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -232,11 +232,7 @@ net.kyori clib.net.kyori - - - org.joml - clib.org.joml - + net.byteflux.libby clib.net.byteflux.libby diff --git a/main/src/main/java/net/citizensnpcs/Citizens.java b/main/src/main/java/net/citizensnpcs/Citizens.java index 95aabefc8..2a9541a6d 100644 --- a/main/src/main/java/net/citizensnpcs/Citizens.java +++ b/main/src/main/java/net/citizensnpcs/Citizens.java @@ -25,6 +25,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +import com.comphenix.protocol.ProtocolLibrary; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -335,8 +336,11 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { .relocate("net{}kyori", "clib{}net{}kyori").build()); lib.loadLibrary(Library.builder().groupId("net{}kyori").artifactId("examination-string").version("1.3.0") .relocate("net{}kyori", "clib{}net{}kyori").build()); - lib.loadLibrary(Library.builder().groupId("org{}joml").artifactId("joml").version("1.10.5") - .relocate("org{}joml", "clib{}org{}joml").build()); + try { + Class.forName("org.joml.Vector3f"); + } catch (Throwable t) { + lib.loadLibrary(Library.builder().groupId("org{}joml").artifactId("joml").version("1.10.5").build()); + } } @Override @@ -420,14 +424,11 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { CommandTrait trait = npc.getTraitNullable(CommandTrait.class); return trait == null ? "" : trait.fillPlaceholder(sender, input); }); + Plugin papi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI"); if (papi != null && papi.isEnabled()) { new CitizensPlaceholders(selector).register(); } - Plugin plib = Bukkit.getPluginManager().getPlugin("ProtocolLib"); - if (plib != null && plib.isEnabled()) { - protocolListener = new ProtocolLibListener(this); - } setupEconomy(); @@ -591,6 +592,18 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { private class CitizensLoadTask implements Runnable { @Override public void run() { + Plugin plib = Bukkit.getPluginManager().getPlugin("ProtocolLib"); + if (plib != null && plib.isEnabled() && ProtocolLibrary.getProtocolManager() != null) { + try { + protocolListener = new ProtocolLibListener(Citizens.this); + } catch (Throwable t) { + Messaging.severe("ProtocolLib support not enabled: enable debug to see error"); + if (Messaging.isDebugging()) { + t.printStackTrace(); + } + } + } + saves.loadInto(npcRegistry); shops.load(); diff --git a/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java b/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java index b64edabae..cad193fd6 100644 --- a/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java +++ b/main/src/main/java/net/citizensnpcs/ProtocolLibListener.java @@ -133,6 +133,7 @@ public class ProtocolLibListener { session.onPacketOverwritten(); } }); + } private StructureModifier> getFlagsModifier(PacketContainer handle) { diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 1e5a9d025..b0b660b5b 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -2318,6 +2318,7 @@ public class NPCCommands { return; } } + if (args.argsLength() == 2) { if ("all".equalsIgnoreCase(action)) { if (!sender.hasPermission("citizens.admin.remove.all") && !sender.hasPermission("citizens.admin")) diff --git a/main/src/main/java/net/citizensnpcs/trait/versioned/WardenTrait.java b/main/src/main/java/net/citizensnpcs/trait/versioned/WardenTrait.java new file mode 100644 index 000000000..236a261a6 --- /dev/null +++ b/main/src/main/java/net/citizensnpcs/trait/versioned/WardenTrait.java @@ -0,0 +1,81 @@ +package net.citizensnpcs.trait.versioned; + +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Warden; + +import com.google.common.collect.Maps; + +import net.citizensnpcs.api.command.Arg; +import net.citizensnpcs.api.command.Command; +import net.citizensnpcs.api.command.CommandContext; +import net.citizensnpcs.api.command.Requirements; +import net.citizensnpcs.api.command.exception.CommandException; +import net.citizensnpcs.api.command.exception.CommandUsageException; +import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.api.trait.Trait; +import net.citizensnpcs.api.trait.TraitName; +import net.citizensnpcs.api.util.Messaging; + +@TraitName("wardentrait") +public class WardenTrait extends Trait { + private final Map anger = Maps.newHashMap(); + + public WardenTrait() { + super("wardentrait"); + } + + private void addAnger(Entity entity, int anger) { + this.anger.put(entity.getUniqueId(), anger); + } + + @Override + public void run() { + if (npc.isSpawned() && npc.getEntity() instanceof Warden) { + Warden warden = (Warden) npc.getEntity(); + for (Map.Entry entry : anger.entrySet()) { + warden.setAnger(Bukkit.getEntity(entry.getKey()), entry.getValue()); + } + } + } + + @Command( + aliases = { "npc" }, + usage = "warden anger [entity uuid/player name] [anger]", + desc = "Sets warden modifiers", + modifiers = { "warden" }, + min = 1, + max = 4, + permission = "citizens.npc.warden") + @Requirements(selected = true, ownership = true, types = EntityType.WARDEN) + public static void Warden(CommandContext args, CommandSender sender, NPC npc, + @Arg(value = 1, completions = { "anger" }) String command, @Arg(2) String player, @Arg(3) Integer anger) + throws CommandException { + WardenTrait trait = npc.getOrAddTrait(WardenTrait.class); + String output = ""; + if (command.equalsIgnoreCase("anger")) { + if (anger == null) + throw new CommandUsageException(); + Entity entity = null; + try { + UUID uuid = UUID.fromString(player); + entity = Bukkit.getEntity(uuid); + } catch (IllegalArgumentException iae) { + entity = Bukkit.getOfflinePlayer(player).getPlayer(); + } + if (entity != null) { + trait.addAnger(entity, anger); + } + } + if (!output.isEmpty()) { + Messaging.send(sender, output.trim()); + } else { + throw new CommandUsageException(); + } + } +} diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/WardenController.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/WardenController.java index f53db69b0..0e03f803f 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/WardenController.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/WardenController.java @@ -94,16 +94,14 @@ public class WardenController extends MobEntityController { return; } NMSImpl.updateMinecraftAIState(npc, this); + npc.update(); if (npc.useMinecraftAI()) { super.customServerAiStep(); } else { NMSImpl.updateAI(this); } - npc.update(); } - - @Override protected SoundEvent getAmbientSound() { return NMSImpl.getSoundEffect(npc, super.getAmbientSound(), NPC.Metadata.AMBIENT_SOUND); diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java index 85acb4f66..747a19afa 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java @@ -254,6 +254,7 @@ import net.citizensnpcs.trait.versioned.SnowmanTrait; import net.citizensnpcs.trait.versioned.SpellcasterTrait; import net.citizensnpcs.trait.versioned.TropicalFishTrait; import net.citizensnpcs.trait.versioned.VillagerTrait; +import net.citizensnpcs.trait.versioned.WardenTrait; import net.citizensnpcs.util.EmptyChannel; import net.citizensnpcs.util.EntityPacketTracker; import net.citizensnpcs.util.Messages; @@ -901,6 +902,7 @@ public class NMSImpl implements NMSBridge { registerTraitWithCommand(manager, SnowmanTrait.class); registerTraitWithCommand(manager, TropicalFishTrait.class); registerTraitWithCommand(manager, VillagerTrait.class); + registerTraitWithCommand(manager, WardenTrait.class); } private void loadEntityTypes() {