Merge branch 'v1.2.7'

Added:
- %time% placeholder can now be in the selling items lore.
- 1.13 support has been added.

Fixed:
- Sometimes for different languages, the comma would show as an unknown character.

Removed:
- MassiveStats has been removed due to its shutdown.

Changes:
- Small code cleanup to make it more readable.
This commit is contained in:
BadBones69 2019-01-25 03:17:20 -05:00
commit 97d341d311
9 changed files with 319 additions and 610 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.badbones69</groupId>
<artifactId>crazyauctions</artifactId>
<version>1.2.6</version>
<version>1.2.7</version>
<repositories>
<repository>
@ -27,7 +27,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -83,9 +83,9 @@
<include>me.badbones69:*</include>
</includes>
</artifactSet>
<!--<finalName>${project.artifactId}[v${project.version}]</finalName>-->
<finalName>Crazy Auctions[v${project.version}-Dev-Build-v2]</finalName>
<!--<outputFile>/Users/badbones/Desktop/Stuff/Server/plugins/Crazy Auctions[v${project.version}].jar</outputFile>-->
<outputFile>/Users/badbones/Plugins/Public Plugins/Crazy Auctions/Crazy Auctions[v${project.version}].jar</outputFile>
<!--<outputFile>/Users/badbones/Plugins/Public Plugins/Crazy Auctions/Crazy Auctions[v${project.version}].jar</outputFile>-->
</configuration>
<executions>
<execution>

View File

