Push latest chanages

This commit is contained in:
Ryder Belserion 2023-02-18 00:48:54 -05:00
parent abc28d901b
commit b53c9dd864
No known key found for this signature in database
GPG Key ID: 8FC2E6C54BBF05FE
26 changed files with 1261 additions and 19 deletions

View File

@ -17,12 +17,17 @@ license {
include("**/*.java")
}
//java {
// toolchain.languageVersion.set(JavaLanguageVersion.of(project.properties["java_version"].toString()))
//}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(project.properties["java_version"].toString()))
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks {
compileJava {
options.release.set(project.properties["java_version"].toString().toInt())
}
}
//tasks {
// compileJava {
// options.release.set(project.properties["java_version"].toString().toInt())
// }
//}

View File

@ -34,6 +34,8 @@ dependencies {
implementation(libs.triumph.gui)
implementation(libs.triumph.cmds)
implementation(libs.vault.api)
}
val projectDescription = settings.versions.projectDescription.get()

View File

@ -1,5 +1,7 @@
package com.badbones69.crazyauctions;
import com.badbones69.crazyauctions.api.economy.vault.VaultSupport;
import com.badbones69.crazyauctions.api.enums.PluginSupport;
import com.badbones69.crazyauctions.configs.Config;
import net.dehya.ruby.PaperManager;
import net.dehya.ruby.RubyCore;
@ -12,7 +14,11 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore {
private static CrazyAuctions plugin;
private final PaperManager paperManager = new PaperManager(this, true);;
private final PaperManager paperManager = new PaperManager(this, true);
private final PluginSupport pluginSupport;
private final Starter starter;
public CrazyAuctions() {
super();
@ -28,6 +34,12 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore {
}
plugin = this;
this.pluginSupport = new PluginSupport();
this.starter = new Starter();
this.pluginSupport.loadCurrency();
}
@Override
@ -57,4 +69,16 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore {
public PaperManager getPaperManager() {
return this.paperManager;
}
public PluginSupport getPluginSupport() {
return this.pluginSupport;
}
public Starter getStarter() {
return this.starter;
}
public VaultSupport getVaultSupport() {
return this.starter.getVaultSupport();
}
}

View File

@ -0,0 +1,27 @@
package com.badbones69.crazyauctions;
import com.badbones69.crazyauctions.api.economy.vault.VaultSupport;
import com.badbones69.crazyauctions.api.enums.PluginSupport;
public class Starter {
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
private VaultSupport vaultSupport;
public void init() {
if (getVaultSupport() != null && PluginSupport.SupportedPlugins.VAULT.isPluginLoaded()) plugin.getLogger().warning("Vault support is now enabled.");
}
public Starter setVaultSupport(VaultSupport vaultSupport) {
this.vaultSupport = vaultSupport;
this.vaultSupport.loadVault();
return this;
}
public VaultSupport getVaultSupport() {
return this.vaultSupport;
}
}

View File

@ -0,0 +1,48 @@
package com.badbones69.crazyauctions.api.economy;
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;
}
}

View File

