mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-25 12:25:20 +01:00
update files
This commit is contained in:
parent
689a5170f4
commit
2b1110f03c
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,7 +13,7 @@ jars
|
||||
paper/build
|
||||
paper/.gradle
|
||||
|
||||
run
|
||||
paper/run
|
||||
!paper/run/config
|
||||
!paper/run/spigot.yml
|
||||
!paper/run/bukkit.yml
|
||||
|
@ -1,14 +0,0 @@
|
||||
plugins {
|
||||
id("root-plugin")
|
||||
}
|
||||
|
||||
project.group = "${rootProject.group}.common"
|
||||
project.version = "${rootProject.version}"
|
||||
|
||||
dependencies {
|
||||
api(libs.configme) {
|
||||
exclude("org.yaml", "snakeyaml")
|
||||
}
|
||||
|
||||
compileOnly(libs.annotations)
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package com.badbones69.crazyauctions.common;
|
||||
|
||||
import ch.jalu.configme.SettingsManager;
|
||||
import ch.jalu.configme.SettingsManagerBuilder;
|
||||
import com.badbones69.crazyauctions.common.config.ConfigBuilder;
|
||||
import com.badbones69.crazyauctions.common.config.types.PluginConfig;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class CrazyAuctionsPlugin {
|
||||
|
||||
private final Path path;
|
||||
|
||||
public CrazyAuctionsPlugin(Path path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
private static SettingsManager locale;
|
||||
private static SettingsManager config;
|
||||
private static SettingsManager pluginConfig;
|
||||
|
||||
public void load() {
|
||||
File pluginConfigFile = new File(this.path.toFile(), "plugin-config.yml");
|
||||
|
||||
pluginConfig = SettingsManagerBuilder
|
||||
.withYamlFile(pluginConfigFile)
|
||||
.useDefaultMigrationService()
|
||||
.configurationData(ConfigBuilder.buildPluginConfig())
|
||||
.create();
|
||||
|
||||
File localeDir = new File(this.path.toFile(), "locale");
|
||||
//FileUtils.extract("/locale/", this.path, false);
|
||||
|
||||
File localeFile = new File(localeDir, pluginConfig.getProperty(PluginConfig.LOCALE_FILE) + ".yml");
|
||||
|
||||
locale = SettingsManagerBuilder
|
||||
.withYamlFile(localeFile)
|
||||
.useDefaultMigrationService()
|
||||
.configurationData(ConfigBuilder.buildLocale())
|
||||
.create();
|
||||
|
||||
// Create config.yml
|
||||
File configFile = new File(this.path.toFile(), "config.yml");
|
||||
|
||||
config = SettingsManagerBuilder
|
||||
.withYamlFile(configFile)
|
||||
.useDefaultMigrationService()
|
||||
.configurationData(ConfigBuilder.buildConfig())
|
||||
.create();
|
||||
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
// Reload configs.
|
||||
pluginConfig.reload();
|
||||
config.reload();
|
||||
|
||||
locale.reload();
|
||||
|
||||
File localeDir = new File(this.path.toFile(), "locale");
|
||||
File localeFile = new File(localeDir, pluginConfig.getProperty(PluginConfig.LOCALE_FILE) + ".yml");
|
||||
|
||||
locale = SettingsManagerBuilder
|
||||
.withYamlFile(localeFile)
|
||||
.useDefaultMigrationService()
|
||||
.configurationData(ConfigBuilder.buildLocale())
|
||||
.create();
|
||||
}
|
||||
|
||||
public static SettingsManager getPluginConfig() {
|
||||
return pluginConfig;
|
||||
}
|
||||
|
||||
public static SettingsManager getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public static SettingsManager getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.badbones69.crazyauctions.common.config;
|
||||
|
||||
import ch.jalu.configme.configurationdata.ConfigurationData;
|
||||
import ch.jalu.configme.configurationdata.ConfigurationDataBuilder;
|
||||
import com.badbones69.crazyauctions.common.config.types.Config;
|
||||
import com.badbones69.crazyauctions.common.config.types.Messages;
|
||||
import com.badbones69.crazyauctions.common.config.types.PluginConfig;
|
||||
|
||||
public class ConfigBuilder {
|
||||
|
||||
private ConfigBuilder() {}
|
||||
|
||||
public static ConfigurationData buildPluginConfig() {
|
||||
return ConfigurationDataBuilder.createConfiguration(
|
||||
PluginConfig.class
|
||||
);
|
||||
}
|
||||
|
||||
public static ConfigurationData buildConfig() {
|
||||
return ConfigurationDataBuilder.createConfiguration(
|
||||
Config.class
|
||||
);
|
||||
}
|
||||
|
||||
public static ConfigurationData buildLocale() {
|
||||
return ConfigurationDataBuilder.createConfiguration(
|
||||
Messages.class
|
||||
);
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package com.badbones69.crazyauctions.common.config.types;
|
||||
|
||||
import ch.jalu.configme.Comment;
|
||||
import ch.jalu.configme.SettingsHolder;
|
||||
import ch.jalu.configme.configurationdata.CommentsConfiguration;
|
||||
import ch.jalu.configme.properties.Property;
|
||||
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
||||
|
||||
public class Config implements SettingsHolder {
|
||||
|
||||
public Config() {}
|
||||
|
||||
@Override
|
||||
public void registerComments(CommentsConfiguration conf) {
|
||||
String[] header = {
|
||||
"Github: https://github.com/Crazy-Crew",
|
||||
"",
|
||||
"Issues: https://github.com/Crazy-Crew/CrazyAuctions/issues",
|
||||
"Features: https://github.com/Crazy-Crew/CrazyAuctions//discussions/categories/features",
|
||||
"",
|
||||
"Legacy color codes such as &7,&c no longer work. You must use MiniMessage",
|
||||
"https://docs.advntr.dev/minimessage/format.html#color"
|
||||
};
|
||||
|
||||
String[] deprecation = {
|
||||
"",
|
||||
"Warning: This section is subject to change so it is considered deprecated.",
|
||||
"This is your warning before the change happens.",
|
||||
""
|
||||
};
|
||||
|
||||
conf.setComment("misc", header);
|
||||
}
|
||||
|
||||
@Comment("Allow damage items to be auctioned off.")
|
||||
public static final Property<Boolean> damaged_items = newProperty("misc.allow-damaged-items", false);
|
||||
|
||||
@Comment("Whether or not to allow `ah sell` or not.")
|
||||
public static final Property<Boolean> selling_module = newProperty("modules.selling-module", true);
|
||||
|
||||
@Comment("Whether or not to allow `ah buy` or not.")
|
||||
public static final Property<Boolean> bidding_module = newProperty("modules.bidding-module", true);
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.badbones69.crazyauctions.common.config.types;
|
||||
|
||||
import ch.jalu.configme.SettingsHolder;
|
||||
import ch.jalu.configme.configurationdata.CommentsConfiguration;
|
||||
import ch.jalu.configme.properties.Property;
|
||||
import ch.jalu.configme.properties.PropertyInitializer;
|
||||
|
||||
public class Messages implements SettingsHolder {
|
||||
|
||||
public Messages() {}
|
||||
|
||||
@Override
|
||||
public void registerComments(CommentsConfiguration conf) {
|
||||
String[] header = {
|
||||
"Submit your translations here: https://github.com/Crazy-Crew/CrazyAuctions/discussions/categories/translations",
|
||||
"",
|
||||
"Legacy color codes such as &7,&c no longer work. You must use MiniMessage",
|
||||
"https://docs.advntr.dev/minimessage/format.html#color"
|
||||
};
|
||||
|
||||
String[] deprecation = {
|
||||
"",
|
||||
"Warning: This section is subject to change so it is considered deprecated.",
|
||||
"This is your warning before the change happens.",
|
||||
""
|
||||
};
|
||||
|
||||
conf.setComment("general", header);
|
||||
}
|
||||
|
||||
public static final Property<String> unknown_command = PropertyInitializer.newProperty("general.unknown-command", "{prefix}<red>The command {command} is not known.</red>");
|
||||
|
||||
public static final Property<String> INVALID_SYNTAX = PropertyInitializer.newProperty("general.invalid-syntax", "{prefix}<gold>{value}</gold> <red>is an invalid {action}.</red>");
|
||||
|
||||
public static final Property<String> NO_PERMISSION = PropertyInitializer.newProperty("general.no-permission", "{prefix}<red>You do not have permission to use that command!</red>");
|
||||
|
||||
public static final Property<String> REQUIRED_ARGUMENT = PropertyInitializer.newProperty("general.checks.required-argument", "{prefix}<red>This argument is not optional</red>");
|
||||
|
||||
public static final Property<String> OPTIONAL_ARGUMENT = PropertyInitializer.newProperty("general.checks.optional-argument", "{prefix}<green>This argument is optional</green>");
|
||||
|
||||
public static final Property<String> NOT_ENOUGH_ARGS = PropertyInitializer.newProperty("general.checks.not-enough-args", "{prefix}<red>You did not supply enough arguments.</red>");
|
||||
|
||||
public static final Property<String> TOO_MANY_ARGS = PropertyInitializer.newProperty("general.checks.too-many-args", "{prefix}<red>You put more arguments then I can handle.</red>");
|
||||
|
||||
public static final Property<String> MUST_BE_PLAYER = PropertyInitializer.newProperty("general.player-checks.must-be-player", "{prefix}<red>You must be a player to use this command.</red>");
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.badbones69.crazyauctions.common.config.types;
|
||||
|
||||
import ch.jalu.configme.Comment;
|
||||
import ch.jalu.configme.SettingsHolder;
|
||||
import ch.jalu.configme.properties.Property;
|
||||
import ch.jalu.configme.properties.PropertyInitializer;
|
||||
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
||||
|
||||
/**
|
||||
* Description: The plugin-settings.yml options.
|
||||
*/
|
||||
public class PluginConfig implements SettingsHolder {
|
||||
|
||||
// Empty constructor required by SettingsHolder
|
||||
protected PluginConfig() {}
|
||||
|
||||
@Comment({
|
||||
"Choose what language you want the plugin to be in.",
|
||||
"",
|
||||
"Available Languages: en-US"
|
||||
})
|
||||
public static final Property<String> LOCALE_FILE = PropertyInitializer.newProperty("language", "en-US");
|
||||
|
||||
@Comment("Whether you want CrazyAuctions to shut up or not, This option is ignored by errors.")
|
||||
public static final Property<Boolean> verbose_logging = newProperty("verbose_logging", true);
|
||||
|
||||
@Comment({
|
||||
"Sends anonymous statistics about how the plugin is used to bstats.org.",
|
||||
"bstats is a service for plugin developers to find out how the plugin being used,",
|
||||
"This information helps us figure out how to better improve the plugin."
|
||||
})
|
||||
public static final Property<Boolean> toggle_metrics = newProperty("toggle_metrics", true);
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package com.badbones69.crazyauctions.common.data;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UserCache {
|
||||
|
||||
/**
|
||||
* Add a player to the hashmap if absent.
|
||||
*
|
||||
* @param uuid player uuid
|
||||
*/
|
||||
void addPlayer(final UUID uuid);
|
||||
|
||||
/**
|
||||
* Remove the player from the hashmap.
|
||||
*
|
||||
* @param uuid player uuid
|
||||
*/
|
||||
void removePlayer(final UUID uuid);
|
||||
|
||||
/**
|
||||
* Fetch the player if online or offline.
|
||||
*
|
||||
* @param uuid player uuid
|
||||
* @return player object
|
||||
*/
|
||||
String getPlayerName(final UUID uuid);
|
||||
|
||||
/**
|
||||
* Fetch the uuid file of the player.
|
||||
*
|
||||
* @param path the path i.e. 'CrazyAuctions/userdata/random-uuid.'
|
||||
* @param uuid the player uuid
|
||||
* @return the complete path
|
||||
*/
|
||||
Path getFile(final Path path, UUID uuid);
|
||||
|
||||
}
|
@ -7,9 +7,9 @@ website = https://modrinth.com/plugin/crazycrates
|
||||
sources = https://github.com/Crazy-Crew/CrazyCrates
|
||||
issues = https://github.com/Crazy-Crew/CrazyCrates/issues
|
||||
|
||||
group = us.crazycrew.crazycrates
|
||||
description = Add unlimited crates to your server with 10 different crate types to choose from!
|
||||
version = 1.18
|
||||
group = com.badbones69.com
|
||||
description = Auction off items in style!
|
||||
version = 1.3
|
||||
apiVersion = 1.20
|
||||
|
||||
minecraftVersion=1.20.2
|
||||
minecraftVersion = 1.20.2
|
@ -1,55 +0,0 @@
|
||||
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.commands.inventories.AuctionInventoryClick;
|
||||
import com.badbones69.crazyauctions.events.DataListener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CrazyAuctions extends JavaPlugin {
|
||||
|
||||
private final ApiManager apiManager;
|
||||
private final PaperCore paperCore;
|
||||
private CommandManager commandManager;
|
||||
|
||||
private CrazyManager crazyManager;
|
||||
|
||||
public CrazyAuctions(ApiManager apiManager, PaperCore paperCore) {
|
||||
this.apiManager = apiManager;
|
||||
this.paperCore = paperCore;
|
||||
}
|
||||
|
||||
@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() {
|
||||
if (this.crazyManager != null) this.crazyManager.stop();
|
||||
}
|
||||
|
||||
public ApiManager getApiManager() {
|
||||
return this.apiManager;
|
||||
}
|
||||
|
||||
public PaperCore getPaperCore() {
|
||||
return this.paperCore;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
public CrazyManager getCrazyManager() {
|
||||
return this.crazyManager;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.badbones69.crazyauctions;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.PaperCore;
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginProviderContext;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.badbones69.crazyauctions.config.types.PluginConfig;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class CrazyStarter implements PluginBootstrap {
|
||||
|
||||
private ApiManager apiManager;
|
||||
|
||||
@Override
|
||||
public void bootstrap(@NotNull BootstrapContext context) {
|
||||
this.apiManager = new ApiManager(context.getDataDirectory());
|
||||
this.apiManager.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) {
|
||||
PaperCore paperCore = new PaperCore(context.getDataDirectory(), Bukkit.getConsoleSender(), ApiManager.getPluginConfig().getProperty(PluginConfig.COMMAND_PREFIX), ApiManager.getPluginConfig().getProperty(PluginConfig.CONSOLE_PREFIX));
|
||||
paperCore.enable();
|
||||
|
||||
return new CrazyAuctions(this.apiManager, paperCore);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
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);
|
||||
|
||||
private StorageManager storageManager;
|
||||
|
||||
public void load(boolean serverStart) {
|
||||
if (serverStart) {
|
||||
this.storageManager = new StorageManager();
|
||||
|
||||
this.storageManager.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,38 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.enums;
|
||||
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
public enum Permissions {
|
||||
|
||||
PLAYER_HELP("player.help", "Gives access to the help command.", PermissionDefault.TRUE);
|
||||
|
||||
private final String node;
|
||||
private final String description;
|
||||
private final PermissionDefault permissionDefault;
|
||||
|
||||
Permissions(String node, String description, PermissionDefault permissionDefault) {
|
||||
this.node = node;
|
||||
this.description = description;
|
||||
this.permissionDefault = permissionDefault;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public PermissionDefault getPermissionDefault() {
|
||||
return this.permissionDefault;
|
||||
}
|
||||
|
||||
public String getBuiltPermission(String action) {
|
||||
return "crazyauctions." + action + "." + this.node;
|
||||
}
|
||||
|
||||
public String getBuiltPermission() {
|
||||
return "crazyauctions.command." + this.node;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.enums.support;
|
||||
|
||||
import com.badbones69.crazyauctions.storage.interfaces.UserManager;
|
||||
import com.badbones69.crazyauctions.storage.types.file.yaml.YamlUserManager;
|
||||
|
||||
public enum DataSupport {
|
||||
|
||||
yaml(YamlUserManager.class);
|
||||
|
||||
private final Class<? extends UserManager> classObject;
|
||||
|
||||
DataSupport(Class<? extends UserManager> classObject) {
|
||||
this.classObject = classObject;
|
||||
}
|
||||
|
||||
public Class<? extends UserManager> getClassObject() {
|
||||
return this.classObject;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem;
|
||||
import com.badbones69.crazyauctions.api.manager.objects.AuctionHouse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when an item is added to an auction house.
|
||||
*/
|
||||
public class AuctionAddEvent extends Event {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final UUID uuid;
|
||||
private final Player player;
|
||||
private final AuctionItem auctionItem;
|
||||
private final AuctionHouse auctionHouse;
|
||||
|
||||
/**
|
||||
* A constructor to include values for a bid event.
|
||||
*
|
||||
* @param uuid the uuid of the player who placed the bid.
|
||||
* @param auctionHouse the auction house the item is being added to.
|
||||
* @param auctionItem the auction item being added.
|
||||
*/
|
||||
public AuctionAddEvent(UUID uuid, AuctionHouse auctionHouse, AuctionItem auctionItem) {
|
||||
this.uuid = uuid;
|
||||
this.player = this.plugin.getServer().getPlayer(uuid);
|
||||
this.auctionHouse = auctionHouse;
|
||||
this.auctionItem = auctionItem;
|
||||
}
|
||||
|
||||
public AuctionItem getAuctionItem() {
|
||||
return auctionItem;
|
||||
}
|
||||
|
||||
public AuctionHouse getAuctionHouse() {
|
||||
return auctionHouse;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when a player bids on an auction.
|
||||
*/
|
||||
public class AuctionBidEvent extends Event {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final UUID uuid;
|
||||
private final Player player;
|
||||
|
||||
private final ItemStack item;
|
||||
|
||||
private final long bidPrice;
|
||||
|
||||
/**
|
||||
* A constructor to include values for a bid event.
|
||||
*
|
||||
* @param uuid the uuid of the player who placed the bid.
|
||||
* @param item the item that was bid on.
|
||||
* @param bidPrice the amount of money that was bid.
|
||||
*/
|
||||
public AuctionBidEvent(UUID uuid, ItemStack item, long bidPrice) {
|
||||
this.uuid = uuid;
|
||||
|
||||
this.player = this.plugin.getServer().getPlayer(uuid);
|
||||
|
||||
this.item = item;
|
||||
|
||||
this.bidPrice = bidPrice;
|
||||
}
|
||||
|
||||
public ItemStack getBidItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public long getBidPrice() {
|
||||
return this.bidPrice;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when a player buys an item.
|
||||
*/
|
||||
public class AuctionBuyEvent extends Event {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final UUID uuid;
|
||||
private final Player player;
|
||||
|
||||
private final ItemStack item;
|
||||
|
||||
private final long price;
|
||||
|
||||
/**
|
||||
* A constructor to include values for a buy event.
|
||||
*
|
||||
* @param uuid the uuid of the player who purchased the item.
|
||||
* @param item the item that was purchased.
|
||||
* @param price the amount of money used to buy.
|
||||
*/
|
||||
public AuctionBuyEvent(UUID uuid, ItemStack item, long price) {
|
||||
this.uuid = uuid;
|
||||
|
||||
this.player = this.plugin.getServer().getPlayer(uuid);
|
||||
|
||||
this.item = item;
|
||||
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public ItemStack getWinningItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public long getBuyPrice() {
|
||||
return this.price;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when an auction is cancelled.
|
||||
*/
|
||||
public class AuctionCancelEvent extends Event {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final UUID uuid;
|
||||
private final Player player;
|
||||
private final OfflinePlayer offlinePlayer;
|
||||
|
||||
private final ItemStack item;
|
||||
|
||||
/**
|
||||
* A constructor to include values for when an item is cancelled.
|
||||
*
|
||||
* @param uuid the uuid of the player whose item cancelled.
|
||||
*/
|
||||
public AuctionCancelEvent(UUID uuid, ItemStack item) {
|
||||
this.uuid = uuid;
|
||||
|
||||
this.player = this.plugin.getServer().getPlayer(uuid);
|
||||
|
||||
this.offlinePlayer = this.plugin.getServer().getOfflinePlayer(uuid);
|
||||
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the expired item.
|
||||
*/
|
||||
public ItemStack getExpiredItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only use this when the player is online.
|
||||
*
|
||||
* @return the online player.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only use this when the player is offline.
|
||||
*
|
||||
* @return the offline player.
|
||||
*/
|
||||
public OfflinePlayer getOfflinePlayer() {
|
||||
return this.offlinePlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the player's uuid.
|
||||
*/
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the handler list.
|
||||
*/
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when an auction expires.
|
||||
*/
|
||||
public class AuctionExpireEvent extends Event {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final UUID uuid;
|
||||
private final Player player;
|
||||
|
||||
private final ItemStack item;
|
||||
|
||||
/**
|
||||
* A constructor to include values for when an item expired.
|
||||
*
|
||||
* @param uuid the uuid of the player whose auction expired.
|
||||
*/
|
||||
public AuctionExpireEvent(UUID uuid, ItemStack item) {
|
||||
this.uuid = uuid;
|
||||
|
||||
this.player = this.plugin.getServer().getPlayer(uuid);
|
||||
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public ItemStack getExpiredItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when a player lists an item.
|
||||
*/
|
||||
public class AuctionListEvent extends Event {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final UUID uuid;
|
||||
private final Player player;
|
||||
|
||||
private final ItemStack item;
|
||||
|
||||
private final long bidPrice;
|
||||
|
||||
/**
|
||||
* A constructor to include values for a bid event.
|
||||
*
|
||||
* @param uuid the uuid of the player who placed the bid.
|
||||
* @param item the item that was bid on.
|
||||
* @param bidPrice the amount of money that was bid.
|
||||
*/
|
||||
public AuctionListEvent(UUID uuid, ItemStack item, long bidPrice) {
|
||||
this.uuid = uuid;
|
||||
|
||||
this.player = this.plugin.getServer().getPlayer(uuid);
|
||||
|
||||
this.item = item;
|
||||
|
||||
this.bidPrice = bidPrice;
|
||||
}
|
||||
|
||||
public ItemStack getBidItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public long getBidPrice() {
|
||||
return this.bidPrice;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when an auction has a winner.
|
||||
*/
|
||||
public class AuctionWinEvent extends Event {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final UUID uuid;
|
||||
private final Player player;
|
||||
|
||||
private final ItemStack item;
|
||||
|
||||
private final long price;
|
||||
|
||||
/**
|
||||
* A constructor to include values for a win event.
|
||||
*
|
||||
* @param uuid the uuid of the player who won the bid.
|
||||
* @param item the item that was won.
|
||||
* @param price the amount of money that was bid.
|
||||
*/
|
||||
public AuctionWinEvent(UUID uuid, ItemStack item, long price) {
|
||||
this.uuid = uuid;
|
||||
|
||||
this.player = this.plugin.getServer().getPlayer(uuid);
|
||||
|
||||
this.item = item;
|
||||
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public ItemStack getWinningItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public long getWinningPrice() {
|
||||
return this.price;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemUtils {
|
||||
|
||||
private final Material skull = Material.PLAYER_HEAD;
|
||||
|
||||
public ItemStack skull() {
|
||||
return new ItemStack(skull);
|
||||
}
|
||||
|
||||
public boolean isPlayerSkull(Material itemStack) {
|
||||
return itemStack != skull;
|
||||
}
|
||||
|
||||
private String getVersion() {
|
||||
String version = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return version.substring(version.lastIndexOf('.') + 1);
|
||||
}
|
||||
|
||||
public Class<?> craftClass(String name) throws ClassNotFoundException {
|
||||
return Class.forName("org.bukkit.craftbukkit." + getVersion() + "." + name);
|
||||
}
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame;
|
||||
|
||||
import com.badbones69.crazyauctions.ApiManager;
|
||||
import com.badbones69.crazyauctions.config.types.Locale;
|
||||
import com.badbones69.crazyauctions.config.types.PluginConfig;
|
||||
import com.badbones69.crazyauctions.frame.CrazyCore;
|
||||
import com.badbones69.crazyauctions.frame.storage.FileHandler;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class PaperCore extends CrazyCore {
|
||||
|
||||
private final Path path;
|
||||
private final Audience audience;
|
||||
private final FileHandler fileHandler;
|
||||
private final String prefix;
|
||||
private final String consolePrefix;
|
||||
|
||||
public PaperCore(Path path, Audience audience, String prefix, String consolePrefix) {
|
||||
// Create directory.
|
||||
this.path = path;
|
||||
this.path.toFile().mkdir();
|
||||
|
||||
this.audience = audience;
|
||||
this.prefix = prefix;
|
||||
this.consolePrefix = consolePrefix;
|
||||
|
||||
this.fileHandler = new FileHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
super.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getDirectory() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConsolePrefix() {
|
||||
return this.consolePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandler getFileHandler() {
|
||||
return this.fileHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Audience adventure() {
|
||||
return this.audience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandTooFewArgs() {
|
||||
return ApiManager.getLocale().getProperty(Locale.NOT_ENOUGH_ARGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandTooManyArgs() {
|
||||
return ApiManager.getLocale().getProperty(Locale.TOO_MANY_ARGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandOptionalMsg() {
|
||||
return ApiManager.getLocale().getProperty(Locale.OPTIONAL_ARGUMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandRequiredMsg() {
|
||||
return ApiManager.getLocale().getProperty(Locale.REQUIRED_ARGUMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandRequirementNotPlayer() {
|
||||
return ApiManager.getLocale().getProperty(Locale.MUST_BE_PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandRequirementNoPermission() {
|
||||
return ApiManager.getLocale().getProperty(Locale.NO_PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandHelpHeader() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandHelpFooter() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_FOOTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandInvalidPage() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.INVALID_HELP_PAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandPageFormat() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandHoverFormat() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_HOVER_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandHoverAction() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_HOVER_ACTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandNavigationText() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_GO_TO_PAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandNavigationNextButton() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_NEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commandNavigationBackButton() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_BACK);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame;
|
||||
|
||||
public class PaperUtils {
|
||||
|
||||
private static boolean hasClass(String className) {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSpigot() {
|
||||
return hasClass("org.spigotmc.SpigotConfig") && !hasClass("io.papermc.paper.configuration.Configuration") || !hasClass("com.destroystokyo.paper.PaperConfig");
|
||||
}
|
||||
|
||||
public static boolean isPaper() {
|
||||
return hasClass("io.papermc.paper.configuration.Configuration") || hasClass("com.destroystokyo.paper.PaperConfig");
|
||||
}
|
||||
|
||||
public static boolean isFolia() {
|
||||
return hasClass("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.adapters;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class LocationTypeAdapter extends TypeAdapter<Location> {
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter out, Location location) throws IOException {
|
||||
out.beginObject();
|
||||
out.name("world").value(location.getWorld().getName());
|
||||
out.name("x").value(location.getX());
|
||||
out.name("y").value(location.getY());
|
||||
out.name("z").value(location.getZ());
|
||||
out.name("yaw").value(location.getYaw());
|
||||
out.name("pitch").value(location.getPitch());
|
||||
out.endObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location read(JsonReader reader) throws IOException {
|
||||
reader.beginObject();
|
||||
|
||||
String worldName = null;
|
||||
double x = 0, y = 0, z = 0;
|
||||
float yaw = 0, pitch = 0;
|
||||
|
||||
while (reader.hasNext()) {
|
||||
String name = reader.nextName();
|
||||
|
||||
switch (name) {
|
||||
case "world" -> worldName = reader.nextString();
|
||||
case "x" -> x = reader.nextDouble();
|
||||
case "y" -> y = reader.nextDouble();
|
||||
case "z" -> z = reader.nextDouble();
|
||||
case "yaw" -> yaw = (float) reader.nextDouble();
|
||||
case "pitch" -> pitch = (float) reader.nextDouble();
|
||||
default -> reader.skipValue();
|
||||
}
|
||||
}
|
||||
|
||||
reader.endObject();
|
||||
|
||||
assert worldName != null;
|
||||
return new Location(Bukkit.getWorld(worldName), x, y, z, yaw, pitch);
|
||||
}
|
||||
}
|
@ -1,268 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command;
|
||||
|
||||
import com.badbones69.crazyauctions.ApiManager;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandActor;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.CommandArgs;
|
||||
import com.badbones69.crazyauctions.config.types.Locale;
|
||||
import com.badbones69.crazyauctions.frame.utils.AdventureUtils;
|
||||
import com.badbones69.crazyauctions.support.PlaceholderSupport;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CommandContext implements CommandActor, CommandArgs {
|
||||
|
||||
private final Audience audience;
|
||||
private final List<String> args;
|
||||
private String label;
|
||||
|
||||
private Player player;
|
||||
|
||||
public CommandContext(Audience audience, String label, List<String> args) {
|
||||
this.audience = audience;
|
||||
|
||||
if (audience instanceof Player) {
|
||||
this.player = (Player) audience;
|
||||
}
|
||||
|
||||
this.label = label;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply(String message) {
|
||||
if (message.isBlank() || message.isEmpty()) return;
|
||||
|
||||
Component component = AdventureUtils.parse(message);
|
||||
|
||||
this.audience.sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply(boolean hasPrefix, String prefix, String message) {
|
||||
if (message.isBlank() || message.isEmpty()) return;
|
||||
|
||||
if (hasPrefix) {
|
||||
Component component = AdventureUtils.parse(prefix).append(AdventureUtils.parse(prefix));
|
||||
|
||||
this.audience.sendMessage(component);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Component component = AdventureUtils.parse(message);
|
||||
|
||||
this.audience.sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply(boolean hasPrefix, String prefix, Component component) {
|
||||
if (hasPrefix) {
|
||||
this.audience.sendMessage(AdventureUtils.parse(prefix).append(component));
|
||||
return;
|
||||
}
|
||||
|
||||
this.audience.sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply(Component component) {
|
||||
this.audience.sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Audience audience, String message) {
|
||||
if (message.isBlank() || message.isEmpty()) return;
|
||||
|
||||
Component component = AdventureUtils.parse(message);
|
||||
|
||||
audience.sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Audience audience, Component component) {
|
||||
audience.sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Audience audience, String message, String prefix, boolean hasPrefix) {
|
||||
if (hasPrefix) {
|
||||
audience.sendMessage(AdventureUtils.parse(prefix).append(AdventureUtils.parse(message)));
|
||||
return;
|
||||
}
|
||||
|
||||
send(audience, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Audience audience, Component message, String prefix, boolean hasPrefix) {
|
||||
if (hasPrefix) {
|
||||
audience.sendMessage(AdventureUtils.parse(prefix).append(message));
|
||||
return;
|
||||
}
|
||||
|
||||
send(audience, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Audience getSender() {
|
||||
return this.audience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return getPlayer() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission permission) {
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String rawPermission) {
|
||||
return this.player.hasPermission(rawPermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public List<String> getArgs() {
|
||||
return Collections.unmodifiableList(this.args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeArgs(int arg) {
|
||||
this.args.remove(arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArgAsInt(int index, boolean notifySender) {
|
||||
Integer value = null;
|
||||
|
||||
try {
|
||||
value = Integer.parseInt(this.args.get(index));
|
||||
} catch (NumberFormatException exception) {
|
||||
if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX)
|
||||
.replaceAll("\\{value}", this.args.get(index))
|
||||
.replaceAll("\\{action}", "number")));
|
||||
}
|
||||
|
||||
if (value != null) return value;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getArgAsLong(int index, boolean notifySender) {
|
||||
Long value = null;
|
||||
|
||||
try {
|
||||
value = Long.parseLong(this.args.get(index));
|
||||
} catch (NumberFormatException exception) {
|
||||
if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX)
|
||||
.replaceAll("\\{value}", this.args.get(index))
|
||||
.replaceAll("\\{action}", "number")));
|
||||
}
|
||||
|
||||
if (value != null) return value;
|
||||
|
||||
return 1L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getArgAsDouble(int index, boolean notifySender) {
|
||||
Double value = null;
|
||||
|
||||
try {
|
||||
value = Double.parseDouble(this.args.get(index));
|
||||
} catch (NumberFormatException exception) {
|
||||
if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX)
|
||||
.replaceAll("\\{value}", this.args.get(index))
|
||||
.replaceAll("\\{action}", "number")));
|
||||
}
|
||||
|
||||
if (value != null) return value;
|
||||
|
||||
return 0.1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getArgAsBoolean(int index, boolean notifySender) {
|
||||
String lowercase = this.args.get(index).toLowerCase();
|
||||
|
||||
switch (lowercase) {
|
||||
case "true", "on", "1" -> {
|
||||
return true;
|
||||
}
|
||||
case "false", "off", "0" -> {
|
||||
return false;
|
||||
}
|
||||
default -> {
|
||||
if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX)
|
||||
.replaceAll("\\{value}", this.args.get(index).toLowerCase())
|
||||
.replaceAll("\\{action}", "boolean")));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getArgAsFloat(int index, boolean notifySender) {
|
||||
Float value = null;
|
||||
|
||||
try {
|
||||
value = Float.parseFloat(this.args.get(index));
|
||||
} catch (NumberFormatException exception) {
|
||||
if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX)
|
||||
.replaceAll("\\{value}", this.args.get(index))
|
||||
.replaceAll("\\{action}", "number")));
|
||||
}
|
||||
|
||||
if (value != null) return value;
|
||||
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getArgAsPlayer(int index, boolean notifySender) {
|
||||
Player player = Bukkit.getServer().getPlayer(this.args.get(index));
|
||||
|
||||
if (player == null) {
|
||||
if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX)
|
||||
.replaceAll("\\{value}", this.args.get(index))
|
||||
.replaceAll("\\{action}", "player")));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getArgAsOfflinePlayer(int index) {
|
||||
CompletableFuture<UUID> future = CompletableFuture.supplyAsync(() -> Bukkit.getServer().getOfflinePlayer(this.args.get(index))).thenApply(OfflinePlayer::getUniqueId);
|
||||
|
||||
return Bukkit.getServer().getOfflinePlayer(future.join());
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandDataEntry;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.Argument;
|
||||
import com.badbones69.crazyauctions.frame.CrazyCore;
|
||||
import com.badbones69.crazyauctions.frame.utils.AdventureUtils;
|
||||
import com.badbones69.crazyauctions.support.PlaceholderSupport;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class CommandEngine extends Command {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private final LinkedList<String> labels = new LinkedList<>();
|
||||
public final LinkedList<Argument> requiredArgs = new LinkedList<>();
|
||||
public final LinkedList<Argument> optionalArgs = new LinkedList<>();
|
||||
|
||||
private final HashMap<String, CommandDataEntry> commandData = new HashMap<>();
|
||||
|
||||
protected CommandEngine(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases) {
|
||||
super(name, description, usageMessage, aliases);
|
||||
}
|
||||
|
||||
public void execute(CommandContext context, String[] args) {
|
||||
perform(context, args);
|
||||
}
|
||||
|
||||
public void execute(CommandContext context) {
|
||||
StringBuilder label = new StringBuilder(context.getLabel());
|
||||
|
||||
if (!context.getArgs().isEmpty()) {
|
||||
for (CommandEngine engine : this.plugin.getCommandManager().getClasses()) {
|
||||
boolean isPresent = context.getArgs().stream().findFirst().isPresent();
|
||||
|
||||
if (isPresent) {
|
||||
label.append(" ").append(context.getArgs().get(0));
|
||||
|
||||
context.removeArgs(0);
|
||||
context.setLabel(label.toString());
|
||||
|
||||
engine.execute(context);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!validate(context)) return;
|
||||
|
||||
perform(context, new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
|
||||
List<String> arguments = Arrays.asList(args);
|
||||
|
||||
CommandContext context = new CommandContext(
|
||||
sender,
|
||||
label,
|
||||
arguments
|
||||
);
|
||||
|
||||
if (arguments.isEmpty()) {
|
||||
execute(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
execute(context, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void perform(CommandContext context, String[] args);
|
||||
|
||||
private boolean validate(CommandContext context) {
|
||||
if (context.getArgs().size() < this.requiredArgs.size()) {
|
||||
context.reply(CrazyCore.api().commandTooFewArgs());
|
||||
sendValidFormat(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.getArgs().size() > this.requiredArgs.size() + this.optionalArgs.size()) {
|
||||
context.reply(CrazyCore.api().commandTooManyArgs());
|
||||
sendValidFormat(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendValidFormat(CommandContext context) {
|
||||
ArrayList<Argument> arguments = new ArrayList<>();
|
||||
|
||||
arguments.addAll(this.requiredArgs);
|
||||
arguments.addAll(this.optionalArgs);
|
||||
|
||||
this.requiredArgs.sort(Comparator.comparing(Argument::order));
|
||||
|
||||
if (context.isPlayer()) {
|
||||
StringBuilder format = new StringBuilder("/" + "crazycrates:" + getLabel());
|
||||
|
||||
TextComponent.@NotNull Builder emptyComponent = Component.text();
|
||||
|
||||
StringBuilder types = new StringBuilder();
|
||||
|
||||
for (Argument arg : arguments) {
|
||||
String value = this.optionalArgs.contains(arg) ? " (" + arg.name() + ") " : " <" + arg.name() + ">";
|
||||
|
||||
String msg = this.optionalArgs.contains(arg) ? CrazyCore.api().commandOptionalMsg() : CrazyCore.api().commandRequiredMsg();
|
||||
|
||||
Component argComponent = AdventureUtils.parse(value).hoverEvent(HoverEvent.showText(AdventureUtils.parse(PlaceholderSupport.setPlaceholders(msg)))).asComponent();
|
||||
|
||||
emptyComponent.append(argComponent);
|
||||
|
||||
boolean isPresent = arg.argumentType().getPossibleValues().stream().findFirst().isPresent();
|
||||
|
||||
if (isPresent) types.append(" ").append(arg.argumentType().getPossibleValues().stream().findFirst().get());
|
||||
}
|
||||
|
||||
TextComponent.@NotNull Builder finalComponent = emptyComponent
|
||||
.hoverEvent(HoverEvent.showText(AdventureUtils.parse("<gold>Click me to insert into chat</gold>")))
|
||||
.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.SUGGEST_COMMAND, format.append(types).toString()))
|
||||
.append(emptyComponent.build());
|
||||
|
||||
context.reply(finalComponent.build());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder format = new StringBuilder("/" + "crazycrates:" + getLabel());
|
||||
|
||||
for (Argument arg : arguments) {
|
||||
String value = this.optionalArgs.contains(arg) ? "(" + arg.name() + ") " : "<" + arg.name() + "> ";
|
||||
|
||||
format.append(value);
|
||||
}
|
||||
|
||||
context.reply(format.toString());
|
||||
}
|
||||
|
||||
public List<String> getLabels() {
|
||||
return Collections.unmodifiableList(this.labels);
|
||||
}
|
||||
|
||||
public Map<String, CommandDataEntry> getCommandData() {
|
||||
return Collections.unmodifiableMap(this.commandData);
|
||||
}
|
||||
|
||||
public List<Argument> getRequiredArgs() {
|
||||
return Collections.unmodifiableList(this.requiredArgs);
|
||||
}
|
||||
|
||||
public List<Argument> getOptionalArgs() {
|
||||
return Collections.unmodifiableList(this.optionalArgs);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandActor;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandDataEntry;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandHelpEntry;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CommandFlow {
|
||||
|
||||
void addCommand(CommandEngine engine);
|
||||
|
||||
boolean hasCommand(String label);
|
||||
|
||||
CommandHelpEntry generateCommandHelp(CommandActor actor);
|
||||
|
||||
int defaultHelpPerPage();
|
||||
|
||||
void updateHelpPerPage(int newAmount);
|
||||
|
||||
CommandDataEntry getCommand(String label);
|
||||
|
||||
void removeCommand(String label);
|
||||
|
||||
Map<String, CommandDataEntry> getCommands();
|
||||
|
||||
List<CommandEngine> getClasses();
|
||||
|
||||
List<String> handleTabComplete(String[] args, CommandEngine engine);
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandActor;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandDataEntry;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.CommandHelpEntry;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.annotations.Hidden;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.Argument;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import java.util.*;
|
||||
|
||||
public class CommandManager implements CommandFlow {
|
||||
|
||||
private final HashMap<String, CommandDataEntry> commands = new HashMap<>();
|
||||
|
||||
private final LinkedList<CommandEngine> classes = new LinkedList<>();
|
||||
|
||||
private int defaultHelpPerPage = 10;
|
||||
|
||||
public static CommandManager create() {
|
||||
return new CommandManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommand(CommandEngine engine) {
|
||||
// If the label already exists. We return!
|
||||
if (hasCommand(engine.getLabel())) return;
|
||||
|
||||
// Create data entry.
|
||||
CommandDataEntry entry = new CommandDataEntry();
|
||||
|
||||
// Set visibility if annotation is present.
|
||||
entry.setHidden(engine.getClass().isAnnotationPresent(Hidden.class));
|
||||
|
||||
if (entry.isHidden()) return;
|
||||
|
||||
// Add to the hash-map & linked list!
|
||||
this.commands.put(engine.getLabel(), entry);
|
||||
this.classes.add(engine);
|
||||
|
||||
// Add command to the server map!
|
||||
Bukkit.getServer().getCommandMap().register("crazycrates", engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCommand(String label) {
|
||||
return this.commands.containsKey(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHelpEntry generateCommandHelp(CommandActor actor) {
|
||||
return new CommandHelpEntry(this, actor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int defaultHelpPerPage() {
|
||||
return this.defaultHelpPerPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHelpPerPage(int newAmount) {
|
||||
this.defaultHelpPerPage = newAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandDataEntry getCommand(String label) {
|
||||
if (hasCommand(label)) return this.commands.get(label);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCommand(String label) {
|
||||
if (!hasCommand(label)) return;
|
||||
|
||||
Command value = Bukkit.getServer().getCommandMap().getCommand(label);
|
||||
|
||||
if (value != null && value.isRegistered()) value.unregister(Bukkit.getServer().getCommandMap());
|
||||
|
||||
this.commands.remove(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, CommandDataEntry> getCommands() {
|
||||
return Collections.unmodifiableMap(this.commands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommandEngine> getClasses() {
|
||||
return Collections.unmodifiableList(this.classes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTabComplete(String[] args, CommandEngine engine) {
|
||||
List<String> completions = Arrays.asList(args);
|
||||
|
||||
if (completions.size() >= 1) {
|
||||
int relativeIndex = this.classes.size();
|
||||
int argToComplete = completions.size() + 1 - relativeIndex;
|
||||
if (engine.requiredArgs.size() >= argToComplete) {
|
||||
ArrayList<Argument> arguments = new ArrayList<>();
|
||||
|
||||
arguments.addAll(engine.requiredArgs);
|
||||
arguments.addAll(engine.optionalArgs);
|
||||
|
||||
ArrayList<String> possibleValues = new ArrayList<>();
|
||||
|
||||
for (Argument argument : arguments) {
|
||||
if (argument.order() == argToComplete) {
|
||||
List<String> possibleValuesArgs = argument.argumentType().getPossibleValues();
|
||||
|
||||
possibleValues = new ArrayList<>(possibleValuesArgs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return possibleValues;
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommandActor {
|
||||
|
||||
void reply(String message);
|
||||
|
||||
void reply(boolean hasPrefix, String prefix, String message);
|
||||
|
||||
void reply(boolean hasPrefix, String prefix, Component component);
|
||||
|
||||
void reply(Component component);
|
||||
|
||||
void send(Audience audience, String message);
|
||||
|
||||
void send(Audience audience, Component component);
|
||||
|
||||
void send(Audience audience, String message, String prefix, boolean hasPrefix);
|
||||
|
||||
void send(Audience audience, Component message, String prefix, boolean hasPrefix);
|
||||
|
||||
Audience getSender();
|
||||
|
||||
boolean isPlayer();
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
boolean hasPermission(Permission permission);
|
||||
|
||||
boolean hasPermission(String rawPermission);
|
||||
|
||||
void setLabel(String alias);
|
||||
|
||||
String getLabel();
|
||||
|
||||
List<String> getArgs();
|
||||
|
||||
void removeArgs(int arg);
|
||||
|
||||
//CommandHelpEntry getHelpEntry();
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders;
|
||||
|
||||
public class CommandDataEntry {
|
||||
|
||||
private boolean isHidden = false;
|
||||
|
||||
public void setHidden(boolean value) {
|
||||
this.isHidden = value;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return this.isHidden;
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders;
|
||||
|
||||
import com.badbones69.crazyauctions.ApiManager;
|
||||
import com.badbones69.crazyauctions.api.frame.command.CommandEngine;
|
||||
import com.badbones69.crazyauctions.api.frame.command.CommandManager;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.Argument;
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.other.ComponentBuilder;
|
||||
import com.badbones69.crazyauctions.config.types.PluginConfig;
|
||||
import com.badbones69.crazyauctions.frame.CrazyCore;
|
||||
import com.badbones69.crazyauctions.support.PlaceholderSupport;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import static com.badbones69.crazyauctions.frame.utils.AdventureUtils.hover;
|
||||
import static com.badbones69.crazyauctions.frame.utils.AdventureUtils.send;
|
||||
|
||||
public class CommandHelpEntry {
|
||||
|
||||
private final CommandManager manager;
|
||||
private final CommandActor actor;
|
||||
|
||||
private int page = 1;
|
||||
private int perPage;
|
||||
private int totalPages;
|
||||
private int totalResults;
|
||||
private boolean lastPage;
|
||||
|
||||
public CommandHelpEntry(CommandManager manager, CommandActor actor) {
|
||||
this.manager = manager;
|
||||
this.actor = actor;
|
||||
|
||||
this.perPage = manager.defaultHelpPerPage();
|
||||
}
|
||||
|
||||
public void showHelp() {
|
||||
this.showHelp(this.actor);
|
||||
}
|
||||
|
||||
public void showHelp(CommandActor actor) {
|
||||
int min = this.perPage * (this.page - 1);
|
||||
int max = min + this.perPage;
|
||||
|
||||
this.totalResults = this.manager.getCommands().size();
|
||||
|
||||
this.totalPages = this.totalResults / this.perPage;
|
||||
|
||||
if (min >= this.totalResults) {
|
||||
actor.reply(ApiManager.getPluginConfig().getProperty(PluginConfig.INVALID_HELP_PAGE).replaceAll("\\{page}", String.valueOf(page)));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, CommandDataEntry> entries = this.manager.getCommands();
|
||||
|
||||
for (int value = min; value < max; value++) {
|
||||
if (this.totalResults - 1 < value) continue;
|
||||
|
||||
CommandEngine command = this.manager.getClasses().get(value);
|
||||
|
||||
CommandDataEntry dataEntry = entries.get(command.getLabel());
|
||||
|
||||
boolean isHidden = dataEntry.isHidden();
|
||||
|
||||
StringBuilder baseFormat = new StringBuilder("/" + command.getLabel());
|
||||
|
||||
String format = CrazyCore.api().commandPageFormat()
|
||||
.replaceAll("\\{command}", baseFormat.toString())
|
||||
.replaceAll("\\{description}", command.getDescription());
|
||||
|
||||
// Only add aliases if the list isn't empty.
|
||||
if (!command.getAliases().isEmpty()) baseFormat.append(" ").append(command.getLabels().get(0));
|
||||
|
||||
ArrayList<Argument> arguments = new ArrayList<>();
|
||||
|
||||
arguments.addAll(command.getOptionalArgs());
|
||||
arguments.addAll(command.getRequiredArgs());
|
||||
|
||||
arguments.sort(Comparator.comparingInt(Argument::order));
|
||||
|
||||
if (actor.isPlayer()) {
|
||||
StringBuilder types = new StringBuilder();
|
||||
|
||||
ComponentBuilder builder = new ComponentBuilder();
|
||||
|
||||
for (Argument arg : arguments) {
|
||||
String argValue = command.optionalArgs.contains(arg) ? " (" + arg.name() + ") " : " <" + arg.name() + ">";
|
||||
|
||||
types.append(argValue);
|
||||
}
|
||||
|
||||
builder.setMessage(format.replaceAll("\\{args}", String.valueOf(types)));
|
||||
|
||||
String hoverShit = baseFormat.append(types).toString();
|
||||
|
||||
String hoverFormat = CrazyCore.api().commandHoverFormat();
|
||||
|
||||
builder.hover(PlaceholderSupport.setPlaceholders(hoverFormat).replaceAll("\\{commands}", hoverShit)).click(hoverShit, ClickEvent.Action.valueOf(CrazyCore.api().commandHoverAction().toUpperCase()));
|
||||
|
||||
actor.reply(builder.build());
|
||||
}
|
||||
|
||||
String footer = CrazyCore.api().commandHelpFooter();
|
||||
|
||||
if (actor.isPlayer()) {
|
||||
String text = CrazyCore.api().commandNavigationText();
|
||||
|
||||
if (page > 1) {
|
||||
int number = page-1;
|
||||
|
||||
hover(actor.getPlayer(), footer.replaceAll("\\{page}", String.valueOf(page)), text.replaceAll("\\{page}", String.valueOf(number)), CrazyCore.api().commandNavigationBackButton(), "/crazycrates help " + number, ClickEvent.Action.RUN_COMMAND);
|
||||
} else if (page < this.manager.getClasses().size()) {
|
||||
int number = page+1;
|
||||
|
||||
hover(actor.getPlayer(), footer.replaceAll("\\{page}", String.valueOf(page)), text.replaceAll("\\{page}", String.valueOf(number)), CrazyCore.api().commandNavigationNextButton(), "/crazycrates help " + number, ClickEvent.Action.RUN_COMMAND);
|
||||
}
|
||||
} else {
|
||||
send(actor.getSender(), footer.replaceAll("\\{page}", String.valueOf(page)), false, "");
|
||||
}
|
||||
}
|
||||
|
||||
this.lastPage = max >= this.totalResults;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public void setPerPage(int perPage) {
|
||||
this.perPage = perPage;
|
||||
}
|
||||
|
||||
public void setPage(int page, int perPage) {
|
||||
this.setPage(page);
|
||||
this.setPerPage(perPage);
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return this.page;
|
||||
}
|
||||
|
||||
public int getPerPage() {
|
||||
return this.perPage;
|
||||
}
|
||||
|
||||
public int getTotalResults() {
|
||||
return this.totalResults;
|
||||
}
|
||||
|
||||
public int getTotalPages() {
|
||||
return this.totalPages;
|
||||
}
|
||||
|
||||
public boolean isLastPage() {
|
||||
return this.lastPage;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Hidden {}
|
@ -1,3 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args;
|
||||
|
||||
public record Argument(String name, int order, ArgumentType argumentType) {}
|
@ -1,9 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ArgumentType {
|
||||
|
||||
public abstract List<String> getPossibleValues();
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface CommandArgs {
|
||||
|
||||
int getArgAsInt(int index, boolean notifySender);
|
||||
|
||||
long getArgAsLong(int index, boolean notifySender);
|
||||
|
||||
double getArgAsDouble(int index, boolean notifySender);
|
||||
|
||||
boolean getArgAsBoolean(int index, boolean notifySender);
|
||||
|
||||
float getArgAsFloat(int index, boolean notifySender);
|
||||
|
||||
Player getArgAsPlayer(int index, boolean notifySender);
|
||||
|
||||
OfflinePlayer getArgAsOfflinePlayer(int index);
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args.builder;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType;
|
||||
import java.util.List;
|
||||
|
||||
public class BooleanArgument extends ArgumentType {
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
return List.of("true", "false");
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args.builder;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DoubleArgument extends ArgumentType {
|
||||
|
||||
private final int numberCap;
|
||||
|
||||
public DoubleArgument(Integer numberCap) {
|
||||
if (numberCap == null) {
|
||||
this.numberCap = 100;
|
||||
return;
|
||||
}
|
||||
|
||||
this.numberCap = numberCap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
List<String> numbers = new ArrayList<>();
|
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.0");
|
||||
|
||||
for (double value = 0.1; value <= this.numberCap; value += 0.1) {
|
||||
String formattedNumber = decimalFormat.format(value);
|
||||
numbers.add(formattedNumber);
|
||||
}
|
||||
|
||||
return numbers;
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args.builder;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FloatArgument extends ArgumentType {
|
||||
|
||||
private final int numberCap;
|
||||
|
||||
public FloatArgument(Integer numberCap) {
|
||||
if (numberCap == null) {
|
||||
this.numberCap = 100;
|
||||
return;
|
||||
}
|
||||
|
||||
this.numberCap = numberCap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
List<String> numbers = new ArrayList<>();
|
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.0f");
|
||||
|
||||
for (float value = 0.1f; value <= this.numberCap; value += 0.1f) {
|
||||
String formattedValue = decimalFormat.format(value);
|
||||
numbers.add(formattedValue);
|
||||
}
|
||||
|
||||
return numbers;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args.builder;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IntArgument extends ArgumentType {
|
||||
|
||||
private final int numberCap;
|
||||
|
||||
public IntArgument(Integer numberCap) {
|
||||
if (numberCap == null) {
|
||||
this.numberCap = 100;
|
||||
return;
|
||||
}
|
||||
|
||||
this.numberCap = numberCap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
List<String> numbers = new ArrayList<>();
|
||||
|
||||
for (int value = 1; value <= this.numberCap; value += 1) numbers.add(String.valueOf(value));
|
||||
|
||||
return numbers;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.args.builder.custom;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PlayerArgument extends ArgumentType {
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
return Bukkit.getServer().getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.other;
|
||||
|
||||
import com.badbones69.crazyauctions.frame.utils.AdventureUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ComponentBuilder {
|
||||
|
||||
private String message;
|
||||
|
||||
private final TextComponent.@NotNull Builder builder = Component.text();
|
||||
|
||||
private final PreciseComponentBuilder preciseBuilder;
|
||||
|
||||
public ComponentBuilder() {
|
||||
this.preciseBuilder = new PreciseComponentBuilder();
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ComponentBuilder append(Component component) {
|
||||
this.builder.append(component);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Component parse(String value) {
|
||||
return AdventureUtils.parse(value);
|
||||
}
|
||||
|
||||
public ComponentBuilder hover(String hoverText) {
|
||||
this.builder.hoverEvent(HoverEvent.showText(parse(hoverText)));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ComponentBuilder click(String clickText, ClickEvent.Action action) {
|
||||
this.builder.clickEvent(ClickEvent.clickEvent(action, clickText));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public class PreciseComponentBuilder {
|
||||
private final TextComponent.@NotNull Builder preciseBuilder = Component.text();
|
||||
|
||||
public PreciseComponentBuilder text(String text) {
|
||||
this.preciseBuilder.append(parse(text));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PreciseComponentBuilder hoverText(String text, String hoverText) {
|
||||
this.preciseBuilder.append(parse(text));
|
||||
this.preciseBuilder.hoverEvent(HoverEvent.showText(parse(hoverText)));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PreciseComponentBuilder hoverText(String hoverText) {
|
||||
this.preciseBuilder.hoverEvent(HoverEvent.showText(parse(hoverText)));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PreciseComponentBuilder click(String clickText, ClickEvent.Action action) {
|
||||
this.preciseBuilder.clickEvent(ClickEvent.clickEvent(action, clickText));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NotNull TextComponent getPreciseBuilder() {
|
||||
return this.preciseBuilder.build();
|
||||
}
|
||||
}
|
||||
|
||||
public PreciseComponentBuilder getPreciseComponent() {
|
||||
return this.preciseBuilder;
|
||||
}
|
||||
|
||||
public @NotNull TextComponent build() {
|
||||
Component message = AdventureUtils.parse(this.message);
|
||||
|
||||
if (getPreciseComponent() != null) {
|
||||
return this.builder.append(message).append(getPreciseComponent().getPreciseBuilder()).build();
|
||||
}
|
||||
|
||||
return this.builder.append(message).build();
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.reqs;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.command.CommandContext;
|
||||
import com.badbones69.crazyauctions.frame.CrazyCore;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
public class CommandRequirements {
|
||||
|
||||
private final boolean asPlayer;
|
||||
private Permission permission;
|
||||
private String rawPermission;
|
||||
|
||||
public CommandRequirements(boolean asPlayer, Permission permission, String rawPermission) {
|
||||
this.asPlayer = asPlayer;
|
||||
|
||||
if (permission != null) this.permission = permission;
|
||||
|
||||
if (!rawPermission.isEmpty() || !rawPermission.isBlank()) this.rawPermission = rawPermission;
|
||||
}
|
||||
|
||||
public boolean checkRequirements(boolean notifySender, CommandContext context) {
|
||||
if (asPlayer && !context.isPlayer()) {
|
||||
if (notifySender) context.reply(CrazyCore.api().commandRequirementNotPlayer());
|
||||
|
||||
// The command is not valid.
|
||||
return false;
|
||||
}
|
||||
|
||||
// The sender is console sender so automatically valid.
|
||||
if (context.getSender() instanceof ConsoleCommandSender) return true;
|
||||
|
||||
if (this.permission != null && !context.hasPermission(this.permission) || this.rawPermission != null && !context.hasPermission(this.rawPermission)) {
|
||||
String value = this.permission != null ? this.permission.getName() : this.rawPermission;
|
||||
|
||||
if (notifySender) context.reply(CrazyCore.api().commandRequirementNoPermission().replaceAll("\\{permission}", value));
|
||||
|
||||
// The command is not valid.
|
||||
return false;
|
||||
}
|
||||
|
||||
// The command is valid.
|
||||
return true;
|
||||
}
|
||||
|
||||
public Permission getPermission() {
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
public String getRawPermission() {
|
||||
return this.rawPermission;
|
||||
}
|
||||
|
||||
public boolean isPlayer() {
|
||||
return this.asPlayer;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.command.builders.reqs;
|
||||
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
public class CommandRequirementsBuilder {
|
||||
|
||||
private boolean asPlayer = false;
|
||||
private Permission permission = null;
|
||||
private String rawPermission = "";
|
||||
|
||||
public CommandRequirementsBuilder asPlayer(boolean value) {
|
||||
this.asPlayer = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandRequirementsBuilder withPermission(Permission permission) {
|
||||
this.permission = permission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandRequirementsBuilder withOutPermission(Permission permission) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandRequirementsBuilder withRawPermission(String rawPermission) {
|
||||
this.rawPermission = rawPermission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandRequirements build() {
|
||||
return new CommandRequirements(asPlayer, permission, rawPermission);
|
||||
}
|
||||
}
|
@ -1,673 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.items;
|
||||
|
||||
import com.badbones69.crazyauctions.api.frame.ItemUtils;
|
||||
import com.badbones69.crazyauctions.frame.CrazyLogger;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ArmorMeta;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.FireworkEffectMeta;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.inventory.meta.trim.ArmorTrim;
|
||||
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.Consumer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BaseItemBuilder<Base extends BaseItemBuilder<Base>> {
|
||||
|
||||
private final ItemUtils SKULL_CHECKER = new ItemUtils();
|
||||
|
||||
private final GsonComponentSerializer gson = GsonComponentSerializer.gson();
|
||||
|
||||
// Core.
|
||||
private ItemStack itemStack;
|
||||
private ItemMeta itemMeta;
|
||||
|
||||
private Material material;
|
||||
|
||||
// Custom Lore.
|
||||
private Field LORE_FIELD;
|
||||
|
||||
// Custom Model Data.
|
||||
private boolean isCustomModelData;
|
||||
|
||||
private int customModelData;
|
||||
|
||||
// Custom Heads.
|
||||
private boolean isHead;
|
||||
private Field profile;
|
||||
private String texture;
|
||||
|
||||
// Potions
|
||||
private boolean isPotion;
|
||||
private boolean isTippedArrow;
|
||||
private Color potionColor;
|
||||
private PotionType potionType;
|
||||
|
||||
// Leather.
|
||||
private boolean isLeather;
|
||||
private boolean isArmor;
|
||||
private TrimMaterial trimMaterial;
|
||||
private TrimPattern trimPattern;
|
||||
private Color armorColor;
|
||||
|
||||
// Banners.
|
||||
private boolean isBanner;
|
||||
private List<Pattern> patterns;
|
||||
|
||||
// Shields.
|
||||
private boolean isShield;
|
||||
|
||||
// Firework.
|
||||
private boolean isFirework;
|
||||
private boolean isFireworkStar;
|
||||
|
||||
// Enchantments/Flags
|
||||
private boolean isDurable;
|
||||
private boolean hideFlags;
|
||||
private boolean isGlowing;
|
||||
|
||||
protected BaseItemBuilder() {
|
||||
this.itemStack = null;
|
||||
this.itemMeta = null;
|
||||
this.material = Material.AIR;
|
||||
this.LORE_FIELD = null;
|
||||
this.isCustomModelData = false;
|
||||
this.customModelData = 0;
|
||||
this.isHead = false;
|
||||
this.profile = null;
|
||||
this.texture = "";
|
||||
this.isPotion = false;
|
||||
this.isTippedArrow = false;
|
||||
this.potionColor = Color.WHITE;
|
||||
this.potionType = PotionType.MUNDANE;
|
||||
this.isLeather = false;
|
||||
this.armorColor = Color.WHITE;
|
||||
this.isBanner = false;
|
||||
this.patterns = Collections.emptyList();
|
||||
this.isShield = false;
|
||||
this.isFirework = false;
|
||||
this.isFireworkStar = false;
|
||||
this.isDurable = false;
|
||||
this.hideFlags = false;
|
||||
this.isGlowing = false;
|
||||
}
|
||||
|
||||
protected BaseItemBuilder(ItemStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
|
||||
try {
|
||||
Class<?> metaClass = SKULL_CHECKER.craftClass("inventory.CraftMetaItem");
|
||||
|
||||
LORE_FIELD = metaClass.getDeclaredField("lore");
|
||||
LORE_FIELD.setAccessible(true);
|
||||
} catch (NoSuchFieldException | ClassNotFoundException exception) {
|
||||
CrazyLogger.warn("Failed to make the lore field accessible as it was not found. Perhaps an invalid item was supplied?");
|
||||
}
|
||||
|
||||
this.material = itemStack.getType();
|
||||
|
||||
switch (this.material) {
|
||||
case PLAYER_HEAD -> this.isHead = true;
|
||||
case POTION, SPLASH_POTION -> this.isPotion = true;
|
||||
case TIPPED_ARROW -> this.isTippedArrow = true;
|
||||
case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS, LEATHER_HORSE_ARMOR -> this.isLeather = true;
|
||||
case SHIELD -> this.isShield = true;
|
||||
case FIREWORK_ROCKET -> this.isFirework = true;
|
||||
case FIREWORK_STAR -> this.isFireworkStar = true;
|
||||
}
|
||||
|
||||
String name = this.material.name();
|
||||
|
||||
this.isArmor = name.endsWith("_HELMET") || name.endsWith("_CHESTPLATE") || name.endsWith("_LEGGINGS") || name.endsWith("_BOOTS");
|
||||
|
||||
// Accounts for all banners.
|
||||
if (this.material.name().contains("BANNER")) this.isBanner = true;
|
||||
|
||||
// if (this.material.name().contains("SPAWN_EGG")) this.isEgg = true;
|
||||
|
||||
this.itemMeta = itemStack.hasItemMeta() ? itemStack.getItemMeta() : Bukkit.getServer().getItemFactory().getItemMeta(material);
|
||||
}
|
||||
|
||||
public Base setDisplayName(Component displayName) {
|
||||
this.itemMeta.displayName(displayName.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE));
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setLore(Component ... lore) {
|
||||
return setLore(Arrays.asList(lore));
|
||||
}
|
||||
|
||||
public Base setLore(List<Component> lore) {
|
||||
List<String> jsonLore = lore.stream().filter(Objects::nonNull).map(this.gson::serialize).toList();
|
||||
|
||||
try {
|
||||
LORE_FIELD.set(this.itemMeta, jsonLore);
|
||||
} catch (IllegalAccessException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base addLore(Consumer<List<Component>> lore) {
|
||||
List<Component> components;
|
||||
|
||||
try {
|
||||
List<String> jsonLore = (List<String>) LORE_FIELD.get(this.itemMeta);
|
||||
|
||||
components = (jsonLore == null) ? new ArrayList<>() : jsonLore.stream().map(this.gson::deserialize).collect(Collectors.toList());
|
||||
} catch (Exception exception) {
|
||||
components = new ArrayList<>();
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
lore.accept(components);
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setAmount(int amount) {
|
||||
this.itemStack.setAmount(amount);
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base addEnchantment(Enchantment enchantment, int level, boolean ignoreLevelRestriction) {
|
||||
this.itemMeta.addEnchant(enchantment, level, ignoreLevelRestriction);
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base removeEnchantment(Enchantment enchantment) {
|
||||
this.itemMeta.removeEnchant(enchantment);
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setEnchantments(HashMap<Enchantment, Integer> enchantments, boolean ignoreLevelRestriction) {
|
||||
enchantments.forEach((enchantment, integer) -> this.itemMeta.addEnchant(enchantment, integer, ignoreLevelRestriction));
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base addPatterns(List<String> patterns) {
|
||||
patterns.forEach(this::addPatterns);
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base addPattern(Pattern pattern) {
|
||||
this.patterns.add(pattern);
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setPattern(List<Pattern> patterns) {
|
||||
this.patterns = patterns;
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base addItemFlags(List<String> flags) {
|
||||
flags.forEach(flag -> {
|
||||
try {
|
||||
ItemFlag itemFlag = ItemFlag.valueOf(flag.toUpperCase());
|
||||
|
||||
addItemFlag(itemFlag);
|
||||
} catch (Exception exception) {
|
||||
CrazyLogger.warn("Failed to add item flag: " + flag + ". The flag is invalid!");
|
||||
}
|
||||
});
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setTexture(String texture) {
|
||||
this.texture = texture;
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setValue(String material) {
|
||||
if (material == null || material.isEmpty()) {
|
||||
CrazyLogger.warn("Material cannot be null or empty, Output: " + material + ".");
|
||||
CrazyLogger.warn("Please take a screenshot of this before asking for support.");
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
String metaData;
|
||||
|
||||
if (isPotion || isTippedArrow) {
|
||||
if (material.contains(";")) {
|
||||
String[] section = material.split(";");
|
||||
|
||||
String[] sectionOne = section[0].split(":");
|
||||
String[] sectionTwo = section[1].split(":");
|
||||
|
||||
try {
|
||||
this.potionType = PotionType.valueOf(sectionOne[1]);
|
||||
} catch (Exception exception) {
|
||||
CrazyLogger.warn("Failed to set potion type " + sectionOne[1] + ". The potion type inputted is invalid.");
|
||||
}
|
||||
|
||||
this.potionColor = getColor(sectionTwo[1]);
|
||||
}
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
if (material.contains(":")) { // Sets the durability or another value option.
|
||||
String[] materialSplit = material.split(":");
|
||||
|
||||
material = materialSplit[0];
|
||||
metaData = materialSplit[1];
|
||||
|
||||
if (metaData.contains("#")) { // <ID>:<Durability>#<CustomModelData>
|
||||
String modelData = metaData.split("#")[1];
|
||||
|
||||
if (isValidInteger(modelData)) {
|
||||
this.isCustomModelData = true;
|
||||
this.customModelData = Integer.parseInt(modelData);
|
||||
}
|
||||
}
|
||||
|
||||
metaData = metaData.replace("#" + customModelData, "");
|
||||
|
||||
if (isValidInteger(metaData)) { // Value is durability.
|
||||
int damage = Integer.parseInt(metaData);
|
||||
|
||||
if (this.itemMeta instanceof Damageable) ((Damageable) this.itemMeta).setDamage(damage);
|
||||
} else { // Value is something else.
|
||||
if (isPotion) {
|
||||
this.potionType = PotionType.valueOf(metaData);
|
||||
|
||||
if (getColor(metaData) != null) this.potionColor = getColor(metaData);
|
||||
}
|
||||
|
||||
if (isLeather) this.armorColor = getColor(metaData);
|
||||
}
|
||||
} else if (material.contains("#")) {
|
||||
String[] materialSplit = material.split("#");
|
||||
material = materialSplit[0];
|
||||
|
||||
if (isValidInteger(materialSplit[1])) { // Value is a number.
|
||||
this.isCustomModelData = true;
|
||||
this.customModelData = Integer.parseInt(materialSplit[1]);
|
||||
}
|
||||
}
|
||||
|
||||
Material matchedMaterial = Material.matchMaterial(material);
|
||||
|
||||
if (matchedMaterial != null) this.material = matchedMaterial;
|
||||
|
||||
if (this.isArmor) ((ArmorMeta) itemMeta).setTrim(new ArmorTrim(this.trimMaterial, this.trimPattern));
|
||||
|
||||
this.itemStack.setType(this.material);
|
||||
|
||||
setItemMeta(this.itemStack.getItemMeta());
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base hideFlags(boolean hideFlags) {
|
||||
this.hideFlags = hideFlags;
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setGlow(boolean isGlowing) {
|
||||
this.isGlowing = isGlowing;
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setTrim(TrimMaterial trimMaterial, TrimPattern trimPattern) {
|
||||
this.trimMaterial = trimMaterial;
|
||||
this.trimPattern = trimPattern;
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setDurable(boolean isDurable) {
|
||||
this.isDurable = isDurable;
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setEffect(FireworkEffect... effects) {
|
||||
return setEffect(Arrays.asList(effects));
|
||||
}
|
||||
|
||||
public Base setEffect(List<FireworkEffect> effects) {
|
||||
if (effects.isEmpty()) return (Base) this;
|
||||
|
||||
if (this.isFireworkStar) {
|
||||
FireworkEffectMeta effectMeta = (FireworkEffectMeta) this.getItemMeta();
|
||||
|
||||
effectMeta.setEffect(effects.get(0));
|
||||
this.setItemMeta(effectMeta);
|
||||
}
|
||||
|
||||
if (this.isFirework) {
|
||||
FireworkMeta fireworkMeta = (FireworkMeta) this.getItemMeta();
|
||||
|
||||
fireworkMeta.addEffects(effects);
|
||||
this.setItemMeta(fireworkMeta);
|
||||
}
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public Base setPower(int power) {
|
||||
if (this.isFirework) {
|
||||
FireworkMeta fireworkMeta = (FireworkMeta) this.getItemMeta();
|
||||
|
||||
fireworkMeta.setPower(power);
|
||||
|
||||
this.setItemMeta(fireworkMeta);
|
||||
}
|
||||
|
||||
return (Base) this;
|
||||
}
|
||||
|
||||
public ItemStack build() {
|
||||
if (this.material != Material.AIR) {
|
||||
if (this.isHead) {
|
||||
// Set the field to accessible.
|
||||
exposeField();
|
||||
|
||||
setPlayerTexture(this.texture);
|
||||
}
|
||||
|
||||
if (this.isPotion || this.isTippedArrow && (this.potionType != null || this.potionColor != null)) {
|
||||
PotionMeta potionMeta = (PotionMeta) this.itemMeta;
|
||||
|
||||
if (this.potionType != null) potionMeta.setBasePotionData(new PotionData(this.potionType));
|
||||
|
||||
if (this.potionColor != null) potionMeta.setColor(this.potionColor);
|
||||
|
||||
this.setItemMeta(potionMeta);
|
||||
}
|
||||
|
||||
if (this.isLeather && this.armorColor != null) {
|
||||
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) this.itemMeta;
|
||||
leatherArmorMeta.setColor(this.armorColor);
|
||||
}
|
||||
|
||||
if (this.isBanner && !this.patterns.isEmpty()) {
|
||||
BannerMeta bannerMeta = (BannerMeta) this.itemMeta;
|
||||
bannerMeta.setPatterns(this.patterns);
|
||||
}
|
||||
|
||||
if (this.isShield && !this.patterns.isEmpty()) {
|
||||
BlockStateMeta shieldMeta = (BlockStateMeta) this.itemMeta;
|
||||
Banner banner = (Banner) shieldMeta.getBlockState();
|
||||
|
||||
banner.setPatterns(this.patterns);
|
||||
banner.update();
|
||||
|
||||
shieldMeta.setBlockState(banner);
|
||||
}
|
||||
|
||||
if (this.isCustomModelData) this.itemMeta.setCustomModelData(this.customModelData);
|
||||
|
||||
if (this.hideFlags) this.itemMeta.addItemFlags(ItemFlag.values());
|
||||
|
||||
this.itemMeta.setUnbreakable(this.isDurable);
|
||||
|
||||
this.addGlow();
|
||||
} else {
|
||||
CrazyLogger.warn("Material cannot be AIR.");
|
||||
}
|
||||
|
||||
this.itemStack.setItemMeta(this.itemMeta);
|
||||
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
private void addItemFlag(ItemFlag itemFlag) {
|
||||
this.itemMeta.addItemFlags(itemFlag);
|
||||
}
|
||||
|
||||
private void setPlayerTexture(String texture) {
|
||||
this.texture = texture;
|
||||
|
||||
Player player = Bukkit.getServer().getPlayer(this.texture);
|
||||
|
||||
if (player != null) {
|
||||
setOwner(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.texture.startsWith("http")) {
|
||||
setTexture(convert(this.texture), UUID.randomUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
setTexture(this.texture, UUID.randomUUID());
|
||||
}
|
||||
|
||||
private void setOwner(OfflinePlayer player) {
|
||||
if (this.SKULL_CHECKER.isPlayerSkull(this.material)) return;
|
||||
|
||||
SkullMeta skullMeta = (SkullMeta) this.getItemMeta();
|
||||
|
||||
skullMeta.setOwningPlayer(player);
|
||||
|
||||
this.setItemMeta(skullMeta);
|
||||
}
|
||||
|
||||
private void addGlow() {
|
||||
if (this.isGlowing) {
|
||||
if (this.itemMeta.hasEnchants()) return;
|
||||
|
||||
this.itemMeta.addEnchant(Enchantment.LUCK, 1, false);
|
||||
|
||||
this.setItemMeta(this.itemMeta);
|
||||
}
|
||||
}
|
||||
|
||||
private void exposeField() {
|
||||
if (this.SKULL_CHECKER.isPlayerSkull(this.material)) return;
|
||||
|
||||
Field field;
|
||||
|
||||
try {
|
||||
SkullMeta skullMeta = (SkullMeta) this.SKULL_CHECKER.skull().getItemMeta();
|
||||
field = skullMeta.getClass().getDeclaredField("profile");
|
||||
|
||||
field.setAccessible(true);
|
||||
} catch (NoSuchFieldException exception) {
|
||||
CrazyLogger.warn("Failed to make the meta field for profile accessible as it was not found. Perhaps an invalid item meta or field supplied?");
|
||||
|
||||
field = null;
|
||||
}
|
||||
|
||||
this.profile = field;
|
||||
}
|
||||
|
||||
private boolean isValidInteger(String value) {
|
||||
try {
|
||||
Integer.parseInt(value);
|
||||
} catch (NumberFormatException exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Color getColor(String color) {
|
||||
if (color != null) {
|
||||
switch (color.toUpperCase()) {
|
||||
case "AQUA" -> {
|
||||
return Color.AQUA;
|
||||
}
|
||||
case "BLACK" -> {
|
||||
return Color.BLACK;
|
||||
}
|
||||
case "BLUE" -> {
|
||||
return Color.BLUE;
|
||||
}
|
||||
case "FUCHSIA" -> {
|
||||
return Color.FUCHSIA;
|
||||
}
|
||||
case "GRAY" -> {
|
||||
return Color.GRAY;
|
||||
}
|
||||
case "GREEN" -> {
|
||||
return Color.GREEN;
|
||||
}
|
||||
case "LIME" -> {
|
||||
return Color.LIME;
|
||||
}
|
||||
case "MAROON" -> {
|
||||
return Color.MAROON;
|
||||
}
|
||||
case "NAVY" -> {
|
||||
return Color.NAVY;
|
||||
}
|
||||
case "OLIVE" -> {
|
||||
return Color.OLIVE;
|
||||
}
|
||||
case "ORANGE" -> {
|
||||
return Color.ORANGE;
|
||||
}
|
||||
case "PURPLE" -> {
|
||||
return Color.PURPLE;
|
||||
}
|
||||
case "RED" -> {
|
||||
return Color.RED;
|
||||
}
|
||||
case "SILVER" -> {
|
||||
return Color.SILVER;
|
||||
}
|
||||
case "TEAL" -> {
|
||||
return Color.TEAL;
|
||||
}
|
||||
case "WHITE" -> {
|
||||
return Color.WHITE;
|
||||
}
|
||||
case "YELLOW" -> {
|
||||
return Color.YELLOW;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
String[] rgb = color.split(",");
|
||||
return Color.fromRGB(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2]));
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addPatterns(String stringPattern) {
|
||||
try {
|
||||
String[] split = stringPattern.split(":");
|
||||
|
||||
for (PatternType pattern : PatternType.values()) {
|
||||
|
||||
if (split[0].equalsIgnoreCase(pattern.name()) || split[0].equalsIgnoreCase(pattern.getIdentifier())) {
|
||||
DyeColor color = getDyeColor(split[1]);
|
||||
|
||||
if (color != null) this.addPattern(new Pattern(color, pattern));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public DyeColor getDyeColor(String color) {
|
||||
if (color != null) {
|
||||
try {
|
||||
return DyeColor.valueOf(color.toUpperCase());
|
||||
} catch (Exception exception) {
|
||||
try {
|
||||
String[] rgb = color.split(",");
|
||||
return DyeColor.getByColor(Color.fromRGB(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])));
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setTexture(String texture, UUID uuid) {
|
||||
if (this.SKULL_CHECKER.isPlayerSkull(this.material)) return;
|
||||
|
||||
if (this.profile == null) return;
|
||||
|
||||
SkullMeta skullMeta = (SkullMeta) this.itemMeta;
|
||||
GameProfile gameProfile = new GameProfile(uuid, null);
|
||||
|
||||
gameProfile.getProperties().put("textures", new Property("textures", texture));
|
||||
|
||||
try {
|
||||
this.profile.set(skullMeta, gameProfile);
|
||||
} catch (Exception exception) {
|
||||
CrazyLogger.warn("Failed to set the meta & game profile. Perhaps an invalid texture?");
|
||||
CrazyLogger.warn("Your Input: " + texture + ".");
|
||||
}
|
||||
|
||||
setItemMeta(skullMeta);
|
||||
}
|
||||
|
||||
private String convert(String url) {
|
||||
URL actualLink;
|
||||
|
||||
try {
|
||||
actualLink = new URL(url);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String encode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualLink + "\"}}}";
|
||||
|
||||
return Base64.getEncoder().encodeToString(encode.getBytes());
|
||||
}
|
||||
|
||||
// Protected getters for extended builders.
|
||||
protected ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
protected void setItemStack(ItemStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
protected ItemMeta getItemMeta() {
|
||||
return this.itemMeta;
|
||||
}
|
||||
|
||||
protected void setItemMeta(ItemMeta itemMeta) {
|
||||
this.itemMeta = itemMeta;
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.items;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemBuilder extends BaseItemBuilder<ItemBuilder> {
|
||||
|
||||
public ItemBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ItemBuilder(ItemStack itemStack) {
|
||||
super(itemStack);
|
||||
}
|
||||
|
||||
public static ItemBuilder setStack(ItemStack itemStack) {
|
||||
return new ItemBuilder(itemStack);
|
||||
}
|
||||
|
||||
public static ItemBuilder setMaterial(Material material) {
|
||||
return new ItemBuilder(new ItemStack(material));
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.frame.items;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ItemNbt {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
public ItemNbt(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public ItemStack setString(ItemStack itemStack, String key, String value) {
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
|
||||
if (meta == null) return null;
|
||||
|
||||
meta.getPersistentDataContainer().set(new NamespacedKey(this.plugin, key), PersistentDataType.STRING, value);
|
||||
itemStack.setItemMeta(meta);
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public String getString(ItemStack itemStack, String key) {
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
|
||||
if (meta == null) return null;
|
||||
|
||||
return meta.getPersistentDataContainer().get(new NamespacedKey(this.plugin, key), PersistentDataType.STRING);
|
||||
}
|
||||
|
||||
public ItemStack setBoolean(ItemStack itemStack, String key, boolean value) {
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
|
||||
if (meta == null) return null;
|
||||
|
||||
meta.getPersistentDataContainer().set(new NamespacedKey(this.plugin, key), PersistentDataType.BOOLEAN, value);
|
||||
itemStack.setItemMeta(meta);
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public ItemStack removeTag(ItemStack itemStack, String key) {
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
|
||||
if (meta == null) return null;
|
||||
|
||||
meta.getPersistentDataContainer().remove(new NamespacedKey(this.plugin, key));
|
||||
itemStack.setItemMeta(meta);
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.enums;
|
||||
|
||||
/**
|
||||
* Description: Defines the auction type to use
|
||||
*/
|
||||
public enum AuctionType {
|
||||
|
||||
BID("Bid"),
|
||||
SELL("Sell");
|
||||
|
||||
private final String name;
|
||||
|
||||
AuctionType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static AuctionType getTypeFromName(String name) {
|
||||
for (AuctionType type : AuctionType.values()) {
|
||||
if (type.getName().equalsIgnoreCase(name)) return type;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.interfaces;
|
||||
|
||||
import com.badbones69.crazyauctions.api.manager.enums.AuctionType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface AuctionItem {
|
||||
|
||||
UUID auctionID = UUID.randomUUID();
|
||||
|
||||
default UUID getAuctionID() {
|
||||
return auctionID;
|
||||
}
|
||||
|
||||
AuctionType getAuctionType();
|
||||
|
||||
UUID getSeller();
|
||||
|
||||
long getPrice();
|
||||
|
||||
long getExpireTime();
|
||||
|
||||
ItemStack getSellingItem();
|
||||
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.objects;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AuctionButtons {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
/*
|
||||
private final ItemBuilder sellingItemsButton;
|
||||
private final ItemBuilder sellingInfoButton;
|
||||
private final ItemBuilder biddingInfoButton;
|
||||
private final ItemBuilder currentListingsInfoButton;
|
||||
private final ItemBuilder expiredItemsButton;
|
||||
private final ItemBuilder expiredInfoButton;
|
||||
private final ItemBuilder categoriesButton;
|
||||
private final ItemBuilder categoriesInfoButton;
|
||||
private final ItemBuilder nextPageButton;
|
||||
private final ItemBuilder refreshPageButton;
|
||||
private final ItemBuilder backPageButton;
|
||||
private final ItemBuilder switchModeButton;
|
||||
|
||||
public AuctionButtons(FileConfiguration file) {
|
||||
String path = "auction-house.settings.buttons.";
|
||||
sellingItemsButton = ItemUtils.convertString(file.getString(path + "selling-items"));
|
||||
sellingInfoButton = ItemUtils.convertString(file.getString(path + "info.selling-items"));
|
||||
biddingInfoButton = ItemUtils.convertString(file.getString(path + "info.bidding"));
|
||||
currentListingsInfoButton = ItemUtils.convertString(file.getString(path + "info.current-listings"));
|
||||
expiredItemsButton = ItemUtils.convertString(file.getString(path + "expired-items"));
|
||||
expiredInfoButton = ItemUtils.convertString(file.getString(path + "info.expired-items"));
|
||||
categoriesButton = ItemUtils.convertString(file.getString(path + "categories"));
|
||||
categoriesInfoButton = ItemUtils.convertString(file.getString(path + "info.categories"));
|
||||
nextPageButton = ItemUtils.convertString(file.getString(path + "next-page"));
|
||||
refreshPageButton = ItemUtils.convertString(file.getString(path + "refresh-page"));
|
||||
backPageButton = ItemUtils.convertString(file.getString(path + "back-page"));
|
||||
switchModeButton = ItemUtils.convertString(file.getString(path + "switch-mode"));
|
||||
}
|
||||
|
||||
|
||||
public ItemBuilder getSellingItemsButton() {
|
||||
return sellingItemsButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getSellingInfoButton() {
|
||||
return sellingInfoButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getBiddingInfoButton() {
|
||||
return biddingInfoButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getCurrentListingsInfoButton() {
|
||||
return currentListingsInfoButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getExpiredItemsButton() {
|
||||
return expiredItemsButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getExpiredInfoButton() {
|
||||
return expiredInfoButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getCategoriesButton() {
|
||||
return categoriesButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getCategoriesInfoButton() {
|
||||
return categoriesInfoButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getNextPageButton() {
|
||||
return nextPageButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getRefreshPageButton() {
|
||||
return refreshPageButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getBackPageButton() {
|
||||
return backPageButton;
|
||||
}
|
||||
|
||||
public ItemBuilder getSwitchModeButton() {
|
||||
return switchModeButton;
|
||||
}*/
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.objects;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.api.frame.items.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description: Creates the auction categories
|
||||
*/
|
||||
public class AuctionCategory {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private String name;
|
||||
private int slot;
|
||||
//private ItemBuilder displayItem;
|
||||
private List<Material> categoryItemList;
|
||||
|
||||
//TODO make it so each AH can have their own categories and the default ones should be able to be disabled.
|
||||
public AuctionCategory(String name, int slot, ItemBuilder displayItem, List<Material> categoryItemList) {
|
||||
this.name = name;
|
||||
this.slot = slot;
|
||||
//this.displayItem = displayItem;
|
||||
this.categoryItemList = categoryItemList;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
//public ItemBuilder getDisplayItem() {
|
||||
// return displayItem;
|
||||
//}
|
||||
|
||||
public List<Material> getCategoryItemList() {
|
||||
return categoryItemList;
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.objects;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.api.manager.enums.AuctionType;
|
||||
import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem;
|
||||
import com.badbones69.crazyauctions.api.manager.objects.auctiontype.BiddingAuction;
|
||||
import com.badbones69.crazyauctions.api.manager.objects.auctiontype.SellingAuction;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionAddEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: Creates the main auction house menu
|
||||
*/
|
||||
public class AuctionHouse {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private String name;
|
||||
private FileConfiguration auctionFile;
|
||||
private InventorySettings inventorySettings;
|
||||
private List<AuctionItem> auctionItems = new ArrayList<>();
|
||||
private List<AuctionCategory> auctionCategories = new ArrayList<>();
|
||||
|
||||
public AuctionHouse(FileConfiguration file) {
|
||||
this.name = file.getString("auction-house.settings.name");
|
||||
this.auctionFile = file;
|
||||
this.inventorySettings = new InventorySettings(file);
|
||||
//Loads the auction house listings into the auction house.
|
||||
//TODO this needs to be moved to a seperated data file that doesnt hold all the auction house settings.
|
||||
for (String auctionID : file.getConfigurationSection("auction-house.item-on-auction").getKeys(false)) {
|
||||
String path = "auction-house.item-on-auction" + auctionID + ".";
|
||||
AuctionType auctionType = AuctionType.getTypeFromName(file.getString(path + "auction-type"));
|
||||
if (auctionType == AuctionType.SELL) {
|
||||
auctionItems.add(new SellingAuction(
|
||||
UUID.fromString(file.getString(path + "seller-uuid")),
|
||||
file.getLong(path + "price"),
|
||||
file.getLong(path + "expire-time"),
|
||||
file.getItemStack(path + "selling-item")));
|
||||
} else {
|
||||
auctionItems.add(new BiddingAuction(
|
||||
UUID.fromString(file.getString(path + "seller-uuid")),
|
||||
UUID.fromString(file.getString(path + "highest-bidder-uuid")),
|
||||
file.getLong(path + "price"),
|
||||
file.getLong(path + "current-bid"),
|
||||
file.getLong(path + "expire-time"),
|
||||
file.getItemStack(path + "selling-item")));
|
||||
}
|
||||
}
|
||||
//Loads the category items into the auction house.
|
||||
//TODO Need to add the default categories like isPotion, isArmor, isFood, Ect...
|
||||
//for (String category : file.getConfigurationSection("auction-house.categories").getKeys(false)) {
|
||||
// String path = "auction-house.categories." + category + ".";
|
||||
// auctionCategories.add(new AuctionCategory(
|
||||
// category,
|
||||
// file.getInt(path + "slot"),
|
||||
//ItemUtils.convertString(file.getString(path + "item")),
|
||||
//file.getStringList(path + "items").stream().map(Material :: matchMaterial).collect(Collectors.toList())));
|
||||
//}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public FileConfiguration getAuctionFile() {
|
||||
return auctionFile;
|
||||
}
|
||||
|
||||
public InventorySettings getInventorySettings() {
|
||||
return inventorySettings;
|
||||
}
|
||||
|
||||
public List<AuctionItem> getAuctionItems() {
|
||||
return auctionItems;
|
||||
}
|
||||
|
||||
public long getAuctionCount(AuctionType auctionType) {
|
||||
return auctionItems.stream().filter(auctionItem -> auctionType == auctionItem.getAuctionType()).count();
|
||||
}
|
||||
|
||||
public void addAuctionItem(AuctionItem auctionItem) {
|
||||
auctionItems.add(auctionItem);
|
||||
AuctionAddEvent event = new AuctionAddEvent(auctionItem.getSeller(), this, auctionItem);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.objects;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Description: Creates the auction house inventory settings
|
||||
*/
|
||||
public class InventorySettings {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private final String title;
|
||||
private final AuctionButtons auctionButtons = null;
|
||||
|
||||
public InventorySettings(FileConfiguration file) {
|
||||
String path = "auction-house.settings.";
|
||||
this.title = file.getString(path + "inventory-title");
|
||||
//this.auctionButtons = new AuctionButtons(file);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public AuctionButtons getAuctionButtons() {
|
||||
return auctionButtons;
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.objects.auctiontype;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.api.manager.enums.AuctionType;
|
||||
import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: Creates the bidding auction type
|
||||
*/
|
||||
public class BiddingAuction implements AuctionItem {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
AuctionType auctionType = AuctionType.BID;
|
||||
UUID seller;
|
||||
UUID highestBidder;
|
||||
long price;
|
||||
long currentBid;
|
||||
long expireTime;
|
||||
ItemStack sellingItem;
|
||||
|
||||
public BiddingAuction(UUID seller, UUID highestBidder, long price, long currentBid, long expireTime, ItemStack sellingItem) {
|
||||
this.seller = seller;
|
||||
this.highestBidder = highestBidder;
|
||||
this.price = price;
|
||||
this.currentBid = 0;
|
||||
this.expireTime = expireTime;
|
||||
this.sellingItem = sellingItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuctionType getAuctionType() {
|
||||
return auctionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSeller() {
|
||||
return seller;
|
||||
}
|
||||
|
||||
public UUID getHighestBidder() {
|
||||
return highestBidder;
|
||||
}
|
||||
|
||||
public void setHighestBidder(UUID highestBidder) {
|
||||
this.highestBidder = highestBidder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public long getCurrentBid() {
|
||||
return currentBid;
|
||||
}
|
||||
|
||||
public void setCurrentBid(long currentBid) {
|
||||
this.currentBid = currentBid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSellingItem() {
|
||||
return sellingItem;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.badbones69.crazyauctions.api.manager.objects.auctiontype;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.api.manager.enums.AuctionType;
|
||||
import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: Creates the selling auction type
|
||||
*/
|
||||
public class SellingAuction implements AuctionItem {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
AuctionType auctionType = AuctionType.SELL;
|
||||
UUID seller;
|
||||
long price;
|
||||
long expireTime;
|
||||
ItemStack sellingItem;
|
||||
|
||||
public SellingAuction(UUID seller, long price, long expireTime, ItemStack sellingItem) {
|
||||
this.seller = seller;
|
||||
this.price = price;
|
||||
this.expireTime = expireTime;
|
||||
this.sellingItem = sellingItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuctionType getAuctionType() {
|
||||
return auctionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSeller() {
|
||||
return seller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSellingItem() {
|
||||
return sellingItem;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.badbones69.crazyauctions.commands;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.api.frame.command.CommandContext;
|
||||
import com.badbones69.crazyauctions.api.frame.command.CommandEngine;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.Collections;
|
||||
|
||||
public class AuctionCommand extends CommandEngine {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
protected AuctionCommand() {
|
||||
super("auctions", "Opens the auction house", "/crazyauctions:auctions", Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform(CommandContext context, String[] args) {
|
||||
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
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;
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform(CommandContext context, String[] args) {
|
||||
this.crazyManager.reload();
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.badbones69.crazyauctions.commands.inventories;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AuctionInventory implements InventoryHolder {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private final Inventory inventory;
|
||||
|
||||
public AuctionInventory() {
|
||||
this.inventory = plugin.getServer().createInventory(this, 9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Inventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.badbones69.crazyauctions.storage.interfaces;
|
||||
|
||||
import com.badbones69.crazyauctions.frame.storage.enums.StorageType;
|
||||
import com.badbones69.crazyauctions.storage.objects.UserData;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UserManager {
|
||||
|
||||
void load(UUID uuid);
|
||||
|
||||
void saveSingular(UUID uuid, boolean serverExit);
|
||||
|
||||
void save(boolean serverExit);
|
||||
|
||||
void convert(File file, UUID uuid, StorageType storageType);
|
||||
|
||||
void addAuction(UUID uuid);
|
||||
|
||||
File getFile(Path path, UUID uuid);
|
||||
|
||||
UserData getUser(UUID uuid);
|
||||
|
||||
Map<UUID, UserData> getUsers();
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.badbones69.crazyauctions.storage.objects;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class UserData {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private final UUID uuid;
|
||||
|
||||
private ConcurrentHashMap<String, String> auctionData = new ConcurrentHashMap<>();
|
||||
|
||||
public UserData(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.plugin.getServer().getPlayer(this.uuid);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
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.storage.interfaces.UserManager;
|
||||
import com.badbones69.crazyauctions.storage.objects.UserData;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class YamlUserManager extends YamlConfiguration implements UserManager {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private final ConcurrentHashMap<UUID, UserData> userData = new ConcurrentHashMap<>();
|
||||
|
||||
public YamlUserManager() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(UUID uuid) {
|
||||
try {
|
||||
File file = new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml");
|
||||
|
||||
if (!file.exists()) file.createNewFile();
|
||||
|
||||
load(file);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSingular(UUID uuid, boolean serverExit) {
|
||||
// If user data empty return.
|
||||
if (this.userData.isEmpty()) return;
|
||||
|
||||
// Check if user data contains keys.
|
||||
if (this.userData.containsKey(uuid)) {
|
||||
// Remove user when done.
|
||||
this.userData.remove(uuid);
|
||||
|
||||
// Save the file then load the changes back in.
|
||||
reload(uuid, serverExit);
|
||||
}
|
||||
}
|
||||
|
||||
private void reload(UUID uuid, boolean serverExit) {
|
||||
try {
|
||||
File file = new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml");
|
||||
|
||||
save(file);
|
||||
|
||||
if (!serverExit) load(uuid);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(boolean serverExit) {
|
||||
// If user data empty return.
|
||||
if (this.userData.isEmpty()) return;
|
||||
|
||||
// If the player is not leaving, continue here as we are stopping the server or doing periodic save.
|
||||
this.userData.forEach((id, user) -> {
|
||||
//user.getKeys().forEach((crateMap, keys) -> set("users." + id + "." + crateMap, keys));
|
||||
|
||||
// Save the file then load the changes back in.
|
||||
reload(id, serverExit);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(File file, UUID uuid, StorageType storageType) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAuction(UUID uuid) {
|
||||
Player player = this.plugin.getServer().getPlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFile(Path path, UUID uuid) {
|
||||
return new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserData getUser(UUID uuid) {
|
||||
Player player = this.plugin.getServer().getPlayer(uuid);
|
||||
|
||||
// Return with their user data.
|
||||
return this.userData.get(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, UserData> getUsers() {
|
||||
return Collections.unmodifiableMap(this.userData);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.badbones69.crazyauctions.support;
|
||||
|
||||
import com.badbones69.crazyauctions.ApiManager;
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.config.types.PluginConfig;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PlaceholderSupport {
|
||||
|
||||
private static final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
public static String setPlaceholders(String placeholder) {
|
||||
placeholder = placeholder.replaceAll("\\{prefix}", ApiManager.getPluginConfig().getProperty(PluginConfig.COMMAND_PREFIX));
|
||||
|
||||
return placeholder;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.badbones69.crazyauctions.support.economy;
|
||||
|
||||
/**
|
||||
* Description: This event is fired when an item is added to an auction house.
|
||||
*/
|
||||
public enum Currency {
|
||||
|
||||
VAULT("Vault"),
|
||||
XP_LEVEL("XP_Level"),
|
||||
XP_TOTAL("XP_Total");
|
||||
|
||||
private final String name;
|
||||
|
||||
Currency(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if it is a compatible currency.
|
||||
* @param currency The currency name you are checking.
|
||||
* @return True if it is supported and false if not.
|
||||
*/
|
||||
public static boolean isCurrency(String currency) {
|
||||
for (Currency value : Currency.values()) {
|
||||
if (currency.equalsIgnoreCase(value.getName())) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a currency enum.
|
||||
* @param currency The currency you want.
|
||||
* @return The currency enum.
|
||||
*/
|
||||
public static Currency getCurrency(String currency) {
|
||||
for (Currency value : Currency.values()) {
|
||||
if (currency.equalsIgnoreCase(value.getName())) return value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the currency.
|
||||
* @return The name of the currency.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
package com.badbones69.crazyauctions.support.economy;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Description: Defines what currency to use.
|
||||
*/
|
||||
public class CurrencyAPI {
|
||||
|
||||
// TODO() Add item support as a currency.
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
/**
|
||||
* Get the amount that a player has from a specific currency.
|
||||
*
|
||||
* @param uuid - The uuid of the player.
|
||||
* @param currency - The currency you wish to get from.
|
||||
* @return amount that the player has of that currency.
|
||||
*/
|
||||
public int getCurrency(UUID uuid, Currency currency) {
|
||||
try {
|
||||
OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(uuid);
|
||||
Player player = plugin.getServer().getPlayer(uuid);
|
||||
|
||||
switch (currency) {
|
||||
case VAULT: //if (player != null) return (int) plugin.getVaultSupport().getVault().getBalance(player);
|
||||
|
||||
case XP_LEVEL: if (player != null) return player.getLevel();
|
||||
|
||||
case XP_TOTAL: if (player != null) return getTotalExperience(player);
|
||||
}
|
||||
} catch (Exception | NoClassDefFoundError ignored) {}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take an amount from a player's currency.
|
||||
*
|
||||
* @param uuid - The uuid of the player.
|
||||
* @param currency - The currency you wish to use.
|
||||
* @param amount - The amount you want to take.
|
||||
*/
|
||||
public void takeCurrency(UUID uuid, Currency currency, int amount) {
|
||||
try {
|
||||
Player player = plugin.getServer().getPlayer(uuid);
|
||||
|
||||
switch (currency) {
|
||||
//case VAULT: if (player != null) plugin.getVaultSupport().getVault().withdrawPlayer(player, amount);
|
||||
case XP_LEVEL: if (player != null) player.setLevel(player.getLevel() - amount);
|
||||
case XP_TOTAL: if (player != null) takeTotalExperience(player, amount);
|
||||
}
|
||||
} catch (Exception | NoClassDefFoundError ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Give an amount to a player's currency.
|
||||
*
|
||||
* @param uuid - The uuid of the player.
|
||||
* @param currency - The currency you want to use.
|
||||
* @param amount - The amount you are giving to the player.
|
||||
*/
|
||||
public void giveCurrency(UUID uuid, Currency currency, int amount) {
|
||||
try {
|
||||
Player player = plugin.getServer().getPlayer(uuid);
|
||||
|
||||
switch (currency) {
|
||||
//case VAULT: if (player != null) plugin.getVaultSupport().getVault().depositPlayer(player, amount);
|
||||
case XP_LEVEL: if (player != null) player.setLevel(player.getLevel() + amount);
|
||||
case XP_TOTAL: if (player != null) takeTotalExperience(player, -amount);
|
||||
}
|
||||
} catch (Exception | NoClassDefFoundError ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has enough of a currency.
|
||||
*
|
||||
* @param uuid - The uuid of the player.
|
||||
* @param currency The currency you wish to check.
|
||||
* @param cost The cost of the item you are checking.
|
||||
* @return true if they have enough to buy it or false if they don't.
|
||||
*/
|
||||
public boolean canBuy(UUID uuid, Currency currency, int cost) {
|
||||
return getCurrency(uuid, currency) >= cost;
|
||||
}
|
||||
|
||||
private void takeTotalExperience(Player player, int amount) {
|
||||
int total = getTotalExperience(player) - amount;
|
||||
player.setTotalExperience(0);
|
||||
player.setTotalExperience(total);
|
||||
player.setLevel(0);
|
||||
player.setExp(0);
|
||||
|
||||
while (total > player.getExpToLevel()) {
|
||||
total -= player.getExpToLevel();
|
||||
player.setLevel(player.getLevel() + 1);
|
||||
}
|
||||
|
||||
float xp = (float) total / (float) player.getExpToLevel();
|
||||
player.setExp(xp);
|
||||
}
|
||||
|
||||
private int getTotalExperience(Player player) { // https://www.spigotmc.org/threads/72804
|
||||
int experience;
|
||||
int level = player.getLevel();
|
||||
|
||||
if (level >= 0 && level <= 15) {
|
||||
experience = (int) Math.ceil(Math.pow(level, 2) + (6 * level));
|
||||
int requiredExperience = 2 * level + 7;
|
||||
double currentExp = Double.parseDouble(Float.toString(player.getExp()));
|
||||
experience += Math.ceil(currentExp * requiredExperience);
|
||||
return experience;
|
||||
} else if (level > 15 && level <= 30) {
|
||||
experience = (int) Math.ceil((2.5 * Math.pow(level, 2) - (40.5 * level) + 360));
|
||||
int requiredExperience = 5 * level - 38;
|
||||
double currentExp = Double.parseDouble(Float.toString(player.getExp()));
|
||||
experience += Math.ceil(currentExp * requiredExperience);
|
||||
return experience;
|
||||
} else {
|
||||
experience = (int) Math.ceil((4.5 * Math.pow(level, 2) - (162.5 * level) + 2220));
|
||||
int requiredExperience = 9 * level - 158;
|
||||
double currentExp = Double.parseDouble(Float.toString(player.getExp()));
|
||||
experience += Math.ceil(currentExp * requiredExperience);
|
||||
return experience;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.badbones69.crazyauctions.support.economy.vault;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Description: Vault support related code.
|
||||
*/
|
||||
public class VaultSupport {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private Economy vault = null;
|
||||
|
||||
public Economy getVault() {
|
||||
return vault;
|
||||
}
|
||||
|
||||
public void loadVault() {
|
||||
RegisteredServiceProvider<Economy> serviceProvider = plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
|
||||
if (serviceProvider != null) vault = serviceProvider.getProvider();
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.badbones69.crazyauctions.utils;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ItemUtils {
|
||||
|
||||
private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.badbones69.crazyauctions.utils.misc;
|
||||
|
||||
import com.badbones69.crazyauctions.ApiManager;
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.config.types.PluginConfig;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ColorUtils {
|
||||
|
||||
private static final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
public static String getPrefix() {
|
||||
return ApiManager.getPluginConfig().getProperty(PluginConfig.COMMAND_PREFIX);
|
||||
}
|
||||
}
|
@ -1,306 +0,0 @@
|
||||
Settings:
|
||||
Prefix: '&7[&4Crazy &bAuctions&7]: ' #Prefix of when you get Crazy Auctions Messages.
|
||||
GUIName: '&4Crazy &bAuctions&8' #Name of the Main GUI.
|
||||
Players-Current-Items: '&8Your Current Listings' #The Name of the Player Current Items GUI.
|
||||
Cancelled/Expired-Items: '&8Cancelled/Expired Listings' #Name of the Canceled/Expired GUI.
|
||||
Buying-Item: '&8Purchase Item: Are You Sure?' #Name of the Buying GUI.
|
||||
Bidding-On-Item: '&8You Are Bidding On This Item.' #Name of the Bidding GUI.
|
||||
Categories: '&8Categories' #Name of the Category GUI.
|
||||
Sell-Time: 2d #The time that each item will sell for.
|
||||
Bid-Time: 2m 30s #Time for each item that is biddable.
|
||||
Full-Expire-Time: 10d #The full time the item is in the crazy auctions.
|
||||
Bid-Winner-Time: 20d #The time the winner of a bid has to claim their prize.
|
||||
Minimum-Sell-Price: 10 #Minimum amount you can sell an item for.
|
||||
Max-Beginning-Sell-Price: 1000000 #Max amount you can sell an item for.
|
||||
Minimum-Bid-Price: 100 #Minimum starting bid.
|
||||
Max-Beginning-Bid-Price: 1000000 #Maximum starting bid.
|
||||
Allow-Damaged-Items: False #Allow items that have been damaged.
|
||||
Category-Page-Opens-First: False #If set to true the categories' page will open when they do /CA.
|
||||
Feature-Toggle: #Toggle if a feature is on or off.
|
||||
Selling: true #Able to use the selling part of the auction house.
|
||||
Bidding: true #Able to use the bidding part of the auction house.
|
||||
Patches:
|
||||
Macro-Dupe: true #Turn to false if you have an issue, but it should patch the bug.
|
||||
Sounds:
|
||||
Toggle: False #Disable the clicking sound.
|
||||
Sound: 'CLICK' #Make sure if you use 1.8 or lower you use the 1.8 sound and 1.9 and up use 1.9 sounds. The default sound is 1.8.
|
||||
#1.8 sounds are found here: http://badbones69.com/javadocs/1.8.8/org/bukkit/Sound.html
|
||||
#1.9 sounds are found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
|
||||
GUISettings: #Settings for things in the gui.
|
||||
SellingItemLore: #The lore on items that are being sold.
|
||||
- '&7-------------------------'
|
||||
- '&aClick here to purchase.'
|
||||
- ''
|
||||
- '&9Price: &e$%price%'
|
||||
- '&9Seller: &e%seller%'
|
||||
- '&7-------------------------'
|
||||
CurrentLore: #Lore on items that are in your current items GUI.
|
||||
- '&7-------------------------'
|
||||
- '&aClick here to cancel.'
|
||||
- ''
|
||||
- '&9Price: &e$%price%'
|
||||
- '&9Expire: &e%time%'
|
||||
- '&7-------------------------'
|
||||
Cancelled/ExpiredLore: #Lore on items that are in your canceled/expired GUI.
|
||||
- '&7-------------------------'
|
||||
- '&aClick here to return to you.'
|
||||
- ''
|
||||
- '&9Full Expire: &e%time%'
|
||||
- '&7-------------------------'
|
||||
Bidding: #Lore on Bidding Items.
|
||||
- '&7-------------------------'
|
||||
- '&aClick here to bid.'
|
||||
- ''
|
||||
- '&9Seller: &e%seller%'
|
||||
- '&9Current Bid: &e$%topbid%'
|
||||
- '&9Top Bidder: &e%topbidder%'
|
||||
- '&9Time Left: &e%time%'
|
||||
- '&7-------------------------'
|
||||
Category-Settings:
|
||||
Armor:
|
||||
Item: '315'
|
||||
Toggle: true
|
||||
Slot: 11
|
||||
Name: '&6&lArmor'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7armor that is currently being sold.'
|
||||
Weapons:
|
||||
Item: '283'
|
||||
Toggle: true
|
||||
Slot: 12
|
||||
Name: '&6&lWeapons'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7weapons that are currently being sold.'
|
||||
Tools:
|
||||
Item: '285'
|
||||
Toggle: true
|
||||
Slot: 13
|
||||
Name: '&6&lTools'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7tools that are currently being sold.'
|
||||
Food:
|
||||
Item: '322'
|
||||
Toggle: true
|
||||
Slot: 14
|
||||
Name: '&6&lFood'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7food that is currently being sold.'
|
||||
Potions:
|
||||
Item: '373:8227'
|
||||
Toggle: true
|
||||
Slot: 15
|
||||
Name: '&6&lPotions'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7potions that are currently being sold.'
|
||||
Blocks:
|
||||
Item: '2'
|
||||
Toggle: true
|
||||
Slot: 16
|
||||
Name: '&6&lBlocks'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7blocks that are currently being sold.'
|
||||
Other:
|
||||
Item: '371'
|
||||
Toggle: true
|
||||
Slot: 17
|
||||
Name: '&6&lOthers'
|
||||
Lore:
|
||||
- '&7This category contains all the'
|
||||
- '&7other items currently being sold.'
|
||||
None:
|
||||
Item: '166'
|
||||
Toggle: true
|
||||
Slot: 23
|
||||
Name: '&6&lNone'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7items currently being sold.'
|
||||
OtherSettings: #Other Settings for the GUIs.
|
||||
SellingItems: #The button for your current items.
|
||||
Item: '264' #The item that this button is.
|
||||
Toggle: true #If the item is in the gui or not.
|
||||
Slot: 46 #The slot it is in. I recommend not changing these. If you do make sure they are still in the bottom row.
|
||||
Name: '&6Items You are Selling' #Name of the item.
|
||||
Lore: #Lore of the item.
|
||||
- '&aClick here to view all the items you'
|
||||
- '&aare currently selling on the auction.'
|
||||
Cancelled/ExpiredItems: #The button for Canceled/Expired Items.
|
||||
Item: '394'
|
||||
Toggle: true
|
||||
Slot: 47
|
||||
Name: '&6Collect Expired / Canceled Items'
|
||||
Lore:
|
||||
- '&aClick here to view and collect all of the'
|
||||
- '&aitems you have canceled or has expired.'
|
||||
PreviousPage: #The button for Previous Page.
|
||||
Item: '339'
|
||||
Toggle: true
|
||||
Slot: 49
|
||||
Name: '&6Previous Page'
|
||||
Lore: { }
|
||||
Refesh: #The button for Refresh Page.
|
||||
Item: '175'
|
||||
Toggle: true
|
||||
Slot: 50
|
||||
Name: '&6Refresh Page'
|
||||
Lore: { }
|
||||
NextPage: #The button for Next Page.
|
||||
Item: '339'
|
||||
Toggle: true
|
||||
Slot: 51
|
||||
Name: '&6Next Page'
|
||||
Lore: { }
|
||||
Category1: #The button for Next Page.
|
||||
Item: '54'
|
||||
Toggle: true
|
||||
Slot: 52
|
||||
Name: '&6Categories'
|
||||
Lore:
|
||||
- '&bCurrent Category: &6%category%'
|
||||
- '&aWant to see items in specific categories?'
|
||||
- '&aClick here to see all categories of items.'
|
||||
Category2: #The button for Next Page.
|
||||
Item: '54'
|
||||
Toggle: true
|
||||
Slot: 48
|
||||
Name: '&6Categories'
|
||||
Lore:
|
||||
- '&bCurrent Category: &6%category%'
|
||||
- '&aWant to see items in specific categories?'
|
||||
- '&aClick here to see all categories of items.'
|
||||
Bidding/Selling: #Switch between Bidding and Selling.
|
||||
Selling:
|
||||
Item: '341'
|
||||
Toggle: true
|
||||
Slot: 53
|
||||
Name: '&6Currently looking at items being sold.'
|
||||
Lore:
|
||||
- '&7&l(&6&l!&7&l) &7Click here to see items'
|
||||
- '&7that you can bid on.'
|
||||
Bidding:
|
||||
Item: '378'
|
||||
Toggle: true
|
||||
Slot: 53
|
||||
Name: '&6Currently looking at items that can be bid on.'
|
||||
Lore:
|
||||
- '&7&l(&6&l!&7&l) &7Click here to see items'
|
||||
- '&7that you can buy at a price.'
|
||||
WhatIsThis: #The info on all the Books buttons.
|
||||
SellingShop: #The Book in the main shop.
|
||||
Item: '340'
|
||||
Toggle: true
|
||||
Slot: 54
|
||||
Name: '&6What Is This Page?'
|
||||
Lore:
|
||||
- '&aThis is the crazy auctions, here you can'
|
||||
- '&aput items for sale, and buy items'
|
||||
- '&athat others have put for sale.'
|
||||
- ''
|
||||
- '&aThe auction is also a great place to make'
|
||||
- '&amoney by selling items that others'
|
||||
- '&amay be interested in buying.'
|
||||
BiddingShop: #The Book in the main shop.
|
||||
Item: '340'
|
||||
Toggle: true
|
||||
Slot: 54
|
||||
Name: '&6What Is This Page?'
|
||||
Lore:
|
||||
- '&aThis is the crazy auctions, here you can'
|
||||
- '&aput items for sale, and bid on items'
|
||||
- '&athat others have put for sale.'
|
||||
- ''
|
||||
- '&aThe bidding auction is also a great place to'
|
||||
- '&amake money by bidding off items that others'
|
||||
- '&amay be interested in bidding on.'
|
||||
CurrentItems: #The Book in the Current items GUI.
|
||||
Item: '340'
|
||||
Toggle: true
|
||||
Slot: 54
|
||||
Name: '&6What Is This Page?'
|
||||
Lore:
|
||||
- '&aThese are your current listings, all of'
|
||||
- '&athe items you currenty have listed on'
|
||||
- '&acrazy auctions are displayed here.'
|
||||
- ''
|
||||
- '&aYou can cancel and view your listings'
|
||||
- '&aexpire time here.'
|
||||
Cancelled/ExpiredItems: #The Book in the Canceled/Expired Items GUI.
|
||||
Item: '340'
|
||||
Toggle: true
|
||||
Slot: 54
|
||||
Name: '&6What Is This Page?'
|
||||
Lore:
|
||||
- '&aThis page houses all of your cancelled and'
|
||||
- '&aexpired items, when a listings is cancelled'
|
||||
- '&aor expires you will be able to return that'
|
||||
- '&aitem back to you from this menu.'
|
||||
- ''
|
||||
- '&aJust click on the item and if you have enough'
|
||||
- '&ainventory space you will receive that item.'
|
||||
Viewing: #The Book in the Viewing Items GUI.
|
||||
Item: '340'
|
||||
Toggle: true
|
||||
Slot: 50
|
||||
Name: '&6What Is This Page?'
|
||||
Lore:
|
||||
- '&aThis page shows all the items that'
|
||||
- '&aa player has currently on the bidding'
|
||||
- '&aand selling market. You can quickly see'
|
||||
- '&awhat a specific player is selling.'
|
||||
Categories: #The Book in the Viewing Items GUI.
|
||||
Item: '340'
|
||||
Toggle: true
|
||||
Slot: 54
|
||||
Name: '&6What Is This Page?'
|
||||
Lore:
|
||||
- '&aThis page shows all the categories'
|
||||
- '&athat you can choose from. When you click'
|
||||
- '&aa category it will open the gui with only'
|
||||
- '&aitems that belong to that category.'
|
||||
Back: #The Back Buttons.
|
||||
Item: '339'
|
||||
Slot: 46
|
||||
Name: '&6Back'
|
||||
Return: #The Return Buttons.
|
||||
Item: '390'
|
||||
Slot: 50
|
||||
Name: '&6Return All'
|
||||
Lore:
|
||||
- '&aClick here to return all cancelled'
|
||||
- '&aand expired items to your inventory.'
|
||||
Confirm: #The Confirm Buttons.
|
||||
Item: '160:5'
|
||||
Name: '&aConfirm'
|
||||
Cancel: #The Cancel Buttons.
|
||||
Item: '160:14'
|
||||
Name: '&cCancel'
|
||||
Your-Item: #The item that shows when you try to buy/bid on your item.
|
||||
Item: '166'
|
||||
Name: '&cYou Can''t Purchase Your Own Item.'
|
||||
Cant-Afford: #The item that shows when you can't afford this item.
|
||||
Item: '166'
|
||||
Name: '&cYou Can''t Afford This Item.'
|
||||
Top-Bidder: #The item for when a player is already the top bidder.
|
||||
Item: '166'
|
||||
Name: '&cYou are already the top bidder.'
|
||||
Bidding: #The item in the middle when bidding on an item.
|
||||
Item: '160:15'
|
||||
Name: '&7Bidding'
|
||||
Lore:
|
||||
- '&7<--&aAdd &cRemove&7-->'
|
||||
- '&9Your Current Bid: &e$%bid%'
|
||||
- '&9Current Top Bid: &e$%topbid%'
|
||||
Bid: #The button for when you want to confirm your bid.
|
||||
Item: '160:3'
|
||||
Name: '&bBid Now'
|
||||
Lore:
|
||||
- '&7Click here to Bid Now.'
|
||||
BlackList:
|
||||
- '7'
|
||||
- '120'
|
@ -9,9 +9,5 @@ pluginManagement {
|
||||
|
||||
rootProject.name = "CrazyAuctions"
|
||||
|
||||
listOf(
|
||||
"paper",
|
||||
"common"
|
||||
).forEach {
|
||||
include(it)
|
||||
}
|
||||
include("common")
|
||||
include("paper")
|
Loading…
Reference in New Issue
Block a user