@ -1,487 +0,0 @@
package com.massivestats;/*
* Copyright 2018 (c) Massive Statistics LLC - All Rights Reserved
* This file may only be used in conjunction with the 'com.massivestats.MassiveStats' service.
*/
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
/**
* com.massivestats.MassiveStats collects plugin and server information for plugin authors.
* You can learn more at our website: https://www.massivestats.com/
*
* @version 3.0
* @author Sam Jakob Harker, Brianna Hazel O'Keefe
*/
@SuppressWarnings("all")
public class MassiveStats implements Listener {
/* START: MASSIVESTATS SETTINGS */
public static final int CLIENT_VERSION = 0; // v3.0
public static final String API_URL = "https://report.massivestats.com/v2/";
public static final String MASSIVE_UPDATE_PERMISSION = "massivestats.update";
/* END: MASSIVESTATS SETTINGS */
private MassiveStatsUpdateTask task = null;
private int pingInterval;
private MassiveStatsDataResponse lastResponse;
private boolean listenerDisabled;
private final JavaPlugin plugin;
private Class jsonElement;
private Class jsonParser;
private Class jsonObject;
private Class jsonPrimitive;
/**
* @param plugin The plugin you wish to collect data for.
* @author Sam Jakob Harker
*/
public MassiveStats(JavaPlugin plugin) {
this(plugin, 900); // default value: 900 seconds (= 15 minutes)
}
/**
* @param plugin The plugin you wish to collect data for.
* @param pingInterval Duration between requests.
* @author Sam Jakob Harker
*/
public MassiveStats(JavaPlugin plugin, int pingInterval) {
try {
jsonElement = Class.forName("com.google.gson.JsonElement");
jsonParser = Class.forName("com.google.gson.JsonParser");
jsonObject = Class.forName("com.google.gson.JsonObject");
jsonPrimitive = Class.forName("com.google.gson.JsonPrimitive");
}catch(ClassNotFoundException ex) {
// Gson not included in classpath (so use NMS version)
try {
jsonElement = Class.forName("net.minecraft.util.com.google.gson.JsonElement");
jsonParser = Class.forName("net.minecraft.util.com.google.gson.JsonParser");
jsonObject = Class.forName("net.minecraft.util.com.google.gson.JsonObject");
jsonPrimitive = Class.forName("net.minecraft.util.com.google.gson.JsonPrimitive");
}catch(ClassNotFoundException ignored) {
Bukkit.getLogger().severe("com.massivestats.MassiveStats could not find an instance/version of Gson to use.");
this.plugin = null;
return;
}
}
// Ensure the pingInterval that is set is reasonable.
if(pingInterval < 10 || pingInterval > 86400) {
pingInterval = 900;
}
// Ensure that a plugin instance has been provided.
if(plugin == null) {
throw new IllegalArgumentException("You must provide a plugin for com.massivestats.MassiveStats to collect data for!");
}
// Set the ping interval.
this.pingInterval = pingInterval;
// Set the plugin reference.
this.plugin = plugin;
// and start sending data to the com.massivestats.MassiveStats server immediately.
start();
// Register join/leave events for the plugin
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
}
/**
* Gets whether or not the built-in com.massivestats.MassiveStats {@link PlayerJoinEvent} listener is enabled.
* @return Whether or not the com.massivestats.MassiveStats listener is enabled.
*/
public boolean isListenerDisabled() {
return listenerDisabled;
}
/**
* Sets whether or not the built-in com.massivestats.MassiveStats {@link PlayerJoinEvent} listener is enabled.
* @param listenerDisabled Whether or not the com.massivestats.MassiveStats listener is enabled.
*/
public void setListenerDisabled(boolean listenerDisabled) {
this.listenerDisabled = listenerDisabled;
}
/**
* Start the com.massivestats.MassiveStats reporting timer.
* If the timer is already running, this method will do nothing.
* @author Sam Jakob Harker
*/
public void start() {
if(this.plugin == null) {
Bukkit.getLogger().severe("com.massivestats.MassiveStats could not find an instance/version of Gson to use and thus cannot start.");
return;
}
if(task == null) {
// If the API endpoint URL is invalid, don't start a new task to prevent the user from being spammed.
try {
new URL(MassiveStats.API_URL);
}catch(MalformedURLException ex) {
getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for com.massivestats.MassiveStats.");
return;
}
task = new MassiveStatsUpdateTask(this);
task.runTaskTimerAsynchronously(plugin, 0L, pingInterval * 20L);
}
}
/**
* Stop the com.massivestats.MassiveStats reporting timer.
* Requests will no longer be sent to the server - or until {@link #start()} is invoked.
* @author Sam Jakob Harker
*/
public void stop() {
if(task == null) {
return;
}
task.cancel();
task = null;
}
/**
* Sets the duration, in seconds, that com.massivestats.MassiveStats should wait before sending another request to the server.
* @param pingInterval Duration between requests.
* @author Sam Jakob Harker
*/
public void setPingInterval(int pingInterval) {
this.pingInterval = pingInterval;
stop();
start();
}
/**
* Returns the duration, in seconds, that com.massivestats.MassiveStats will wait before sending another request to the server.
* @return Duration between requests.
* @author Sam Jakob Harker
*/
public int getPingInterval() {
return pingInterval;
}
/**
* Returns the plugin that this com.massivestats.MassiveStats instance is collecting data for.
* @return com.massivestats.MassiveStats instance plugin.
* @author Sam Jakob Harker
*/
public JavaPlugin getPlugin() {
return plugin;
}
void setLastResponse(MassiveStatsDataResponse lastResponse) {
this.lastResponse = lastResponse;
}
/**
* Returns the contents of the last response from the com.massivestats.MassiveStats server.
* @return com.massivestats.MassiveStats server response.
* @author Sam Jakob Harker
*/
public MassiveStatsDataResponse getLastResponse() {
return lastResponse;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
// Ensure the listener should be active
if(lastResponse == null || listenerDisabled) {
return;
}
// Of course, only notify the user if the plugin is not up to date.
if(lastResponse.isUpToDate()) {
return;
}
// and only notify operators - or players with the correct permission.
if(!event.getPlayer().isOp() && !event.getPlayer().hasPermission(MassiveStats.MASSIVE_UPDATE_PERMISSION)) {
return;
}
event.getPlayer().sendMessage(lastResponse.getUpdateMessage());
}
Class getJsonElement() {
return jsonElement;
}
Class getJsonParser() {
return jsonParser;
}
Class getJsonObject() {
return jsonObject;
}
Class getJsonPrimitive() {
return jsonPrimitive;
}
}
class MassiveStatsUpdateTask extends BukkitRunnable {
private final MassiveStats instance;
MassiveStatsUpdateTask(MassiveStats requester) {
instance = requester;
}
@Override
@SuppressWarnings("all")
public void run() {
try {
// Generate the request payload and serialize it as JSON.
String payload = new MassiveStatsDataRequest(instance).serialize();
// Then create a new HttpsUrlConnection to the API server and open it.
HttpsURLConnection connection = (HttpsURLConnection) new URL(MassiveStats.API_URL).openConnection();
// Ensure that we don't hang the server with our 'dang shenanigans'.
connection.setConnectTimeout(2500);
connection.setReadTimeout(3500);
// Set the all-important request headers before we begin POSTing...
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
connection.setRequestProperty("User-Agent", "Massive/" + MassiveStats.CLIENT_VERSION);
// Open the output stream, write the payload, and then close the stream.
connection.setDoOutput(true);
DataOutputStream output = new DataOutputStream(connection.getOutputStream());
output.writeBytes(payload);
output.flush();
output.close();
// Ensure that the server was happy with our data.
int responseCode = connection.getResponseCode();
if(responseCode != 200) {
throw new IOException();
}
// Now, read the server's response to our payload...
BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
// ...line by line.
String line;
while((line = input.readLine()) != null) {
response.append(line);
}
input.close();
// Now, we parse the JSON object.
try {
if(response.toString().contains("ERR_DATA_MISSING")) {
Bukkit.getLogger().severe("com.massivestats.MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName());
instance.stop();
return;
}
Object parser = instance.getJsonParser().newInstance();
// JsonElement
Object serverResponseRaw =
parser.getClass().getMethod("parse", String.class).invoke(parser, response.toString());
// JsonObject
Object serverResponse = serverResponseRaw.getClass().getMethod("getAsJsonObject", null)
.invoke(serverResponseRaw, null);
Method serverResponseGet = instance.getJsonObject().getMethod("get", String.class);
Method getAsBoolean =
instance.getJsonPrimitive().getMethod("getAsBoolean", null);
Method getAsString =
instance.getJsonPrimitive().getMethod("getAsString", null);
if(serverResponseGet.invoke(serverResponse, "upToDate") == null) {
Bukkit.getLogger().severe("com.massivestats.MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName());
instance.stop();
return;
}
if(serverResponseGet.invoke(serverResponse, "notice") != null) {
Bukkit.getLogger().severe(
(String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "notice"))
);
instance.stop();
return;
}
boolean upToDate = (boolean) getAsBoolean.invoke(serverResponseGet.invoke(serverResponse, "upToDate"), null);
String latestVersion = (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "latestVersion"), null);
String updateMessage = ChatColor.translateAlternateColorCodes(
'&', (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "updateMessage"), null)
);
instance.setLastResponse(new MassiveStatsDataResponse(
upToDate, latestVersion, updateMessage
));
}catch(IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
instance.getPlugin()
.getLogger().warning("com.massivestats.MassiveStats returned an invalid response for this plugin.");
}
// Finally, call an event to mark the update.
}catch(MalformedURLException ex) {
instance.getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for com.massivestats.MassiveStats.");
}catch(IOException ex) {
instance.getPlugin()
.getLogger().warning("com.massivestats.MassiveStats was unable to communicate with its API endpoint.");
}
}
}
class MassiveStatsDataRequest {
private Object jsonObject;
MassiveStatsDataRequest(MassiveStats requester) {
try {
jsonObject = requester.getJsonObject().newInstance();
Method add =
requester.getJsonObject().newInstance().getClass().getMethod("add", String.class, requester.getJsonElement());
Method addPropertyString =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, String.class);
Method addPropertyNumber =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Number.class);
Method addPropertyBoolean =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Boolean.class);
addPropertyNumber.invoke(jsonObject, "now", System.currentTimeMillis());
/* PLUGIN DATA */
Object pluginObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(pluginObject, "name", requester.getPlugin().getDescription().getName());
addPropertyString.invoke(pluginObject, "version", requester.getPlugin().getDescription().getVersion());
add.invoke(jsonObject, "plugin", pluginObject);
/* SERVER DATA */
Object minecraftServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(minecraftServerObject, "players", Bukkit.getServer().getOnlinePlayers().size());
addPropertyBoolean.invoke(minecraftServerObject, "onlineMode", Bukkit.getServer().getOnlineMode());
addPropertyString.invoke(minecraftServerObject, "version", Bukkit.getServer().getVersion());
Object javaServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(javaServerObject, "version", System.getProperty("java.version"));
Object osServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(osServerObject, "name", System.getProperty("os.name"));
addPropertyString.invoke(osServerObject, "arch", System.getProperty("os.arch"));
addPropertyString.invoke(osServerObject, "version", System.getProperty("os.version"));
Object hardwareServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(hardwareServerObject, "cores", Runtime.getRuntime().availableProcessors());
Object serverObject = jsonObject.getClass().newInstance();
add.invoke(serverObject, "minecraft", minecraftServerObject);
add.invoke(serverObject, "java", javaServerObject);
add.invoke(serverObject, "os", osServerObject);
add.invoke(serverObject, "hardware", hardwareServerObject);
add.invoke(jsonObject, "server", serverObject);
/* MASSIVE DATA */
Object massiveObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(massiveObject, "version", MassiveStats.CLIENT_VERSION);
addPropertyNumber.invoke(massiveObject, "pingInterval", requester.getPingInterval());
//object.add("Massive", massiveObject);
add.invoke(jsonObject, "Massive", massiveObject);
}catch(IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
}
@SuppressWarnings("all")
public String serialize() {
//return object.toString();
try {
Method toString = jsonObject.getClass().getMethod("toString", null);
return (String) toString.invoke(jsonObject);
}catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
}
@SuppressWarnings("unused") final class MassiveStatsDataResponse {
private final boolean isUpToDate;
private final String newVersion;
private final String updateMessage;
MassiveStatsDataResponse(boolean isUpToDate, String newVersion, String updateMessage) {
this.isUpToDate = isUpToDate;
if(!isUpToDate) {
this.newVersion = newVersion;
this.updateMessage = updateMessage;
return;
}
this.newVersion = null;
this.updateMessage = null;
}
/**
* Indicates whether or not this version of the plugin is the latest.
* True = This is the latest version of the plugin.
* False = There is an update available.
* @return Whether or not there is an update available.
*/
public boolean isUpToDate() {
return isUpToDate;
}
/**
* Gets the name of the latest version. If this is the latest version, it returns null.
* @return The name of the latest version.
*/
public String getLatestVersion() {
return newVersion;
}
/**
* Gets the message to display, convincing the user to update to the new version of the plugin.
* @return The update message to display.
*/
public String getUpdateMessage() {
return updateMessage;
}
}