@ -0,0 +1,131 @@
package com.badbones69.crazyauctions.api.economy;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.UUID;
public class CurrencyAPI {
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
/**
* 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;
}
}
}

View File

@ -0,0 +1,22 @@
package com.badbones69.crazyauctions.api.economy.vault;
import com.badbones69.crazyauctions.CrazyAuctions;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultSupport {
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
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();
}
}

View File

@ -0,0 +1,112 @@
package com.badbones69.crazyauctions.api.enums;
import com.badbones69.crazyauctions.CrazyAuctions;
import com.badbones69.crazyauctions.api.economy.vault.VaultSupport;
import com.badbones69.crazyauctions.utils.utilities.misc.ColorUtils;
import org.bukkit.plugin.Plugin;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PluginSupport {
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
private final Map<SupportedPlugins, Boolean> cachedPlugins = new HashMap<>();
public void updateHooks() {
cachedPlugins.clear();
for (SupportedPlugins supportedPlugin : SupportedPlugins.values()) {
if (supportedPlugin.isPluginLoaded() && supportedPlugin.getLoadedPlugin().isEnabled()) {
String website = supportedPlugin.getLoadedPlugin().getDescription().getWebsite();
List<String> author = supportedPlugin.getLoadedPlugin().getDescription().getAuthors();
String name = supportedPlugin.getLoadedPlugin().getDescription().getName();
String main = supportedPlugin.getLoadedPlugin().getDescription().getMain();
switch (supportedPlugin) {
default: supportedPlugin.addPlugin(true);
}
} else {
supportedPlugin.addPlugin(false);
}
}
printHooks();
}
public void printHooks() {
if (cachedPlugins.isEmpty()) updateHooks();
plugin.getLogger().info(ColorUtils.color("&8&l=== &e&lCrazyAuctions Hook Status &8&l==="));
cachedPlugins.keySet().forEach(value -> {
if (value.isPluginLoaded()) {
plugin.getLogger().info(ColorUtils.color("&6&l" + value.name() + " &a&lFOUND"));
} else {
plugin.getLogger().info(ColorUtils.color("&6&l" + value.name() + " &c&lNOT FOUND"));
}
});
}
/**
* Loads the currency if it is on the server.
*/
public void loadCurrency() {
for (SupportedPlugins supportedPlugin : SupportedPlugins.values()) {
if (supportedPlugin.isPluginLoaded() && supportedPlugin.getLoadedPlugin().isEnabled()) {
switch (supportedPlugin) {
case VAULT: this.plugin.getStarter().setVaultSupport(new VaultSupport()).init();
}
return;
}
}
plugin.getLogger().warning("No economy plugin found, Any economy based feature will not work.");
}
public enum SupportedPlugins {
// Economy Plugins
VAULT("Vault"),
// Region Protection
WORLDGUARD("WorldGuard"),
WORLDEDIT("WorldEdit");
private final String pluginName;
SupportedPlugins(String pluginName) {
this.pluginName = pluginName;
}
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
private final PluginSupport pluginSupport = plugin.getPluginSupport();
public boolean isPluginLoaded() {
return plugin.getServer().getPluginManager().getPlugin(pluginName) != null;
}
public Plugin getLoadedPlugin() {
return plugin.getServer().getPluginManager().getPlugin(pluginName);
}
public boolean isCachedPluginLoaded() {
return pluginSupport.cachedPlugins.get(this);
}
public void addPlugin(boolean value) {
pluginSupport.cachedPlugins.put(this, value);
}
public void removePlugin() {
pluginSupport.cachedPlugins.remove(this);
}
public boolean isPluginEnabled() {
return pluginSupport.cachedPlugins.get(this);
}
}
}

View File

