From dcbefa6e9b3110d15149ba9ed7d97cafc0953b91 Mon Sep 17 00:00:00 2001 From: d0by Date: Sat, 19 Feb 2022 19:38:37 +0100 Subject: [PATCH] 2.0.6 & 2.0.7 --- build.gradle | 2 +- .../decentsoftware/holograms/api/DecentHologramsAPI.java | 6 ------ .../java/eu/decentsoftware/holograms/api/Settings.java | 3 ++- .../decentsoftware/holograms/api/actions/ActionType.java | 3 ++- .../decentsoftware/holograms/api/holograms/Hologram.java | 8 ++++---- .../holograms/api/holograms/HologramLine.java | 2 +- .../holograms/api/holograms/HologramManager.java | 3 ++- .../holograms/plugin/commands/HologramsCommand.java | 8 ++++---- .../holograms/plugin/features/DamageDisplayFeature.java | 8 +++++--- .../holograms/plugin/features/HealingDisplayFeature.java | 8 +++++--- src/main/resources/config.yml | 3 +++ src/main/resources/plugin.yml | 8 ++++++++ 12 files changed, 37 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index b862feaf..999ed81f 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { defaultTasks 'build' group 'eu.decentsoftware.holograms' -version '2.2.6' +version '2.2.7' description 'Lightweight yet very powerful hologram plugin with many features and configuration options.' repositories { diff --git a/src/main/java/eu/decentsoftware/holograms/api/DecentHologramsAPI.java b/src/main/java/eu/decentsoftware/holograms/api/DecentHologramsAPI.java index 735f0415..04bce927 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/DecentHologramsAPI.java +++ b/src/main/java/eu/decentsoftware/holograms/api/DecentHologramsAPI.java @@ -38,12 +38,6 @@ public static boolean isRunning() { /** * Get the instance of running DecentHolograms. - *

- * If you use shaded version of the API, you must enable - * it first using {@link DecentHologramsAPI#onEnable()} class. - * Also, don't forget to disable the API in you onDisable method - * when you are done using it. {@link DecentHologramsAPI#onDisable()} - *

* * @return the instance of running DecentHolograms. */ diff --git a/src/main/java/eu/decentsoftware/holograms/api/Settings.java b/src/main/java/eu/decentsoftware/holograms/api/Settings.java index d394987c..77ba4d61 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/Settings.java +++ b/src/main/java/eu/decentsoftware/holograms/api/Settings.java @@ -20,10 +20,11 @@ public class Settings { public static final Configuration CONFIG = new Configuration(DECENT_HOLOGRAMS.getPlugin(), DECENT_HOLOGRAMS.getDataFolder(), "config.yml"); public static final ConfigValue CHECK_UPDATES = new ConfigValue<>(CONFIG, false, "update-checker", true); + public static final IntegerConfigValue CLICK_COOLDOWN = new IntegerConfigValue(CONFIG, false, "click-cooldown", 20, 10, 300); public static final ConfigValue DEFAULT_TEXT = new ConfigValue<>(CONFIG, false, "defaults.text", "Blank Line"); public static final ConfigValue DEFAULT_DOWN_ORIGIN = new ConfigValue<>(CONFIG, false, "defaults.down-origin", false); - public static final ConfigValue DEFAULT_ALWAYS_FACE_PLAYER = new ConfigValue<>(CONFIG, false, "defaults.always-face-player", true); +// public static final ConfigValue DEFAULT_ALWAYS_FACE_PLAYER = new ConfigValue<>(CONFIG, false, "defaults.always-face-player", true); public static final DoubleConfigValue DEFAULT_HEIGHT_TEXT = new DoubleConfigValue(CONFIG, false, "defaults.height.text", 0.3D, 0.0D, 2.5D); public static final DoubleConfigValue DEFAULT_HEIGHT_ICON = new DoubleConfigValue(CONFIG, false, "defaults.height.icon", 0.6D, 0.0D, 2.5D); diff --git a/src/main/java/eu/decentsoftware/holograms/api/actions/ActionType.java b/src/main/java/eu/decentsoftware/holograms/api/actions/ActionType.java index 1e4fdffc..69018e38 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/actions/ActionType.java +++ b/src/main/java/eu/decentsoftware/holograms/api/actions/ActionType.java @@ -97,7 +97,8 @@ public boolean execute(Player player, String... args) { Validate.notNull(player); String string = String.join(":", args); - if (string.split(":").length != 4) { + String[] spl = string.split(":"); + if (spl.length == 3 || spl.length == 5) { string = player.getLocation().getWorld().getName() + ":" + string; } Location location = LocationUtils.asLocation(string); diff --git a/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java b/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java index ed94d849..8d429d69 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java +++ b/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java @@ -87,9 +87,9 @@ public static Collection getCachedHolograms() { if (config.isBoolean("down-origin")) { hologram.setDownOrigin(config.getBoolean("down-origin", Settings.DEFAULT_DOWN_ORIGIN.getValue())); } - if (config.isBoolean("always-face-player")) { - hologram.setAlwaysFacePlayer(config.getBoolean("always-face-player", Settings.DEFAULT_ALWAYS_FACE_PLAYER.getValue())); - } +// if (config.isBoolean("always-face-player")) { +// hologram.setAlwaysFacePlayer(config.getBoolean("always-face-player", Settings.DEFAULT_ALWAYS_FACE_PLAYER.getValue())); +// } if (!config.contains("pages") && config.contains("lines")) { // Old Config @@ -160,7 +160,7 @@ public static Collection getCachedHolograms() { protected final Map viewerPages = new ConcurrentHashMap<>(); protected final DList pages = new DList<>(); protected boolean downOrigin = Settings.DEFAULT_DOWN_ORIGIN.getValue(); - protected boolean alwaysFacePlayer = Settings.DEFAULT_ALWAYS_FACE_PLAYER.getValue(); + protected boolean alwaysFacePlayer = false; //Settings.DEFAULT_ALWAYS_FACE_PLAYER.getValue(); private final AtomicInteger tickCounter; /* diff --git a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramLine.java b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramLine.java index 41f7e74f..96bd7d31 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramLine.java +++ b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramLine.java @@ -401,7 +401,7 @@ public void updateAnimations(Player... players) { if (HologramLineType.TEXT.equals(type)) { UUID uuid = player.getUniqueId(); String lastText = lastTextMap.get(uuid); - String text = getText(player, false); + String text = getText(player, true); if (!text.equals(lastText)) { lastTextMap.put(uuid, text); nms.updateFakeEntityCustomName(player, text, entityIds[0]); diff --git a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramManager.java b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramManager.java index 0dc1892d..3777f242 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramManager.java +++ b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramManager.java @@ -4,6 +4,7 @@ import com.google.common.cache.CacheBuilder; import eu.decentsoftware.holograms.api.DecentHolograms; import eu.decentsoftware.holograms.api.DecentHologramsAPI; +import eu.decentsoftware.holograms.api.Settings; import eu.decentsoftware.holograms.api.actions.ClickType; import eu.decentsoftware.holograms.api.holograms.offset.OffsetListener; import eu.decentsoftware.holograms.api.utils.Common; @@ -33,7 +34,7 @@ public class HologramManager extends Ticked { public HologramManager() { super(20L); this.clickCooldowns = CacheBuilder.newBuilder() - .expireAfterWrite(250, TimeUnit.MILLISECONDS) // Expire after five ticks + .expireAfterWrite(Settings.CLICK_COOLDOWN.getValue() * 50L, TimeUnit.MILLISECONDS) .build(); this.offsetListener = null; this.register(); diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/commands/HologramsCommand.java b/src/main/java/eu/decentsoftware/holograms/plugin/commands/HologramsCommand.java index d6c1b621..7d18b0a4 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/commands/HologramsCommand.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/commands/HologramsCommand.java @@ -24,7 +24,7 @@ @CommandInfo( aliases = {"holograms", "hologram", "dh", "holo"}, - permission = "", + permission = "dh.default", usage = "/dh ", description = "The main DecentHolograms Command." ) @@ -62,7 +62,7 @@ public HologramsCommand() { @Override public CommandHandler getCommandHandler() { return (sender, args) -> { - if (sender.hasPermission("dh.help")) { + if (sender.hasPermission("dh.admin")) { if (args.length == 0) { Lang.USE_HELP.send(sender); return true; @@ -70,8 +70,8 @@ public CommandHandler getCommandHandler() { Lang.UNKNOWN_SUB_COMMAND.send(sender); Lang.USE_HELP.send(sender); } else { - Lang.sendVersionMessage(sender); - } + Lang.sendVersionMessage(sender); + } return true; }; } diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java b/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java index 490eb1a4..bd118d9a 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java @@ -69,9 +69,11 @@ public void onDamage(EntityDamageEvent e) { Entity entity = e.getEntity(); double damage = e.getFinalDamage(); - Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1, 0)); - String text = String.format(appearance.replace("{damage}", "%.1f"), damage); - PLUGIN.getHologramManager().spawnTemporaryHologramLine(location, text, duration); + if (damage > 0d) { + Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1, 0)); + String text = String.format(appearance.replace("{damage}", "%.1f"), damage); + PLUGIN.getHologramManager().spawnTemporaryHologramLine(location, text, duration); + } } } diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java b/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java index 107603b1..a6018dac 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java @@ -69,9 +69,11 @@ public void onDamage(EntityRegainHealthEvent e) { Entity entity = e.getEntity(); double heal = e.getAmount(); - Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1, 0)); - String text = String.format(appearance.replace("{heal}", "%.1f"), heal); - PLUGIN.getHologramManager().spawnTemporaryHologramLine(location, text, duration); + if (heal > 0d) { + Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1, 0)); + String text = String.format(appearance.replace("{heal}", "%.1f"), heal); + PLUGIN.getHologramManager().spawnTemporaryHologramLine(location, text, duration); + } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 40259f72..1a02ee3e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,6 +40,9 @@ defaults: # Check for updates on plugin startup? [true/false] update-checker: true +# Click cooldown in ticks +click-cooldown: 20 + # # # # # # # # # # # # # # # # # diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 97646eb1..ff6f516b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -14,3 +14,11 @@ commands: aliases: [dh, holograms, hologram, holo] usage: /decentholograms description: The main command of DecentHolograms plugin. + +permissions: + dh.admin: + dh.default: true + description: Allows player to use DecentHolograms. + dh.default: + default: true + description: Allows player to see the version after using '/decentholograms'. \ No newline at end of file