View File

@ -1,6 +1,5 @@
package me.badbones69.crazyauctions;
import com.massivestats.MassiveStats;
import me.badbones69.crazyauctions.api.*;
import me.badbones69.crazyauctions.api.FileManager.Files;
import me.badbones69.crazyauctions.api.events.AuctionListEvent;
@ -40,10 +39,6 @@ public class Main extends JavaPlugin implements Listener {
if(!Vault.setupEconomy()) {
saveDefaultConfig();
}
try {
MassiveStats massiveStats = new MassiveStats(this);
}catch(Exception e) {
}
Messages.addMissingMessages();
}
@ -169,7 +164,7 @@ public class Main extends JavaPlugin implements Listener {
player.sendMessage(Messages.DOSENT_HAVE_ITEM_IN_HAND.getMessage());
return false;
}
Long price = Long.parseLong(args[1]);
long price = Long.parseLong(args[1]);
if(args[0].equalsIgnoreCase("Bid")) {
if(price < Files.CONFIG.getFile().getLong("Settings.Minimum-Bid-Price")) {
player.sendMessage(Messages.BID_PRICE_TO_LOW.getMessage());
@ -253,6 +248,8 @@ public class Main extends JavaPlugin implements Listener {
}
}
String seller = player.getName();
// For testing as another player
//String seller = "Test-Account";
int num = 1;
Random r = new Random();
for(; Files.DATA.getFile().contains("Items." + num); num++) ;
@ -329,6 +326,37 @@ public class Main extends JavaPlugin implements Listener {
private ArrayList<Material> getDamageableItems() {
ArrayList<Material> ma = new ArrayList<>();
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("GOLDEN_HELMET"));
ma.add(Material.matchMaterial("GOLDEN_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLDEN_LEGGINGS"));
ma.add(Material.matchMaterial("GOLDEN_BOOTS"));
ma.add(Material.matchMaterial("WOODEN_SWORD"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("WOODEN_PICKAXE"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("WOODEN_SHOVEL"));
ma.add(Material.matchMaterial("STONE_SHOVEL"));
ma.add(Material.matchMaterial("IRON_SHOVEL"));
ma.add(Material.matchMaterial("DIAMOND_SHOVEL"));
ma.add(Material.matchMaterial("WOODEN_HOE"));
ma.add(Material.matchMaterial("GOLDEN_HOE"));
}else {
ma.add(Material.matchMaterial("GOLD_HELMET"));
ma.add(Material.matchMaterial("GOLD_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLD_LEGGINGS"));
ma.add(Material.matchMaterial("GOLD_BOOTS"));
ma.add(Material.matchMaterial("WOOD_SWORD"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("WOOD_PICKAXE"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("WOOD_SPADE"));
ma.add(Material.matchMaterial("STONE_SPADE"));
ma.add(Material.matchMaterial("IRON_SPADE"));
ma.add(Material.matchMaterial("DIAMOND_SPADE"));
ma.add(Material.matchMaterial("WOOD_HOE"));
ma.add(Material.matchMaterial("GOLD_HOE"));
}
ma.add(Material.DIAMOND_HELMET);
ma.add(Material.DIAMOND_CHESTPLATE);
ma.add(Material.DIAMOND_LEGGINGS);
@ -337,10 +365,6 @@ public class Main extends JavaPlugin implements Listener {
ma.add(Material.CHAINMAIL_CHESTPLATE);
ma.add(Material.CHAINMAIL_LEGGINGS);
ma.add(Material.CHAINMAIL_BOOTS);
ma.add(Material.GOLD_HELMET);
ma.add(Material.GOLD_CHESTPLATE);
ma.add(Material.GOLD_LEGGINGS);
ma.add(Material.GOLD_BOOTS);
ma.add(Material.IRON_HELMET);
ma.add(Material.IRON_CHESTPLATE);
ma.add(Material.IRON_LEGGINGS);
@ -350,27 +374,18 @@ public class Main extends JavaPlugin implements Listener {
ma.add(Material.LEATHER_LEGGINGS);
ma.add(Material.LEATHER_BOOTS);
ma.add(Material.BOW);
ma.add(Material.WOOD_SWORD);
ma.add(Material.STONE_SWORD);
ma.add(Material.IRON_SWORD);
ma.add(Material.DIAMOND_SWORD);
ma.add(Material.WOOD_AXE);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.WOOD_PICKAXE);
ma.add(Material.STONE_PICKAXE);
ma.add(Material.IRON_PICKAXE);
ma.add(Material.DIAMOND_PICKAXE);
ma.add(Material.WOOD_AXE);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.WOOD_SPADE);
ma.add(Material.STONE_SPADE);
ma.add(Material.IRON_SPADE);
ma.add(Material.DIAMOND_SPADE);
ma.add(Material.WOOD_HOE);
ma.add(Material.STONE_HOE);
ma.add(Material.IRON_HOE);
ma.add(Material.DIAMOND_HOE);

View File

@ -3,6 +3,7 @@ package me.badbones69.crazyauctions;
import me.badbones69.crazyauctions.api.FileManager;
import me.badbones69.crazyauctions.api.FileManager.Files;
import me.badbones69.crazyauctions.api.Messages;
import me.badbones69.crazyauctions.api.Version;
import me.badbones69.crazyauctions.api.events.AuctionWinBidEvent;
import me.badbones69.crazyauctions.currency.CurrencyManager;
import org.bukkit.*;
@ -14,7 +15,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import java.text.NumberFormat;
import java.util.*;
public class Methods {
@ -50,7 +50,12 @@ public class Methods {
try {
item = new ItemStack(m, amount, (short) ty);
}catch(Exception e) {
item = new ItemStack(Material.STAINED_CLAY, 1, (short) 14);
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1);
}else {
item = new ItemStack(Material.matchMaterial("STAINED_CLAY"), 1, (short) 14);
}
}
return item;
}
@ -67,7 +72,12 @@ public class Methods {
try {
item = new ItemStack(m, amount, (short) ty);
}catch(Exception e) {
item = new ItemStack(Material.STAINED_CLAY, 1, (short) 14);
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1);
}else {
item = new ItemStack(Material.matchMaterial("STAINED_CLAY"), 1, (short) 14);
}
}
ItemMeta me = item.getItemMeta();
me.setDisplayName(color(name));
@ -88,7 +98,12 @@ public class Methods {
try {
item = new ItemStack(m, amount, (short) ty);
}catch(Exception e) {
item = new ItemStack(Material.STAINED_CLAY, 1, (short) 14);
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1);
}else {
item = new ItemStack(Material.matchMaterial("STAINED_CLAY"), 1, (short) 14);
}
}
ItemMeta me = item.getItemMeta();
me.setDisplayName(color(name));
@ -400,7 +415,7 @@ public class Methods {
}
public static String getPrice(String ID, Boolean Expired) {
Long price = 0L;
long price = 0L;
if(Expired) {
if(Files.DATA.getFile().contains("OutOfTime/Cancelled." + ID + ".Price")) {
price = Files.DATA.getFile().getLong("OutOfTime/Cancelled." + ID + ".Price");
@ -410,7 +425,7 @@ public class Methods {
price = Files.DATA.getFile().getLong("Items." + ID + ".Price");
}
}
return NumberFormat.getNumberInstance().format(price);
return String.valueOf(price);
}
}

View File

@ -52,6 +52,17 @@ public enum Category {
private static ArrayList<Material> getArmor() {
ArrayList<Material> ma = new ArrayList<>();
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("GOLDEN_HELMET"));
ma.add(Material.matchMaterial("GOLDEN_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLDEN_LEGGINGS"));
ma.add(Material.matchMaterial("GOLDEN_BOOTS"));
}else {
ma.add(Material.matchMaterial("GOLD_HELMET"));
ma.add(Material.matchMaterial("GOLD_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLD_LEGGINGS"));
ma.add(Material.matchMaterial("GOLD_BOOTS"));
}
ma.add(Material.DIAMOND_HELMET);
ma.add(Material.DIAMOND_CHESTPLATE);
ma.add(Material.DIAMOND_LEGGINGS);
@ -60,10 +71,6 @@ public enum Category {
ma.add(Material.CHAINMAIL_CHESTPLATE);
ma.add(Material.CHAINMAIL_LEGGINGS);
ma.add(Material.CHAINMAIL_BOOTS);
ma.add(Material.GOLD_HELMET);
ma.add(Material.GOLD_CHESTPLATE);
ma.add(Material.GOLD_LEGGINGS);
ma.add(Material.GOLD_BOOTS);
ma.add(Material.IRON_HELMET);
ma.add(Material.IRON_CHESTPLATE);
ma.add(Material.IRON_LEGGINGS);
@ -77,19 +84,37 @@ public enum Category {
private static ArrayList<Material> getTools() {
ArrayList<Material> ma = new ArrayList<>();
ma.add(Material.WOOD_PICKAXE);
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("WOODEN_PICKAXE"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("WOODEN_SHOVEL"));
ma.add(Material.matchMaterial("WOODEN_HOE"));
ma.add(Material.matchMaterial("GOLDEN_PICKAXE"));
ma.add(Material.matchMaterial("GOLDEN_AXE"));
ma.add(Material.matchMaterial("GOLDEN_SHOVEL"));
ma.add(Material.matchMaterial("GOLDEN_HOE"));
ma.add(Material.matchMaterial("STONE_SHOVEL"));
ma.add(Material.matchMaterial("IRON_SHOVEL"));
ma.add(Material.matchMaterial("DIAMOND_SHOVEL"));
}else {
ma.add(Material.matchMaterial("WOOD_PICKAXE"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("WOOD_SPADE"));
ma.add(Material.matchMaterial("WOOD_HOE"));
ma.add(Material.matchMaterial("GOLD_PICKAXE"));
ma.add(Material.matchMaterial("GOLD_AXE"));
ma.add(Material.matchMaterial("GOLD_SPADE"));
ma.add(Material.matchMaterial("GOLD_HOE"));
ma.add(Material.matchMaterial("STONE_SPADE"));
ma.add(Material.matchMaterial("IRON_SPADE"));
ma.add(Material.matchMaterial("DIAMOND_SPADE"));
}
ma.add(Material.STONE_PICKAXE);
ma.add(Material.IRON_PICKAXE);
ma.add(Material.DIAMOND_PICKAXE);
ma.add(Material.WOOD_AXE);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.WOOD_SPADE);
ma.add(Material.STONE_SPADE);
ma.add(Material.IRON_SPADE);
ma.add(Material.DIAMOND_SPADE);
ma.add(Material.WOOD_HOE);
ma.add(Material.STONE_HOE);
ma.add(Material.IRON_HOE);
ma.add(Material.DIAMOND_HOE);
@ -98,11 +123,20 @@ public enum Category {
private static ArrayList<Material> getWeapons() {
ArrayList<Material> ma = new ArrayList<>();
ma.add(Material.WOOD_SWORD);
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("WOODEN_SWORD"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("GOLDEN_SWORD"));
ma.add(Material.matchMaterial("GOLDEN_AXE"));
}else {
ma.add(Material.matchMaterial("WOOD_SWORD"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("GOLD_SWORD"));
ma.add(Material.matchMaterial("GOLD_AXE"));
}
ma.add(Material.STONE_SWORD);
ma.add(Material.IRON_SWORD);
ma.add(Material.DIAMOND_SWORD);
ma.add(Material.WOOD_AXE);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);

View File

@ -0,0 +1,121 @@
package me.badbones69.crazyauctions.api;
import org.bukkit.Bukkit;
public enum Version {
TOO_OLD(-1),
v1_7_R1(171), v1_7_R2(172), v1_7_R3(173), v1_7_R4(174),
v1_8_R1(181), v1_8_R2(182), v1_8_R3(183),
v1_9_R1(191), v1_9_R2(192),
v1_10_R1(1101),
v1_11_R1(1111),
v1_12_R1(1121),
v1_13_R1(1131),
TOO_NEW(-2);
private static Version latest;
private Integer versionInteger;
public static Version currentVersion;
private Version(int versionInteger) {
this.versionInteger = versionInteger;
}
/**
*
* @return Get the server's Minecraft version.
*/
public static Version getCurrentVersion() {
if(currentVersion == null) {
String ver = Bukkit.getServer().getClass().getPackage().getName();
int v = Integer.parseInt(ver.substring(ver.lastIndexOf('.') + 1).replaceAll("_", "").replaceAll("R", "").replaceAll("v", ""));
for(Version version : values()) {
if(version.getVersionInteger() == v) {
currentVersion = version;
break;
}
}
if(v > Version.getLatestVersion().getVersionInteger()) {
currentVersion = Version.getLatestVersion();
}
if(currentVersion == null) {
currentVersion = Version.TOO_NEW;
}
}
return currentVersion;
}
/**
*
* @return The server's minecraft version as an integer.
*/
public Integer getVersionInteger() {
return this.versionInteger;
}
/**
* Get the latest version allowed by the Version class.
* @return The latest version.
*/
public static Version getLatestVersion() {
if(latest == null) {
Version v = Version.TOO_OLD;
for(Version version : values()) {
if(version.comparedTo(v) == 1) {
v = version;
}
}
return v;
}else {
return latest;
}
}
/**
* This checks if the current version is older, newer, or is the checked version.
* @param version The version you are checking.
* @return -1 if older, 0 if the same, and 1 if newer.
*/
public Integer comparedTo(Version version) {
int resault = -1;
int current = this.getVersionInteger();
int check = version.getVersionInteger();
if(current > check || check == -2) {// check is newer then current
resault = 1;
}else if(current == check) {// check is the same as current
resault = 0;
}else if(current < check || check == -1) {// check is older then current
resault = -1;
}
return resault;
}
/**
* Checks to see if the current version is newer then the checked version.
* @param version The version you are checking.
* @return True if newer then the checked version and false if the same or older.
*/
public Boolean isNewer(Version version) {
return this.versionInteger > version.versionInteger || this.versionInteger == -2;
}
/**
* Checks to see if the current version is the same as the checked version.
* @param version The version you are checking.
* @return True if both the current and checked version is the same and false if otherwise.
*/
public Boolean isSame(Version version) {
return this.versionInteger.equals(version.versionInteger);
}
/**
* Checks to see if the current version is older then the checked version.
* @param version The version you are checking.
* @return True if older then the checked version and false if the same or newer.
*/
public Boolean isOlder(Version version) {
return this.versionInteger < version.versionInteger || this.versionInteger == -1;
}
}

View File

@ -1,11 +1,8 @@
package me.badbones69.crazyauctions.controllers;
import me.badbones69.crazyauctions.Methods;
import me.badbones69.crazyauctions.api.Category;
import me.badbones69.crazyauctions.api.CrazyAuctions;
import me.badbones69.crazyauctions.api.*;
import me.badbones69.crazyauctions.api.FileManager.Files;
import me.badbones69.crazyauctions.api.Messages;
import me.badbones69.crazyauctions.api.ShopType;
import me.badbones69.crazyauctions.api.events.AuctionBuyEvent;
import me.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
import me.badbones69.crazyauctions.currency.CurrencyManager;
@ -25,14 +22,15 @@ import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
public class GUI implements Listener {
private static HashMap<Player, Integer> bidding = new HashMap<>();
private static HashMap<Player, String> biddingID = new HashMap<>();
private static HashMap<Player, ShopType> Type = new HashMap<>(); // Shop Type
private static HashMap<Player, Category> Cat = new HashMap<>(); // Category Type
private static HashMap<Player, ShopType> shopType = new HashMap<>(); // Shop Type
private static HashMap<Player, Category> shopCategory = new HashMap<>(); // Category Type
private static HashMap<Player, List<Integer>> List = new HashMap<>();
private static HashMap<Player, String> IDs = new HashMap<>();
private static CrazyAuctions crazyAuctions = CrazyAuctions.getInstance();
@ -49,9 +47,9 @@ public class GUI implements Listener {
Files.DATA.saveFile();
}
if(cat != null) {
Cat.put(player, cat);
shopCategory.put(player, cat);
}else {
Cat.put(player, Category.NONE);
shopCategory.put(player, Category.NONE);
}
if(data.contains("Items")) {
for(String i : data.getConfigurationSection("Items").getKeys(false)) {
@ -70,7 +68,7 @@ public class GUI implements Listener {
}else {
if(sell == ShopType.SELL) {
for(String l : config.getStringList("Settings.GUISettings.SellingItemLore")) {
lore.add(l.replaceAll("%Price%", Methods.getPrice(i, false)).replaceAll("%price%", Methods.getPrice(i, false)).replaceAll("%Seller%", data.getString("Items." + i + ".Seller")).replaceAll("%seller%", data.getString("Items." + i + ".Seller")));
lore.add(l.replaceAll("%Price%", String.format(Locale.ENGLISH, "%,d", Long.parseLong(Methods.getPrice(i, false)))).replaceAll("%price%", String.format(Locale.ENGLISH, "%,d", Long.parseLong(Methods.getPrice(i, false)))).replaceAll("%Seller%", data.getString("Items." + i + ".Seller")).replaceAll("%seller%", data.getString("Items." + i + ".Seller")).replaceAll("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replaceAll("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))));
}
items.add(Methods.addLore(data.getItemStack("Items." + i + ".Item").clone(), lore));
ID.add(data.getInt("Items." + i + ".StoreID"));
@ -91,14 +89,14 @@ public class GUI implements Listener {
options.add("Category1");
options.add("Category2");
if(sell == ShopType.SELL) {
Type.put(player, ShopType.SELL);
shopType.put(player, ShopType.SELL);
if(crazyAuctions.isBiddingEnabled()) {
options.add("Bidding/Selling.Selling");
}
options.add("WhatIsThis.SellingShop");
}
if(sell == ShopType.BID) {
Type.put(player, ShopType.BID);
shopType.put(player, ShopType.BID);
if(crazyAuctions.isSellingEnabled()) {
options.add("Bidding/Selling.Bidding");
}
@ -114,7 +112,7 @@ public class GUI implements Listener {
String name = config.getString("Settings.GUISettings.OtherSettings." + o + ".Name");
List<String> lore = new ArrayList<>();
int slot = config.getInt("Settings.GUISettings.OtherSettings." + o + ".Slot");
String cName = Methods.color(config.getString("Settings.GUISettings.Category-Settings." + Cat.get(player).getName() + ".Name"));
String cName = Methods.color(config.getString("Settings.GUISettings.Category-Settings." + shopCategory.get(player).getName() + ".Name"));
if(config.contains("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
for(String l : config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
lore.add(l.replaceAll("%Category%", cName).replaceAll("%category%", cName));
@ -163,7 +161,7 @@ public class GUI implements Listener {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name));
}
}
Type.put(player, shop);
shopType.put(player, shop);
player.openInventory(inv);
}
@ -269,7 +267,7 @@ public class GUI implements Listener {
FileConfiguration config = Files.CONFIG.getFile();
FileConfiguration data = Files.DATA.getFile();
if(!data.contains("Items." + ID)) {
openShop(player, ShopType.SELL, Cat.get(player), 1);
openShop(player, ShopType.SELL, shopCategory.get(player), 1);
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage());
return;
}
@ -302,7 +300,7 @@ public class GUI implements Listener {
ItemStack item = data.getItemStack("Items." + ID + ".Item");
List<String> lore = new ArrayList<>();
for(String l : config.getStringList("Settings.GUISettings.SellingLore")) {
lore.add(l.replaceAll("%Price%", Methods.getPrice(ID, false)).replaceAll("%price%", Methods.getPrice(ID, false)).replaceAll("%Seller%", data.getString("Items." + ID + ".Seller")).replaceAll("%seller%", data.getString("Items." + ID + ".Seller")));
lore.add(l.replaceAll("%Price%", Methods.getPrice(ID, false)).replaceAll("%price%", Methods.getPrice(ID, false)).replaceAll("%Seller%", data.getString("Items." + ID + ".Seller")).replaceAll("%seller%", data.getString("Items." + ID + ".Seller")).replaceAll("%Time%", Methods.convertToTime(data.getLong("Items." + l + ".Time-Till-Expire"))).replaceAll("%time%", Methods.convertToTime(data.getLong("Items." + l + ".Time-Till-Expire"))));
}
inv.setItem(4, Methods.addLore(item.clone(), lore));
IDs.put(player, ID);
@ -314,21 +312,32 @@ public class GUI implements Listener {
FileConfiguration config = Files.CONFIG.getFile();
FileConfiguration data = Files.DATA.getFile();
if(!data.contains("Items." + ID)) {
openShop(player, ShopType.BID, Cat.get(player), 1);
openShop(player, ShopType.BID, shopCategory.get(player), 1);
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage());
return;
}
Inventory inv = Bukkit.createInventory(null, 27, Methods.color(config.getString("Settings.Bidding-On-Item")));
if(!bidding.containsKey(player)) bidding.put(player, 0);
inv.setItem(9, Methods.makeItem("160:5", 1, "&a+1"));
inv.setItem(10, Methods.makeItem("160:5", 1, "&a+10"));
inv.setItem(11, Methods.makeItem("160:5", 1, "&a+100"));
inv.setItem(12, Methods.makeItem("160:5", 1, "&a+1000"));
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
inv.setItem(9, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+1"));
inv.setItem(10, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+10"));
inv.setItem(11, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+100"));
inv.setItem(12, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+1000"));
inv.setItem(14, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-1000"));
inv.setItem(15, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-100"));
inv.setItem(16, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-10"));
inv.setItem(17, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-1"));
}else {
inv.setItem(9, Methods.makeItem("160:5", 1, "&a+1"));
inv.setItem(10, Methods.makeItem("160:5", 1, "&a+10"));
inv.setItem(11, Methods.makeItem("160:5", 1, "&a+100"));
inv.setItem(12, Methods.makeItem("160:5", 1, "&a+1000"));
inv.setItem(14, Methods.makeItem("160:14", 1, "&c-1000"));
inv.setItem(15, Methods.makeItem("160:14", 1, "&c-100"));
inv.setItem(16, Methods.makeItem("160:14", 1, "&c-10"));
inv.setItem(17, Methods.makeItem("160:14", 1, "&c-1"));
}
inv.setItem(13, getBiddingGlass(player, ID));
inv.setItem(14, Methods.makeItem("160:14", 1, "&c-1000"));
inv.setItem(15, Methods.makeItem("160:14", 1, "&c-100"));
inv.setItem(16, Methods.makeItem("160:14", 1, "&c-10"));
inv.setItem(17, Methods.makeItem("160:14", 1, "&c-1"));
inv.setItem(22, Methods.makeItem(config.getString("Settings.GUISettings.OtherSettings.Bid.Item"), 1, config.getString("Settings.GUISettings.OtherSettings.Bid.Name"), config.getStringList("Settings.GUISettings.OtherSettings.Bid.Lore")));
inv.setItem(4, getBiddingItem(player, ID));
@ -455,12 +464,12 @@ public class GUI implements Listener {
if(item.getItemMeta().hasDisplayName()) {
for(Category cat : Category.values()) {
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.Category-Settings." + cat.getName() + ".Name")))) {
openShop(player, Type.get(player), cat, 1);
openShop(player, shopType.get(player), cat, 1);
playClick(player);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
playClick(player);
return;
}
@ -548,7 +557,7 @@ public class GUI implements Listener {
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.NextPage.Name")))) {
Methods.updateAuction();
int page = Integer.parseInt(inv.getName().split("#")[1]);
openShop(player, Type.get(player), Cat.get(player), page + 1);
openShop(player, shopType.get(player), shopCategory.get(player), page + 1);
playClick(player);
return;
}
@ -556,24 +565,24 @@ public class GUI implements Listener {
Methods.updateAuction();
int page = Integer.parseInt(inv.getName().split("#")[1]);
if(page == 1) page++;
openShop(player, Type.get(player), Cat.get(player), page - 1);
openShop(player, shopType.get(player), shopCategory.get(player), page - 1);
playClick(player);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Refesh.Name")))) {
Methods.updateAuction();
int page = Integer.parseInt(inv.getName().split("#")[1]);
openShop(player, Type.get(player), Cat.get(player), page);
openShop(player, shopType.get(player), shopCategory.get(player), page);
playClick(player);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Selling.Name")))) {
openShop(player, ShopType.BID, Cat.get(player), 1);
openShop(player, ShopType.BID, shopCategory.get(player), 1);
playClick(player);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Bidding.Name")))) {
openShop(player, ShopType.SELL, Cat.get(player), 1);
openShop(player, ShopType.SELL, shopCategory.get(player), 1);
playClick(player);
return;
}
@ -588,12 +597,12 @@ public class GUI implements Listener {
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category1.Name")))) {
openCategories(player, Type.get(player));
openCategories(player, shopType.get(player));
playClick(player);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category2.Name")))) {
openCategories(player, Type.get(player));
openCategories(player, shopType.get(player));
playClick(player);
return;
}
@ -632,10 +641,11 @@ public class GUI implements Listener {
player.sendMessage(Messages.ADMIN_FORCE_CENCELLED.getMessage());
playClick(player);
int page = Integer.parseInt(inv.getName().split("#")[1]);
openShop(player, Type.get(player), Cat.get(player), page);
openShop(player, shopType.get(player), shopCategory.get(player), page);
return;
}
}
final Runnable runnable = () -> inv.setItem(slot, item);
if(data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
String it = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
@ -647,10 +657,10 @@ public class GUI implements Listener {
}
inv.setItem(slot, I);
playClick(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> inv.setItem(slot, item), 3 * 20);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
return;
}
Long cost = data.getLong("Items." + i + ".Price");
long cost = data.getLong("Items." + i + ".Price");
if(CurrencyManager.getMoney(player) < cost) {
String it = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Name");
@ -662,7 +672,7 @@ public class GUI implements Listener {
}
inv.setItem(slot, I);
playClick(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> inv.setItem(slot, item), 3 * 20);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
return;
}
if(data.getBoolean("Items." + i + ".Biddable")) {
@ -677,7 +687,7 @@ public class GUI implements Listener {
}
inv.setItem(slot, I);
playClick(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> inv.setItem(slot, item), 3 * 20);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
return;
}
playClick(player);
@ -693,7 +703,7 @@ public class GUI implements Listener {
}
if(!T) {
playClick(player);
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage());
return;
}
@ -716,7 +726,7 @@ public class GUI implements Listener {
String seller = data.getString("Items." + ID + ".Seller");
if(!data.contains("Items." + ID)) {
playClick(player);
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage());
return;
}
@ -750,11 +760,11 @@ public class GUI implements Listener {
data.set("Items." + ID, null);
Files.DATA.saveFile();
playClick(player);
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cancel.Name")))) {
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
playClick(player);
return;
}
@ -772,7 +782,7 @@ public class GUI implements Listener {
if(item.hasItemMeta()) {
if(item.getItemMeta().hasDisplayName()) {
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
playClick(player);
return;
}
@ -801,7 +811,7 @@ public class GUI implements Listener {
}
if(!T) {
playClick(player);
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage());
return;
}
@ -821,7 +831,7 @@ public class GUI implements Listener {
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
Methods.updateAuction();
playClick(player);
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.PreviousPage.Name")))) {
@ -887,7 +897,7 @@ public class GUI implements Listener {
}
if(!T) {
playClick(player);
openShop(player, Type.get(player), Cat.get(player), 1);
openShop(player, shopType.get(player), shopCategory.get(player), 1);
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage());
}
}

View File

@ -56,7 +56,7 @@ Settings:
- '&7-------------------------'
Category-Settings:
Armor:
Item: '315'
Item: 'GOLDEN_CHESTPLATE'
Toggle: true
Slot: 11
Name: '&6&lArmor'
@ -64,7 +64,7 @@ Settings:
- '&7This category contains all'
- '&7armor that is currently being sold.'
Weapons:
Item: '283'
Item: 'GOLDEN_SWORD'
Toggle: true
Slot: 12
Name: '&6&lWeapons'
@ -72,7 +72,7 @@ Settings:
- '&7This category contains all'
- '&7weapons that is currently being sold.'
Tools:
Item: '285'
Item: 'GOLDEN_PICKAXE'
Toggle: true
Slot: 13
Name: '&6&lTools'
@ -80,7 +80,7 @@ Settings:
- '&7This category contains all'
- '&7tools that is currently being sold.'
Food:
Item: '322'
Item: 'GOLDEN_APPLE'
Toggle: true
Slot: 14
Name: '&6&lFood'
@ -88,7 +88,7 @@ Settings:
- '&7This category contains all'
- '&7food that is currently being sold.'
Potions:
Item: '373:8227'
Item: 'POTION'
Toggle: true
Slot: 15
Name: '&6&lPotions'
@ -96,7 +96,7 @@ Settings:
- '&7This category contains all'
- '&7potions that is currently being sold.'
Blocks:
Item: '2'
Item: 'GRASS_BLOCK'
Toggle: true
Slot: 16
Name: '&6&lBlocks'
@ -104,7 +104,7 @@ Settings:
- '&7This category contains all'
- '&7blocks that is currently being sold.'
Other:
Item: '371'
Item: 'GOLD_NUGGET'
Toggle: true
Slot: 17
Name: '&6&lOthers'
@ -112,7 +112,7 @@ Settings:
- '&7This category contains all the'
- '&7other items currently being sold.'
None:
Item: '166'
Item: 'BARRIER'
Toggle: true
Slot: 23
Name: '&6&lNone'
@ -121,7 +121,7 @@ Settings:
- '&7items currently being sold.'
OtherSettings: #Other Settings for the GUIs.
SellingItems: #The button for your current items.
Item: '264' #The item that this button is.
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.
@ -129,7 +129,7 @@ Settings:
- '&aClick here to view all the items you'
- '&aare currently selling on the auction.'
Cancelled/ExpiredItems: #The button for Cancelled/Expired Items.
Item: '394'
Item: 'POISONOUS_POTATO'
Toggle: true
Slot: 47
Name: '&6Collect Expired / Cancelled Items'
@ -137,25 +137,25 @@ Settings:
- '&aClick here to view and collect all of the'
- '&aitems you have cancelled or has expired.'
PreviousPage: #The button for Previous Page.
Item: '339'
Item: 'PAPER'
Toggle: true
Slot: 49
Name: '&6Previous Page'
Lore: {}
Refesh: #The button for Refresh Page.
Item: '175'
Item: 'SUNFLOWER'
Toggle: true
Slot: 50
Name: '&6Refresh Page'
Lore: {}
NextPage: #The button for Next Page.
Item: '339'
Item: 'PAPER'
Toggle: true
Slot: 51
Name: '&6Next Page'
Lore: {}
Category1: #The button for Next Page.
Item: '54'
Item: 'CHEST'
Toggle: true
Slot: 52
Name: '&6Categories'
@ -164,7 +164,7 @@ Settings:
- '&aWant see items in specific categories?'
- '&aClick here to see all categories of items.'
Category2: #The button for Next Page.
Item: '54'
Item: 'CHEST'
Toggle: true
Slot: 48
Name: '&6Categories'
@ -174,7 +174,7 @@ Settings:
- '&aClick here to see all categories of items.'
Bidding/Selling: #Switch between Bidding and Selling.
Selling:
Item: '341'
Item: 'SLIME_BALL'
Toggle: true
Slot: 53
Name: '&6Currently looking at items being sold.'
@ -182,7 +182,7 @@ Settings:
- '&7&l(&6&l!&7&l) &7Click here to see items'
- '&7that you can be bidded on.'
Bidding:
Item: '378'
Item: 'MAGMA_CREAM'
Toggle: true
Slot: 53
Name: '&6Currently looking at items that can be bid on.'
@ -191,7 +191,7 @@ Settings:
- '&7that you can buy at a price.'
WhatIsThis: #The info on all the Books buttons.
SellingShop: #The Book in the main shop.
Item: '340'
Item: 'BOOK'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
@ -204,7 +204,7 @@ Settings:
- '&amoney by selling items that others'
- '&amay be interested in buying.'
BiddingShop: #The Book in the main shop.
Item: '340'
Item: 'BOOK'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
@ -217,7 +217,7 @@ Settings:
- '&amake money by bidding off items that others'
- '&amay be interested in bidding on.'
CurrentItems: #The Book in the Current items GUI.
Item: '340'
Item: 'BOOK'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
@ -229,7 +229,7 @@ Settings:
- '&aYou can cancel and view your listings'
- '&aexpire time here.'
Cancelled/ExpiredItems: #The Book in the Cancelled/Expired Items GUI.
Item: '340'
Item: 'BOOK'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
@ -242,7 +242,7 @@ Settings:
- '&aJust click on the item and if you have enough'
- '&ainventory space you will receive that item.'
Viewing: #The Book in the Viewing Items GUI.
Item: '340'
Item: 'BOOK'
Toggle: true
Slot: 50
Name: '&6What Is This Page?'
@ -252,7 +252,7 @@ Settings:
- '&aand selling market. You can quickly see'
- '&awhat a specific player is selling.'
Categories: #The Book in the Viewing Items GUI.
Item: '340'
Item: 'BOOK'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
@ -262,43 +262,43 @@ Settings:
- '&aa category it will open the gui with only'
- '&aitems that belong to that category.'
Back: #The Back Buttons.
Item: '339'
Item: 'PAPER'
Slot: 46
Name: '&6Back'
Return: #The Return Buttons.
Item: '390'
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: '160:5'
Item: 'LIME_STAINED_GLASS_PANE'
Name: '&aConfirm'
Cancel: #The Cancel Buttons.
Item: '160:14'
Item: 'RED_STAINED_GLASS_PANE'
Name: '&cCancel'
Your-Item: #The item that shows when you try to buy/bid on your item.
Item: '166'
Item: 'BARRIER'
Name: '&cYou Cant Purchase Your Own Item.'
Cant-Afford: #The item that shows when you cant afford this item.
Item: '166'
Item: 'BARRIER'
Name: '&cYou Cant Afford This Item.'
Top-Bidder: #The item for when a player is already the top bidder.
Item: '166'
Item: 'BARRIER'
Name: '&cYou are already the top bidder.'
Bidding: #The item in the middle when bidding on an item.
Item: '160:15'
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: '160:3'
Item: 'LIGHT_BLUE_STAINED_GLASS_PANE'
Name: '&bBid Now'
Lore:
- '&7Click here to Bid Now.'
BlackList:
- '7'
- '120'
- 'BEDROCK'
- 'END_PORTAL_FRAME'

View File

@ -4,8 +4,9 @@ main: me.badbones69.crazyauctions.Main
website: https://www.spigotmc.org/resources/authors/kicjow.9719/
version: ${version}
depend: [Vault]
api-version: 1.13
description: >
A plugin to auction off items globally.
A plugin to auction off items globally.
commands:
ca:
description: Opens the Crazy Auctions GUI.