@ -0,0 +1,112 @@
package com.badbones69.crazyauctions.api.enums;
import com.badbones69.crazyauctions.CrazyAuctions;
/**
* @author Badbones69
*/
public enum ServerProtocol {
TOO_OLD(1),
v1_8_R1(181), v1_8_R2(182), v1_8_R3(183),
v1_9_R1(191), v1_9_R2(192),
v1_10_R1(1101),
v1_11_R1(1111),
v1_12_R1(1121),
v1_13_R2(1132),
v1_14_R1(1141),
v1_15_R1(1151),
v1_16_R1(1161), v1_16_R2(1162),v1_16_R3(1163),
v1_17_R1(1171),
v1_18_R2(1182),
v1_19_R1(1191),
v1_19_R2(1192),
v1_19_R3(1192),
TOO_NEW(-2);
private static ServerProtocol currentProtocol;
private static ServerProtocol latest;
private static final CrazyAuctions plugin = CrazyAuctions.getPlugin();
private final int versionProtocol;
ServerProtocol(int versionProtocol) {
this.versionProtocol = versionProtocol;
}
public static ServerProtocol getCurrentProtocol() {
String serVer = plugin.getServer().getClass().getPackage().getName();
int serProt = Integer.parseInt(
serVer.substring(
serVer.lastIndexOf('.') + 1
).replace("_", "").replace("R", "").replace("v", "")
);
for (ServerProtocol protocol : values()) {
if (protocol.versionProtocol == serProt) {
currentProtocol = protocol;
break;
}
}
if (currentProtocol == null) currentProtocol = ServerProtocol.TOO_NEW;
return currentProtocol;
}
public static boolean isLegacy() {
return isOlder(ServerProtocol.v1_13_R2);
}
public static ServerProtocol getLatestProtocol() {
if (latest != null) return latest;
ServerProtocol old = ServerProtocol.TOO_OLD;
for (ServerProtocol protocol : values()) {
if (protocol.compare(old) == 1) old = protocol;
}
return old;
}
public static boolean isAtLeast(ServerProtocol protocol) {
if (currentProtocol == null) getCurrentProtocol();
int proto = currentProtocol.versionProtocol;
return proto >= protocol.versionProtocol || proto == -2;
}
public static boolean isNewer(ServerProtocol protocol) {
if (currentProtocol == null) getCurrentProtocol();
return currentProtocol.versionProtocol > protocol.versionProtocol || currentProtocol.versionProtocol == -2;
}
public static boolean isSame(ServerProtocol protocol) {
if (currentProtocol == null) getCurrentProtocol();
return currentProtocol.versionProtocol == protocol.versionProtocol;
}
public static boolean isOlder(ServerProtocol protocol) {
if (currentProtocol == null) getCurrentProtocol();
int proto = currentProtocol.versionProtocol;
return proto < protocol.versionProtocol || proto == -1;
}
public int compare(ServerProtocol protocol) {
int result = -1;
int current = versionProtocol;
int check = protocol.versionProtocol;
if (current > check || check == -2) {
result = 1;
} else if (current == check) {
result = 0;
}
return result;
}
}

View File

@ -0,0 +1,5 @@
package com.badbones69.crazyauctions.api.enums.eco;
public enum AuctionCategory {
}

View File

@ -0,0 +1,25 @@
package com.badbones69.crazyauctions.api.enums.eco;
public enum AuctionType {
SELL_TYPE(""),
BID_TYPE("");
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;
}
}

View File

@ -0,0 +1,66 @@
package com.badbones69.crazyauctions.api.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
*
* @author Ryder Belserion
*
* This event is fired when a player bids on an auction.
*
*/
public class AuctionBidEvent extends Event {
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 = Bukkit.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;
}
}

View File

@ -0,0 +1,67 @@
package com.badbones69.crazyauctions.api.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
*
* @author Ryder Belserion
*
* This event is fired when a player buys an item.
*
*/
public class AuctionBuyEvent extends Event {
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 = Bukkit.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;
}
}

View File

@ -0,0 +1,83 @@
package com.badbones69.crazyauctions.api.events;
import org.bukkit.Bukkit;
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.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
*
* @author Ryder Belserion
*
* This event is fired when an auction is cancelled.
*
*/
public class AuctionCancelEvent extends Event {
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 = Bukkit.getPlayer(uuid);
this.offlinePlayer = Bukkit.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;
}
}

View File

@ -0,0 +1,56 @@
package com.badbones69.crazyauctions.api.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
*
* @author Ryder Belserion
*
* This event is fired when an auction expires.
*
*/
public class AuctionExpireEvent extends Event {
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 = Bukkit.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;
}
}

View File

@ -0,0 +1,67 @@
package com.badbones69.crazyauctions.api.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
*
* @author Ryder Belserion
*
* This event is fired when a player bids on an auction.
*
*/
public class AuctionListEvent extends Event {
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 = Bukkit.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;
}
}

View File

