Skip to content

Commit

Permalink
Merge pull request #16 from Tweetzy/dev
Browse files Browse the repository at this point in the history
Dev merge
  • Loading branch information
kiranhart authored May 12, 2023
2 parents 30dc913 + e005006 commit c1c3ae0
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 70 deletions.
41 changes: 19 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<artifactId>skulls</artifactId>

<name>Skulls</name>
<version>3.8.0</version>
<version>3.9.2</version>
<packaging>jar</packaging>

<properties>
<author>Kiran Hart</author>
<jarName>Skulls</jarName>
<main.class>${project.groupId}.${project.artifactId}.${project.name}</main.class>
<java.version>1.8</java.version>
<flight.version>3.10.0</flight.version>
<flight.version>3.12.0</flight.version>
<flight.path>ca.tweetzy</flight.path>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -26,6 +26,10 @@
<name>Tweetzy Maven Repo On Repsy</name>
<url>https://repo.repsy.io/mvn/kiran/tweetzy</url>
</repository>
<repository>
<id>nms-repo</id>
<url>https://repo.codemc.io/repository/nms/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
Expand All @@ -45,6 +49,11 @@
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> <dependency>
<groupId>${flight.path}</groupId>
<artifactId>flight</artifactId>
<version>${flight.version}</version>
Expand All @@ -66,7 +75,12 @@
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions> </dependency>
<dependency>
<groupId>me.TechsCode</groupId>
<artifactId>UltraEconomyAPI</artifactId>
Expand Down Expand Up @@ -139,27 +153,10 @@
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>C:\Dev\Minecraft\latest\plugins</outputDirectory>
<resources>
<resource>
<directory>C:\Users\Kiran\Documents\Development\Minecraft\Active\${project.name}\target</directory>
<include>${project.name}.jar</include>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-to-ready-jars</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>C:\Users\Kiran\Documents\Development\Minecraft\Ready Jars\</outputDirectory>
<outputDirectory>D:\Development\Spigot Servers\Latest Version\plugins</outputDirectory>
<resources>
<resource>
<directory>C:\Users\Kiran\Documents\Development\Minecraft\Active\${project.name}\target</directory>
<directory>${project.build.directory}</directory>
<include>${project.name}.jar</include>
<filtering>false</filtering>
</resource>
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/ca/tweetzy/skulls/Skulls.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ca/tweetzy/skulls/commands/InspectCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,7 +83,7 @@ protected List<String> 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
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ca/tweetzy/skulls/commands/SearchCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -77,7 +78,7 @@ protected List<String> 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
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/ca/tweetzy/skulls/commands/SkullsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/ca/tweetzy/skulls/guis/CustomCategoryListGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/ca/tweetzy/skulls/guis/MainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
});
Expand All @@ -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)) {

Expand All @@ -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));
});
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/ca/tweetzy/skulls/guis/SkullsViewGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ca/tweetzy/skulls/hooks/WorldGuardHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
}
16 changes: 13 additions & 3 deletions src/main/java/ca/tweetzy/skulls/impl/economy/ItemEconomy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand All @@ -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
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/ca/tweetzy/skulls/listeners/SkullBlockListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -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());
}

}
}
1 change: 0 additions & 1 deletion src/main/java/ca/tweetzy/skulls/manager/SkullManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public void downloadHistorySkulls(@NonNull final History history, Consumer<List<
});
finished.accept(heads);


} catch (Exception e) {
Common.log("&cTweetzy.ca's api is currently unavailable, you can try again shortly.");
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ca/tweetzy/skulls/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public final class Settings extends FlightSettings {
public static final ConfigEntry ECONOMY = create("economy", "Vault").withComment("You can use Vault or Item");
public static final ConfigEntry ITEM_ECONOMY_ITEM = create("item economy item", CompMaterial.GOLD_INGOT.name());
public static final ConfigEntry MAIN_MENU_REQUIRES_NO_PERM = create("main menu requires no permission", true);
public static final ConfigEntry GENERAL_USAGE_REQUIRES_NO_PERM = create("general usage requires no permission", false, "If true, no permission is required to use except for admin stuff");

public static final ConfigEntry CATEGORIES_ALPHABET_ENABLED = create("enabled categories.alphabet", true);
public static final ConfigEntry CATEGORIES_ANIMALS_ENABLED = create("enabled categories.animals", true);
Expand Down
Loading

0 comments on commit c1c3ae0

Please sign in to comment.