mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-10 10:10:22 +01:00
fuck you
This commit is contained in:
parent
3021ef6c45
commit
e3641ff7bb
@ -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")
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import gradle.kotlin.dsl.accessors._3060c13235291a72581396bc01940dbe.processResources
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("paper-plugin")
|
||||
id("root-plugin")
|
||||
}
|
||||
|
||||
group = "${rootProject.group}.core"
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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
|
12
gradlew
vendored
12
gradlew
vendored
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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("<red>This is a test</red>"));
|
||||
|
||||
auctionInventory.getInventory().addItem(builder.build());
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<UUID, UserData> 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
|
||||
|
Loading…
Reference in New Issue
Block a user