From 421757e48457b3f2a5a5ab5123845b687d31149d Mon Sep 17 00:00:00 2001 From: Silent Date: Wed, 10 May 2023 22:16:56 +0200 Subject: [PATCH] changes --- pom.xml | 2 +- src/main/java/tsp/headdb/HeadDB.java | 7 -- .../core/api/event/HeadPurchaseEvent.java | 83 ------------------- .../tsp/headdb/core/command/CommandInfo.java | 8 +- .../tsp/headdb/core/command/CommandMain.java | 34 ++++---- .../tsp/headdb/core/util/BuildProperties.java | 45 ---------- src/main/resources/plugin.yml | 22 +++-- 7 files changed, 34 insertions(+), 167 deletions(-) delete mode 100644 src/main/java/tsp/headdb/core/api/event/HeadPurchaseEvent.java delete mode 100644 src/main/java/tsp/headdb/core/util/BuildProperties.java diff --git a/pom.xml b/pom.xml index ab1b66e..94b8aad 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ tsp.headdb HeadDB - 5.0.0-rc.4 + 5.0.0-rc.5 jar HeadDB diff --git a/src/main/java/tsp/headdb/HeadDB.java b/src/main/java/tsp/headdb/HeadDB.java index fda1087..f718519 100644 --- a/src/main/java/tsp/headdb/HeadDB.java +++ b/src/main/java/tsp/headdb/HeadDB.java @@ -19,7 +19,6 @@ import tsp.headdb.core.economy.VaultProvider; import tsp.headdb.core.storage.Storage; import tsp.headdb.core.task.UpdateTask; -import tsp.headdb.core.util.BuildProperties; import tsp.headdb.core.util.HeadDBLogger; import tsp.smartplugin.SmartPlugin; import tsp.smartplugin.inventory.PaneListener; @@ -35,7 +34,6 @@ public class HeadDB extends SmartPlugin { private static HeadDB instance; private HeadDBLogger logger; - private BuildProperties buildProperties; private TranslatableLocalization localization; private Storage storage; private BasicEconomyProvider economyProvider; @@ -47,7 +45,6 @@ public class HeadDB extends SmartPlugin { instance.saveDefaultConfig(); instance.logger = new HeadDBLogger(getConfig().getBoolean("debug")); instance.logger.info("Loading HeadDB - " + instance.getDescription().getVersion()); - instance.buildProperties = new BuildProperties(this); new UpdateTask(getConfig().getLong("refresh", 86400L)).schedule(this); instance.logger.info("Loaded " + loadLocalization() + " languages!"); @@ -177,10 +174,6 @@ public class HeadDB extends SmartPlugin { return localization; } - public BuildProperties getBuildProperties() { - return buildProperties; - } - public HeadDBLogger getLog() { return logger; } diff --git a/src/main/java/tsp/headdb/core/api/event/HeadPurchaseEvent.java b/src/main/java/tsp/headdb/core/api/event/HeadPurchaseEvent.java deleted file mode 100644 index 4a9acb5..0000000 --- a/src/main/java/tsp/headdb/core/api/event/HeadPurchaseEvent.java +++ /dev/null @@ -1,83 +0,0 @@ -package tsp.headdb.core.api.event; - -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; -import tsp.headdb.implementation.head.Head; - -import java.math.BigDecimal; - -/** - * Called BEFORE a head is added to the inventory but AFTER the transaction is complete. - * This gives you the chance to cancel and refund the money. - * This event is fired asynchronously! - * - * @author TheSilentPro (Silent) - * @see Event#isAsynchronous() - * - * @deprecated Possible issues. - */ -@Deprecated -public class HeadPurchaseEvent extends Event implements Cancellable { - - private static final HandlerList HANDLER_LIST = new HandlerList(); - private Player player; - private Head head; - private BigDecimal cost; - private final boolean success; - private boolean cancelled; - - public HeadPurchaseEvent(Player player, Head head, BigDecimal cost, boolean success) { - super(true); - this.player = player; - this.head = head; - this.cost = cost; - this.success = success; - } - - public boolean isSuccessful() { - return success; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - - @NotNull - @Override - public HandlerList getHandlers() { - return HANDLER_LIST; - } - - public Player getPlayer() { - return player; - } - - public void setPlayer(Player player) { - this.player = player; - } - - public Head getHead() { - return head; - } - - public void setHead(Head head) { - this.head = head; - } - - public BigDecimal getCost() { - return cost; - } - - public void setCost(BigDecimal cost) { - this.cost = cost; - } -} \ No newline at end of file diff --git a/src/main/java/tsp/headdb/core/command/CommandInfo.java b/src/main/java/tsp/headdb/core/command/CommandInfo.java index 8c7ec7f..65fcb26 100644 --- a/src/main/java/tsp/headdb/core/command/CommandInfo.java +++ b/src/main/java/tsp/headdb/core/command/CommandInfo.java @@ -2,8 +2,6 @@ package tsp.headdb.core.command; import org.bukkit.command.CommandSender; import tsp.headdb.HeadDB; -import tsp.headdb.core.util.BuildProperties; -import tsp.headdb.core.util.Utils; import tsp.smartplugin.player.PlayerUtils; public class CommandInfo extends SubCommand { @@ -15,10 +13,8 @@ public class CommandInfo extends SubCommand { @Override public void handle(CommandSender sender, String[] args) { if (HeadDB.getInstance().getConfig().getBoolean("showAdvancedPluginInfo")) { - BuildProperties build = HeadDB.getInstance().getBuildProperties(); - PlayerUtils.sendMessage(sender, "&7Running &6HeadDB - " + build.getVersion()); - PlayerUtils.sendMessage(sender, "&7Created by &6" + Utils.toString(HeadDB.getInstance().getDescription().getAuthors())); - PlayerUtils.sendMessage(sender, "&7Compiled on &6" + build.getTimestamp() + " &7by &6" + build.getAuthor()); + PlayerUtils.sendMessage(sender, "&7Running &6HeadDB - " + HeadDB.getInstance().getDescription().getVersion()); + PlayerUtils.sendMessage(sender, "&7GitHub: &6https://github.com/TheSilentPro/HeadDB"); } else { PlayerUtils.sendMessage(sender, "&7Running &6HeadDB &7by &6TheSilentPro (Silent)"); PlayerUtils.sendMessage(sender, "&7GitHub: &6https://github.com/TheSilentPro/HeadDB"); diff --git a/src/main/java/tsp/headdb/core/command/CommandMain.java b/src/main/java/tsp/headdb/core/command/CommandMain.java index 6c1be8d..82b6202 100644 --- a/src/main/java/tsp/headdb/core/command/CommandMain.java +++ b/src/main/java/tsp/headdb/core/command/CommandMain.java @@ -135,24 +135,26 @@ public class CommandMain extends HeadDBCommand implements CommandExecutor, TabCo })); // local - pane.setButton(getInstance().getConfig().getInt("gui.main.meta.local.slot"), new Button(Utils.getItemFromConfig("gui.main.meta.local.item", Material.COMPASS), e -> { - Set localHeads = HeadAPI.getLocalHeads(); - PagedPane localPane = Utils.createPaged(player, Utils.translateTitle(getLocalization().getMessage(player.getUniqueId(), "menu.main.local.name").orElse("Local Heads"), localHeads.size(), "Local")); - for (LocalHead head : localHeads) { - localPane.addButton(new Button(head.getItem(), le -> { - if (le.isLeftClick()) { - ItemStack localItem = head.getItem(); - if (le.isShiftClick()) { - localItem.setAmount(64); + if (getInstance().getConfig().getBoolean("localHeads")) { + pane.setButton(getInstance().getConfig().getInt("gui.main.meta.local.slot"), new Button(Utils.getItemFromConfig("gui.main.meta.local.item", Material.COMPASS), e -> { + Set localHeads = HeadAPI.getLocalHeads(); + PagedPane localPane = Utils.createPaged(player, Utils.translateTitle(getLocalization().getMessage(player.getUniqueId(), "menu.main.local.name").orElse("Local Heads"), localHeads.size(), "Local")); + for (LocalHead head : localHeads) { + localPane.addButton(new Button(head.getItem(), le -> { + if (le.isLeftClick()) { + ItemStack localItem = head.getItem(); + if (le.isShiftClick()) { + localItem.setAmount(64); + } + + player.getInventory().addItem(localItem); } + })); + } - player.getInventory().addItem(localItem); - } - })); - } - - localPane.open(player); - })); + localPane.open(player); + })); + } // Fill Utils.fill(pane, Utils.getItemFromConfig("gui.main.fill", Material.BLACK_STAINED_GLASS_PANE)); diff --git a/src/main/java/tsp/headdb/core/util/BuildProperties.java b/src/main/java/tsp/headdb/core/util/BuildProperties.java deleted file mode 100644 index 2c5a157..0000000 --- a/src/main/java/tsp/headdb/core/util/BuildProperties.java +++ /dev/null @@ -1,45 +0,0 @@ -package tsp.headdb.core.util; - -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.InputStream; -import java.io.InputStreamReader; - -/** - * This class contains the properties of the build. - * - * @author TheSilentPro (Silent) - */ -public class BuildProperties { - - private String version = "unknown"; - private String timestamp = "unknown"; - private String author = "unknown"; - - public BuildProperties(JavaPlugin plugin) { - InputStream in = plugin.getResource("plugin.yml"); - if (in == null) { - plugin.getLogger().severe("Could not get plugin.yml to read build information."); - return; - } - - YamlConfiguration data = YamlConfiguration.loadConfiguration(new InputStreamReader(in)); - this.version = data.getString("version", "unknown"); - this.timestamp = data.getString("buildTimestamp", "unknown"); - this.author = data.getString("buildAuthor", "unknown"); - } - - public String getVersion() { - return version; - } - - public String getTimestamp() { - return timestamp; - } - - public String getAuthor() { - return author; - } - -} \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8f37b87..087e1b6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,3 @@ -#file: noinspection YAMLSchemaValidation name: ${project.name} description: ${project.description} @@ -9,18 +8,11 @@ api-version: 1.19 author: TheSilentPro (Silent) spigot-id: 84967 -buildTimestamp: ${build.timestamp} -buildAuthor: ${build.author} - -# Although not up-to-date, spigot already includes gson. This is here just in case. -#libraries: -# - "com.google.code.gson:gson:2.10" - commands: headdb: usage: /headdb help description: Open the database - aliases: [hdb, headdatabase, headmenu] + aliases: ["hdb", "headdatabase", "headmenu"] permissions: headdb.admin: @@ -30,6 +22,10 @@ permissions: headdb.command.search: true headdb.command.give: true headdb.command.update: true + headdb.command.reload: true + headdb.command.language: true + headdb.command.settings: true + headdb.command.texture: true headdb.favorites: true headdb.local: true headdb.category.*: true @@ -41,6 +37,14 @@ permissions: default: op headdb.command.update: default: op + headdb.command.reload: + default: op + headdb.command.language: + default: op + headdb.command.settings: + default: op + headdb.command.texture: + default: op headdb.favorites: default: op headdb.local: