diff --git a/main/src/main/java/net/citizensnpcs/Citizens.java b/main/src/main/java/net/citizensnpcs/Citizens.java index 51c93c136..c760b2e26 100644 --- a/main/src/main/java/net/citizensnpcs/Citizens.java +++ b/main/src/main/java/net/citizensnpcs/Citizens.java @@ -405,8 +405,10 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { traitFactory = new CitizensTraitFactory(this); traitFactory.registerTrait(TraitInfo.create(ShopTrait.class).withSupplier(() -> new ShopTrait(shops))); selector = new NPCSelector(this); - templateRegistry = new TemplateRegistry(new File(this.getDataFolder(), "templates").toPath()); - + templateRegistry = new TemplateRegistry(new File(getDataFolder(), "templates").toPath()); + if (!new File(getDataFolder(), "skins").exists()) { + new File(getDataFolder(), "skins").mkdir(); + } Bukkit.getPluginManager().registerEvents(new EventListen(), this); Bukkit.getPluginManager().registerEvents(new Placeholders(), this); diff --git a/main/src/main/java/net/citizensnpcs/EventListen.java b/main/src/main/java/net/citizensnpcs/EventListen.java index a3ae230c9..02320e259 100644 --- a/main/src/main/java/net/citizensnpcs/EventListen.java +++ b/main/src/main/java/net/citizensnpcs/EventListen.java @@ -456,6 +456,7 @@ public class EventListen implements Listener { @EventHandler public void onNPCKnockback(NPCKnockbackEvent event) { + event.setCancelled(event.getNPC().isProtected()); if (event.getNPC().data().has(NPC.Metadata.KNOCKBACK)) { event.setCancelled(!event.getNPC().data().get(NPC.Metadata.KNOCKBACK, true)); } diff --git a/main/src/main/java/net/citizensnpcs/Settings.java b/main/src/main/java/net/citizensnpcs/Settings.java index cb31f65e0..8529ba4ab 100644 --- a/main/src/main/java/net/citizensnpcs/Settings.java +++ b/main/src/main/java/net/citizensnpcs/Settings.java @@ -110,7 +110,7 @@ public class Settings { "npc.pathfinding.default-distance-margin", 1), DEFAULT_HOLOGRAM_RENDERER( "The default renderer for holograms, must be one of the following:
interaction - matches inbuilt nametags most closely
display - allows for different colored backgrounds
armorstand - creates an armorstand and teleports it to the player", - "npc.hologram.default-renderer", "interaction"), + "npc.hologram.default-renderer", "display"), DEFAULT_LOOK_CLOSE("Enable look close by default", "npc.default.look-close.enabled", false), DEFAULT_LOOK_CLOSE_RANGE("Default look close range in blocks", "npc.default.look-close.range", 10), DEFAULT_NPC_HOLOGRAM_LINE_HEIGHT("Default distance between hologram lines", "npc.hologram.default-line-height", diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 5033b2762..4537bf89d 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -23,6 +23,7 @@ import org.bukkit.DyeColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; import org.bukkit.Rotation; import org.bukkit.Sound; @@ -893,7 +894,9 @@ public class NPCCommands { StringBuilder builder = new StringBuilder(); for (String part : parts) { if (part.contains(":")) { - Template template = templateRegistry.getTemplateByNamespacedKey(part); + int idx = part.indexOf(':'); + Template template = templateRegistry + .getTemplateByKey(new NamespacedKey(part.substring(0, idx), part.substring(idx + 1))); if (template == null) continue; template.apply(npc); @@ -3347,7 +3350,8 @@ public class NPCCommands { modifiers = { "tpto" }, min = 2, max = 3, - permission = "citizens.npc.tpto") + permission = "citizens.npc.tpto", + parsePlaceholders = true) @Requirements public void tpto(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Entity from = null, to = null; diff --git a/main/src/main/java/net/citizensnpcs/commands/TemplateCommands.java b/main/src/main/java/net/citizensnpcs/commands/TemplateCommands.java index c82b385a0..e3396dcca 100644 --- a/main/src/main/java/net/citizensnpcs/commands/TemplateCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/TemplateCommands.java @@ -3,6 +3,7 @@ package net.citizensnpcs.commands; import java.util.Collection; import java.util.stream.Collectors; +import org.bukkit.NamespacedKey; import org.bukkit.command.CommandSender; import com.google.common.base.Joiner; @@ -36,25 +37,47 @@ public class TemplateCommands { min = 2, permission = "citizens.templates.apply") public void apply(CommandContext args, CommandSender sender, NPC npc, - @Arg(value = 1, completionsProvider = TemplateCompletions.class) String templateName) + @Arg(value = 1, completionsProvider = TemplateCompletions.class) String templateKey) throws CommandException { Template template = null; - if (templateName.contains(":")) { - template = registry.getTemplateByNamespacedKey(templateName); + if (templateKey.contains(":")) { + int idx = templateKey.indexOf(':'); + template = registry + .getTemplateByKey(new NamespacedKey(templateKey.substring(0, idx), templateKey.substring(idx + 1))); } else { - Collection