@ -0,0 +1,67 @@
package com.badbones69.crazyauctions.api.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
*
* @author Ryder Belserion
*
* This event is fired when an auction has a winner.
*
*/
public class AuctionWinEvent extends Event {
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 = Bukkit.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;
}
}

View File

@ -2,26 +2,43 @@ package com.badbones69.crazyauctions.configs;
import com.badbones69.crazyauctions.CrazyAuctions;
import net.dehya.ruby.common.annotations.FileBuilder;
import net.dehya.ruby.common.annotations.yaml.BlockType;
import net.dehya.ruby.common.annotations.yaml.Comment;
import net.dehya.ruby.common.annotations.yaml.Header;
import net.dehya.ruby.common.annotations.yaml.Key;
import net.dehya.ruby.common.enums.FileType;
import net.dehya.ruby.files.FileExtension;
@FileBuilder(isLogging = true, isAsync = true, isData = false, fileType = FileType.YAML)
@Header("""
/*@Header("""
Discord: https://discord.gg/crazycrew
Github: https://github.com/Crazy-Crew
Report Issues: https://github.com/Crazy-Crew/CrazyAuctions/issues
Request Features/Support: https://github.com/orgs/Crazy-Crew/discussions
""")
""")*/
public class Config extends FileExtension {
@Key("settings.prefix")
@Comment("The prefix used in front of messages.")
public static String PREFIX = "&8[&bCrazyAuctions&8]: ";
@Key("settings.locale-file")
@Comment("The language file to use from the locale folder. Supported languages are English(en).")
@BlockType
public static String LOCALE_FILE = "locale-en.yml";
@Key("settings.update-checker")
@Comment("Whether you want to be notified when an update is published to Modrinth.")
public static boolean UPDATE_CHECKER = true;
@Key("settings.toggle-metrics")
@Comment("Whether metrics are sent to https://bstats.org or not.")
@Comment("Whether you want your server statistics to be sent to https://bstats.org/ ( Requires a restart! )")
public static boolean TOGGLE_METRICS = true;
@Key("settings.config-version")
@Comment("DO NOT TOUCH THIS: We use this to identify if your configs are outdated.")
public static int CONFIG_VERSION = 2;
public Config() {
super("config.yml");
}

View File

@ -0,0 +1,30 @@
package com.badbones69.crazyauctions.configs;
import com.badbones69.crazyauctions.CrazyAuctions;
import net.dehya.ruby.common.annotations.FileBuilder;
import net.dehya.ruby.common.enums.FileType;
import net.dehya.ruby.files.FileExtension;
import java.nio.file.Path;
@FileBuilder(isLogging = true, isAsync = false, isData = false, fileType = FileType.YAML)
/*@Header("""
If you notice any translation issues, Do not hesitate to contact our Translators.
Discord: https://discord.gg/crazycrew
Github: https://github.com/Crazy-Crew
Report Issues: https://github.com/Crazy-Crew/CrazyCrates/issues
Request Features/Support: https://github.com/orgs/Crazy-Crew/discussions
""")*/
public class Locale extends FileExtension {
public Locale(Path path) {
super(Config.LOCALE_FILE, path.resolve("locale"));
}
public static void reload(CrazyAuctions plugin) {
plugin.getPaperManager().getPaperFileManager().extract("/locale", plugin.getDirectory());
plugin.getPaperManager().getPaperFileManager().addFile(new Locale(plugin.getDirectory()));
}
}

View File

@ -0,0 +1,34 @@
package com.badbones69.crazyauctions.configs.convert;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class ConfigConversion {
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
public void convertConfig() {
File file = new File(this.plugin.getDataFolder() + "/config.yml");
File secondFile = new File(this.plugin.getDataFolder() + "/config-v1.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
if (yamlConfiguration.getString("Settings.Config-Version") == null && !secondFile.exists()) {
this.plugin.getLogger().warning("Could not find Config-Version, I am assuming configurations have been converted.");
return;
}
if (file.renameTo(secondFile)) this.plugin.getLogger().warning("Renamed " + file.getName() + " to config-v1.yml");
YamlConfiguration secondConfiguration = YamlConfiguration.loadConfiguration(secondFile);
try {
yamlConfiguration.save(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,11 @@
package com.badbones69.crazyauctions.utils;
import com.badbones69.crazyauctions.api.enums.ServerProtocol;
import org.bukkit.Material;
public class ItemUtils {
public static Material getMaterial(String newMaterial, String oldMaterial) {
return Material.matchMaterial(ServerProtocol.isNewer(ServerProtocol.v1_12_R1) ? newMaterial : oldMaterial);
}
}

View File

@ -0,0 +1,93 @@
package com.badbones69.crazyauctions.utils.utilities.misc;
import com.badbones69.crazyauctions.api.enums.ServerProtocol;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ColorUtils {
private static final Pattern HEX_PATTERN = Pattern.compile("#[a-fA-F\\d]{6}");
public static String color(String message) {
if (ServerProtocol.isNewer(ServerProtocol.v1_15_R1)) {
Matcher matcher = HEX_PATTERN.matcher(message);
StringBuffer buffer = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(buffer, ChatColor.valueOf(matcher.group()).toString());
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}
return ChatColor.translateAlternateColorCodes('&', message);
}
public static void color(List<Color> colors, String colorString) {
if (colorString.contains(", ")) {
for (String color : colorString.split(", ")) {
Color c = getColor(color);
if (c != null) colors.add(c);
}
} else {
Color c = getColor(colorString);
if (c != null) colors.add(c);
}
}
public static Color getColor(String color) {
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 "YELLOW":
return Color.YELLOW;
}
return Color.WHITE;
}
public static String removeColor(String msg) {
return ChatColor.stripColor(msg);
}
public static String getPrefix(String string) {
return "Fuck Off";
//return color(Files.CONFIG.getFile().getString("Settings.Prefix") + string);
}
public static String getPrefix() {
return getPrefix("");
}
}

View File

@ -0,0 +1,52 @@
package com.badbones69.crazyauctions.utils.utilities.misc;
public class NumberUtils {
public static boolean isInt(String value) {
try {
Integer.parseInt(value);
} catch (NumberFormatException nfe) {
return false;
}
return true;
}
/**
* This converts a String into a number if using a roman numeral from I-X.
* @param level The string you want to convert.
* @return The roman numeral as a number.
*/
public static int convertLevelInteger(String level) {
switch (level) {
case "I": return 1;
case "II": return 2;
case "III": return 3;
case "IV": return 4;
case "V": return 5;
case "VI": return 6;
case "VII": return 7;
case "VIII": return 8;
case "IX": return 9;
case "X": return 10;
default: {
if (isInt(level)) {
return Integer.parseInt(level);
} else {
return 0;
}
}
}
}
}

View File

@ -1,8 +1,8 @@
# Discord: https://discord.gg/crazycrew
# Github: https://github.com/Crazy-Crew
#
# Report Issues: https://github.com/Crazy-Crew/CrazyAuctions/issues
# Request Features/Support: https://github.com/orgs/Crazy-Crew/discussions
settings:
toggle-metrics: true # Whether metrics are sent to https://bstats.org or not.
prefix: "&8[&bCrazyAuctions&8]: " # The prefix used in front of messages.
verbose-logging: false # Whether you want to have extra logging enabled... Currently does nothing!
update-checker: true # Whether you want to be notified when an update is published to Modrinth.
toggle-metrics: true # Whether you want your server statistics to be sent to https://bstats.org/ ( Requires a restart! )
config-version: 2 # DO NOT TOUCH THIS: We use this to identify if configs are outdated.

View File

@ -0,0 +1,86 @@
misc:
unknown-command: '&cThis command is not known.'
reload-plugin: '&7You have reloaded CrazyAuctions.'
errors:
internal-error: '&cAn internal error has occurred. Please check the console for the full error.'
player:
purchased-item: '&7You have bought an item for &a$%price%.'
won-bidding: '&7You have won a bid for &a$%price%. &7Use &c/ah collect &7to collect your winnings.'
item-sold: '&7Thank you for purchasing this item.'
requirements:
not-a-number: '&a%arg% &cis not a number.'
too-many-args: '&cYou put more arguments then I can handle.'
not-enough-args: '&cYou did not supply enough arguments.'
must-be-player: '&cYou must be a player to use this command.'
must-be-console-sender: '&cYou must be using console to use this command.'
must-have-item-in-hand: '&cYou must have an item in your hand.'
target-not-online: '&cThe player &6%player% &cis not online.'
target-same-player: '&cYou cannot use this command on yourself.'
no-permission: '&cYou do not have permission to use that command!'
inventory-not-empty: '&cInventory is not empty, Please make room in your inventory before buying/retrieving items.'
admin:
force-cancelled: '&7You have force-cancelled the sale belonging to &c%player%.'
force-cancelled-player: '&cOne of the items you had was force cancelled by an admin.'
auctions:
other:
player-bought-item: '&7%player% &chas bought your item for &a$%price%.'
player-won-your-bid: '&7%player% &chas won your item with a bid of &a$%price%.'
fixes:
book-not-allowed: '&cThat book is not able to be sold in the auctionhouse.'
items:
damaged-goods: '&cThat item is considered damaged goods and cannot be sold.'
blacklisted: '&cThat item is not allowed to be sold here.'
max-amount: '&cYou can''t list any more items in the auctionhouse.'
invalid-item: '&cThat item isn''t in the auctionhouse anymore.'
expired-item: '&cAn item in your auctionhouse has expired.'
cancelled-item: '&7You have cancelled an item that was in the auctionhouse, View &c/ah expired &7to view your items.'
returned-item: '&7Item has been returned.'
added-item-to-auction: '&7You have added an item to the auctionhouse for &a$%price%.'
economy:
money-required: '&cYou need &a$%money_needed% &cto purchase this.'
invalid-currency: '&cThat is not a currency, Valid Types: %currencies%'
bidding:
disabled: '&cThe ability to bid for items is disabled.'
successful: '&7You have bid &a$%bid% &7on that item.'
price:
low: '&cStarting bid price is too low, The minimum is &a$100.'
high: '&cStarting bid price is too high, The maximum is &a$1000000.'
bid-lower-than-current-bid: '&cThe bid you tried to place is lower than &a%current_bid%, &cPlease raise your bid!'
selling:
disabled: '&cThe ability to sell for items is disabled.'
price:
low: '&cSell price is too low, The minimum is &a$10.'
high: '&cSell price is too high, The maximum is &a$1000000.'
world-disabled: '&cAuctions are disabled in &a%world%.'
command:
#ah:
# msg: ''
#view:
# msg: ''
#sell:
# msg: ''
#expired:
# msg: ''
#listed:
# msg: ''
admin-help:
- ' &eCrazyAuctions Admin Help'
- ''
- '&8» &6/cc additem [crate] [prize] &7- &eAdd items in-game to a prize in a crate.'
player-help:
- ' &2CrazyAuctions Player Help'
- ''
- '&8» &6/ah &7- &eOpens the auctionhouse.'
- '&8» &6/ah view <player> &7- &eSee what a player is selling.'
- '&8» &6/ah sell/bid <price> [amount] &7- &eList the item you are holding on the crazy auction.'
- '&8» &6/ah expired/collect &7- &eView & manage your cancelled/expired items.'
- '&8» &6/ah listed &7- &eView/manage the items you are selling.'
- '&8» &6/ah help &7- &eView this help menu.'

View File

@ -4,7 +4,7 @@ main: "${group}.CrazyAuctions"
authors: [BadBones69, RyderBelserion]
version: ${version}
api-version: "1.17"
api-version: "1.13"
description: ${description}
website: ${website}