From 574049d39ae55c1eb5d8417d9750cc33cb7c52c5 Mon Sep 17 00:00:00 2001 From: Brianna Date: Sat, 1 Feb 2020 06:49:07 -0500 Subject: [PATCH 1/9] Fixed strange compile issue. --- src/main/java/com/songoda/epicanchors/EpicAnchors.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/epicanchors/EpicAnchors.java b/src/main/java/com/songoda/epicanchors/EpicAnchors.java index 2c483ac..97cc0fe 100644 --- a/src/main/java/com/songoda/epicanchors/EpicAnchors.java +++ b/src/main/java/com/songoda/epicanchors/EpicAnchors.java @@ -171,7 +171,7 @@ public class EpicAnchors extends SongodaPlugin { } public ItemStack makeAnchorItem(int ticks) { - ItemStack item = getCoreConfig().getMaterial("Main.Anchor Block Material", CompatibleMaterial.END_PORTAL_FRAME).getItem(); + ItemStack item = Settings.MATERIAL.getMaterial().getItem(); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(Methods.formatName(ticks, true)); ArrayList lore = new ArrayList<>(); From 3ad95db13361154aa133a6eae5a20cc101b141e5 Mon Sep 17 00:00:00 2001 From: Brianna Date: Mon, 16 Mar 2020 14:54:26 -0400 Subject: [PATCH 2/9] Updated language file. --- src/main/resources/en_US.lang | 47 +++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang index 5446901..717de32 100644 --- a/src/main/resources/en_US.lang +++ b/src/main/resources/en_US.lang @@ -1,25 +1,36 @@ -#General Messages +# General Messages -general.nametag.prefix = "&8[&6EpicAnchors&8]" -general.nametag.next = "&9Next" -general.nametag.back = "&9Back" +general: + nametag: + prefix: '&8[&6EpicAnchors&8]' + next: '&9Next' + back: '&9Back' -#Interface Messages +# Interface Messages -interface.button.addtimewithxp = "&aAdd 30 Minutes with XP" -interface.button.addtimewithxplore = "&7Cost: &a%cost% Levels" -interface.button.addtimewitheconomy = "&aAdd 30 Minutes with ECO" -interface.button.addtimewitheconomylore = "&7Cost: &a$%cost%" -interface.anchor.title = "ChunkAnchor" -interface.anchor.smalltitle = "&eChunkAnchor" +interface: + button: + addtimewithxp: '&aAdd 30 Minutes with XP' + addtimewithxplore: '&7Cost: &a%cost% Levels' + addtimewitheconomy: '&aAdd 30 Minutes with ECO' + addtimewitheconomylore: '&7Cost: &a$%cost%' + anchor: + title: ChunkAnchor + smalltitle: '&eChunkAnchor' -#Command Messages +# Command Messages -command.give.success = "&7You have been given a ChunkAnchor." -command.show.start = "&7Anchor visualizer &2enabled." -command.show.stop = "&7Anchor visualizer &cdisabled." +command: + give: + success: '&7You have been given a ChunkAnchor.' + show: + start: '&7Anchor visualizer &2enabled.' + stop: '&7Anchor visualizer &cdisabled.' -#Event Messages +# Event Messages -event.general.nopermission = "&cYou do not have permission to do that." -event.upgrade.cannotafford = "&cYou cant afford that" \ No newline at end of file +event: + general: + nopermission: '&cYou do not have permission to do that.' + upgrade: + cannotafford: '&cYou cant afford that.' From 905e6e52fb6194fd54556a47c16a8d6a5354c721 Mon Sep 17 00:00:00 2001 From: Brianna Date: Sat, 1 Feb 2020 06:50:01 -0500 Subject: [PATCH 3/9] Removed CI --- .gitlab-ci.yml | 21 --------------------- pom.xml | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 24 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 9f48f12..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,21 +0,0 @@ -stages: - - build - -variables: - name: "EpicAnchors" - path: "/builds/$CI_PROJECT_PATH" - version: "1.4.6" - -build: - stage: build - image: maven:3.5.3-jdk-8 - script: - - find $path/ -type f -name "*.xml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g - - find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g - - mvn clean package - - find $path/ -depth -path '*original*' -delete - - mv $path/target/*.jar $path/ - artifacts: - name: $name-$version - paths: - - "$path/*.jar" diff --git a/pom.xml b/pom.xml index d01d223..3aab1c6 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ com.songoda EpicAnchors 4.0.0 - maven-version-number + 1.4.6 clean install EpicAnchors-${project.version} @@ -16,6 +16,28 @@ 1.8 + + com.google.code.maven-replacer-plugin + replacer + 1.5.3 + + + prepare-package + + replace + + + + + ${project.build.directory}/classes/plugin.yml + + + maven-version-number + ${project.version} + + + + org.apache.maven.plugins maven-shade-plugin @@ -78,8 +100,8 @@ org.spigotmc - spigot-api - 1.14.4-R0.1-SNAPSHOT + spigot + 1.15 provided From 650995d14a966b7a8ab5dca4a079573e56075e84 Mon Sep 17 00:00:00 2001 From: Brianna Date: Mon, 16 Mar 2020 14:53:30 -0400 Subject: [PATCH 4/9] Added Public repo --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 3aab1c6..2ca82d2 100644 --- a/pom.xml +++ b/pom.xml @@ -92,6 +92,10 @@ private http://repo.songoda.com/artifactory/private/ + + public + https://repo.songoda.com/artifactory/public/ + spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ From 94faccbc415edb9126dc69a429948e4fbc650fde Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Mon, 23 Mar 2020 16:34:20 -0400 Subject: [PATCH 5/9] Added infinite anchors --- .../songoda/epicanchors/anchor/Anchor.java | 10 ++++++++ .../epicanchors/commands/CommandGive.java | 19 +++++++++------ .../songoda/epicanchors/gui/GUIOverview.java | 24 ++++++++++++++----- .../epicanchors/listeners/BlockListeners.java | 6 ++++- .../songoda/epicanchors/tasks/AnchorTask.java | 7 ++++-- .../songoda/epicanchors/utils/Methods.java | 15 +++++++++++- src/main/resources/en_US.lang | 1 + 7 files changed, 65 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/songoda/epicanchors/anchor/Anchor.java b/src/main/java/com/songoda/epicanchors/anchor/Anchor.java index 98814a3..489bbaf 100644 --- a/src/main/java/com/songoda/epicanchors/anchor/Anchor.java +++ b/src/main/java/com/songoda/epicanchors/anchor/Anchor.java @@ -11,6 +11,7 @@ public class Anchor { private Location location; private int ticksLeft; + private boolean isInfinite; private final int chunkX; private final int chunkZ; @@ -20,6 +21,7 @@ public class Anchor { this.chunkX = location.getBlockX() >> 4; this.chunkZ = location.getBlockZ() >> 4; this.ticksLeft = ticksLeft; + this.isInfinite = (ticksLeft == -99); } public void addTime(String type, Player player) { @@ -96,4 +98,12 @@ public class Anchor { public void setTicksLeft(int ticksLeft) { this.ticksLeft = ticksLeft; } + + public boolean isInfinite() { + return isInfinite; + } + + public void setInfinite(boolean infinite) { + isInfinite = infinite; + } } diff --git a/src/main/java/com/songoda/epicanchors/commands/CommandGive.java b/src/main/java/com/songoda/epicanchors/commands/CommandGive.java index c089023..1535d8b 100644 --- a/src/main/java/com/songoda/epicanchors/commands/CommandGive.java +++ b/src/main/java/com/songoda/epicanchors/commands/CommandGive.java @@ -2,6 +2,7 @@ package com.songoda.epicanchors.commands; import com.songoda.core.commands.AbstractCommand; import com.songoda.epicanchors.EpicAnchors; +import com.songoda.epicanchors.utils.Methods; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -31,16 +32,19 @@ public class CommandGive extends AbstractCommand { return ReturnType.SYNTAX_ERROR; } - try { - Integer.parseInt(args[1]); - } catch (Exception e) { + + + ItemStack itemStack; + + if (Methods.isInt(args[1])) { + itemStack = (Integer.parseInt(args[1]) <= 0) ? instance.makeAnchorItem(-99) : instance.makeAnchorItem(Integer.parseInt(args[1]) * 20 * 60 * 60); + } else if (args[1].toLowerCase().equals("infinite")) { + itemStack = instance.makeAnchorItem(-99); + } else { instance.getLocale().newMessage("&cYou can only use whole numbers...").sendPrefixedMessage(sender); return ReturnType.FAILURE; } - - ItemStack itemStack = instance.makeAnchorItem(Integer.parseInt(args[1]) * 20 * 60 * 60); - if (target != null) { target.getInventory().addItem(itemStack); instance.getLocale().getMessage("command.give.success").sendPrefixedMessage(target); @@ -50,6 +54,7 @@ public class CommandGive extends AbstractCommand { instance.getLocale().getMessage("command.give.success").sendPrefixedMessage(player); } } + return ReturnType.SUCCESS; } @@ -75,7 +80,7 @@ public class CommandGive extends AbstractCommand { @Override public String getSyntax() { - return "/ea give "; + return "/ea give "; } @Override diff --git a/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java b/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java index c05c4bd..33babdf 100644 --- a/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java +++ b/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java @@ -49,22 +49,22 @@ public class GUIOverview extends Gui { setItem(13, GuiUtils.createButtonItem(plugin.makeAnchorItem(anchor.getTicksLeft()), plugin.getLocale().getMessage("interface.anchor.smalltitle").getMessage(), - ChatColor.GRAY + Methods.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining.")); + (anchor.isInfinite()) ? ChatColor.GRAY + "Infinite" : ChatColor.GRAY + Methods.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining.")); if (EconomyManager.isEnabled() && Settings.ADD_TIME_WITH_ECONOMY.getBoolean()) { setButton(15, GuiUtils.createButtonItem(Settings.ECO_ICON.getMaterial(CompatibleMaterial.SUNFLOWER), plugin.getLocale().getMessage("interface.button.addtimewitheconomy").getMessage(), plugin.getLocale().getMessage("interface.button.addtimewitheconomylore") - .processPlaceholder("cost", Methods.formatEconomy(Settings.ECONOMY_COST.getDouble())).getMessage()), // EconomyManager.formatEconomy adds its own prefix/suffix - event -> anchor.addTime("ECO", event.player)); + .processPlaceholder("cost", Methods.formatEconomy(Settings.ECONOMY_COST.getDouble())).getMessage()), // EconomyManager.formatEconomy adds its own prefix/suffix + event -> checkInfiniteAndAlert(anchor, event.player, true)); } if (Settings.ADD_TIME_WITH_XP.getBoolean()) { setButton(11, GuiUtils.createButtonItem(Settings.XP_ICON.getMaterial(CompatibleMaterial.EXPERIENCE_BOTTLE), plugin.getLocale().getMessage("interface.button.addtimewithxp").getMessage(), plugin.getLocale().getMessage("interface.button.addtimewithxplore") - .processPlaceholder("cost", String.valueOf(Settings.XP_COST.getInt())).getMessage()), - event -> anchor.addTime("XP", event.player)); + .processPlaceholder("cost", String.valueOf(Settings.XP_COST.getInt())).getMessage()), + event -> checkInfiniteAndAlert(anchor, event.player, false)); } } @@ -72,7 +72,19 @@ public class GUIOverview extends Gui { private void runTask() { task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> { updateItem(13, plugin.getLocale().getMessage("interface.anchor.smalltitle").getMessage(), - ChatColor.GRAY + Methods.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining."); + (anchor.isInfinite()) ? ChatColor.GRAY + "Infinite" : ChatColor.GRAY + Methods.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining."); }, 5L, 5L); } + + private void checkInfiniteAndAlert(Anchor anchor, Player p, boolean eco) { + if (anchor.isInfinite()) { + plugin.getLocale().getMessage("interface.button.infinite").sendPrefixedMessage(p); + } else { + if (eco) { + anchor.addTime("ECO", p); + } else { + anchor.addTime("XP", p); + } + } + } } diff --git a/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java b/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java index 4cbe436..dbfa78a 100644 --- a/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java +++ b/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java @@ -29,8 +29,12 @@ public class BlockListeners implements Listener { || plugin.getTicksFromItem(item) == 0) return; Anchor anchor = new Anchor(event.getBlock().getLocation(), plugin.getTicksFromItem(item)); - plugin.getAnchorManager().addAnchor(event.getBlock().getLocation(), anchor); + if (plugin.getTicksFromItem(item) == -99) { + anchor.setInfinite(true); + } + + plugin.getAnchorManager().addAnchor(event.getBlock().getLocation(), anchor); plugin.updateHologram(anchor); } diff --git a/src/main/java/com/songoda/epicanchors/tasks/AnchorTask.java b/src/main/java/com/songoda/epicanchors/tasks/AnchorTask.java index a357241..5209833 100644 --- a/src/main/java/com/songoda/epicanchors/tasks/AnchorTask.java +++ b/src/main/java/com/songoda/epicanchors/tasks/AnchorTask.java @@ -110,9 +110,12 @@ public class AnchorTask extends BukkitRunnable { } int ticksLeft = anchor.getTicksLeft(); - anchor.setTicksLeft(ticksLeft - 3); - if (ticksLeft <= 0) { + if (!anchor.isInfinite()) { + anchor.setTicksLeft(ticksLeft - 3); + } + + if (ticksLeft <= 0 && !anchor.isInfinite()) { anchor.bust(); chunk.unload(); return; diff --git a/src/main/java/com/songoda/epicanchors/utils/Methods.java b/src/main/java/com/songoda/epicanchors/utils/Methods.java index a19ecfc..be9a55b 100644 --- a/src/main/java/com/songoda/epicanchors/utils/Methods.java +++ b/src/main/java/com/songoda/epicanchors/utils/Methods.java @@ -19,7 +19,7 @@ public class Methods { String remaining = Methods.makeReadable((ticks2 / 20L) * 1000L); - String name = Settings.NAMETAG.getString().replace("{REMAINING}", remaining); + String name = Settings.NAMETAG.getString().replace("{REMAINING}", (ticks2 <= 0) ? "Infinite" : remaining); String info = ""; if (full) { @@ -156,6 +156,19 @@ public class Methods { return 0; } + public static boolean isInt(String number) { + if (number != null && !number.equals("")) { + try { + Integer.parseInt(number); + return true; + } catch (NumberFormatException var2) { + return false; + } + } else { + return false; + } + } + /** * Formats the specified double into the Economy format specified in the Arconix config. * diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang index 717de32..0a08cdb 100644 --- a/src/main/resources/en_US.lang +++ b/src/main/resources/en_US.lang @@ -14,6 +14,7 @@ interface: addtimewithxplore: '&7Cost: &a%cost% Levels' addtimewitheconomy: '&aAdd 30 Minutes with ECO' addtimewitheconomylore: '&7Cost: &a$%cost%' + infinite: '&cCannot upgrade an infinite anchor!' anchor: title: ChunkAnchor smalltitle: '&eChunkAnchor' From 3a42baac23436743e375fc1a1dfa7aa1d712aa17 Mon Sep 17 00:00:00 2001 From: Brianna Date: Wed, 25 Mar 2020 15:32:38 -0400 Subject: [PATCH 6/9] Code cleanup. --- .../com/songoda/epicanchors/EpicAnchors.java | 5 +- .../songoda/epicanchors/gui/GUIOverview.java | 10 +- .../listeners/InteractListeners.java | 3 +- .../songoda/epicanchors/utils/Methods.java | 106 +----------------- 4 files changed, 16 insertions(+), 108 deletions(-) diff --git a/src/main/java/com/songoda/epicanchors/EpicAnchors.java b/src/main/java/com/songoda/epicanchors/EpicAnchors.java index 97cc0fe..5b26d0c 100644 --- a/src/main/java/com/songoda/epicanchors/EpicAnchors.java +++ b/src/main/java/com/songoda/epicanchors/EpicAnchors.java @@ -8,6 +8,7 @@ import com.songoda.core.configuration.Config; import com.songoda.core.gui.GuiManager; import com.songoda.core.hooks.EconomyManager; import com.songoda.core.hooks.HologramManager; +import com.songoda.core.utils.TextUtils; import com.songoda.epicanchors.anchor.Anchor; import com.songoda.epicanchors.anchor.AnchorManager; import com.songoda.epicanchors.commands.*; @@ -79,7 +80,7 @@ public class EpicAnchors extends SongodaPlugin { ); anchorManager = new AnchorManager(); - Bukkit.getScheduler().runTaskLater(this, () -> loadAnchorsFromFile(), 5L); + Bukkit.getScheduler().runTaskLater(this, this::loadAnchorsFromFile, 5L); // Start tasks new AnchorTask(this); @@ -177,7 +178,7 @@ public class EpicAnchors extends SongodaPlugin { ArrayList lore = new ArrayList<>(); String[] parts = Settings.LORE.getString().split("\\|"); for (String line : parts) { - lore.add(Methods.formatText(line)); + lore.add(TextUtils.formatText(line)); } meta.setLore(lore); item.setItemMeta(meta); diff --git a/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java b/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java index 33babdf..8cc9790 100644 --- a/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java +++ b/src/main/java/com/songoda/epicanchors/gui/GUIOverview.java @@ -4,6 +4,8 @@ import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiUtils; import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.utils.TextUtils; +import com.songoda.core.utils.TimeUtils; import com.songoda.epicanchors.EpicAnchors; import com.songoda.epicanchors.anchor.Anchor; import com.songoda.epicanchors.settings.Settings; @@ -27,7 +29,7 @@ public class GUIOverview extends Gui { this.player = player; this.setRows(3); - this.setTitle(Methods.formatText(plugin.getLocale().getMessage("interface.anchor.title").getMessage())); + this.setTitle(TextUtils.formatText(plugin.getLocale().getMessage("interface.anchor.title").getMessage())); runTask(); constructGUI(); @@ -49,13 +51,13 @@ public class GUIOverview extends Gui { setItem(13, GuiUtils.createButtonItem(plugin.makeAnchorItem(anchor.getTicksLeft()), plugin.getLocale().getMessage("interface.anchor.smalltitle").getMessage(), - (anchor.isInfinite()) ? ChatColor.GRAY + "Infinite" : ChatColor.GRAY + Methods.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining.")); + (anchor.isInfinite()) ? ChatColor.GRAY + "Infinite" : ChatColor.GRAY + TimeUtils.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining.")); if (EconomyManager.isEnabled() && Settings.ADD_TIME_WITH_ECONOMY.getBoolean()) { setButton(15, GuiUtils.createButtonItem(Settings.ECO_ICON.getMaterial(CompatibleMaterial.SUNFLOWER), plugin.getLocale().getMessage("interface.button.addtimewitheconomy").getMessage(), plugin.getLocale().getMessage("interface.button.addtimewitheconomylore") - .processPlaceholder("cost", Methods.formatEconomy(Settings.ECONOMY_COST.getDouble())).getMessage()), // EconomyManager.formatEconomy adds its own prefix/suffix + .processPlaceholder("cost", EconomyManager.formatEconomy(Settings.ECONOMY_COST.getDouble())).getMessage()), // EconomyManager.formatEconomy adds its own prefix/suffix event -> checkInfiniteAndAlert(anchor, event.player, true)); } @@ -72,7 +74,7 @@ public class GUIOverview extends Gui { private void runTask() { task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> { updateItem(13, plugin.getLocale().getMessage("interface.anchor.smalltitle").getMessage(), - (anchor.isInfinite()) ? ChatColor.GRAY + "Infinite" : ChatColor.GRAY + Methods.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining."); + (anchor.isInfinite()) ? ChatColor.GRAY + "Infinite" : ChatColor.GRAY + TimeUtils.makeReadable((long) (anchor.getTicksLeft() / 20) * 1000) + " remaining."); }, 5L, 5L); } diff --git a/src/main/java/com/songoda/epicanchors/listeners/InteractListeners.java b/src/main/java/com/songoda/epicanchors/listeners/InteractListeners.java index 2f9cf6d..9959a44 100644 --- a/src/main/java/com/songoda/epicanchors/listeners/InteractListeners.java +++ b/src/main/java/com/songoda/epicanchors/listeners/InteractListeners.java @@ -1,5 +1,6 @@ package com.songoda.epicanchors.listeners; +import com.songoda.core.compatibility.CompatibleHand; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleParticleHandler; import com.songoda.core.compatibility.CompatibleSound; @@ -55,7 +56,7 @@ public class InteractListeners implements Listener { anchor.setTicksLeft(anchor.getTicksLeft() + instance.getTicksFromItem(item)); if (player.getGameMode() != GameMode.CREATIVE) - ItemUtils.takeActiveItem(player); + ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event)); player.playSound(player.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 0.6F, 15.0F); diff --git a/src/main/java/com/songoda/epicanchors/utils/Methods.java b/src/main/java/com/songoda/epicanchors/utils/Methods.java index be9a55b..848e621 100644 --- a/src/main/java/com/songoda/epicanchors/utils/Methods.java +++ b/src/main/java/com/songoda/epicanchors/utils/Methods.java @@ -1,5 +1,7 @@ package com.songoda.epicanchors.utils; +import com.songoda.core.utils.TextUtils; +import com.songoda.core.utils.TimeUtils; import com.songoda.epicanchors.settings.Settings; import org.bukkit.*; import org.bukkit.block.Block; @@ -17,50 +19,16 @@ public class Methods { public static String formatName(int ticks2, boolean full) { - String remaining = Methods.makeReadable((ticks2 / 20L) * 1000L); + String remaining = TimeUtils.makeReadable((ticks2 / 20L) * 1000L); String name = Settings.NAMETAG.getString().replace("{REMAINING}", (ticks2 <= 0) ? "Infinite" : remaining); String info = ""; if (full) { - info += convertToInvisibleString(ticks2 + ":"); + info += TextUtils.convertToInvisibleString(ticks2 + ":"); } - return info + formatText(name); - } - - public static String formatText(String text) { - if (text == null || text.equals("")) - return ""; - return formatText(text, false); - } - - public static String formatText(String text, boolean cap) { - if (text == null || text.equals("")) - return ""; - if (cap) - text = text.substring(0, 1).toUpperCase() + text.substring(1); - return ChatColor.translateAlternateColorCodes('&', text); - } - - public static String convertToInvisibleString(String s) { - if (s == null || s.equals("")) - return ""; - StringBuilder hidden = new StringBuilder(); - for (char c : s.toCharArray()) hidden.append(ChatColor.COLOR_CHAR + "").append(c); - return hidden.toString(); - } - - /** - * Serializes the location of the block specified. - * - * @param b The block whose location is to be saved. - * @return The serialized data. - */ - public static String serializeLocation(Block b) { - if (b == null) - return ""; - return serializeLocation(b.getLocation()); + return info + TextUtils.formatText(name); } /** @@ -104,58 +72,6 @@ public class Methods { return location; } - public static String makeReadable(Long time) { - if (time == null) - return ""; - - StringBuilder sb = new StringBuilder(); - - long days = TimeUnit.MILLISECONDS.toDays(time); - long hours = TimeUnit.MILLISECONDS.toHours(time) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(time)); - long minutes = TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)); - long seconds = TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time)); - - if (days != 0L) - sb.append(" ").append(days).append("d"); - if (hours != 0L) - sb.append(" ").append(hours).append("h"); - if (minutes != 0L) - sb.append(" ").append(minutes).append("m"); - if (seconds != 0L) - sb.append(" ").append(seconds).append("s"); - return sb.toString().trim(); - } - - - public static long parseTime(String input) { - long result = 0; - StringBuilder number = new StringBuilder(); - for (int i = 0; i < input.length(); i++) { - char c = input.charAt(i); - if (Character.isDigit(c)) { - number.append(c); - } else if (Character.isLetter(c) && (number.length() > 0)) { - result += convert(Integer.parseInt(number.toString()), c); - number = new StringBuilder(); - } - } - return result; - } - - private static long convert(long value, char unit) { - switch (unit) { - case 'd': - return value * 1000 * 60 * 60 * 24; - case 'h': - return value * 1000 * 60 * 60; - case 'm': - return value * 1000 * 60; - case 's': - return value * 1000; - } - return 0; - } - public static boolean isInt(String number) { if (number != null && !number.equals("")) { try { @@ -168,16 +84,4 @@ public class Methods { return false; } } - - /** - * Formats the specified double into the Economy format specified in the Arconix config. - * - * @param amt The double to format. - * @return The economy formatted double. - */ - public static String formatEconomy(double amt) { - return formatter.format(amt); - } - static DecimalFormat formatter = new DecimalFormat("#,###.00"); - } From d56469269b49011f2fd986dcf0ca34482375d195 Mon Sep 17 00:00:00 2001 From: Brianna Date: Wed, 25 Mar 2020 15:35:19 -0400 Subject: [PATCH 7/9] Added translations. --- src/main/java/com/songoda/epicanchors/utils/Methods.java | 4 +++- src/main/resources/en_US.lang | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/epicanchors/utils/Methods.java b/src/main/java/com/songoda/epicanchors/utils/Methods.java index 848e621..b76dda0 100644 --- a/src/main/java/com/songoda/epicanchors/utils/Methods.java +++ b/src/main/java/com/songoda/epicanchors/utils/Methods.java @@ -2,6 +2,7 @@ package com.songoda.epicanchors.utils; import com.songoda.core.utils.TextUtils; import com.songoda.core.utils.TimeUtils; +import com.songoda.epicanchors.EpicAnchors; import com.songoda.epicanchors.settings.Settings; import org.bukkit.*; import org.bukkit.block.Block; @@ -21,7 +22,8 @@ public class Methods { String remaining = TimeUtils.makeReadable((ticks2 / 20L) * 1000L); - String name = Settings.NAMETAG.getString().replace("{REMAINING}", (ticks2 <= 0) ? "Infinite" : remaining); + String name = Settings.NAMETAG.getString().replace("{REMAINING}", (ticks2 <= 0) + ? EpicAnchors.getInstance().getLocale().getMessage("infinite").getMessage() : remaining); String info = ""; if (full) { diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang index 0a08cdb..94a1891 100644 --- a/src/main/resources/en_US.lang +++ b/src/main/resources/en_US.lang @@ -3,8 +3,8 @@ general: nametag: prefix: '&8[&6EpicAnchors&8]' - next: '&9Next' - back: '&9Back' + word: + infinite: 'Infinite' # Interface Messages From a91e92c001607db58151f69289d97c6ffdc388c4 Mon Sep 17 00:00:00 2001 From: Brianna Date: Wed, 25 Mar 2020 15:46:43 -0400 Subject: [PATCH 8/9] Remove portal listener on 1.8 --- .../com/songoda/epicanchors/EpicAnchors.java | 4 ++++ .../epicanchors/listeners/BlockListeners.java | 7 ------- .../listeners/PortalListeners.java | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java diff --git a/src/main/java/com/songoda/epicanchors/EpicAnchors.java b/src/main/java/com/songoda/epicanchors/EpicAnchors.java index 5b26d0c..e32c491 100644 --- a/src/main/java/com/songoda/epicanchors/EpicAnchors.java +++ b/src/main/java/com/songoda/epicanchors/EpicAnchors.java @@ -4,6 +4,7 @@ import com.songoda.core.SongodaCore; import com.songoda.core.SongodaPlugin; import com.songoda.core.commands.CommandManager; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.configuration.Config; import com.songoda.core.gui.GuiManager; import com.songoda.core.hooks.EconomyManager; @@ -14,6 +15,7 @@ import com.songoda.epicanchors.anchor.AnchorManager; import com.songoda.epicanchors.commands.*; import com.songoda.epicanchors.listeners.BlockListeners; import com.songoda.epicanchors.listeners.InteractListeners; +import com.songoda.epicanchors.listeners.PortalListeners; import com.songoda.epicanchors.settings.Settings; import com.songoda.epicanchors.tasks.AnchorTask; import com.songoda.epicanchors.tasks.VisualizeTask; @@ -91,6 +93,8 @@ public class EpicAnchors extends SongodaPlugin { PluginManager pluginManager = Bukkit.getPluginManager(); pluginManager.registerEvents(new BlockListeners(this), this); pluginManager.registerEvents(new InteractListeners(this), this); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) + pluginManager.registerEvents(new PortalListeners(this), this); // Register Hologram Plugin HologramManager.load(this); diff --git a/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java b/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java index dbfa78a..7f989d8 100644 --- a/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java +++ b/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java @@ -7,7 +7,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.world.PortalCreateEvent; import org.bukkit.inventory.ItemStack; public class BlockListeners implements Listener { @@ -38,10 +37,4 @@ public class BlockListeners implements Listener { plugin.updateHologram(anchor); } - - @EventHandler - public void onPortalCreation(PortalCreateEvent e) { - if (e.getBlocks().size() < 1) return; - if (plugin.getAnchorManager().isAnchor(e.getBlocks().get(0).getLocation())) e.setCancelled(true); - } } diff --git a/src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java b/src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java new file mode 100644 index 0000000..09ecaf6 --- /dev/null +++ b/src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java @@ -0,0 +1,21 @@ +package com.songoda.epicanchors.listeners; + +import com.songoda.epicanchors.EpicAnchors; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.world.PortalCreateEvent; + +public class PortalListeners implements Listener { + + private EpicAnchors plugin; + + public PortalListeners(EpicAnchors instance) { + this.plugin = instance; + } + + @EventHandler + public void onPortalCreation(PortalCreateEvent e) { + if (e.getBlocks().size() < 1) return; + if (plugin.getAnchorManager().isAnchor(e.getBlocks().get(0).getLocation())) e.setCancelled(true); + } +} From cf6753dbc3783a755ad9070b97ae6cd6e56d81ca Mon Sep 17 00:00:00 2001 From: Brianna Date: Wed, 25 Mar 2020 15:35:52 -0400 Subject: [PATCH 9/9] version 1.4.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2ca82d2..33ae7de 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ com.songoda EpicAnchors 4.0.0 - 1.4.6 + 1.4.7 clean install EpicAnchors-${project.version}