mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-12 10:24:29 +01:00
commit
d3a724a319
32
.gitignore
vendored
32
.gitignore
vendored
@ -1,20 +1,22 @@
|
||||
build
|
||||
.gradle
|
||||
.idea
|
||||
|
||||
core/.gradle
|
||||
core/build
|
||||
|
||||
fabric/.gradle
|
||||
fabric/build
|
||||
|
||||
paper/.gradle
|
||||
paper/build
|
||||
|
||||
build
|
||||
|
||||
buildSrc/build
|
||||
buildSrc/.gradle
|
||||
buildSrc/build
|
||||
|
||||
.vscode/
|
||||
core/bin/
|
||||
paper/bin/
|
||||
common/.gradle
|
||||
common/build
|
||||
|
||||
jars
|
||||
|
||||
paper/build
|
||||
paper/.gradle
|
||||
|
||||
paper/run
|
||||
!paper/run/config
|
||||
!paper/run/spigot.yml
|
||||
!paper/run/bukkit.yml
|
||||
!paper/run/eula.txt
|
||||
!paper/run/server.properties
|
||||
!paper/run/plugins
|
22
CONTRIBUTING.md
Normal file
22
CONTRIBUTING.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Contributing to CrazyCrates
|
||||
Contributions to the project are always welcome, Pull Requests do have some guidelines before being approved.
|
||||
|
||||
## You should always create the fork as a personal repository not in an organization.
|
||||
Any pull request made by a fork in an organization prevents modifications. Everyone has their own way of doing things and rather asking you to change that. A personal fork lets com change the things
|
||||
that we have a tick about.
|
||||
|
||||
If you do not use a personal fork, We have to manually merge your pull request which means it's marked as closed instead of merged.
|
||||
|
||||
## Requirements
|
||||
* `git`
|
||||
* Java 17 ( Adoptium is recommended )
|
||||
|
||||
Pull Requests must be labeled properly according to if it's a bug fix, a new feature or enhancements to the code base.
|
||||
* `git checkout -b fix/your_fix`
|
||||
* `git checkout -b feature/your_feature`
|
||||
* `git checkout -b quality/your_enhancement`
|
||||
* Commit your changes using `git commit -m 'your commit'`
|
||||
* Push to your branch using `git push`
|
||||
* Open a pull request to the `main` branch on our repository to add your change.
|
||||
|
||||
You must explain what your pull request is changing and if needed, Supply a video of your change as Pull Requests are a way to get feedback.
|
22
README.md
22
README.md
@ -1,8 +1,8 @@
|
||||
<br />
|
||||
|
||||
<div align="center">
|
||||
[![crazyauctions](https://raw.githubusercontent.com/RyderBelserion/Assets/main/crazycrew/webp/CrazyAuctionsBanner.webp)](https://modrinth.com/plugin/crazyauctions)
|
||||
|
||||
[![CrazyAuctions](https://raw.githubusercontent.com/RyderBelserion/Assets/main/crazycrew/webp/CrazyAuctionsBanner.webp)](https://modrinth.com/plugin/crazyauctions)
|
||||
<div align="center">
|
||||
|
||||
[![Contributors][contributors-shield]][contributors-url]
|
||||
[![Forks][forks-shield]][forks-url]
|
||||
@ -16,14 +16,14 @@
|
||||
![Purpur](https://cdn.jsdelivr.net/gh/intergrav/devins-badges/assets/compact/supported/purpur_vector.svg)
|
||||
|
||||
<p align="center">
|
||||
A crates plugin that offers quality crates with ease!
|
||||
Auction off your items in style!
|
||||
<br />
|
||||
<a href="https://docs.crazycrew.us/CrazyAuctions/home"><strong>Explore the docs »</strong></a>
|
||||
<a href="https://github.com/Crazy-Crew/CrazyAuctions/wiki"><strong>Explore the docs »</strong></a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://github.com/Crazy-Crew/CrazyAuctions/issues">Report Bug</a>
|
||||
·
|
||||
<a href="https://github.com/Crazy-Crew/CrazyAuctions/discussions/categories/features">Request Feature</a>
|
||||
<a href="https://github.com/Crazy-Crew/CrazyAuctions/discussions/categories/feature-requests">Request Feature</a>
|
||||
·
|
||||
<a href="https://discord.gg/badbones-s-live-chat-182615261403283459">Get Support</a>
|
||||
</p>
|
||||
@ -47,8 +47,12 @@
|
||||
</ol>
|
||||
</details>
|
||||
|
||||
### Resource Page
|
||||
<a href="https://modrinth.com/plugin/crazyzuctions">![Modrinth](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/compact/available/modrinth_46h.png)</a>
|
||||
## Resource Page
|
||||
|
||||
### Beta Builds
|
||||
All beta builds will be on Modrinth marked as beta.<br>
|
||||
|
||||
<a href="https://modrinth.com/plugin/crazyauctions">![Modrinth](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/available/modrinth_64h.png)</a>
|
||||
|
||||
## Getting Started
|
||||
|
||||
@ -75,7 +79,7 @@ A list of things necessary to make sure you can build CrazyAuctions properly.
|
||||
|
||||
## Roadmap
|
||||
|
||||
Check our public [trello board](https://trello.com/b/bzQ5TwXo) for our current plans, any bugs and general tracking of the project progress.
|
||||
Check our public [trello board](https://trello.com/b/CcPYmsBt) for our current plans, any bugs and general tracking of the project progress.
|
||||
|
||||
## Contributing
|
||||
|
||||
@ -83,7 +87,7 @@ Check our public [trello board](https://trello.com/b/bzQ5TwXo) for our current p
|
||||
2. Create your Feature Branch (`git checkout -b feature/yourfeature`)
|
||||
3. Commit your Changes (`git commit -m 'your amazing feature.'`)
|
||||
4. Push to the Branch (`git push`)
|
||||
5. Open a Pull Request to the `main` branch to add your feature/fix.
|
||||
5. Open a Pull Request to the dev branch to add your feature/fix.
|
||||
|
||||
## License
|
||||
|
||||
|
99
build.gradle
99
build.gradle
@ -1,71 +1,64 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
alias(libs.plugins.paperweight)
|
||||
alias(libs.plugins.shadowjar)
|
||||
|
||||
alias(libs.plugins.runpaper)
|
||||
}
|
||||
|
||||
defaultTasks 'build'
|
||||
project.group = "${rootProject.group}.paper"
|
||||
project.version = rootProject.version
|
||||
|
||||
def combineJars = tasks.register("combineJars", org.gradle.jvm.tasks.Jar) {
|
||||
mustRunAfter build
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
from(files(subprojects.findAll { it.name != 'webmap' }.collect {
|
||||
it.layout.buildDirectory.file("libs/${rootProject.name}-${it.name}-${it.version}.jar").get()
|
||||
}).filter { it.name != 'MANIFEST.MF' }.collect { if (it.isDirectory()) it else zipTree(it) })
|
||||
|
||||
doLast {
|
||||
File dir = new File(rootDir, "jars")
|
||||
|
||||
if (dir.exists()) dir.delete()
|
||||
|
||||
dir.mkdirs()
|
||||
|
||||
copy {
|
||||
from(layout.buildDirectory.file("libs/${rootProject.name}-${rootProject.version}.jar"))
|
||||
into(dir)
|
||||
}
|
||||
}
|
||||
base {
|
||||
archivesName = "${rootProject.name}-${project.name}"
|
||||
}
|
||||
|
||||
assemble {
|
||||
subprojects.forEach { project -> dependsOn ":${project.name}:build" }
|
||||
dependencies {
|
||||
implementation(libs.metrics)
|
||||
|
||||
finalizedBy combineJars
|
||||
compileOnly(libs.vault)
|
||||
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:$minecraftVersion-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java-library'
|
||||
tasks {
|
||||
runServer {
|
||||
jvmArgs("-Dnet.kyori.ansi.colorLevel=truecolor")
|
||||
|
||||
repositories {
|
||||
maven { url = 'https://repo.crazycrew.us/releases' }
|
||||
|
||||
maven { url = 'https://jitpack.io' }
|
||||
|
||||
mavenCentral()
|
||||
minecraftVersion(minecraftVersion)
|
||||
}
|
||||
|
||||
if (name == "paper") {
|
||||
repositories {
|
||||
maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
mergeServiceFiles()
|
||||
|
||||
exclude("META-INF/**")
|
||||
|
||||
List.of(
|
||||
"org.bstats"
|
||||
).forEach {
|
||||
relocate(it, "libs.$it")
|
||||
}
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = 'UTF-8'
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
processResources {
|
||||
filteringCharset = 'UTF-8'
|
||||
Map<String, String> props = new HashMap<>()
|
||||
|
||||
props.put("name", rootProject.name)
|
||||
props.put("version", "$rootProject.version")
|
||||
props.put("group", "$project.group")
|
||||
props.put("description", rootProject.description)
|
||||
|
||||
props.put("apiVersion", apiVersion)
|
||||
props.put("authors", authors)
|
||||
props.put("website", website)
|
||||
|
||||
inputs.properties(props)
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "
|
||||
cluster_paper = { module = "com.ryderbelserion.cluster.paper:cluster-paper", version.ref = "cluster_version" }
|
||||
cluster_api = { module = "com.ryderbelserion.cluster.api:cluster-api", version.ref = "cluster_version" }
|
||||
|
||||
nbtapi = { module = "de.tr7zw:item-nbt-api", version = "2.12.0" }
|
||||
vault = { module = "com.github.MilkBowl:VaultAPI", version = "1.7.1" }
|
||||
|
||||
triumph_cmds = { module = "dev.triumphteam:triumph-cmd-bukkit", version = "2.0.0-SNAPSHOT" }
|
||||
|
||||
|
@ -13,6 +13,10 @@ base {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.metrics)
|
||||
|
||||
compileOnly(libs.vault)
|
||||
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:$minecraftVersion-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
@ -31,6 +35,12 @@ tasks {
|
||||
mergeServiceFiles()
|
||||
|
||||
exclude("META-INF/**")
|
||||
|
||||
List.of(
|
||||
"org.bstats"
|
||||
).forEach {
|
||||
relocate(it, "libs.$it")
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
@ -47,7 +57,7 @@ tasks {
|
||||
|
||||
inputs.properties(props)
|
||||
|
||||
filesMatching("paper-plugin.yml") {
|
||||
filesMatching("plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,22 @@
|
||||
package com.badbones69.crazyauctions.paper;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.api.CrazyManager;
|
||||
import com.badbones69.crazyauctions.paper.api.FileManager;
|
||||
import com.badbones69.crazyauctions.paper.api.enums.Messages;
|
||||
import com.badbones69.crazyauctions.paper.api.support.PluginSupport;
|
||||
import com.badbones69.crazyauctions.paper.api.support.metrics.MetricsWrapper;
|
||||
import com.badbones69.crazyauctions.paper.commands.AuctionCommand;
|
||||
import com.badbones69.crazyauctions.paper.commands.AuctionTab;
|
||||
import com.badbones69.crazyauctions.paper.controllers.GuiListener;
|
||||
import com.badbones69.crazyauctions.paper.controllers.MarcoListener;
|
||||
import com.badbones69.crazyauctions.paper.currency.VaultSupport;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class CrazyAuctions extends JavaPlugin {
|
||||
|
||||
@ -13,15 +27,85 @@ public class CrazyAuctions extends JavaPlugin {
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private FileManager fileManager;
|
||||
private CrazyManager crazyManager;
|
||||
|
||||
private VaultSupport support;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Instantiate timer
|
||||
this.timer = new Timer();
|
||||
|
||||
this.fileManager = new FileManager();
|
||||
this.crazyManager = new CrazyManager();
|
||||
|
||||
this.fileManager.setup();
|
||||
this.crazyManager.load();
|
||||
|
||||
getServer().getPluginManager().registerEvents(new GuiListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new MarcoListener(), this);
|
||||
|
||||
registerCommand(getCommand("crazyauctions"), new AuctionTab(), new AuctionCommand());
|
||||
|
||||
// Run a task every 5 seconds to update auctions.
|
||||
TimerTask task = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Methods.updateAuction();
|
||||
}
|
||||
};
|
||||
|
||||
this.timer.scheduleAtFixedRate(task, 20L, 5000L);
|
||||
|
||||
// Add new messages.
|
||||
Messages.addMissingMessages();
|
||||
|
||||
// Enable vault support if enabled.
|
||||
if (PluginSupport.VAULT.isPluginEnabled()) {
|
||||
this.support = new VaultSupport();
|
||||
support.loadVault();
|
||||
}
|
||||
|
||||
// Create bstats instance.
|
||||
MetricsWrapper wrapper = new MetricsWrapper();
|
||||
wrapper.start();
|
||||
}
|
||||
|
||||
private void registerCommand(PluginCommand pluginCommand, TabCompleter tabCompleter, CommandExecutor commandExecutor) {
|
||||
if (pluginCommand != null) {
|
||||
pluginCommand.setExecutor(commandExecutor);
|
||||
|
||||
if (tabCompleter != null) pluginCommand.setTabCompleter(tabCompleter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Cancel all timers.
|
||||
if (this.timer != null) this.timer.cancel();
|
||||
if (timer != null) timer.cancel();
|
||||
|
||||
this.crazyManager.unload();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Timer getTimer() {
|
||||
return this.timer;
|
||||
}
|
||||
|
||||
public VaultSupport getSupport() {
|
||||
return this.support;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CrazyManager getCrazyManager() {
|
||||
return this.crazyManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FileManager getFileManager() {
|
||||
return this.fileManager;
|
||||
}
|
||||
|
||||
public boolean isLogging() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,457 @@
|
||||
package com.badbones69.crazyauctions.paper;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.api.FileManager.Files;
|
||||
import com.badbones69.crazyauctions.paper.api.enums.Messages;
|
||||
import com.badbones69.crazyauctions.paper.api.events.AuctionExpireEvent;
|
||||
import com.badbones69.crazyauctions.paper.api.events.AuctionWinBidEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Methods {
|
||||
|
||||
private final static CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
private final static Pattern HEX_PATTERN = Pattern.compile("#[a-fA-F0-9]{6}");
|
||||
|
||||
public static String color(String message) {
|
||||
Matcher matcher = HEX_PATTERN.matcher(message);
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(buffer, net.md_5.bungee.api.ChatColor.of(matcher.group()).toString());
|
||||
}
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return color(Files.CONFIG.getFile().getString("Settings.Prefix", ""));
|
||||
}
|
||||
|
||||
public static String getPrefix(String msg) {
|
||||
return color(Files.CONFIG.getFile().getString("Settings.Prefix", "") + msg);
|
||||
}
|
||||
|
||||
public static String removeColor(String msg) {
|
||||
return ChatColor.stripColor(msg);
|
||||
}
|
||||
|
||||
public static ItemStack makeItem(String type, int amount) {
|
||||
int ty = 0;
|
||||
|
||||
if (type.contains(":")) {
|
||||
String[] b = type.split(":");
|
||||
type = b[0];
|
||||
ty = Integer.parseInt(b[1]);
|
||||
}
|
||||
|
||||
Material m = Material.matchMaterial(type);
|
||||
ItemStack item;
|
||||
|
||||
try {
|
||||
item = new ItemStack(m, amount, (short) ty);
|
||||
} catch (Exception e) {
|
||||
item = new ItemStack(Material.RED_TERRACOTTA);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack makeItem(String type, int amount, String name) {
|
||||
int ty = 0;
|
||||
|
||||
if (type.contains(":")) {
|
||||
String[] b = type.split(":");
|
||||
type = b[0];
|
||||
ty = Integer.parseInt(b[1]);
|
||||
}
|
||||
|
||||
Material m = Material.matchMaterial(type);
|
||||
ItemStack item;
|
||||
|
||||
try {
|
||||
item = new ItemStack(m, amount, (short) ty);
|
||||
} catch (Exception e) {
|
||||
item = new ItemStack(Material.RED_TERRACOTTA);
|
||||
}
|
||||
|
||||
ItemMeta me = item.getItemMeta();
|
||||
|
||||
me.setDisplayName(color(name));
|
||||
item.setItemMeta(me);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack makeItem(String type, int amount, String name, List<String> lore) {
|
||||
ArrayList<String> l = new ArrayList<>();
|
||||
int ty = 0;
|
||||
if (type.contains(":")) {
|
||||
String[] b = type.split(":");
|
||||
type = b[0];
|
||||
ty = Integer.parseInt(b[1]);
|
||||
}
|
||||
Material m = Material.matchMaterial(type);
|
||||
ItemStack item;
|
||||
|
||||
try {
|
||||
item = new ItemStack(m, amount, (short) ty);
|
||||
} catch (Exception e) {
|
||||
item = new ItemStack(Material.RED_TERRACOTTA);
|
||||
}
|
||||
|
||||
ItemMeta me = item.getItemMeta();
|
||||
me.setDisplayName(color(name));
|
||||
|
||||
for (String L : lore) l.add(color(L));
|
||||
|
||||
me.setLore(l);
|
||||
item.setItemMeta(me);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack makeItem(Material material, int amount, int type, String name) {
|
||||
ItemStack item = new ItemStack(material, amount, (short) type);
|
||||
ItemMeta m = item.getItemMeta();
|
||||
m.setDisplayName(color(name));
|
||||
item.setItemMeta(m);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore) {
|
||||
ArrayList<String> l = new ArrayList<>();
|
||||
ItemStack item = new ItemStack(material, amount, (short) type);
|
||||
ItemMeta m = item.getItemMeta();
|
||||
|
||||
m.setDisplayName(color(name));
|
||||
for (String L : lore) l.add(color(L));
|
||||
m.setLore(l);
|
||||
item.setItemMeta(m);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore, Map<Enchantment, Integer> enchants) {
|
||||
ItemStack item = new ItemStack(material, amount, (short) type);
|
||||
ItemMeta m = item.getItemMeta();
|
||||
|
||||
m.setDisplayName(name);
|
||||
m.setLore(lore);
|
||||
item.setItemMeta(m);
|
||||
item.addUnsafeEnchantments(enchants);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack addLore(ItemStack item, String i) {
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
ItemMeta m = item.getItemMeta();
|
||||
|
||||
if (item.getItemMeta().hasLore()) {
|
||||
lore.addAll(item.getItemMeta().getLore());
|
||||
}
|
||||
|
||||
lore.add(i);
|
||||
m.setLore(lore);
|
||||
item.setItemMeta(m);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack addLore(ItemStack item, List<String> list) {
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
ItemMeta m = item.getItemMeta();
|
||||
|
||||
if (item.hasItemMeta() && item.getItemMeta().hasLore()) {
|
||||
lore.addAll(item.getItemMeta().getLore());
|
||||
}
|
||||
|
||||
for (String i : list) lore.add(color(i));
|
||||
m.setLore(lore);
|
||||
item.setItemMeta(m);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack getItemInHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
public static void setItemInHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
}
|
||||
|
||||
public static boolean isInt(String s) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
} catch (NumberFormatException nfe) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isLong(String s) {
|
||||
try {
|
||||
Long.parseLong(s);
|
||||
} catch (NumberFormatException nfe) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Player getPlayer(String name) {
|
||||
try {
|
||||
return Bukkit.getServer().getPlayer(name);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||
return Bukkit.getServer().getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public static boolean isOnline(String name) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isOnline(String name, CommandSender p) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
p.sendMessage(Messages.NOT_ONLINE.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(Player player, String perm) {
|
||||
if (!player.hasPermission("crazyauctions." + perm)) {
|
||||
player.sendMessage(Messages.NO_PERMISSION.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(CommandSender sender, String perm) {
|
||||
if (sender instanceof Player player) {
|
||||
if (!player.hasPermission("crazyauctions." + perm)) {
|
||||
player.sendMessage(Messages.NO_PERMISSION.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getPage(List<ItemStack> list, Integer page) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
if (page <= 0) page = 1;
|
||||
int max = 45;
|
||||
int index = page * max - max;
|
||||
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||
for (; index < endIndex; index++) {
|
||||
if (index < list.size()) items.add(list.get(index));
|
||||
}
|
||||
|
||||
for (; items.size() == 0; page--) {
|
||||
if (page <= 0) break;
|
||||
index = page * max - max;
|
||||
endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||
for (; index < endIndex; index++) {
|
||||
if (index < list.size()) items.add(list.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static List<Integer> getPageInts(List<Integer> list, Integer page) {
|
||||
List<Integer> items = new ArrayList<>();
|
||||
if (page <= 0) page = 1;
|
||||
int max = 45;
|
||||
int index = page * max - max;
|
||||
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (index < list.size()) items.add(list.get(index));
|
||||
}
|
||||
|
||||
for (; items.size() == 0; page--) {
|
||||
if (page <= 0) break;
|
||||
index = page * max - max;
|
||||
endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||
for (; index < endIndex; index++) {
|
||||
if (index < list.size()) items.add(list.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static int getMaxPage(List<ItemStack> list) {
|
||||
int maxPage = 1;
|
||||
int amount = list.size();
|
||||
for (; amount > 45; amount -= 45, maxPage++) ;
|
||||
return maxPage;
|
||||
}
|
||||
|
||||
public static String convertToTime(long time) {
|
||||
Calendar C = Calendar.getInstance();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(time);
|
||||
int total = ((int) (cal.getTimeInMillis() / 1000) - (int) (C.getTimeInMillis() / 1000));
|
||||
int D = 0;
|
||||
int H = 0;
|
||||
int M = 0;
|
||||
int S = 0;
|
||||
for (; total > 86400; total -= 86400, D++) ;
|
||||
for (; total > 3600; total -= 3600, H++) ;
|
||||
for (; total > 60; total -= 60, M++) ;
|
||||
S += total;
|
||||
return D + "d " + H + "h " + M + "m " + S + "s ";
|
||||
}
|
||||
|
||||
public static long convertToMill(String time) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
for (String i : time.split(" ")) {
|
||||
if (i.contains("D") || i.contains("d")) {
|
||||
cal.add(Calendar.DATE, Integer.parseInt(i.replace("D", "").replace("d", "")));
|
||||
}
|
||||
if (i.contains("H") || i.contains("h")) {
|
||||
cal.add(Calendar.HOUR, Integer.parseInt(i.replace("H", "").replace("h", "")));
|
||||
}
|
||||
if (i.contains("M") || i.contains("m")) {
|
||||
cal.add(Calendar.MINUTE, Integer.parseInt(i.replace("M", "").replace("m", "")));
|
||||
}
|
||||
if (i.contains("S") || i.contains("s")) {
|
||||
cal.add(Calendar.SECOND, Integer.parseInt(i.replace("S", "").replace("s", "")));
|
||||
}
|
||||
}
|
||||
|
||||
return cal.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static boolean isInvFull(Player player) {
|
||||
return player.getInventory().firstEmpty() == -1;
|
||||
}
|
||||
|
||||
public static void updateAuction() {
|
||||
FileConfiguration data = Files.DATA.getFile();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
Calendar expireTime = Calendar.getInstance();
|
||||
Calendar fullExpireTime = Calendar.getInstance();
|
||||
boolean shouldSave = false;
|
||||
|
||||
if (data.contains("OutOfTime/Cancelled")) {
|
||||
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
||||
fullExpireTime.setTimeInMillis(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"));
|
||||
if (cal.after(fullExpireTime)) {
|
||||
data.set("OutOfTime/Cancelled." + i, null);
|
||||
shouldSave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
expireTime.setTimeInMillis(data.getLong("Items." + i + ".Time-Till-Expire"));
|
||||
fullExpireTime.setTimeInMillis(data.getLong("Items." + i + ".Full-Time"));
|
||||
|
||||
if (cal.after(expireTime)) {
|
||||
int num = 1;
|
||||
for (; data.contains("OutOfTime/Cancelled." + num); num++) ;
|
||||
|
||||
if (data.getBoolean("Items." + i + ".Biddable") && !data.getString("Items." + i + ".TopBidder").equalsIgnoreCase("None") && plugin.getSupport().getMoney(getPlayer(data.getString("Items." + i + ".TopBidder"))) >= data.getInt("Items." + i + ".Price")) {
|
||||
String winner = data.getString("Items." + i + ".TopBidder");
|
||||
String seller = data.getString("Items." + i + ".Seller");
|
||||
Long price = data.getLong("Items." + i + ".Price");
|
||||
|
||||
plugin.getSupport().addMoney(getOfflinePlayer(seller), price);
|
||||
plugin.getSupport().removeMoney(getOfflinePlayer(winner), price);
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Price%", getPrice(i, false));
|
||||
placeholders.put("%price%", getPrice(i, false));
|
||||
placeholders.put("%Player%", winner);
|
||||
placeholders.put("%player%", winner);
|
||||
|
||||
if (isOnline(winner) && getPlayer(winner) != null) {
|
||||
Player player = getPlayer(winner);
|
||||
Bukkit.getPluginManager().callEvent(new AuctionWinBidEvent(player, data.getItemStack("Items." + i + ".Item"), price));
|
||||
player.sendMessage(Messages.WIN_BIDDING.getMessage(placeholders));
|
||||
}
|
||||
|
||||
if (isOnline(seller) && getPlayer(seller) != null) {
|
||||
Player player = getPlayer(seller);
|
||||
player.sendMessage(Messages.SOMEONE_WON_PLAYERS_BID.getMessage(placeholders));
|
||||
}
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", winner);
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", fullExpireTime.getTimeInMillis());
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getItemStack("Items." + i + ".Item"));
|
||||
} else {
|
||||
String seller = data.getString("Items." + i + ".Seller");
|
||||
Player player = getPlayer(seller);
|
||||
|
||||
if (isOnline(seller) && getPlayer(seller) != null) {
|
||||
player.sendMessage(Messages.ITEM_HAS_EXPIRED.getMessage());
|
||||
}
|
||||
|
||||
AuctionExpireEvent event = new AuctionExpireEvent(player, data.getItemStack("Items." + i + ".Item"));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", fullExpireTime.getTimeInMillis());
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getItemStack("Items." + i + ".Item"));
|
||||
}
|
||||
|
||||
data.set("Items." + i, null);
|
||||
shouldSave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSave) Files.DATA.saveFile();
|
||||
}
|
||||
|
||||
public static String getPrice(String ID, Boolean Expired) {
|
||||
long price = 0L;
|
||||
|
||||
if (Expired) {
|
||||
if (Files.DATA.getFile().contains("OutOfTime/Cancelled." + ID + ".Price")) {
|
||||
price = Files.DATA.getFile().getLong("OutOfTime/Cancelled." + ID + ".Price");
|
||||
}
|
||||
} else {
|
||||
if (Files.DATA.getFile().contains("Items." + ID + ".Price")) {
|
||||
price = Files.DATA.getFile().getLong("Items." + ID + ".Price");
|
||||
}
|
||||
}
|
||||
|
||||
return String.valueOf(price);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.badbones69.crazyauctions.paper.api;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.api.FileManager.Files;
|
||||
import com.badbones69.crazyauctions.paper.api.enums.ShopType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CrazyManager {
|
||||
|
||||
private boolean sellingEnabled;
|
||||
private boolean biddingEnabled;
|
||||
|
||||
public void load() {
|
||||
this.sellingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Selling", true);
|
||||
|
||||
this.biddingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Bidding", true);
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
Files.DATA.saveFile();
|
||||
}
|
||||
|
||||
public boolean isSellingEnabled() {
|
||||
return sellingEnabled;
|
||||
}
|
||||
|
||||
public boolean isBiddingEnabled() {
|
||||
return biddingEnabled;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getItems(Player player, ShopType type) {
|
||||
FileConfiguration data = Files.DATA.getFile();
|
||||
ArrayList<ItemStack> items = new ArrayList<>();
|
||||
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
|
||||
if (data.getBoolean("Items." + i + ".Biddable")) {
|
||||
if (type == ShopType.BID) {
|
||||
items.add(data.getItemStack("Items." + i + ".Item").clone());
|
||||
}
|
||||
} else {
|
||||
if (type == ShopType.SELL) {
|
||||
items.add(data.getItemStack("Items." + i + ".Item").clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
@ -0,0 +1,505 @@
|
||||
package com.badbones69.crazyauctions.paper.api;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.CrazyAuctions;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class FileManager {
|
||||
|
||||
@NotNull
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
private final HashMap<Files, File> files = new HashMap<>();
|
||||
private final List<String> homeFolders = new ArrayList<>();
|
||||
private final List<CustomFile> customFiles = new ArrayList<>();
|
||||
private final HashMap<String, String> jarHomeFolders = new HashMap<>();
|
||||
private final HashMap<String, String> autoGenerateFiles = new HashMap<>();
|
||||
private final HashMap<Files, FileConfiguration> configurations = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Sets up the plugin and loads all necessary files.
|
||||
*/
|
||||
public FileManager setup() {
|
||||
if (!this.plugin.getDataFolder().exists()) this.plugin.getDataFolder().mkdirs();
|
||||
|
||||
this.files.clear();
|
||||
this.customFiles.clear();
|
||||
this.configurations.clear();
|
||||
|
||||
// Loads all the normal static files.
|
||||
for (Files file : Files.values()) {
|
||||
File newFile = new File(this.plugin.getDataFolder(), file.getFileLocation());
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Loading the " + file.getFileName());
|
||||
|
||||
if (!newFile.exists()) {
|
||||
try (InputStream jarFile = getClass().getResourceAsStream("/" + file.getFileJar())) {
|
||||
File serverFile = new File(this.plugin.getDataFolder(), "/" + file.getFileLocation());
|
||||
copyFile(jarFile, serverFile);
|
||||
} catch (Exception exception) {
|
||||
this.plugin.getLogger().log(Level.WARNING, "Failed to load file: " + file.getFileName(), exception);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
this.files.put(file, newFile);
|
||||
if (file.getFileName().endsWith(".yml")) this.configurations.put(file, YamlConfiguration.loadConfiguration(newFile));
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully loaded " + file.getFileName());
|
||||
}
|
||||
|
||||
// Starts to load all the custom files.
|
||||
if (!this.homeFolders.isEmpty()) {
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Loading custom files.");
|
||||
|
||||
for (String homeFolder : this.homeFolders) {
|
||||
File homeFile = new File(this.plugin.getDataFolder(), "/" + homeFolder);
|
||||
|
||||
if (homeFile.exists()) {
|
||||
String[] list = homeFile.list();
|
||||
|
||||
if (list != null) {
|
||||
for (String name : list) {
|
||||
if (name.endsWith(".yml")) {
|
||||
CustomFile file = new CustomFile(name, homeFolder);
|
||||
|
||||
if (file.exists()) {
|
||||
this.customFiles.add(file);
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Loaded new custom file: " + homeFolder + "/" + name + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
homeFile.mkdir();
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("The folder " + homeFolder + "/ was not found so it was created.");
|
||||
|
||||
for (String fileName : this.autoGenerateFiles.keySet()) {
|
||||
if (this.autoGenerateFiles.get(fileName).equalsIgnoreCase(homeFolder)) {
|
||||
homeFolder = this.autoGenerateFiles.get(fileName);
|
||||
|
||||
try (InputStream jarFile = getClass().getResourceAsStream((this.jarHomeFolders.getOrDefault(fileName, homeFolder)) + "/" + fileName)) {
|
||||
File serverFile = new File(this.plugin.getDataFolder(), homeFolder + "/" + fileName);
|
||||
copyFile(jarFile, serverFile);
|
||||
|
||||
if (fileName.toLowerCase().endsWith(".yml")) this.customFiles.add(new CustomFile(fileName, homeFolder));
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Created new default file: " + homeFolder + "/" + fileName + ".");
|
||||
} catch (Exception exception) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Failed to create new default file: " + homeFolder + "/" + fileName + "!", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Finished loading custom files.");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a folder that has custom files in it. Make sure to have a "/" in front of the folder name.
|
||||
* @param homeFolder The folder that has custom files in it.
|
||||
*/
|
||||
public FileManager registerCustomFilesFolder(String homeFolder) {
|
||||
this.homeFolders.add(homeFolder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a folder that has custom files in it. Make sure to have a "/" in front of the folder name.
|
||||
* @param homeFolder The folder with custom files in it.
|
||||
*/
|
||||
public FileManager unregisterCustomFilesFolder(String homeFolder) {
|
||||
this.homeFolders.remove(homeFolder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a file that needs to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
|
||||
* @param fileName The name of the file you want to auto-generate when the folder doesn't exist.
|
||||
* @param homeFolder The folder that has custom files in it.
|
||||
*/
|
||||
public FileManager registerDefaultGenerateFiles(String fileName, String homeFolder) {
|
||||
this.autoGenerateFiles.put(fileName, homeFolder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a file that needs to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
|
||||
* @param fileName The name of the file you want to auto-generate when the folder doesn't exist.
|
||||
* @param homeFolder The folder that has custom files in it.
|
||||
* @param jarHomeFolder The folder that the file is found in the jar.
|
||||
*/
|
||||
public FileManager registerDefaultGenerateFiles(String fileName, String homeFolder, String jarHomeFolder) {
|
||||
this.autoGenerateFiles.put(fileName, homeFolder);
|
||||
this.jarHomeFolders.put(fileName, jarHomeFolder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a file that doesn't need to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
|
||||
* @param fileName The file that you want to remove from auto-generating.
|
||||
*/
|
||||
public FileManager unregisterDefaultGenerateFiles(String fileName) {
|
||||
this.autoGenerateFiles.remove(fileName);
|
||||
this.jarHomeFolders.remove(fileName);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file from the system.
|
||||
* @return The file from the system.
|
||||
*/
|
||||
public FileConfiguration getFile(Files file) {
|
||||
return this.configurations.get(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a custom file from the loaded custom files instead of a hardcoded one.
|
||||
* This allows you to get custom files like Per player data files.
|
||||
* @param name Name of the crate you want. (Without the .yml)
|
||||
* @return The custom file you wanted otherwise if not found will return null.
|
||||
*/
|
||||
public CustomFile getFile(String name) {
|
||||
for (CustomFile file : this.customFiles) {
|
||||
if (file.getName().equalsIgnoreCase(name)) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeFile(String name) {
|
||||
this.customFiles.remove(getFile(name));
|
||||
}
|
||||
|
||||
public void addFile(String name, String folder) {
|
||||
this.customFiles.add(new CustomFile(name, folder));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the file from the loaded state to the file system.
|
||||
*/
|
||||
public void saveFile(Files file) {
|
||||
try {
|
||||
this.configurations.get(file).save(this.files.get(file));
|
||||
} catch (IOException exception) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Could not save " + file.getFileName() + "!", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a custom file.
|
||||
* @param name The name of the custom file.
|
||||
*/
|
||||
public void saveFile(String name) {
|
||||
CustomFile file = getFile(name);
|
||||
|
||||
if (file == null) {
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().warning("The file " + name + ".yml could not be found!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
file.getFile().save(new File(this.plugin.getDataFolder(), file.getHomeFolder() + "/" + file.getFileName()));
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully saved the " + file.getFileName() + ".");
|
||||
} catch (Exception exception) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Could not save " + file.getFileName() + "!", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a custom file.
|
||||
*
|
||||
* @param file The custom file you are saving.
|
||||
*/
|
||||
public void saveFile(CustomFile file) {
|
||||
file.saveFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the loaded state file and loads the file systems file.
|
||||
*/
|
||||
public void reloadFile(Files file) {
|
||||
if (file.getFileName().endsWith(".yml")) this.configurations.put(file, YamlConfiguration.loadConfiguration(this.files.get(file)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the loaded state file and loads the file systems file.
|
||||
*/
|
||||
public void reloadFile(String name) {
|
||||
CustomFile file = getFile(name);
|
||||
|
||||
if (file != null) {
|
||||
try {
|
||||
file.file = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "/" + file.getHomeFolder() + "/" + file.getFileName()));
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully reloaded the " + file.getFileName() + ".");
|
||||
} catch (Exception exception) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Could not reload the " + file.getFileName() + "!", exception);
|
||||
}
|
||||
} else {
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().warning("The file " + name + ".yml could not be found!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the loaded state file and loads the filesystems file.
|
||||
*/
|
||||
public void reloadFile(CustomFile file) {
|
||||
file.reloadFile();
|
||||
}
|
||||
|
||||
public void reloadAllFiles() {
|
||||
for (Files file : Files.values()) {
|
||||
file.reloadFile();
|
||||
}
|
||||
|
||||
for (CustomFile file : this.customFiles) {
|
||||
file.reloadFile();
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getAllCratesNames() {
|
||||
List<String> files = new ArrayList<>();
|
||||
|
||||
String[] file = new File(this.plugin.getDataFolder(), "/crates").list();
|
||||
|
||||
if (file != null) {
|
||||
for (String name : file) {
|
||||
if (!name.endsWith(".yml")) continue;
|
||||
|
||||
files.add(name.replaceAll(".yml", ""));
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Was found here: <a href="https://bukkit.org/threads/extracting-file-from-jar.16962">...</a>
|
||||
*/
|
||||
private void copyFile(InputStream in, File out) throws Exception {
|
||||
try (InputStream fis = in; FileOutputStream fos = new FileOutputStream(out)) {
|
||||
byte[] buf = new byte[1024];
|
||||
int i;
|
||||
|
||||
while ((i = fis.read(buf)) != -1) {
|
||||
fos.write(buf, 0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Files {
|
||||
|
||||
// ENUM_NAME("fileName.yml", "fileLocation.yml"),
|
||||
// ENUM_NAME("fileName.yml", "newFileLocation.yml", "oldFileLocation.yml"),
|
||||
CONFIG("config.yml", "config.yml"),
|
||||
MESSAGES("messages.yml", "messages.yml"),
|
||||
TEST_FILE("test-file.yml", "test-file.yml"),
|
||||
DATA("data.yml", "data.yml");
|
||||
|
||||
private final String fileName;
|
||||
private final String fileJar;
|
||||
private final String fileLocation;
|
||||
|
||||
@NotNull
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
@NotNull
|
||||
private final FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
/**
|
||||
* The files that the server will try and load.
|
||||
* @param fileName The file name that will be in the plugin's folder.
|
||||
* @param fileLocation The location the file in the plugin's folder.
|
||||
*/
|
||||
Files(String fileName, String fileLocation) {
|
||||
this(fileName, fileLocation, fileLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* The files that the server will try and load.
|
||||
* @param fileName The file name that will be in the plugin's folder.
|
||||
* @param fileLocation The location of the file will be in the plugin's folder.
|
||||
* @param fileJar The location of the file in the jar.
|
||||
*/
|
||||
Files(String fileName, String fileLocation, String fileJar) {
|
||||
this.fileName = fileName;
|
||||
this.fileLocation = fileLocation;
|
||||
this.fileJar = fileJar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the file.
|
||||
* @return The name of the file.
|
||||
*/
|
||||
public String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The location the jar it is at.
|
||||
* @return The location in the jar the file is in.
|
||||
*/
|
||||
public String getFileLocation() {
|
||||
return this.fileLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location of the file in the jar.
|
||||
* @return The location of the file in the jar.
|
||||
*/
|
||||
public String getFileJar() {
|
||||
return this.fileJar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file from the system.
|
||||
* @return The file from the system.
|
||||
*/
|
||||
public FileConfiguration getFile() {
|
||||
return this.fileManager.getFile(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the file from the loaded state to the file system.
|
||||
*/
|
||||
public void saveFile() {
|
||||
this.fileManager.saveFile(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the loaded state file and loads the file systems file.
|
||||
*/
|
||||
public void reloadFile() {
|
||||
if (this.getFileName().endsWith(".yml")) this.fileManager.reloadFile(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomFile {
|
||||
|
||||
private final String name;
|
||||
private final String fileName;
|
||||
private final String homeFolder;
|
||||
private FileConfiguration file;
|
||||
|
||||
@NotNull
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
/**
|
||||
* A custom file that is being made.
|
||||
* @param name Name of the file.
|
||||
* @param homeFolder The home folder of the file.
|
||||
*/
|
||||
public CustomFile(String name, String homeFolder) {
|
||||
this.name = name.replace(".yml", "");
|
||||
this.fileName = name;
|
||||
this.homeFolder = homeFolder;
|
||||
|
||||
if (new File(this.plugin.getDataFolder(), "/" + homeFolder).exists()) {
|
||||
if (new File(this.plugin.getDataFolder(), "/" + homeFolder + "/" + name).exists()) {
|
||||
this.file = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "/" + homeFolder + "/" + name));
|
||||
} else {
|
||||
this.file = null;
|
||||
}
|
||||
} else {
|
||||
new File(this.plugin.getDataFolder(), "/" + homeFolder).mkdir();
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("The folder " + homeFolder + "/ was not found so it was created.");
|
||||
|
||||
this.file = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the file without the .yml part.
|
||||
* @return The name of the file without the .yml.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full name of the file.
|
||||
* @return Full name of the file.
|
||||
*/
|
||||
public String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the home folder of the file.
|
||||
* @return The name of the home folder the files are in.
|
||||
*/
|
||||
public String getHomeFolder() {
|
||||
return this.homeFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ConfigurationFile.
|
||||
* @return The ConfigurationFile of this file.
|
||||
*/
|
||||
public FileConfiguration getFile() {
|
||||
return this.file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the file actually exists in the file system.
|
||||
* @return True if it does and false if it doesn't.
|
||||
*/
|
||||
public boolean exists() {
|
||||
return this.file != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the custom file.
|
||||
*/
|
||||
public void saveFile() {
|
||||
if (this.file != null) {
|
||||
try {
|
||||
this.file.save(new File(this.plugin.getDataFolder(), this.homeFolder + "/" + this.fileName));
|
||||
|
||||
if (this.plugin.isLogging()) plugin.getLogger().info("Successfully saved the " + this.fileName + ".");
|
||||
} catch (Exception exception) {
|
||||
this.plugin.getLogger().log(Level.WARNING, "Could not save " + this.fileName + "!", exception);
|
||||
}
|
||||
} else {
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().warning("There was a null custom file that could not be found!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the loaded state file and loads the filesystems file.
|
||||
*/
|
||||
public void reloadFile() {
|
||||
if (this.file != null) {
|
||||
try {
|
||||
this.file = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "/" + this.homeFolder + "/" + this.fileName));
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully reloaded the " + this.fileName + ".");
|
||||
} catch (Exception exception) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Could not reload the " + this.fileName + "!", exception);
|
||||
}
|
||||
} else {
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().warning("There was a null custom file that was not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
package com.badbones69.crazyauctions.paper.api.enums;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public enum Category {
|
||||
|
||||
NONE("None", new ArrayList<>()),
|
||||
OTHER("Other", getOthers()),
|
||||
ARMOR("Armor", getArmor()),
|
||||
WEAPONS("Weapons", getWeapons()),
|
||||
TOOLS("Tools", getTools()),
|
||||
FOOD("Food", getFood()),
|
||||
POTIONS("Potions", getPotions()),
|
||||
BLOCKS("Blocks", getBlocks());
|
||||
|
||||
private final String name;
|
||||
private final ArrayList<Material> items;
|
||||
|
||||
/**
|
||||
* @param name Name of the Shop Type.
|
||||
*/
|
||||
private Category(String name, ArrayList<Material> items) {
|
||||
this.name = name;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the Type you want.
|
||||
* @return Returns the Type as an Enum.
|
||||
*/
|
||||
public static Category getFromName(String name) {
|
||||
for (Category type : Category.values()) {
|
||||
if (type.getName().equalsIgnoreCase(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getArmor() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
ma.add(Material.GOLDEN_HELMET);
|
||||
ma.add(Material.GOLDEN_CHESTPLATE);
|
||||
ma.add(Material.GOLDEN_LEGGINGS);
|
||||
ma.add(Material.GOLDEN_BOOTS);
|
||||
ma.add(Material.DIAMOND_HELMET);
|
||||
ma.add(Material.DIAMOND_CHESTPLATE);
|
||||
ma.add(Material.DIAMOND_LEGGINGS);
|
||||
ma.add(Material.DIAMOND_BOOTS);
|
||||
ma.add(Material.CHAINMAIL_HELMET);
|
||||
ma.add(Material.CHAINMAIL_CHESTPLATE);
|
||||
ma.add(Material.CHAINMAIL_LEGGINGS);
|
||||
ma.add(Material.CHAINMAIL_BOOTS);
|
||||
ma.add(Material.IRON_HELMET);
|
||||
ma.add(Material.IRON_CHESTPLATE);
|
||||
ma.add(Material.IRON_LEGGINGS);
|
||||
ma.add(Material.IRON_BOOTS);
|
||||
ma.add(Material.DIAMOND_HELMET);
|
||||
ma.add(Material.DIAMOND_CHESTPLATE);
|
||||
ma.add(Material.DIAMOND_LEGGINGS);
|
||||
ma.add(Material.DIAMOND_BOOTS);
|
||||
ma.add(Material.NETHERITE_HELMET);
|
||||
ma.add(Material.NETHERITE_CHESTPLATE);
|
||||
ma.add(Material.NETHERITE_LEGGINGS);
|
||||
ma.add(Material.NETHERITE_BOOTS);
|
||||
|
||||
return ma;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getTools() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
ma.add(Material.WOODEN_PICKAXE);
|
||||
ma.add(Material.WOODEN_AXE);
|
||||
ma.add(Material.WOODEN_SHOVEL);
|
||||
ma.add(Material.WOODEN_HOE);
|
||||
ma.add(Material.GOLDEN_PICKAXE);
|
||||
ma.add(Material.GOLDEN_AXE);
|
||||
ma.add(Material.GOLDEN_SHOVEL);
|
||||
ma.add(Material.GOLDEN_HOE);
|
||||
ma.add(Material.STONE_SHOVEL);
|
||||
ma.add(Material.IRON_SHOVEL);
|
||||
ma.add(Material.DIAMOND_SHOVEL);
|
||||
ma.add(Material.STONE_PICKAXE);
|
||||
ma.add(Material.IRON_PICKAXE);
|
||||
ma.add(Material.DIAMOND_PICKAXE);
|
||||
ma.add(Material.STONE_AXE);
|
||||
ma.add(Material.IRON_AXE);
|
||||
ma.add(Material.DIAMOND_AXE);
|
||||
ma.add(Material.STONE_HOE);
|
||||
ma.add(Material.IRON_HOE);
|
||||
ma.add(Material.DIAMOND_HOE);
|
||||
ma.add(Material.NETHERITE_PICKAXE);
|
||||
ma.add(Material.NETHERITE_AXE);
|
||||
ma.add(Material.NETHERITE_HOE);
|
||||
ma.add(Material.NETHERITE_SHOVEL);
|
||||
return ma;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getWeapons() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
ma.add(Material.GOLDEN_PICKAXE);
|
||||
ma.add(Material.GOLDEN_AXE);
|
||||
ma.add(Material.GOLDEN_SHOVEL);
|
||||
ma.add(Material.GOLDEN_HOE);
|
||||
ma.add(Material.STONE_SWORD);
|
||||
ma.add(Material.IRON_SWORD);
|
||||
ma.add(Material.DIAMOND_SWORD);
|
||||
ma.add(Material.STONE_AXE);
|
||||
ma.add(Material.IRON_AXE);
|
||||
ma.add(Material.DIAMOND_AXE);
|
||||
ma.add(Material.BOW);
|
||||
ma.add(Material.NETHERITE_SWORD);
|
||||
ma.add(Material.NETHERITE_AXE);
|
||||
return ma;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getFood() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
for (Material m : Material.values()) {
|
||||
if (m.isEdible()) {
|
||||
if (m != Material.POTION) ma.add(m);
|
||||
}
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getPotions() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
ma.add(Material.POTION);
|
||||
ma.add(Material.SPLASH_POTION);
|
||||
ma.add(Material.LINGERING_POTION);
|
||||
return ma;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getBlocks() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
for (Material m : Material.values()) {
|
||||
if (m.isBlock()) {
|
||||
ma.add(m);
|
||||
}
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getOthers() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
for (Material m : Material.values()) {
|
||||
if (!(getArmor().contains(m) || getTools().contains(m) || getWeapons().contains(m) || getFood().contains(m) || getPotions().contains(m) || getBlocks().contains(m))) {
|
||||
ma.add(m);
|
||||
}
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the type name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<Material> getItems() {
|
||||
return items;
|
||||
}
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
package com.badbones69.crazyauctions.paper.api.enums;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.Methods;
|
||||
import com.badbones69.crazyauctions.paper.api.FileManager.Files;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public enum Messages {
|
||||
|
||||
PLAYERS_ONLY("Players-Only", "&cOnly players can use this command."),
|
||||
RELOAD("Reload", "&7You have just reloaded the Crazy Auctions Files."),
|
||||
NEED_MORE_MONEY("Need-More-Money", "&cYou are in need of &a$%money_needed%&c."),
|
||||
INVENTORY_FULL("Inventory-Full", "&cYour inventory is too full. Please open up some space to buy that."),
|
||||
NO_PERMISSION("No-Permission", "&cYou do not have permission to use that command!"),
|
||||
NOT_ONLINE("Not-Online", "&cThat player is not online at this time."),
|
||||
DOESNT_HAVE_ITEM_IN_HAND("Doesnt-Have-Item-In-Hand", "&cYou must have an item in your hand."),
|
||||
NOT_A_NUMBER("Not-A-Number", "&c%arg% is not a number."),
|
||||
GOT_ITEM_BACK("Got-Item-Back", "&7Your item has been returned."),
|
||||
CANCELLED_ITEM("Cancelled-Item", "&7You have cancelled an item on the auction list, return your items with /ah expired."),
|
||||
ITEM_HAS_EXPIRED("Item-Has-Expired", "&7An item you have in the Crazy Auctions has just expired."),
|
||||
ADMIN_FORCE_CANCELLED("Admin-Force-Cancelled", "&7You have just force cancelled a sale."),
|
||||
ADMIN_FORCE_CANCELLED_TO_PLAYER("Admin-Force-Cancelled-To-Player", "&cOne of your items was just force cancelled by an Admin."),
|
||||
ITEM_DOESNT_EXIST("Item-Doesnt-Exist", "&cThat item isnt in the crazy auctions any more."),
|
||||
MAX_ITEMS("Max-Items", "&cYou cant list any more items to the Crazy Auctions."),
|
||||
ITEM_BLACKLISTED("Item-BlackListed", "&cThat item is not allowed to be sold here."),
|
||||
ITEM_DAMAGED("Item-Damaged", "&cThat item is damaged and is not allowed to be sold here."),
|
||||
SOLD_MESSAGE("Sold-Msg", "&7Thank you for buying this item."),
|
||||
BID_MORE_MONEY("Bid-More-Money", "&cYour bid is to low, please bid more."),
|
||||
NOT_A_CURRENCY("Not-A-Currency", "&cThat is not a currency. Please use Money or Tokens ."),
|
||||
SELL_PRICE_TO_LOW("Sell-Price-To-Low", "&cYour sell price is to low the minimum is &a$10&c."),
|
||||
SELL_PRICE_TO_HIGH("Sell-Price-To-High", "&cYour sell price is to high the maximum is &a$1000000&c."),
|
||||
BID_PRICE_TO_LOW("Bid-Price-To-Low", "&cYour starting bid price is to low the minimum is &a$100&c."),
|
||||
BID_PRICE_TO_HIGH("Bid-Price-To-High", "&cYour starting bid price is to high the maximum is &a$1000000&c."),
|
||||
BOUGHT_ITEM("Bought-Item", "&7You have just bought a item for &a$%price%&7."),
|
||||
WIN_BIDDING("Win-Bidding", "&7You have just won a bid for &a$%price%&7. Do /Ah Collect to collect your winnings."),
|
||||
PLAYER_BOUGHT_ITEM("Player-Bought-Item", "&7%player% has bought your item for &a$%price%."),
|
||||
SOMEONE_WON_PLAYERS_BID("Someone-Won-Players-Bid", "&7%player% has won your item you from a bid for &a$%price%."),
|
||||
ADDED_ITEM_TO_AUCTION("Added-Item-To-Auction", "&7You have just added a item to the crazy auctions for &a$%price%&7."),
|
||||
BID_MESSAGE("Bid-Msg", "&7You have just bid &a$%Bid% &7on that item."),
|
||||
SELLING_DISABLED("Selling-Disabled", "&cThe selling option is disabled."),
|
||||
BIDDING_DISABLED("Bidding-Disabled", "&cThe bidding option is disabled."),
|
||||
CRAZYAUCTIONS_VIEW("CrazyAuctions-View", "&c/ah view <player>"),
|
||||
CRAZYAUCTIONS_SELL_BID("CrazyAuctions-Sell-Bid", "&c/ah sell/bid <price> [amount of items]"),
|
||||
BOOK_NOT_ALLOWED("Book-Not-Allowed", "&cThat book is not able to be sold in this auction house!"),
|
||||
HELP("Help-Menu", Arrays.asList(
|
||||
"&e-- &6Crazy Auctions Help &e--",
|
||||
"&9/Ah - &eOpens the crazy auction.",
|
||||
"&9/Ah View <Player> - &eSee what a player is selling.",
|
||||
"&9/Ah Sell/Bid <Price> [Amount of items] - &eList the item you are holding on the crazy auction.",
|
||||
"&9/Ah Expired/Collect - &eView and manage your cancelled and expired items.",
|
||||
"&9/Ah Listed - &eView and manage the items you are selling.",
|
||||
"&9/Ah Help - &eView this help menu."));
|
||||
|
||||
private final String path;
|
||||
private String defaultMessage;
|
||||
private List<String> defaultListMessage;
|
||||
|
||||
private Messages(String path, String defaultMessage) {
|
||||
this.path = path;
|
||||
this.defaultMessage = defaultMessage;
|
||||
}
|
||||
|
||||
private Messages(String path, List<String> defaultListMessage) {
|
||||
this.path = path;
|
||||
this.defaultListMessage = defaultListMessage;
|
||||
}
|
||||
|
||||
public static String convertList(List<String> list) {
|
||||
String message = "";
|
||||
for (String m : list) {
|
||||
message += Methods.color(m) + "\n";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String convertList(List<String> list, HashMap<String, String> placeholders) {
|
||||
String message = "";
|
||||
for (String m : list) {
|
||||
message += Methods.color(m) + "\n";
|
||||
}
|
||||
for (String ph : placeholders.keySet()) {
|
||||
message = Methods.color(message.replace(ph, placeholders.get(ph))).replace(ph, placeholders.get(ph).toLowerCase());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void addMissingMessages() {
|
||||
FileConfiguration messages = Files.MESSAGES.getFile();
|
||||
boolean saveFile = false;
|
||||
for (Messages message : values()) {
|
||||
if (!messages.contains("Messages." + message.getPath())) {
|
||||
saveFile = true;
|
||||
if (message.getDefaultMessage() != null) {
|
||||
messages.set("Messages." + message.getPath(), message.getDefaultMessage());
|
||||
} else {
|
||||
messages.set("Messages." + message.getPath(), message.getDefaultListMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (saveFile) {
|
||||
Files.MESSAGES.saveFile();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
if (isList()) {
|
||||
if (exists()) {
|
||||
return Methods.color(convertList(Files.MESSAGES.getFile().getStringList("Messages." + path)));
|
||||
} else {
|
||||
return Methods.color(convertList(getDefaultListMessage()));
|
||||
}
|
||||
} else {
|
||||
if (exists()) {
|
||||
return Methods.getPrefix(Files.MESSAGES.getFile().getString("Messages." + path));
|
||||
} else {
|
||||
return Methods.getPrefix(getDefaultMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessage(HashMap<String, String> placeholders) {
|
||||
String message;
|
||||
if (isList()) {
|
||||
if (exists()) {
|
||||
message = Methods.color(convertList(Files.MESSAGES.getFile().getStringList("Messages." + path), placeholders));
|
||||
} else {
|
||||
message = Methods.color(convertList(getDefaultListMessage(), placeholders));
|
||||
}
|
||||
} else {
|
||||
if (exists()) {
|
||||
message = Methods.getPrefix(Files.MESSAGES.getFile().getString("Messages." + path));
|
||||
} else {
|
||||
message = Methods.getPrefix(getDefaultMessage());
|
||||
}
|
||||
for (String ph : placeholders.keySet()) {
|
||||
if (message.contains(ph)) {
|
||||
message = message.replace(ph, placeholders.get(ph)).replace(ph, placeholders.get(ph).toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getMessageNoPrefix() {
|
||||
if (isList()) {
|
||||
if (exists()) {
|
||||
return Methods.color(convertList(Files.MESSAGES.getFile().getStringList("Messages." + path)));
|
||||
} else {
|
||||
return Methods.color(convertList(getDefaultListMessage()));
|
||||
}
|
||||
} else {
|
||||
if (exists()) {
|
||||
return Methods.color(Files.MESSAGES.getFile().getString("Messages." + path));
|
||||
} else {
|
||||
return Methods.color(getDefaultMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessageNoPrefix(HashMap<String, String> placeholders) {
|
||||
String message;
|
||||
if (isList()) {
|
||||
if (exists()) {
|
||||
message = Methods.color(convertList(Files.MESSAGES.getFile().getStringList("Messages." + path), placeholders));
|
||||
} else {
|
||||
message = Methods.color(convertList(getDefaultListMessage(), placeholders));
|
||||
}
|
||||
} else {
|
||||
if (exists()) {
|
||||
message = Methods.color(Files.MESSAGES.getFile().getString("Messages." + path));
|
||||
} else {
|
||||
message = Methods.color(getDefaultMessage());
|
||||
}
|
||||
for (String ph : placeholders.keySet()) {
|
||||
if (message.contains(ph)) {
|
||||
message = message.replace(ph, placeholders.get(ph)).replace(ph, placeholders.get(ph).toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private Boolean exists() {
|
||||
return Files.MESSAGES.getFile().contains("Messages." + path);
|
||||
}
|
||||
|
||||
private Boolean isList() {
|
||||
if (Files.MESSAGES.getFile().contains("Messages." + path)) {
|
||||
return !Files.MESSAGES.getFile().getStringList("Messages." + path).isEmpty();
|
||||
} else {
|
||||
return defaultMessage == null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
private String getDefaultMessage() {
|
||||
return defaultMessage;
|
||||
}
|
||||
|
||||
private List<String> getDefaultListMessage() {
|
||||
return defaultListMessage;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.badbones69.crazyauctions.paper.api.enums;
|
||||
|
||||
public enum Reaons {
|
||||
|
||||
/**
|
||||
* Cancelled by an administrator.
|
||||
*/
|
||||
ADMIN_FORCE_CANCEL(),
|
||||
/**
|
||||
* Cancelled by the player them self.
|
||||
*/
|
||||
PLAYER_FORCE_CANCEL()
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.badbones69.crazyauctions.paper.api.enums;
|
||||
|
||||
public enum ShopType {
|
||||
|
||||
SELL("Sell"), BID("Bid");
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* @param name name of the Shop Type.
|
||||
*/
|
||||
private ShopType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name name of the Type you want.
|
||||
* @return Returns the Type as an Enum.
|
||||
*/
|
||||
public static ShopType getFromName(String name) {
|
||||
for (ShopType type : ShopType.values()) {
|
||||
if (type.getName().equalsIgnoreCase(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the type name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.badbones69.crazyauctions.paper.api.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a player buys something from the selling auction house.
|
||||
*
|
||||
*/
|
||||
public class AuctionBuyEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final long price;
|
||||
private final ItemStack item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player The player who bought the item.
|
||||
* @param item The item that was bought.
|
||||
* @param price The price of the item.
|
||||
*/
|
||||
public AuctionBuyEvent(Player player, ItemStack item, long price) {
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public long getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.badbones69.crazyauctions.paper.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.api.enums.Reaons;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a player's item is cancelled.
|
||||
*
|
||||
*/
|
||||
public class AuctionCancelledEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final boolean isOnline;
|
||||
private final ItemStack item;
|
||||
private final Reaons reason;
|
||||
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private Player onlinePlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param offlinePlayer The player whose item is cancelled.
|
||||
* @param item The item that is cancelled.
|
||||
*/
|
||||
public AuctionCancelledEvent(OfflinePlayer offlinePlayer, ItemStack item, Reaons reason) {
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
this.item = item;
|
||||
this.isOnline = false;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param onlinePlayer The player whose item is cancelled.
|
||||
* @param item The item that is cancelled.
|
||||
*/
|
||||
public AuctionCancelledEvent(Player onlinePlayer, ItemStack item, Reaons reason) {
|
||||
this.onlinePlayer = onlinePlayer;
|
||||
this.item = item;
|
||||
this.isOnline = true;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer() {
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
public Player getOnlinePlayer() {
|
||||
return onlinePlayer;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public Reaons getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.badbones69.crazyauctions.paper.api.events;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a player item expires.
|
||||
*
|
||||
*/
|
||||
public class AuctionExpireEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final boolean isOnline;
|
||||
private final ItemStack item;
|
||||
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private Player onlinePlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param offlinePlayer The player whose item is expiring.
|
||||
* @param item The item that is expiring.
|
||||
*/
|
||||
public AuctionExpireEvent(OfflinePlayer offlinePlayer, ItemStack item) {
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
this.item = item;
|
||||
this.isOnline = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param onlinePlayer The player whose item is expiring.
|
||||
* @param item The item that is expiring.
|
||||
*/
|
||||
public AuctionExpireEvent(Player onlinePlayer, ItemStack item) {
|
||||
this.onlinePlayer = onlinePlayer;
|
||||
this.item = item;
|
||||
this.isOnline = true;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer() {
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
public Player getOnlinePlayer() {
|
||||
return onlinePlayer;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.badbones69.crazyauctions.paper.api.events;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.api.enums.ShopType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a new item is listed onto the auction house.
|
||||
*
|
||||
*/
|
||||
public class AuctionListEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player player;
|
||||
private final long price;
|
||||
private final ShopType shop;
|
||||
private final ItemStack item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player The player who is listing the item.
|
||||
* @param shop The shop type the item is being listed to.
|
||||
* @param item The item being listed.
|
||||
* @param price The price the item is being listed for.
|
||||
*/
|
||||
public AuctionListEvent(Player player, ShopType shop, ItemStack item, long price) {
|
||||
this.player = player;
|
||||
this.shop = shop;
|
||||
this.item = item;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public ShopType getShopType() {
|
||||
return shop;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public long getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.badbones69.crazyauctions.paper.api.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is fired when a player places a new bid onto an item in the auction house.
|
||||
*/
|
||||
public class AuctionNewBidEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player player;
|
||||
private final long bid;
|
||||
private final ItemStack item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player The player who placed the bid.
|
||||
* @param item The item that was bid on.
|
||||
* @param bid The amount of money that was bid.
|
||||
*/
|
||||
public AuctionNewBidEvent(Player player, ItemStack item, long bid) {
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
this.bid = bid;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public long getBid() {
|
||||
return bid;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.badbones69.crazyauctions.paper.api.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a bidding item's time has run out and so a player wins the item.
|
||||
*
|
||||
*/
|
||||
public class AuctionWinBidEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player player;
|
||||
private final long bid;
|
||||
private final ItemStack item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player The player who won the item.
|
||||
* @param item The item that was won.
|
||||
* @param bid The bid that was placed on the item.
|
||||
*/
|
||||
public AuctionWinBidEvent(Player player, ItemStack item, long bid) {
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
this.bid = bid;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public long getBid() {
|
||||
return bid;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.badbones69.crazyauctions.paper.api.support;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.CrazyAuctions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum PluginSupport {
|
||||
|
||||
DECENT_HOLOGRAMS("DecentHolograms"),
|
||||
HOLOGRAPHIC_DISPLAYS("HolographicDisplays"),
|
||||
VAULT("Vault"),
|
||||
CMI("CMI"),
|
||||
PLACEHOLDERAPI("PlaceholderAPI"),
|
||||
ORAXEN("Oraxen"),
|
||||
ITEMS_ADDER("ItemsAdder");
|
||||
|
||||
private final String name;
|
||||
|
||||
@NotNull
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
PluginSupport(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isPluginEnabled() {
|
||||
return this.plugin.getServer().getPluginManager().isPluginEnabled(this.name);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.badbones69.crazyauctions.paper.api.support.metrics;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.CrazyAuctions;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MetricsWrapper {
|
||||
|
||||
@NotNull
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
private Metrics metrics;
|
||||
|
||||
public void start() {
|
||||
if (this.metrics != null) {
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().warning("Metrics is already enabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.metrics = new Metrics(this.plugin, 4624);
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().fine("Metrics has been enabled.");
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.metrics == null) {
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().warning("Metrics isn't enabled so we do nothing.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.metrics.shutdown();
|
||||
this.metrics = null;
|
||||
|
||||
if (this.plugin.isLogging()) this.plugin.getLogger().fine("Metrics has been turned off.");
|
||||
}
|
||||
}
|
@ -0,0 +1,524 @@
|
||||
package com.badbones69.crazyauctions.paper.commands;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.paper.Methods;
|
||||
import com.badbones69.crazyauctions.paper.api.CrazyManager;
|
||||
import com.badbones69.crazyauctions.paper.api.FileManager;
|
||||
import com.badbones69.crazyauctions.paper.api.FileManager.Files;
|
||||
import com.badbones69.crazyauctions.paper.api.enums.Category;
|
||||
import com.badbones69.crazyauctions.paper.api.enums.Messages;
|
||||
import com.badbones69.crazyauctions.paper.api.enums.ShopType;
|
||||
import com.badbones69.crazyauctions.paper.api.events.AuctionListEvent;
|
||||
import com.badbones69.crazyauctions.paper.controllers.GuiListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class AuctionCommand implements CommandExecutor {
|
||||
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
private final CrazyManager crazyManager = this.plugin.getCrazyManager();
|
||||
|
||||
private final FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, String commandLabel, String[] args) {
|
||||
FileConfiguration config = Files.CONFIG.getFile();
|
||||
FileConfiguration data = Files.DATA.getFile();
|
||||
|
||||
if (args.length == 0) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (config.contains("Settings.Category-Page-Opens-First")) {
|
||||
if (config.getBoolean("Settings.Category-Page-Opens-First")) {
|
||||
GuiListener.openCategories(player, ShopType.SELL);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (crazyManager.isSellingEnabled()) {
|
||||
GuiListener.openShop(player, ShopType.SELL, Category.NONE, 1);
|
||||
} else if (crazyManager.isBiddingEnabled()) {
|
||||
GuiListener.openShop(player, ShopType.BID, Category.NONE, 1);
|
||||
} else {
|
||||
player.sendMessage(Methods.getPrefix() + Methods.color("&cThe bidding and selling options are both disabled. Please contact the admin about this."));
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "help" -> {
|
||||
if (!Methods.hasPermission(sender, "access")) {
|
||||
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(Messages.HELP.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
case "test" -> {
|
||||
if (!Methods.hasPermission(sender, "test")) {
|
||||
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
int times = 1;
|
||||
|
||||
if (args.length >= 2) {
|
||||
if (!Methods.isInt(args[1])) {
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Arg%", args[1]);
|
||||
placeholders.put("%arg%", args[1]);
|
||||
sender.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
|
||||
return true;
|
||||
}
|
||||
|
||||
times = Integer.parseInt(args[1]);
|
||||
}
|
||||
|
||||
int price = 10;
|
||||
int amount = 1;
|
||||
ItemStack item = Methods.getItemInHand((Player) sender);
|
||||
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
// For testing as another player
|
||||
String seller = "Test-Account";
|
||||
|
||||
for (int it = 1; it <= times; it++) {
|
||||
int num = 1;
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
for (; data.contains("Items." + num); num++) ;
|
||||
|
||||
data.set("Items." + num + ".Price", price);
|
||||
data.set("Items." + num + ".Seller", seller);
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time")));
|
||||
} else {
|
||||
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time")));
|
||||
}
|
||||
|
||||
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time")));
|
||||
int id = random.nextInt(Integer.MAX_VALUE);
|
||||
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false))
|
||||
if (data.getInt("Items." + i + ".StoreID") == id)
|
||||
id = random.nextInt(Integer.MAX_VALUE);
|
||||
|
||||
data.set("Items." + num + ".StoreID", id);
|
||||
data.set("Items." + num + ".Biddable", args[0].equalsIgnoreCase("Bid"));
|
||||
data.set("Items." + num + ".TopBidder", "None");
|
||||
|
||||
ItemStack stack = item.clone();
|
||||
stack.setAmount(amount);
|
||||
|
||||
data.set("Items." + num + ".Item", stack);
|
||||
}
|
||||
|
||||
Files.DATA.saveFile();
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Price%", String.valueOf(price));
|
||||
placeholders.put("%price%", String.valueOf(price));
|
||||
|
||||
sender.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
|
||||
|
||||
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
|
||||
Methods.setItemInHand((Player) sender, new ItemStack(Material.AIR));
|
||||
} else {
|
||||
item.setAmount(item.getAmount() - amount);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Messages.DOESNT_HAVE_ITEM_IN_HAND.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
case "reload" -> {
|
||||
if (!Methods.hasPermission(sender, "admin")) {
|
||||
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
this.fileManager.setup();
|
||||
this.crazyManager.load();
|
||||
|
||||
sender.sendMessage(Messages.RELOAD.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
case "view" -> {
|
||||
if (!Methods.hasPermission(sender, "view")) {
|
||||
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
GuiListener.openViewer(player, args[1], 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(Messages.CRAZYAUCTIONS_VIEW.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
case "expired", "collect" -> {
|
||||
if (!Methods.hasPermission(sender, "access")) {
|
||||
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
GuiListener.openPlayersExpiredList(player, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
case "listed" -> {
|
||||
if (!Methods.hasPermission(sender, "access")) return true;
|
||||
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
GuiListener.openPlayersCurrentList(player, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
case "sell", "bid" -> {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
if (args[0].equalsIgnoreCase("sell")) {
|
||||
if (!crazyManager.isSellingEnabled()) {
|
||||
player.sendMessage(Messages.SELLING_DISABLED.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Methods.hasPermission(player, "sell")) return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
if (!crazyManager.isBiddingEnabled()) {
|
||||
player.sendMessage(Messages.BIDDING_DISABLED.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Methods.hasPermission(player, "bid")) return true;
|
||||
}
|
||||
|
||||
ItemStack item = Methods.getItemInHand(player);
|
||||
int amount = item.getAmount();
|
||||
|
||||
if (args.length >= 3) {
|
||||
if (!Methods.isInt(args[2])) {
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Arg%", args[2]);
|
||||
placeholders.put("%arg%", args[2]);
|
||||
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
|
||||
return true;
|
||||
}
|
||||
|
||||
amount = Integer.parseInt(args[2]);
|
||||
if (amount <= 0) amount = 1;
|
||||
if (amount > item.getAmount()) amount = item.getAmount();
|
||||
}
|
||||
|
||||
if (!Methods.isLong(args[1])) {
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Arg%", args[1]);
|
||||
placeholders.put("%arg%", args[1]);
|
||||
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Methods.getItemInHand(player).getType() == Material.AIR) {
|
||||
player.sendMessage(Messages.DOESNT_HAVE_ITEM_IN_HAND.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
long price = Long.parseLong(args[1]);
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
if (price < config.getLong("Settings.Minimum-Bid-Price")) {
|
||||
player.sendMessage(Messages.BID_PRICE_TO_LOW.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (price > config.getLong("Settings.Max-Beginning-Bid-Price")) {
|
||||
player.sendMessage(Messages.BID_PRICE_TO_HIGH.getMessage());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (price < config.getLong("Settings.Minimum-Sell-Price")) {
|
||||
player.sendMessage(Messages.SELL_PRICE_TO_LOW.getMessage());
|
||||
return true;
|
||||
}
|
||||
if (price > config.getLong("Settings.Max-Beginning-Sell-Price")) {
|
||||
player.sendMessage(Messages.SELL_PRICE_TO_HIGH.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.hasPermission("crazyauctions.bypass")) {
|
||||
int SellLimit = 0;
|
||||
int BidLimit = 0;
|
||||
|
||||
for (PermissionAttachmentInfo permission : player.getEffectivePermissions()) {
|
||||
String perm = permission.getPermission();
|
||||
|
||||
if (perm.startsWith("crazyauctions.sell.")) {
|
||||
perm = perm.replace("crazyauctions.sell.", "");
|
||||
|
||||
if (Methods.isInt(perm)) {
|
||||
if (Integer.parseInt(perm) > SellLimit) {
|
||||
SellLimit = Integer.parseInt(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (perm.startsWith("crazyauctions.bid.")) {
|
||||
perm = perm.replace("crazyauctions.bid.", "");
|
||||
if (Methods.isInt(perm)) {
|
||||
if (Integer.parseInt(perm) > BidLimit) {
|
||||
BidLimit = Integer.parseInt(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < 100; i++) {
|
||||
if (SellLimit < i) {
|
||||
if (player.hasPermission("crazyauctions.sell." + i)) {
|
||||
SellLimit = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (BidLimit < i) {
|
||||
if (player.hasPermission("crazyauctions.bid." + i)) {
|
||||
BidLimit = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("sell")) {
|
||||
if (crazyManager.getItems(player, ShopType.SELL).size() >= SellLimit) {
|
||||
player.sendMessage(Messages.MAX_ITEMS.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
if (crazyManager.getItems(player, ShopType.BID).size() >= BidLimit) {
|
||||
player.sendMessage(Messages.MAX_ITEMS.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String id : config.getStringList("Settings.BlackList")) {
|
||||
if (item.getType() == Methods.makeItem(id, 1).getType()) {
|
||||
player.sendMessage(Messages.ITEM_BLACKLISTED.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.getBoolean("Settings.Allow-Damaged-Items")) {
|
||||
for (Material i : getDamageableItems()) {
|
||||
if (item.getType() == i) {
|
||||
if (item.getDurability() > 0) {
|
||||
player.sendMessage(Messages.ITEM_DAMAGED.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowBook(item)) {
|
||||
player.sendMessage(Messages.BOOK_NOT_ALLOWED.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
String seller = player.getName();
|
||||
int num = 1;
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
for (; data.contains("Items." + num); num++) ;
|
||||
data.set("Items." + num + ".Price", price);
|
||||
data.set("Items." + num + ".Seller", seller);
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time")));
|
||||
} else {
|
||||
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time")));
|
||||
}
|
||||
|
||||
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time")));
|
||||
int id = random.nextInt(999999);
|
||||
// Runs 3x to check for same ID.
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false))
|
||||
if (data.getInt("Items." + i + ".StoreID") == id) id = random.nextInt(Integer.MAX_VALUE);
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false))
|
||||
if (data.getInt("Items." + i + ".StoreID") == id) id = random.nextInt(Integer.MAX_VALUE);
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false))
|
||||
if (data.getInt("Items." + i + ".StoreID") == id) id = random.nextInt(Integer.MAX_VALUE);
|
||||
data.set("Items." + num + ".StoreID", id);
|
||||
ShopType type = ShopType.SELL;
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
data.set("Items." + num + ".Biddable", true);
|
||||
type = ShopType.BID;
|
||||
} else {
|
||||
data.set("Items." + num + ".Biddable", false);
|
||||
}
|
||||
|
||||
data.set("Items." + num + ".TopBidder", "None");
|
||||
|
||||
ItemStack stack = item.clone();
|
||||
stack.setAmount(amount);
|
||||
|
||||
data.set("Items." + num + ".Item", stack);
|
||||
|
||||
Files.DATA.saveFile();
|
||||
|
||||
this.plugin.getServer().getPluginManager().callEvent(new AuctionListEvent(player, type, stack, price));
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
|
||||
placeholders.put("%Price%", String.valueOf(price));
|
||||
placeholders.put("%price%", String.valueOf(price));
|
||||
player.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
|
||||
|
||||
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
|
||||
Methods.setItemInHand(player, new ItemStack(Material.AIR));
|
||||
} else {
|
||||
item.setAmount(item.getAmount() - amount);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage(Messages.CRAZYAUCTIONS_SELL_BID.getMessage());
|
||||
}
|
||||
|
||||
default -> {
|
||||
sender.sendMessage(Methods.getPrefix("&cPlease do /crazyauctions help for more information."));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Material> getDamageableItems() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
ma.add(Material.GOLDEN_HELMET);
|
||||
ma.add(Material.GOLDEN_CHESTPLATE);
|
||||
ma.add(Material.GOLDEN_LEGGINGS);
|
||||
ma.add(Material.GOLDEN_BOOTS);
|
||||
ma.add(Material.GOLDEN_HOE);
|
||||
ma.add(Material.WOODEN_SWORD);
|
||||
ma.add(Material.WOODEN_PICKAXE);
|
||||
ma.add(Material.WOODEN_AXE);
|
||||
ma.add(Material.WOODEN_SHOVEL);
|
||||
ma.add(Material.WOODEN_HOE);
|
||||
ma.add(Material.STONE_SHOVEL);
|
||||
ma.add(Material.IRON_SHOVEL);
|
||||
ma.add(Material.DIAMOND_SHOVEL);
|
||||
ma.add(Material.CROSSBOW);
|
||||
ma.add(Material.TRIDENT);
|
||||
ma.add(Material.TURTLE_HELMET);
|
||||
ma.add(Material.DIAMOND_HELMET);
|
||||
ma.add(Material.DIAMOND_CHESTPLATE);
|
||||
ma.add(Material.DIAMOND_LEGGINGS);
|
||||
ma.add(Material.DIAMOND_BOOTS);
|
||||
ma.add(Material.CHAINMAIL_HELMET);
|
||||
ma.add(Material.CHAINMAIL_CHESTPLATE);
|
||||
ma.add(Material.CHAINMAIL_LEGGINGS);
|
||||
ma.add(Material.CHAINMAIL_BOOTS);
|
||||
ma.add(Material.IRON_HELMET);
|
||||
ma.add(Material.IRON_CHESTPLATE);
|
||||
ma.add(Material.IRON_LEGGINGS);
|
||||
ma.add(Material.IRON_BOOTS);
|
||||
ma.add(Material.LEATHER_HELMET);
|
||||
ma.add(Material.LEATHER_CHESTPLATE);
|
||||
ma.add(Material.LEATHER_LEGGINGS);
|
||||
ma.add(Material.LEATHER_BOOTS);
|
||||
ma.add(Material.BOW);
|
||||
ma.add(Material.STONE_SWORD);
|
||||
ma.add(Material.IRON_SWORD);
|
||||
ma.add(Material.DIAMOND_SWORD);
|
||||
ma.add(Material.STONE_AXE);
|
||||
ma.add(Material.IRON_AXE);
|
||||
ma.add(Material.DIAMOND_AXE);
|
||||
ma.add(Material.STONE_PICKAXE);
|
||||
ma.add(Material.IRON_PICKAXE);
|
||||
ma.add(Material.DIAMOND_PICKAXE);
|
||||
ma.add(Material.STONE_AXE);
|
||||
ma.add(Material.IRON_AXE);
|
||||
ma.add(Material.DIAMOND_AXE);
|
||||
ma.add(Material.STONE_HOE);
|
||||
ma.add(Material.IRON_HOE);
|
||||
ma.add(Material.DIAMOND_HOE);
|
||||
ma.add(Material.FLINT_AND_STEEL);
|
||||
ma.add(Material.ANVIL);
|
||||
ma.add(Material.FISHING_ROD);
|
||||
|
||||
return ma;
|
||||
}
|
||||
|
||||
private boolean allowBook(ItemStack item) {
|
||||
if (item != null && item.hasItemMeta() && item.getItemMeta() instanceof BookMeta bookMeta) {
|
||||
this.plugin.getLogger().info("Checking " + item.getType() + " for illegal unicode.");
|
||||
|
||||
FileConfiguration file = Files.TEST_FILE.getFile();
|
||||
|
||||
try {
|
||||
file.set("Test", item);
|
||||
|
||||
Files.TEST_FILE.saveFile();
|
||||
|
||||
this.plugin.getLogger().info(item.getType() + " has passed unicode checks.");
|
||||
} catch (YAMLException exception) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, item.getType() + " has failed unicode checks and has been denied.", exception);
|
||||
return false;
|
||||
}
|
||||
|
||||
return bookMeta.getPages().stream().mapToInt(String :: length).sum() < 2000;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.badbones69.crazyauctions.paper.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AuctionTab implements TabCompleter {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) {
|
||||
List<String> completions = new ArrayList<>();
|
||||
if (args.length == 1) { // /voucher
|
||||
if (hasPermission(sender, "access")) {
|
||||
completions.add("help");
|
||||
completions.add("collect");
|
||||
completions.add("expired");
|
||||
completions.add("listed");
|
||||
}
|
||||
if (hasPermission(sender, "test")) completions.add("test");
|
||||
if (hasPermission(sender, "admin")) completions.add("reload");
|
||||
if (hasPermission(sender, "view")) completions.add("view");
|
||||
if (hasPermission(sender, "sell")) completions.add("sell");
|
||||
if (hasPermission(sender, "bid")) completions.add("bid");
|
||||
return StringUtil.copyPartialMatches(args[0], completions, new ArrayList<>());
|
||||
} else if (args.length == 2) { // /crazyauctions arg0
|
||||
return StringUtil.copyPartialMatches(args[1], completions, new ArrayList<>());
|
||||
} else if (args.length == 3) { // /crazyauctions arg0 arg1
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "bid", "sell" -> {
|
||||
if (hasPermission(sender, "bid") || hasPermission(sender, "sell")) completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
|
||||
}
|
||||
}
|
||||
|
||||
return StringUtil.copyPartialMatches(args[2], completions, new ArrayList<>());
|
||||
} else if (args.length == 4) { // /crazyauctions arg0 arg1 arg2
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "bid", "sell" -> {
|
||||
if (hasPermission(sender, "bid") || hasPermission(sender, "sell")) completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
|
||||
}
|
||||
}
|
||||
|
||||
return StringUtil.copyPartialMatches(args[3], completions, new ArrayList<>());
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private boolean hasPermission(CommandSender sender, String node) {
|
||||
return sender.hasPermission("crazyauctions." + node) || sender.hasPermission("crazyauctions.admin.*");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
package com.badbones69.crazyauctions.paper.controllers;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.api.FileManager.Files;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class MarcoListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPreCommand(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
boolean macro = Files.CONFIG.getFile().getBoolean("Settings.Patches.Macro-Dupe", true);
|
||||
|
||||
if (!macro) return;
|
||||
|
||||
if (!player.isOnline() || player.isDead()) event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.badbones69.crazyauctions.paper.currency;
|
||||
|
||||
import com.badbones69.crazyauctions.paper.CrazyAuctions;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VaultSupport {
|
||||
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
private Economy vault = null;
|
||||
|
||||
public Economy getVault() {
|
||||
return vault;
|
||||
}
|
||||
|
||||
public void loadVault() {
|
||||
RegisteredServiceProvider<Economy> serviceProvider = this.plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
|
||||
if (serviceProvider != null) vault = serviceProvider.getProvider();
|
||||
}
|
||||
|
||||
public Long getMoney(@NotNull Player player) {
|
||||
return (long) vault.getBalance(player);
|
||||
}
|
||||
|
||||
public void removeMoney(@NotNull Player player, Long amount) {
|
||||
vault.withdrawPlayer(player, amount);
|
||||
}
|
||||
|
||||
public void removeMoney(@NotNull OfflinePlayer player, Long amount) {
|
||||
vault.withdrawPlayer(player, amount);
|
||||
}
|
||||
|
||||
public void addMoney(Player player, Long amount) {
|
||||
vault.depositPlayer(player, amount);
|
||||
}
|
||||
|
||||
public void addMoney(OfflinePlayer player, Long amount) {
|
||||
vault.depositPlayer(player, amount);
|
||||
}
|
||||
}
|
305
paper/src/main/resources/config.yml
Normal file
305
paper/src/main/resources/config.yml
Normal file
@ -0,0 +1,305 @@
|
||||
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: '&8Canceled/Expired Listings' #Name of the Cancelled/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.
|
||||
#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: 'GOLDEN_CHESTPLATE'
|
||||
Toggle: true
|
||||
Slot: 11
|
||||
Name: '&6&lArmor'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7armor that is currently being sold.'
|
||||
Weapons:
|
||||
Item: 'GOLDEN_SWORD'
|
||||
Toggle: true
|
||||
Slot: 12
|
||||
Name: '&6&lWeapons'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7weapons that are currently being sold.'
|
||||
Tools:
|
||||
Item: 'GOLDEN_PICKAXE'
|
||||
Toggle: true
|
||||
Slot: 13
|
||||
Name: '&6&lTools'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7tools that are currently being sold.'
|
||||
Food:
|
||||
Item: 'GOLDEN_APPLE'
|
||||
Toggle: true
|
||||
Slot: 14
|
||||
Name: '&6&lFood'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7food that is currently being sold.'
|
||||
Potions:
|
||||
Item: 'POTION'
|
||||
Toggle: true
|
||||
Slot: 15
|
||||
Name: '&6&lPotions'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7potions that are currently being sold.'
|
||||
Blocks:
|
||||
Item: 'GRASS_BLOCK'
|
||||
Toggle: true
|
||||
Slot: 16
|
||||
Name: '&6&lBlocks'
|
||||
Lore:
|
||||
- '&7This category contains all'
|
||||
- '&7blocks that are currently being sold.'
|
||||
Other:
|
||||
Item: 'GOLD_NUGGET'
|
||||
Toggle: true
|
||||
Slot: 17
|
||||
Name: '&6&lOthers'
|
||||
Lore:
|
||||
- '&7This category contains all the'
|
||||
- '&7other items currently being sold.'
|
||||
None:
|
||||
Item: 'BARRIER'
|
||||
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: 'DIAMOND' #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 Cancelled/Expired Items.
|
||||
Item: 'POISONOUS_POTATO'
|
||||
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: 'PAPER'
|
||||
Toggle: true
|
||||
Slot: 49
|
||||
Name: '&6Previous Page'
|
||||
Lore: { }
|
||||
Refesh: #The button for Refresh Page.
|
||||
Item: 'SUNFLOWER'
|
||||
Toggle: true
|
||||
Slot: 50
|
||||
Name: '&6Refresh Page'
|
||||
Lore: { }
|
||||
NextPage: #The button for Next Page.
|
||||
Item: 'PAPER'
|
||||
Toggle: true
|
||||
Slot: 51
|
||||
Name: '&6Next Page'
|
||||
Lore: { }
|
||||
Category1: #The button for Next Page.
|
||||
Item: 'CHEST'
|
||||
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: 'CHEST'
|
||||
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: 'SLIME_BALL'
|
||||
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: 'MAGMA_CREAM'
|
||||
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: 'BOOK'
|
||||
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: 'BOOK'
|
||||
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: 'BOOK'
|
||||
Toggle: true
|
||||
Slot: 54
|
||||
Name: '&6What Is This Page?'
|
||||
Lore:
|
||||
- '&aThese are your current listings, all of'
|
||||
- '&athe items you currently 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: 'BOOK'
|
||||
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: 'BOOK'
|
||||
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: 'BOOK'
|
||||
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: 'PAPER'
|
||||
Slot: 46
|
||||
Name: '&6Back'
|
||||
Return: #The Return Buttons.
|
||||
Item: 'FLOWER_POT'
|
||||
Slot: 50
|
||||
Name: '&6Return All'
|
||||
Lore:
|
||||
- '&aClick here to return all cancelled'
|
||||
- '&aand expired items to your inventory.'
|
||||
Confirm: #The Confirm Buttons.
|
||||
Item: 'LIME_STAINED_GLASS_PANE'
|
||||
Name: '&aConfirm'
|
||||
Cancel: #The Cancel Buttons.
|
||||
Item: 'RED_STAINED_GLASS_PANE'
|
||||
Name: '&cCancel'
|
||||
Your-Item: #The item that shows when you try to buy/bid on your item.
|
||||
Item: 'BARRIER'
|
||||
Name: '&cYou Can''t Purchase Your Own Item.'
|
||||
Cant-Afford: #The item that shows when you can't afford this item.
|
||||
Item: 'BARRIER'
|
||||
Name: '&cYou Can''t Afford This Item.'
|
||||
Top-Bidder: #The item for when a player is already the top bidder.
|
||||
Item: 'BARRIER'
|
||||
Name: '&cYou are already the top bidder.'
|
||||
Bidding: #The item in the middle when bidding on an item.
|
||||
Item: 'BLACK_STAINED_GLASS_PANE'
|
||||
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: 'LIGHT_BLUE_STAINED_GLASS_PANE'
|
||||
Name: '&bBid Now'
|
||||
Lore:
|
||||
- '&7Click here to Bid Now.'
|
||||
BlackList:
|
||||
- 'BEDROCK'
|
||||
- 'END_PORTAL_FRAME'
|
2
paper/src/main/resources/data.yml
Normal file
2
paper/src/main/resources/data.yml
Normal file
@ -0,0 +1,2 @@
|
||||
Items: {}
|
||||
OutOfTime/Cancelled: {}
|
45
paper/src/main/resources/messages.yml
Normal file
45
paper/src/main/resources/messages.yml
Normal file
@ -0,0 +1,45 @@
|
||||
Messages:
|
||||
Players-Only: '&cOnly players can use this command.'
|
||||
Reload: '&7You have just reloaded the Crazy Auctions Files.'
|
||||
Need-More-Money: '&cYou are in need of &a$%money_needed%&c.'
|
||||
Inventory-Full: '&cYour inventory is too full. Please open up some space to buy that.'
|
||||
No-Permission: '&cYou do not have permission to use that command!'
|
||||
Not-Online: '&cThat player is not online.'
|
||||
Doesnt-Have-Item-In-Hand: '&cYou must have an item in your hand.'
|
||||
Not-A-Number: '&c%arg% is not a number.'
|
||||
Got-Item-Back: '&7Your item has been returned.'
|
||||
Cancelled-Item: '&7You have canceled an item on the auction list, return your items with /ah expired.'
|
||||
Item-Has-Expired: '&7An item you have in the Crazy Auctions has expired.'
|
||||
Admin-Force-Cancelled: '&7You have force canceled a sale.'
|
||||
Admin-Force-Cancelled-To-Player: '&cOne of your items was force canceled by an Admin.'
|
||||
Item-Doesnt-Exist: '&cThat item isn''t in the crazy auctions any more.'
|
||||
Max-Items: '&cYou can''t list any more items to the Crazy Auctions.'
|
||||
Item-BlackListed: '&cThat item is not allowed to be sold here.'
|
||||
Item-Damaged: '&cThat item is damaged and is not allowed to be sold here.'
|
||||
Sold-Msg: '&7Thank you for buying this item.'
|
||||
Bid-More-Money: '&cYour bid is too low, please bid more.'
|
||||
Not-A-Currency: '&cThat is not a currency. Please use Money or Tokens.' #Remove Tokens if you do not have TokenManager.
|
||||
Sell-Price-To-Low: '&cYour sell price is too low the minimum is &a$10&c.'
|
||||
Sell-Price-To-High: '&cYour sell price is too high the maximum is &a$1000000&c.'
|
||||
Bid-Price-To-Low: '&cYour starting bid price is too low the minimum is &a$100&c.'
|
||||
Bid-Price-To-High: '&cYour starting bid price is too high the maximum is &a$1000000&c.'
|
||||
Bought-Item: '&7You have just bought an item for &a$%price%&7.'
|
||||
Win-Bidding: '&7You have just won a bid for &a$%price%&7. Do /Ah Collect to collect your winnings.'
|
||||
Player-Bought-Item: '&7%player% has bought your item for &a$%price%.'
|
||||
Someone-Won-Players-Bid: '&7%player% has won your item with a bid of &a$%price%.'
|
||||
Added-Item-To-Auction: '&7You have just added an item to the crazy auctions for &a$%price%&7.'
|
||||
Bid-Msg: '&7You have just bid &a$%Bid% &7on that item.'
|
||||
Selling-Disabled: '&cThe selling option is disabled.'
|
||||
Bidding-Disabled: '&cThe bidding option is disabled.'
|
||||
CrazyAuctions-Help: '&c/ah help'
|
||||
CrazyAuctions-View: '&c/ah view <player>'
|
||||
CrazyAuctions-Sell-Bid: '&c/ah sell/bid <price> [amount of items]'
|
||||
Book-Not-Allowed: '&cThat book is not able to be sold in this auction house!'
|
||||
Help-Menu:
|
||||
- '&e-- &6Crazy Auctions Help &e--'
|
||||
- '&9/Ah - &eOpens the crazy auction.'
|
||||
- '&9/Ah View <Player> - &eSee what a player is selling.'
|
||||
- '&9/Ah Sell/Bid <Price> [Amount of items] - &eList the item you are holding on the crazy auction.'
|
||||
- '&9/Ah Expired/Collect - &eView and manage your canceled and expired items.'
|
||||
- '&9/Ah Listed - &eView and manage the items you are selling.'
|
||||
- '&9/Ah Help - &eView this help menu.'
|
49
paper/src/main/resources/plugin.yml
Normal file
49
paper/src/main/resources/plugin.yml
Normal file
@ -0,0 +1,49 @@
|
||||
name: '${name}'
|
||||
main: '${group}.${name}'
|
||||
|
||||
authors: ${authors}
|
||||
|
||||
version: '${version}'
|
||||
api-version: '${apiVersion}'
|
||||
description: '${description}'
|
||||
website: '${website}'
|
||||
|
||||
depend: [Vault]
|
||||
|
||||
commands:
|
||||
crazyauctions:
|
||||
description: Opens the Crazy Auctions GUI.
|
||||
aliases: [crazyauction, ah, ca]
|
||||
|
||||
permissions:
|
||||
crazyauctions.access:
|
||||
default: true
|
||||
|
||||
crazyauctions.test:
|
||||
default: op
|
||||
|
||||
crazyauctions.view:
|
||||
default: true
|
||||
|
||||
crazyauctions.reload:
|
||||
default: op
|
||||
|
||||
crazyauctions.sell:
|
||||
default: true
|
||||
|
||||
crazyauctions.bid:
|
||||
default: true
|
||||
|
||||
crazyauctions.player.*:
|
||||
default: false
|
||||
children:
|
||||
crazyauctions.bid: true
|
||||
crazyauctions.sell: true
|
||||
crazyauctions.access: true
|
||||
crazyauctions.view: true
|
||||
|
||||
crazyauctions.admin:
|
||||
default: op
|
||||
children:
|
||||
crazyauctions.test: true
|
||||
crazyauctions.reload: true
|
2
paper/src/main/resources/test-file.yml
Normal file
2
paper/src/main/resources/test-file.yml
Normal file
@ -0,0 +1,2 @@
|
||||
#!!DO NOT DELETE!!
|
||||
#Used for unicode checking in books.
|
@ -10,5 +10,4 @@ pluginManagement {
|
||||
|
||||
rootProject.name = 'CrazyAuctions'
|
||||
|
||||
include 'common'
|
||||
include 'paper'
|
Loading…
Reference in New Issue
Block a user