Skip to content

Commit 520bae9

Browse files
committed
Refactor totem item config and update GUI classes
Moved the totem item definition from ItemRegistry to a new TotemConfig class for better configuration management. Updated GiveCommand to use TotemConfig for totem item creation. Renamed GuiItem to MenuItem and refactored GUI menu classes to use MenuItem. Improved PluginMessages with new messages and added PAPIProvider integration. Cleaned up ItemConstruct and EnchantConstructType logic, and removed unused ItemRegistry. Took 1 hour 57 minutes
1 parent 93c6d1e commit 520bae9

80 files changed

Lines changed: 429 additions & 345 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/dev/oribuin/fishing/FishingPlugin.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import dev.oribuin.fishing.config.impl.Config;
55
import dev.oribuin.fishing.config.impl.MySQLConfig;
66
import dev.oribuin.fishing.config.impl.PluginMessages;
7-
import dev.oribuin.fishing.gui.impl.totem.TotemMainMenu;
7+
import dev.oribuin.fishing.config.impl.TotemConfig;
88
import dev.oribuin.fishing.hook.plugin.HeadDbProvider;
9+
import dev.oribuin.fishing.hook.plugin.PAPIProvider;
910
import dev.oribuin.fishing.listener.FishListener;
1011
import dev.oribuin.fishing.listener.PlayerListeners;
1112
import dev.oribuin.fishing.listener.TotemListeners;
@@ -38,10 +39,11 @@ public void onEnable() {
3839

3940
// Load this plugin configs
4041
this.configLoader = new ConfigLoader();
41-
this.configLoader.loadConfig(Config.class, "config");
42+
this.configLoader.loadConfig(Config.class, "settings");
4243
this.configLoader.loadConfig(PluginMessages.class, "messages");
43-
this.configLoader.loadConfig(MySQLConfig.class, "mysql-config");
44-
44+
this.configLoader.loadConfig(MySQLConfig.class, "database-settings");
45+
this.configLoader.loadConfig(TotemConfig.class, "totem-settings");
46+
4547
// Load the plugin managers
4648
this.commandManager = new CommandManager(this);
4749
this.dataManager = new DataManager(this);
@@ -55,17 +57,17 @@ public void onEnable() {
5557
manager.registerEvents(new FishListener(this), this);
5658
manager.registerEvents(new PlayerListeners(this), this);
5759
manager.registerEvents(new TotemListeners(this), this);
58-
59-
if (HeadDbProvider.isEnabled()) {
60-
manager.registerEvents(new HeadDbProvider(), this);
61-
}
60+
61+
// register plugin hooks
62+
if (HeadDbProvider.isEnabled()) manager.registerEvents(new HeadDbProvider(), this);
63+
if (PAPIProvider.isEnabled()) new PAPIProvider(this).register();
6264
}
6365

6466
public void reload() {
6567
this.commandManager.reload(this);
6668
this.tierManager.reload(this);
6769
this.fishManager.reload(this);
68-
this.augmentManager.reload(this);
70+
this.augmentManager.reload(this);
6971
this.totemManager.reload(this);
7072
this.menuManager.reload(this);
7173
this.dataManager.reload(this);
@@ -106,5 +108,5 @@ public MenuManager getMenuManager() {
106108
public ConfigLoader getConfigLoader() {
107109
return configLoader;
108110
}
109-
111+
110112
}

src/main/java/dev/oribuin/fishing/api/Propertied.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void loadProperties(PersistentDataContainer container) {
5151
*/
5252
public final <T> T applyProperty(PersistentDataType<?, T> type, NamespacedKey key, T value) {
5353
this.properties.put(key, type);
54-
54+
5555
if (value != null) {
5656
this.container.put(key, value);
5757
}

src/main/java/dev/oribuin/fishing/api/event/EventWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @param <T> The event type to be registered with the function
1515
*/
1616
public record EventWrapper<T extends Event>(Class<T> event, BiConsumer<T, Integer> function, EventPriority order) {
17-
17+
1818
/**
1919
* Call the function that was registered with the event, This will cast the event to the correct type
2020
*

src/main/java/dev/oribuin/fishing/api/event/def/FishingEvents.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ default void onConditionCheck(ConditionCheckEvent event, int level) {}
8080

8181
/**
8282
* The functionality provided when a fish bites the rod before it is caught
83-
* @param event The fishing event
83+
*
84+
* @param event The fishing event
8485
* @param level The level of the ability that was used, if applicable (0 if not)
8586
*/
8687
default void onBite(PlayerFishEvent event, int level) {}
87-
88+
8889
}

src/main/java/dev/oribuin/fishing/api/event/def/TotemEvents.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public interface TotemEvents {
2020
* @param event The event that was called when a player activates a totem
2121
*/
2222
default void onActivate(TotemActivateEvent event) {}
23-
23+
2424
/**
2525
* The functionality provided when the fishing totem deactivates
2626
*
2727
* @param event The event that was called when the totem deactivates
2828
*/
2929
default void onDeactivate(TotemActivateEvent event) {}
30-
30+
3131
}

src/main/java/dev/oribuin/fishing/api/event/impl/FishCatchEvent.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class FishCatchEvent extends PlayerEvent implements Cancellable {
2626
private final ItemStack rod;
2727
private final FishHook hook;
2828
private Fish fish;
29-
29+
3030
private final int baseEntropy;
3131
private final int baseFishExp;
3232
private final float baseNaturalExp;
@@ -75,7 +75,8 @@ public Map<Augment, Integer> getAugments() {
7575

7676
/**
7777
* The fishing rod the player is using to catch the fish
78-
*-
78+
* -
79+
*
7980
* @return The fishing rod {@link ItemStack}
8081
*/
8182
public @NotNull ItemStack rod() {
@@ -108,7 +109,7 @@ public Map<Augment, Integer> getAugments() {
108109
public void fish(@Nullable Fish fish) {
109110
this.fish = fish;
110111
}
111-
112+
112113
/**
113114
* The base amount of entropy the fish gives
114115
*
@@ -135,7 +136,7 @@ public int entropy() {
135136
public void entropy(int entropy) {
136137
this.entropy = entropy;
137138
}
138-
139+
139140
/**
140141
* The base amount of plugin experience the fish gives
141142
*
@@ -162,7 +163,7 @@ public int fishExp() {
162163
public void fishExp(int fishExp) {
163164
this.fishExp = fishExp;
164165
}
165-
166+
166167
/**
167168
* The base minecraft experience the fish gives
168169
*

src/main/java/dev/oribuin/fishing/api/event/impl/TotemDeactivateEvent.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import dev.oribuin.fishing.model.totem.Totem;
44
import org.bukkit.Bukkit;
5-
import org.bukkit.entity.Player;
65
import org.bukkit.event.Cancellable;
76
import org.bukkit.event.Event;
87
import org.bukkit.event.HandlerList;
9-
import org.bukkit.event.player.PlayerEvent;
108
import org.jetbrains.annotations.NotNull;
119

1210
/**
@@ -21,7 +19,7 @@ public class TotemDeactivateEvent extends Event implements Cancellable {
2119
/**
2220
* Define a new Totem Deactivate Event, This is called when a totem deactivates by running out of time.
2321
*
24-
* @param totem The {@link Totem} that is being deactivated
22+
* @param totem The {@link Totem} that is being deactivated
2523
*/
2624
public TotemDeactivateEvent(@NotNull Totem totem) {
2725
super(!Bukkit.isPrimaryThread());
@@ -37,7 +35,7 @@ public TotemDeactivateEvent(@NotNull Totem totem) {
3735
public @NotNull Totem totem() {
3836
return this.totem;
3937
}
40-
38+
4139
/**
4240
* Get the handlers for this event class
4341
*

src/main/java/dev/oribuin/fishing/api/task/AsyncTicker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ default ScheduledTask schedule() {
4141

4242
return PluginScheduler.get().runTaskTimerAsync(this::tickAsync, this.delay().toSeconds(), 0, TimeUnit.SECONDS);
4343
}
44-
44+
4545
}

src/main/java/dev/oribuin/fishing/command/argument/FishArgumentHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class FishArgumentHandler implements ArgumentParser<CommandSender, Fish>
4343
.toList()
4444
);
4545
}
46-
46+
4747
public static final class FishParserException extends ParserException {
4848

4949
private final String input;

src/main/java/dev/oribuin/fishing/command/impl/GiveCommand.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dev.oribuin.fishing.FishingPlugin;
44
import dev.oribuin.fishing.command.FishCommand;
55
import dev.oribuin.fishing.config.impl.PluginMessages;
6-
import dev.oribuin.fishing.item.ItemRegistry;
6+
import dev.oribuin.fishing.config.impl.TotemConfig;
77
import dev.oribuin.fishing.model.augment.Augment;
88
import dev.oribuin.fishing.model.fish.Fish;
99
import dev.oribuin.fishing.model.totem.Totem;
@@ -26,7 +26,7 @@ public class GiveCommand implements FishCommand {
2626
public GiveCommand(FishingPlugin plugin) {
2727
this.plugin = plugin;
2828
}
29-
29+
3030
/**
3131
* Give a fish to a specified player
3232
*
@@ -98,9 +98,9 @@ public void giveAugment(CommandSender sender, Player target, Augment augment, In
9898
/**
9999
* Give a totem to a specified player
100100
*
101-
* @param sender The sender running the command
102-
* @param target The target receiving the augment
103-
* @param amount The amount of augments being given
101+
* @param sender The sender running the command
102+
* @param target The target receiving the augment
103+
* @param amount The amount of augments being given
104104
*/
105105
@Command("fishing|fish give <target> totem [amount]")
106106
@Permission("fishing.give")
@@ -109,9 +109,9 @@ public void giveTotem(CommandSender sender, Player target, Integer amount) {
109109
if (amount == null || amount < 0) amount = 1;
110110

111111
Totem totem = new Totem(null, target);
112-
ItemStack itemStack = ItemRegistry.FISHING_TOTEM.build(totem.placeholders()); // todo: make not horrific, move to TotemManager
112+
ItemStack itemStack = TotemConfig.get().getTotemItem().build(totem.placeholders());
113113
totem.saveTo(itemStack);
114-
114+
115115
if (itemStack == null) {
116116
sender.sendMessage("An error occurred while creating the fish item."); // TODO: Plugin Message
117117
return;

0 commit comments

Comments
 (0)