diff --git a/buildSrc/src/main/kotlin/paper-plugin.gradle.kts b/buildSrc/src/main/kotlin/paper-plugin.gradle.kts
index bc95fe3..0466172 100644
--- a/buildSrc/src/main/kotlin/paper-plugin.gradle.kts
+++ b/buildSrc/src/main/kotlin/paper-plugin.gradle.kts
@@ -1,8 +1,6 @@
plugins {
id("root-plugin")
- id("com.github.johnrengelman.shadow")
-
id("io.papermc.paperweight.userdev")
}
@@ -11,8 +9,6 @@ repositories {
}
dependencies {
- compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
-
paperweight.paperDevBundle("1.20.1-R0.1-SNAPSHOT")
}
diff --git a/buildSrc/src/main/kotlin/root-plugin.gradle.kts b/buildSrc/src/main/kotlin/root-plugin.gradle.kts
index daa27f3..c136b53 100644
--- a/buildSrc/src/main/kotlin/root-plugin.gradle.kts
+++ b/buildSrc/src/main/kotlin/root-plugin.gradle.kts
@@ -1,8 +1,8 @@
-import gradle.kotlin.dsl.accessors._3060c13235291a72581396bc01940dbe.processResources
-
plugins {
`java-library`
`maven-publish`
+
+ id("com.github.johnrengelman.shadow")
}
repositories {
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
index 76bf9ee..d02117e 100644
--- a/core/build.gradle.kts
+++ b/core/build.gradle.kts
@@ -1,5 +1,5 @@
plugins {
- id("paper-plugin")
+ id("root-plugin")
}
group = "${rootProject.group}.core"
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index ccebba7..033e24c 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 9a71537..9f4197d 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
\ No newline at end of file
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 79a61d4..fcb6fca 100644
--- a/gradlew
+++ b/gradlew
@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
@@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java b/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java
index 1c2d206..ae3129d 100644
--- a/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java
+++ b/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java
@@ -1,8 +1,10 @@
package com.badbones69.crazyauctions;
+import com.badbones69.crazyauctions.api.CrazyManager;
import com.badbones69.crazyauctions.api.frame.PaperCore;
import com.badbones69.crazyauctions.api.frame.command.CommandManager;
-import com.badbones69.crazyauctions.frame.CrazyLogger;
+import com.badbones69.crazyauctions.commands.inventories.AuctionInventoryClick;
+import com.badbones69.crazyauctions.events.DataListener;
import org.bukkit.plugin.java.JavaPlugin;
public class CrazyAuctions extends JavaPlugin {
@@ -11,6 +13,8 @@ public class CrazyAuctions extends JavaPlugin {
private final PaperCore paperCore;
private CommandManager commandManager;
+ private CrazyManager crazyManager;
+
public CrazyAuctions(ApiManager apiManager, PaperCore paperCore) {
this.apiManager = apiManager;
this.paperCore = paperCore;
@@ -19,11 +23,17 @@ public class CrazyAuctions extends JavaPlugin {
@Override
public void onEnable() {
this.commandManager = CommandManager.create();
+
+ this.crazyManager = new CrazyManager();
+ this.crazyManager.load(true);
+
+ getServer().getPluginManager().registerEvents(new DataListener(), this);
+ getServer().getPluginManager().registerEvents(new AuctionInventoryClick(), this);
}
@Override
public void onDisable() {
- CrazyLogger.debug("Dick");
+ if (this.crazyManager != null) this.crazyManager.stop();
}
public ApiManager getApiManager() {
@@ -37,4 +47,8 @@ public class CrazyAuctions extends JavaPlugin {
public CommandManager getCommandManager() {
return this.commandManager;
}
+
+ public CrazyManager getCrazyManager() {
+ return this.crazyManager;
+ }
}
\ No newline at end of file
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java b/paper/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java
index 280a78d..884856d 100644
--- a/paper/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java
+++ b/paper/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java
@@ -1,27 +1,34 @@
package com.badbones69.crazyauctions.api;
import com.badbones69.crazyauctions.CrazyAuctions;
+import com.badbones69.crazyauctions.storage.types.StorageManager;
import org.bukkit.plugin.java.JavaPlugin;
public class CrazyManager {
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
- public void load() {
+ private StorageManager storageManager;
- // Used for user data.
- init();
- }
+ public void load(boolean serverStart) {
+ if (serverStart) {
+ this.storageManager = new StorageManager();
- public void reload(boolean serverStop) {
-
- if (!serverStop) {
- // Used for user data.
- init();
+ this.storageManager.init();
}
}
- private void init() {
+ public void reload() {
+ if (this.plugin.getApiManager() != null) this.plugin.getApiManager().reload();
+
+ if (this.storageManager.getUserManager() != null) this.storageManager.getUserManager().save(false);
+ }
+
+ public void stop() {
}
+
+ public StorageManager getStorageManager() {
+ return this.storageManager;
+ }
}
\ No newline at end of file
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/commands/admin/CommandReload.java b/paper/src/main/java/com/badbones69/crazyauctions/commands/admin/CommandReload.java
index a8ff996..bd2479d 100644
--- a/paper/src/main/java/com/badbones69/crazyauctions/commands/admin/CommandReload.java
+++ b/paper/src/main/java/com/badbones69/crazyauctions/commands/admin/CommandReload.java
@@ -1,6 +1,7 @@
package com.badbones69.crazyauctions.commands.admin;
import com.badbones69.crazyauctions.CrazyAuctions;
+import com.badbones69.crazyauctions.api.CrazyManager;
import com.badbones69.crazyauctions.api.frame.command.CommandContext;
import com.badbones69.crazyauctions.api.frame.command.CommandEngine;
import org.bukkit.plugin.java.JavaPlugin;
@@ -9,6 +10,7 @@ import java.util.Collections;
public class CommandReload extends CommandEngine {
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
+ private final CrazyManager crazyManager = this.plugin.getCrazyManager();
public CommandReload() {
super("reload", "Reloads the plugin.", "/crazyauctions:reload", Collections.emptyList());
@@ -16,6 +18,6 @@ public class CommandReload extends CommandEngine {
@Override
protected void perform(CommandContext context, String[] args) {
-
+ this.crazyManager.reload();
}
}
\ No newline at end of file
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventoryClick.java b/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventoryClick.java
new file mode 100644
index 0000000..fb49a6c
--- /dev/null
+++ b/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventoryClick.java
@@ -0,0 +1,35 @@
+package com.badbones69.crazyauctions.commands.inventories;
+
+import com.badbones69.crazyauctions.api.frame.items.ItemBuilder;
+import com.badbones69.crazyauctions.frame.utils.AdventureUtils;
+import org.bukkit.Material;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+
+public class AuctionInventoryClick implements Listener {
+
+ @EventHandler
+ public void onAuctionClick(InventoryClickEvent event) {
+ Inventory inventory = event.getClickedInventory();
+
+ if (inventory == null || (!(inventory.getHolder() instanceof AuctionInventory auctionInventory))) return;
+
+ event.setCancelled(true);
+
+ ItemStack clicked = event.getCurrentItem();
+
+ if (clicked != null) {
+ event.getWhoClicked().sendMessage("Beep Boo Boo Beep!");
+
+ ItemBuilder builder = ItemBuilder.setStack(new ItemStack(Material.DIAMOND_SWORD));
+
+ builder.setAmount(3);
+ builder.setDisplayName(AdventureUtils.parse("This is a test"));
+
+ auctionInventory.getInventory().addItem(builder.build());
+ }
+ }
+}
\ No newline at end of file
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/events/DataListener.java b/paper/src/main/java/com/badbones69/crazyauctions/events/DataListener.java
new file mode 100644
index 0000000..5d230ae
--- /dev/null
+++ b/paper/src/main/java/com/badbones69/crazyauctions/events/DataListener.java
@@ -0,0 +1,27 @@
+package com.badbones69.crazyauctions.events;
+
+import com.badbones69.crazyauctions.CrazyAuctions;
+import com.badbones69.crazyauctions.storage.interfaces.UserManager;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public class DataListener implements Listener {
+
+ private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
+
+ private final UserManager userManager = this.plugin.getCrazyManager().getStorageManager().getUserManager();
+
+ @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
+ public void onPlayerJoin(PlayerJoinEvent event) {
+ this.userManager.load(event.getPlayer().getUniqueId());
+ }
+
+ @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
+ public void onPlayerQuit(PlayerQuitEvent event) {
+ this.userManager.saveSingular(event.getPlayer().getUniqueId(), true);
+ }
+}
\ No newline at end of file
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/storage/interfaces/UserManager.java b/paper/src/main/java/com/badbones69/crazyauctions/storage/interfaces/UserManager.java
index 4dfa3f1..fd76a9a 100644
--- a/paper/src/main/java/com/badbones69/crazyauctions/storage/interfaces/UserManager.java
+++ b/paper/src/main/java/com/badbones69/crazyauctions/storage/interfaces/UserManager.java
@@ -13,13 +13,13 @@ public interface UserManager {
void saveSingular(UUID uuid, boolean serverExit);
- void save(UUID uuid, boolean serverExit);
+ void save(boolean serverExit);
void convert(File file, UUID uuid, StorageType storageType);
void addAuction(UUID uuid);
- Path getFile(Path path, UUID uuid);
+ File getFile(Path path, UUID uuid);
UserData getUser(UUID uuid);
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/storage/types/StorageManager.java b/paper/src/main/java/com/badbones69/crazyauctions/storage/types/StorageManager.java
new file mode 100644
index 0000000..c978530
--- /dev/null
+++ b/paper/src/main/java/com/badbones69/crazyauctions/storage/types/StorageManager.java
@@ -0,0 +1,17 @@
+package com.badbones69.crazyauctions.storage.types;
+
+import com.badbones69.crazyauctions.storage.interfaces.UserManager;
+import com.badbones69.crazyauctions.storage.types.file.yaml.YamlUserManager;
+
+public class StorageManager {
+
+ private UserManager userManager;
+
+ public void init() {
+ this.userManager = new YamlUserManager();
+ }
+
+ public UserManager getUserManager() {
+ return this.userManager;
+ }
+}
\ No newline at end of file
diff --git a/paper/src/main/java/com/badbones69/crazyauctions/storage/types/file/yaml/YamlUserManager.java b/paper/src/main/java/com/badbones69/crazyauctions/storage/types/file/yaml/YamlUserManager.java
index 013a72a..5fc8f73 100644
--- a/paper/src/main/java/com/badbones69/crazyauctions/storage/types/file/yaml/YamlUserManager.java
+++ b/paper/src/main/java/com/badbones69/crazyauctions/storage/types/file/yaml/YamlUserManager.java
@@ -2,7 +2,6 @@ package com.badbones69.crazyauctions.storage.types.file.yaml;
import com.badbones69.crazyauctions.CrazyAuctions;
import com.badbones69.crazyauctions.frame.storage.enums.StorageType;
-import com.badbones69.crazyauctions.frame.storage.types.file.yaml.keys.FilePath;
import com.badbones69.crazyauctions.storage.interfaces.UserManager;
import com.badbones69.crazyauctions.storage.objects.UserData;
import org.bukkit.configuration.InvalidConfigurationException;
@@ -21,20 +20,20 @@ public class YamlUserManager extends YamlConfiguration implements UserManager {
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
- private final File file;
-
private final ConcurrentHashMap userData = new ConcurrentHashMap<>();
- public YamlUserManager(Path path, UUID uuid) {
- this.file = path.resolve(uuid + ".yml").toFile();
+ public YamlUserManager() {
+
}
@Override
public void load(UUID uuid) {
try {
- if (!this.file.exists()) this.file.createNewFile();
+ File file = new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml");
- load(this.file);
+ if (!file.exists()) file.createNewFile();
+
+ load(file);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
@@ -57,7 +56,10 @@ public class YamlUserManager extends YamlConfiguration implements UserManager {
private void reload(UUID uuid, boolean serverExit) {
try {
- save(this.file);
+ File file = new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml");
+
+ save(file);
+
if (!serverExit) load(uuid);
} catch (IOException e) {
e.printStackTrace();
@@ -65,7 +67,7 @@ public class YamlUserManager extends YamlConfiguration implements UserManager {
}
@Override
- public void save(UUID uuid, boolean serverExit) {
+ public void save(boolean serverExit) {
// If user data empty return.
if (this.userData.isEmpty()) return;
@@ -74,7 +76,7 @@ public class YamlUserManager extends YamlConfiguration implements UserManager {
//user.getKeys().forEach((crateMap, keys) -> set("users." + id + "." + crateMap, keys));
// Save the file then load the changes back in.
- reload(uuid, serverExit);
+ reload(id, serverExit);
});
}
@@ -89,8 +91,8 @@ public class YamlUserManager extends YamlConfiguration implements UserManager {
}
@Override
- public Path getFile(Path path, UUID uuid) {
- return path.resolve(uuid + ".yml");
+ public File getFile(Path path, UUID uuid) {
+ return new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml");
}
@Override