diff --git a/pom.xml b/pom.xml index d87ba07..2185b89 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ skulls Skulls - 3.8.0 + 3.9.2 jar @@ -15,7 +15,7 @@ Skulls ${project.groupId}.${project.artifactId}.${project.name} 1.8 - 3.10.0 + 3.12.0 ca.tweetzy UTF-8 @@ -26,6 +26,10 @@ Tweetzy Maven Repo On Repsy https://repo.repsy.io/mvn/kiran/tweetzy + + nms-repo + https://repo.codemc.io/repository/nms/ + jitpack.io https://jitpack.io @@ -45,6 +49,11 @@ + org.spigotmc + spigot + 1.19.4-R0.1-SNAPSHOT + provided + ${flight.path} flight ${flight.version} @@ -66,7 +75,12 @@ VaultAPI 1.7 provided - + + + org.bukkit + bukkit + + me.TechsCode UltraEconomyAPI @@ -139,27 +153,10 @@ copy-resources - C:\Dev\Minecraft\latest\plugins - - - C:\Users\Kiran\Documents\Development\Minecraft\Active\${project.name}\target - ${project.name}.jar - false - - - - - - copy-to-ready-jars - package - - copy-resources - - - C:\Users\Kiran\Documents\Development\Minecraft\Ready Jars\ + D:\Development\Spigot Servers\Latest Version\plugins - C:\Users\Kiran\Documents\Development\Minecraft\Active\${project.name}\target + ${project.build.directory} ${project.name}.jar false diff --git a/src/main/java/ca/tweetzy/skulls/Skulls.java b/src/main/java/ca/tweetzy/skulls/Skulls.java index d5068a6..bd058a6 100644 --- a/src/main/java/ca/tweetzy/skulls/Skulls.java +++ b/src/main/java/ca/tweetzy/skulls/Skulls.java @@ -20,7 +20,6 @@ import ca.tweetzy.flight.FlightPlugin; import ca.tweetzy.flight.command.CommandManager; -import ca.tweetzy.flight.config.tweetzy.TweetzyYamlConfig; import ca.tweetzy.flight.database.DataMigrationManager; import ca.tweetzy.flight.database.DatabaseConnector; import ca.tweetzy.flight.database.SQLiteConnector; @@ -50,8 +49,6 @@ */ public final class Skulls extends FlightPlugin { - private final TweetzyYamlConfig coreConfig = new TweetzyYamlConfig(this, "config.yml"); - private final GuiManager guiManager = new GuiManager(this); private final CommandManager commandManager = new CommandManager(this); @@ -106,11 +103,6 @@ public static Skulls getInstance() { return (Skulls) FlightPlugin.getInstance(); } - - public static TweetzyYamlConfig getCoreConfig() { - return getInstance().coreConfig; - } - // gui manager public static GuiManager getGuiManager() { return getInstance().guiManager; diff --git a/src/main/java/ca/tweetzy/skulls/commands/InspectCommand.java b/src/main/java/ca/tweetzy/skulls/commands/InspectCommand.java index 5a27221..77442d7 100644 --- a/src/main/java/ca/tweetzy/skulls/commands/InspectCommand.java +++ b/src/main/java/ca/tweetzy/skulls/commands/InspectCommand.java @@ -29,6 +29,7 @@ import ca.tweetzy.skulls.Skulls; import ca.tweetzy.skulls.api.interfaces.PlacedSkull; import ca.tweetzy.skulls.api.interfaces.Skull; +import ca.tweetzy.skulls.settings.Settings; import ca.tweetzy.skulls.settings.Translations; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; @@ -82,7 +83,7 @@ protected List tab(CommandSender sender, String... args) { @Override public String getPermissionNode() { - return "skulls.command.inspect"; + return Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean() ? null : "skulls.command.inspect"; } @Override diff --git a/src/main/java/ca/tweetzy/skulls/commands/SearchCommand.java b/src/main/java/ca/tweetzy/skulls/commands/SearchCommand.java index cb89562..eccfcfa 100644 --- a/src/main/java/ca/tweetzy/skulls/commands/SearchCommand.java +++ b/src/main/java/ca/tweetzy/skulls/commands/SearchCommand.java @@ -26,6 +26,7 @@ import ca.tweetzy.skulls.api.interfaces.SkullUser; import ca.tweetzy.skulls.guis.SkullsViewGUI; import ca.tweetzy.skulls.impl.SkullPlayer; +import ca.tweetzy.skulls.settings.Settings; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -77,7 +78,7 @@ protected List tab(CommandSender commandSender, String... strings) { @Override public String getPermissionNode() { - return "skulls.command.search"; + return Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean() ? null : "skulls.command.search"; } @Override diff --git a/src/main/java/ca/tweetzy/skulls/commands/SkullsCommand.java b/src/main/java/ca/tweetzy/skulls/commands/SkullsCommand.java index ad9844e..f9ff4c0 100644 --- a/src/main/java/ca/tweetzy/skulls/commands/SkullsCommand.java +++ b/src/main/java/ca/tweetzy/skulls/commands/SkullsCommand.java @@ -49,10 +49,10 @@ protected ReturnType execute(CommandSender commandSender, String... strings) { if (commandSender instanceof Player) { final Player player = (Player) commandSender; - if (Skulls.getSkullManager().isLoading()) { - Common.tell(player, TranslationManager.string(Translations.LOADING)); - return ReturnType.FAIL; - } +// if (Skulls.getSkullManager().isLoading()) { +// Common.tell(player, TranslationManager.string(Translations.LOADING)); +// return ReturnType.FAIL; +// } if (player.hasPermission("skulls.command.main") || Settings.MAIN_MENU_REQUIRES_NO_PERM.getBoolean()) Skulls.getGuiManager().showGUI(player, new MainGUI(player)); diff --git a/src/main/java/ca/tweetzy/skulls/guis/CustomCategoryListGUI.java b/src/main/java/ca/tweetzy/skulls/guis/CustomCategoryListGUI.java index dd9cd5c..f6e94cd 100644 --- a/src/main/java/ca/tweetzy/skulls/guis/CustomCategoryListGUI.java +++ b/src/main/java/ca/tweetzy/skulls/guis/CustomCategoryListGUI.java @@ -30,6 +30,7 @@ import ca.tweetzy.skulls.api.enums.ViewMode; import ca.tweetzy.skulls.api.interfaces.Category; import ca.tweetzy.skulls.impl.SkullCategory; +import ca.tweetzy.skulls.settings.Settings; import ca.tweetzy.skulls.settings.Translations; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -100,10 +101,11 @@ public boolean onResult(String string) { @Override protected void onClick(Category category, GuiClickEvent clickEvent) { - if (!clickEvent.player.hasPermission("skulls.customcategory." + category.getId().toLowerCase())) { - Common.tell(clickEvent.player, TranslationManager.string(Translations.CATEGORY_PERMISSION)); - return; - } + if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean()) + if (!clickEvent.player.hasPermission("skulls.customcategory." + category.getId().toLowerCase())) { + Common.tell(clickEvent.player, TranslationManager.string(Translations.CATEGORY_PERMISSION)); + return; + } clickEvent.manager.showGUI(clickEvent.player, new SkullsViewGUI(this, Skulls.getPlayerManager().findPlayer(clickEvent.player), category.getId(), ViewMode.LIST)); } diff --git a/src/main/java/ca/tweetzy/skulls/guis/MainGUI.java b/src/main/java/ca/tweetzy/skulls/guis/MainGUI.java index 466a6b6..2bd616c 100644 --- a/src/main/java/ca/tweetzy/skulls/guis/MainGUI.java +++ b/src/main/java/ca/tweetzy/skulls/guis/MainGUI.java @@ -29,6 +29,7 @@ import ca.tweetzy.skulls.api.enums.BaseCategory; import ca.tweetzy.skulls.api.enums.ViewMode; import ca.tweetzy.skulls.model.SkullItem; +import ca.tweetzy.skulls.settings.Settings; import ca.tweetzy.skulls.settings.Translations; import lombok.NonNull; import org.bukkit.entity.Player; @@ -60,10 +61,11 @@ protected void draw() { .lore(TranslationManager.list(Translations.GUI_MAIN_ITEMS_CATEGORY_LORE, "category_size", Skulls.getSkullManager().getSkullCount(baseCategory.getId()))) .make(), click -> { - if (!click.player.hasPermission("skulls.category." + baseCategory.getId().toLowerCase().replace(" ", "").replace("&", ""))) { - Common.tell(click.player, TranslationManager.string(Translations.CATEGORY_PERMISSION)); - return; - } + if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean()) + if (!click.player.hasPermission("skulls.category." + baseCategory.getId().toLowerCase().replace(" ", "").replace("&", ""))) { + Common.tell(click.player, TranslationManager.string(Translations.CATEGORY_PERMISSION)); + return; + } click.manager.showGUI(click.player, new SkullsViewGUI(this, Skulls.getPlayerManager().findPlayer(click.player), baseCategory.getId(), ViewMode.LIST)); }); @@ -74,10 +76,11 @@ protected void draw() { .lore(TranslationManager.list(Translations.GUI_MAIN_ITEMS_SEARCH_LORE)) .make(), click -> { - if (!click.player.hasPermission("skulls.search")) { - Common.tell(click.player, TranslationManager.string(Translations.NO_PERMISSION)); - return; - } + if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean()) + if (!click.player.hasPermission("skulls.search")) { + Common.tell(click.player, TranslationManager.string(Translations.NO_PERMISSION)); + return; + } new TitleInput(Skulls.getInstance(), click.player, TranslationManager.string(Translations.INPUT_SKULL_SEARCH_TITLE), TranslationManager.string(Translations.INPUT_SKULL_SEARCH_SUBTITLE)) { @@ -101,10 +104,11 @@ public boolean onResult(String string) { .lore(TranslationManager.list(Translations.GUI_MAIN_ITEMS_FAVOURITES_LORE)) .make(), click -> { - if (!click.player.hasPermission("skulls.favourites")) { - Common.tell(click.player, TranslationManager.string(Translations.NO_PERMISSION)); - return; - } + if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean()) + if (!click.player.hasPermission("skulls.favourites")) { + Common.tell(click.player, TranslationManager.string(Translations.NO_PERMISSION)); + return; + } click.manager.showGUI(click.player, new SkullsViewGUI(this, Skulls.getPlayerManager().findPlayer(click.player), "", ViewMode.FAVOURITE)); }); diff --git a/src/main/java/ca/tweetzy/skulls/guis/SkullsViewGUI.java b/src/main/java/ca/tweetzy/skulls/guis/SkullsViewGUI.java index a4ed043..f3b9e05 100644 --- a/src/main/java/ca/tweetzy/skulls/guis/SkullsViewGUI.java +++ b/src/main/java/ca/tweetzy/skulls/guis/SkullsViewGUI.java @@ -18,11 +18,13 @@ package ca.tweetzy.skulls.guis; +import ca.tweetzy.flight.comp.enums.CompMaterial; import ca.tweetzy.flight.gui.Gui; import ca.tweetzy.flight.gui.events.GuiClickEvent; import ca.tweetzy.flight.gui.template.PagedGUI; import ca.tweetzy.flight.settings.TranslationManager; import ca.tweetzy.flight.utils.Common; +import ca.tweetzy.flight.utils.PlayerUtil; import ca.tweetzy.flight.utils.QuickItem; import ca.tweetzy.skulls.Skulls; import ca.tweetzy.skulls.api.enums.ViewMode; @@ -124,7 +126,11 @@ protected void onClick(Skull skull, GuiClickEvent event) { player.getInventory().addItem(skull.getItemStack()); } - if (event.clickType == ClickType.RIGHT && player.hasPermission("skulls.favourite")) { + if (event.clickType == ClickType.RIGHT) { + if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean() && !player.hasPermission("skulls.favourite")) + return; + + this.skullPlayer.toggleFavourite(skull.getId()); this.skullPlayer.sync(); diff --git a/src/main/java/ca/tweetzy/skulls/hooks/WorldGuardHook.java b/src/main/java/ca/tweetzy/skulls/hooks/WorldGuardHook.java index caa4378..5adee25 100644 --- a/src/main/java/ca/tweetzy/skulls/hooks/WorldGuardHook.java +++ b/src/main/java/ca/tweetzy/skulls/hooks/WorldGuardHook.java @@ -58,7 +58,7 @@ public boolean isAllowedBreak(@NonNull final Player player, @NonNull final Block return true; - return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD); + return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD) || query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), Flags.BLOCK_BREAK); } } diff --git a/src/main/java/ca/tweetzy/skulls/impl/economy/ItemEconomy.java b/src/main/java/ca/tweetzy/skulls/impl/economy/ItemEconomy.java index 5eeccbf..e88e539 100644 --- a/src/main/java/ca/tweetzy/skulls/impl/economy/ItemEconomy.java +++ b/src/main/java/ca/tweetzy/skulls/impl/economy/ItemEconomy.java @@ -18,11 +18,14 @@ package ca.tweetzy.skulls.impl.economy; -import ca.tweetzy.skulls.model.PlayerInventoryHelper; +import ca.tweetzy.flight.utils.Common; +import ca.tweetzy.flight.utils.PlayerUtil; import ca.tweetzy.skulls.api.interfaces.Economy; +import ca.tweetzy.skulls.model.PlayerInventoryHelper; import ca.tweetzy.skulls.settings.Settings; import lombok.NonNull; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * Date Created: April 21 2022 @@ -32,6 +35,10 @@ */ public final class ItemEconomy implements Economy { + public ItemEconomy() { + Common.log("&aSetting up item economy provider"); + } + @Override public String getName() { return "Item"; @@ -44,12 +51,15 @@ public boolean requiresExternalPlugin() { @Override public boolean has(@NonNull Player player, double amount) { - return PlayerInventoryHelper.getItemCountInPlayerInventory(player, Settings.ITEM_ECONOMY_ITEM.getMaterial().parseItem()) >= (int) amount; + final ItemStack item = Settings.ITEM_ECONOMY_ITEM.getItemStack(); + final int total = PlayerUtil.getItemCountInPlayerInventory(player, item); + return total >= (int) amount; } @Override public void withdraw(@NonNull Player player, double amount) { - PlayerInventoryHelper.removeSpecificItemQuantityFromPlayer(player, Settings.ITEM_ECONOMY_ITEM.getMaterial().parseItem(), (int) amount); + final ItemStack item = Settings.ITEM_ECONOMY_ITEM.getItemStack(); + PlayerInventoryHelper.removeSpecificItemQuantityFromPlayer(player, item, (int) amount); } @Override diff --git a/src/main/java/ca/tweetzy/skulls/listeners/SkullBlockListener.java b/src/main/java/ca/tweetzy/skulls/listeners/SkullBlockListener.java index db02e62..c73e908 100644 --- a/src/main/java/ca/tweetzy/skulls/listeners/SkullBlockListener.java +++ b/src/main/java/ca/tweetzy/skulls/listeners/SkullBlockListener.java @@ -28,7 +28,6 @@ import ca.tweetzy.skulls.impl.PlacedSkullLocation; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; @@ -48,13 +47,16 @@ public void onSkullPlace(final BlockPlaceEvent event) { } final ItemStack item = PlayerUtil.getHand(event.getPlayer()); - if (!NBTEditor.contains(item, "Skulls:ID")) return; + if (!NBTEditor.contains(item, "Skulls:ID")) { + return; + } final Block block = event.getBlockPlaced(); - if (block.getType() != CompMaterial.PLAYER_HEAD.parseMaterial()) return; + if (block.getType() == CompMaterial.PLAYER_HEAD.parseMaterial() || block.getType() == CompMaterial.PLAYER_WALL_HEAD.parseMaterial()) { + final int skullId = Integer.parseInt(NBTEditor.getString(item, "Skulls:ID")); + Skulls.getSkullManager().addPlacedSkull(new PlacedSkullLocation(UUID.randomUUID(), skullId, block.getLocation())); + } - final int skullId = Integer.parseInt(NBTEditor.getString(item, "Skulls:ID")); - Skulls.getSkullManager().addPlacedSkull(new PlacedSkullLocation(UUID.randomUUID(), skullId, block.getLocation())); } @EventHandler() @@ -66,16 +68,17 @@ public void onSkullBreak(final BlockBreakEvent event) { } final Block block = event.getBlock(); - if (block.getType() != CompMaterial.PLAYER_HEAD.parseMaterial()) return; - if (!Skulls.getSkullManager().getPlacedSkulls().containsKey(block.getLocation())) return; + if (block.getType() == CompMaterial.PLAYER_HEAD.parseMaterial() || block.getType() == CompMaterial.PLAYER_WALL_HEAD.parseMaterial()) { + if (!Skulls.getSkullManager().getPlacedSkulls().containsKey(block.getLocation())) return; - final PlacedSkull placedSkull = Skulls.getSkullManager().getPlacedSkulls().get(block.getLocation()); - Skulls.getSkullManager().removePlacedSkull(placedSkull); + final PlacedSkull placedSkull = Skulls.getSkullManager().getPlacedSkulls().get(block.getLocation()); + Skulls.getSkullManager().removePlacedSkull(placedSkull); - event.setDropItems(false); - final Skull skull = Skulls.getSkullManager().getSkull(placedSkull.getSkullId()); - block.getWorld().dropItemNaturally(block.getLocation(), skull.getItemStack()); + event.setDropItems(false); + final Skull skull = Skulls.getSkullManager().getSkull(placedSkull.getSkullId()); + block.getWorld().dropItemNaturally(block.getLocation(), skull.getItemStack()); + } } } diff --git a/src/main/java/ca/tweetzy/skulls/manager/SkullManager.java b/src/main/java/ca/tweetzy/skulls/manager/SkullManager.java index 74c8bf3..1db63b8 100644 --- a/src/main/java/ca/tweetzy/skulls/manager/SkullManager.java +++ b/src/main/java/ca/tweetzy/skulls/manager/SkullManager.java @@ -253,7 +253,6 @@ public void downloadHistorySkulls(@NonNull final History history, Consumer