mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2025-01-08 19:38:15 +01:00
a bit of cleanup
This commit is contained in:
parent
a433903bda
commit
f6da775719
@ -69,7 +69,7 @@ public class Methods {
|
|||||||
|
|
||||||
public static Player getPlayer(String name) {
|
public static Player getPlayer(String name) {
|
||||||
try {
|
try {
|
||||||
return Bukkit.getServer().getPlayer(UUID.fromString(name));
|
return plugin.getServer().getPlayer(UUID.fromString(name));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -84,11 +84,11 @@ public class Methods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||||
return Bukkit.getServer().getOfflinePlayer(UUID.fromString(name));
|
return plugin.getServer().getOfflinePlayer(UUID.fromString(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnline(String name) {
|
public static boolean isOnline(String name) {
|
||||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
if (player.getName().equalsIgnoreCase(name)) {
|
if (player.getName().equalsIgnoreCase(name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public class Methods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnline(String name, CommandSender p) {
|
public static boolean isOnline(String name, CommandSender p) {
|
||||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
if (player.getName().equalsIgnoreCase(name)) {
|
if (player.getName().equalsIgnoreCase(name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -111,6 +111,7 @@ public class Methods {
|
|||||||
public static boolean hasPermission(Player player, String perm) {
|
public static boolean hasPermission(Player player, String perm) {
|
||||||
if (!player.hasPermission("crazyauctions." + perm)) {
|
if (!player.hasPermission("crazyauctions." + perm)) {
|
||||||
player.sendMessage(Messages.NO_PERMISSION.getMessage(player));
|
player.sendMessage(Messages.NO_PERMISSION.getMessage(player));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ public class Methods {
|
|||||||
if (sender instanceof Player player) {
|
if (sender instanceof Player player) {
|
||||||
if (!player.hasPermission("crazyauctions." + perm)) {
|
if (!player.hasPermission("crazyauctions." + perm)) {
|
||||||
player.sendMessage(Messages.NO_PERMISSION.getMessage(player));
|
player.sendMessage(Messages.NO_PERMISSION.getMessage(player));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,10 +134,13 @@ public class Methods {
|
|||||||
|
|
||||||
public static List<ItemStack> getPage(List<ItemStack> list, Integer page) {
|
public static List<ItemStack> getPage(List<ItemStack> list, Integer page) {
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
|
|
||||||
if (page <= 0) page = 1;
|
if (page <= 0) page = 1;
|
||||||
|
|
||||||
int max = 45;
|
int max = 45;
|
||||||
int index = page * max - max;
|
int index = page * max - max;
|
||||||
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||||
|
|
||||||
for (; index < endIndex; index++) {
|
for (; index < endIndex; index++) {
|
||||||
if (index < list.size()) items.add(list.get(index));
|
if (index < list.size()) items.add(list.get(index));
|
||||||
}
|
}
|
||||||
@ -154,7 +159,9 @@ public class Methods {
|
|||||||
|
|
||||||
public static List<Integer> getPageInts(List<Integer> list, Integer page) {
|
public static List<Integer> getPageInts(List<Integer> list, Integer page) {
|
||||||
List<Integer> items = new ArrayList<>();
|
List<Integer> items = new ArrayList<>();
|
||||||
|
|
||||||
if (page <= 0) page = 1;
|
if (page <= 0) page = 1;
|
||||||
|
|
||||||
int max = 45;
|
int max = 45;
|
||||||
int index = page * max - max;
|
int index = page * max - max;
|
||||||
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||||
@ -163,10 +170,12 @@ public class Methods {
|
|||||||
if (index < list.size()) items.add(list.get(index));
|
if (index < list.size()) items.add(list.get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; items.size() == 0; page--) {
|
for (; items.isEmpty(); page--) {
|
||||||
if (page <= 0) break;
|
if (page <= 0) break;
|
||||||
|
|
||||||
index = page * max - max;
|
index = page * max - max;
|
||||||
endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||||
|
|
||||||
for (; index < endIndex; index++) {
|
for (; index < endIndex; index++) {
|
||||||
if (index < list.size()) items.add(list.get(index));
|
if (index < list.size()) items.add(list.get(index));
|
||||||
}
|
}
|
||||||
@ -178,23 +187,30 @@ public class Methods {
|
|||||||
public static int getMaxPage(List<ItemStack> list) {
|
public static int getMaxPage(List<ItemStack> list) {
|
||||||
int maxPage = 1;
|
int maxPage = 1;
|
||||||
int amount = list.size();
|
int amount = list.size();
|
||||||
|
|
||||||
for (; amount > 45; amount -= 45, maxPage++) ;
|
for (; amount > 45; amount -= 45, maxPage++) ;
|
||||||
|
|
||||||
return maxPage;
|
return maxPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertToTime(long time) {
|
public static String convertToTime(long time) {
|
||||||
Calendar C = Calendar.getInstance();
|
Calendar C = Calendar.getInstance();
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
|
|
||||||
cal.setTimeInMillis(time);
|
cal.setTimeInMillis(time);
|
||||||
|
|
||||||
int total = ((int) (cal.getTimeInMillis() / 1000) - (int) (C.getTimeInMillis() / 1000));
|
int total = ((int) (cal.getTimeInMillis() / 1000) - (int) (C.getTimeInMillis() / 1000));
|
||||||
int D = 0;
|
int D = 0;
|
||||||
int H = 0;
|
int H = 0;
|
||||||
int M = 0;
|
int M = 0;
|
||||||
int S = 0;
|
int S = 0;
|
||||||
|
|
||||||
for (; total > 86400; total -= 86400, D++) ;
|
for (; total > 86400; total -= 86400, D++) ;
|
||||||
for (; total > 3600; total -= 3600, H++) ;
|
for (; total > 3600; total -= 3600, H++) ;
|
||||||
for (; total > 60; total -= 60, M++) ;
|
for (; total > 60; total -= 60, M++) ;
|
||||||
|
|
||||||
S += total;
|
S += total;
|
||||||
|
|
||||||
return D + "d " + H + "h " + M + "m " + S + "s ";
|
return D + "d " + H + "h " + M + "m " + S + "s ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,12 +221,15 @@ public class Methods {
|
|||||||
if (i.contains("D") || i.contains("d")) {
|
if (i.contains("D") || i.contains("d")) {
|
||||||
cal.add(Calendar.DATE, Integer.parseInt(i.replace("D", "").replace("d", "")));
|
cal.add(Calendar.DATE, Integer.parseInt(i.replace("D", "").replace("d", "")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.contains("H") || i.contains("h")) {
|
if (i.contains("H") || i.contains("h")) {
|
||||||
cal.add(Calendar.HOUR, Integer.parseInt(i.replace("H", "").replace("h", "")));
|
cal.add(Calendar.HOUR, Integer.parseInt(i.replace("H", "").replace("h", "")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.contains("M") || i.contains("m")) {
|
if (i.contains("M") || i.contains("m")) {
|
||||||
cal.add(Calendar.MINUTE, Integer.parseInt(i.replace("M", "").replace("m", "")));
|
cal.add(Calendar.MINUTE, Integer.parseInt(i.replace("M", "").replace("m", "")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.contains("S") || i.contains("s")) {
|
if (i.contains("S") || i.contains("s")) {
|
||||||
cal.add(Calendar.SECOND, Integer.parseInt(i.replace("S", "").replace("s", "")));
|
cal.add(Calendar.SECOND, Integer.parseInt(i.replace("S", "").replace("s", "")));
|
||||||
}
|
}
|
||||||
@ -225,16 +244,20 @@ public class Methods {
|
|||||||
|
|
||||||
public static void updateAuction() {
|
public static void updateAuction() {
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
Calendar expireTime = Calendar.getInstance();
|
Calendar expireTime = Calendar.getInstance();
|
||||||
Calendar fullExpireTime = Calendar.getInstance();
|
Calendar fullExpireTime = Calendar.getInstance();
|
||||||
|
|
||||||
boolean shouldSave = false;
|
boolean shouldSave = false;
|
||||||
|
|
||||||
if (data.contains("OutOfTime/Cancelled")) {
|
if (data.contains("OutOfTime/Cancelled")) {
|
||||||
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
||||||
fullExpireTime.setTimeInMillis(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"));
|
fullExpireTime.setTimeInMillis(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"));
|
||||||
|
|
||||||
if (cal.after(fullExpireTime)) {
|
if (cal.after(fullExpireTime)) {
|
||||||
data.set("OutOfTime/Cancelled." + i, null);
|
data.set("OutOfTime/Cancelled." + i, null);
|
||||||
|
|
||||||
shouldSave = true;
|
shouldSave = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,12 +270,13 @@ public class Methods {
|
|||||||
|
|
||||||
if (cal.after(expireTime)) {
|
if (cal.after(expireTime)) {
|
||||||
int num = 1;
|
int num = 1;
|
||||||
|
|
||||||
for (; data.contains("OutOfTime/Cancelled." + num); num++) ;
|
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")) {
|
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 winner = data.getString("Items." + i + ".TopBidder");
|
||||||
String seller = data.getString("Items." + i + ".Seller");
|
String seller = data.getString("Items." + i + ".Seller");
|
||||||
Long price = data.getLong("Items." + i + ".Price");
|
long price = data.getLong("Items." + i + ".Price");
|
||||||
|
|
||||||
plugin.getSupport().addMoney(getOfflinePlayer(seller), price);
|
plugin.getSupport().addMoney(getOfflinePlayer(seller), price);
|
||||||
plugin.getSupport().removeMoney(getOfflinePlayer(winner), price);
|
plugin.getSupport().removeMoney(getOfflinePlayer(winner), price);
|
||||||
@ -265,7 +289,9 @@ public class Methods {
|
|||||||
|
|
||||||
if (isOnline(winner) && getPlayer(winner) != null) {
|
if (isOnline(winner) && getPlayer(winner) != null) {
|
||||||
Player player = getPlayer(winner);
|
Player player = getPlayer(winner);
|
||||||
Bukkit.getPluginManager().callEvent(new AuctionWinBidEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")), price));
|
|
||||||
|
plugin.getServer().getPluginManager().callEvent(new AuctionWinBidEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")), price));
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.sendMessage(Messages.WIN_BIDDING.getMessage(player, placeholders));
|
player.sendMessage(Messages.WIN_BIDDING.getMessage(player, placeholders));
|
||||||
}
|
}
|
||||||
@ -273,6 +299,7 @@ public class Methods {
|
|||||||
|
|
||||||
if (isOnline(seller) && getPlayer(seller) != null) {
|
if (isOnline(seller) && getPlayer(seller) != null) {
|
||||||
Player player = getPlayer(seller);
|
Player player = getPlayer(seller);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.sendMessage(Messages.SOMEONE_WON_PLAYERS_BID.getMessage(player, placeholders));
|
player.sendMessage(Messages.SOMEONE_WON_PLAYERS_BID.getMessage(player, placeholders));
|
||||||
}
|
}
|
||||||
@ -291,7 +318,8 @@ public class Methods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AuctionExpireEvent event = new AuctionExpireEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")));
|
AuctionExpireEvent event = new AuctionExpireEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")));
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
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 + ".Full-Time", fullExpireTime.getTimeInMillis());
|
||||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||||
@ -310,15 +338,13 @@ public class Methods {
|
|||||||
public static String getPrice(String ID, Boolean Expired) {
|
public static String getPrice(String ID, Boolean Expired) {
|
||||||
long price = 0L;
|
long price = 0L;
|
||||||
|
|
||||||
if (Expired) {
|
FileConfiguration configuration = Files.data.getConfiguration();
|
||||||
FileConfiguration configuration = Files.data.getConfiguration();
|
|
||||||
|
|
||||||
|
if (Expired) {
|
||||||
if (configuration.contains("OutOfTime/Cancelled." + ID + ".Price")) {
|
if (configuration.contains("OutOfTime/Cancelled." + ID + ".Price")) {
|
||||||
price = configuration.getLong("OutOfTime/Cancelled." + ID + ".Price");
|
price = configuration.getLong("OutOfTime/Cancelled." + ID + ".Price");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FileConfiguration configuration = Files.data.getConfiguration();
|
|
||||||
|
|
||||||
if (configuration.contains("Items." + ID + ".Price")) {
|
if (configuration.contains("Items." + ID + ".Price")) {
|
||||||
price = configuration.getLong("Items." + ID + ".Price");
|
price = configuration.getLong("Items." + ID + ".Price");
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@ public class CrazyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSellingEnabled() {
|
public boolean isSellingEnabled() {
|
||||||
return sellingEnabled;
|
return this.sellingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBiddingEnabled() {
|
public boolean isBiddingEnabled() {
|
||||||
return biddingEnabled;
|
return this.biddingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ItemStack> getItems(Player player, ShopType type) {
|
public ArrayList<ItemStack> getItems(Player player, ShopType type) {
|
||||||
|
@ -41,6 +41,7 @@ public enum Category {
|
|||||||
|
|
||||||
private static ArrayList<Material> getArmor() {
|
private static ArrayList<Material> getArmor() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
ma.add(Material.GOLDEN_HELMET);
|
ma.add(Material.GOLDEN_HELMET);
|
||||||
ma.add(Material.GOLDEN_CHESTPLATE);
|
ma.add(Material.GOLDEN_CHESTPLATE);
|
||||||
ma.add(Material.GOLDEN_LEGGINGS);
|
ma.add(Material.GOLDEN_LEGGINGS);
|
||||||
@ -71,6 +72,7 @@ public enum Category {
|
|||||||
|
|
||||||
private static ArrayList<Material> getTools() {
|
private static ArrayList<Material> getTools() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
ma.add(Material.WOODEN_PICKAXE);
|
ma.add(Material.WOODEN_PICKAXE);
|
||||||
ma.add(Material.WOODEN_AXE);
|
ma.add(Material.WOODEN_AXE);
|
||||||
ma.add(Material.WOODEN_SHOVEL);
|
ma.add(Material.WOODEN_SHOVEL);
|
||||||
@ -95,11 +97,13 @@ public enum Category {
|
|||||||
ma.add(Material.NETHERITE_AXE);
|
ma.add(Material.NETHERITE_AXE);
|
||||||
ma.add(Material.NETHERITE_HOE);
|
ma.add(Material.NETHERITE_HOE);
|
||||||
ma.add(Material.NETHERITE_SHOVEL);
|
ma.add(Material.NETHERITE_SHOVEL);
|
||||||
|
|
||||||
return ma;
|
return ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<Material> getWeapons() {
|
private static ArrayList<Material> getWeapons() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
ma.add(Material.GOLDEN_PICKAXE);
|
ma.add(Material.GOLDEN_PICKAXE);
|
||||||
ma.add(Material.GOLDEN_AXE);
|
ma.add(Material.GOLDEN_AXE);
|
||||||
ma.add(Material.GOLDEN_SHOVEL);
|
ma.add(Material.GOLDEN_SHOVEL);
|
||||||
@ -113,44 +117,53 @@ public enum Category {
|
|||||||
ma.add(Material.BOW);
|
ma.add(Material.BOW);
|
||||||
ma.add(Material.NETHERITE_SWORD);
|
ma.add(Material.NETHERITE_SWORD);
|
||||||
ma.add(Material.NETHERITE_AXE);
|
ma.add(Material.NETHERITE_AXE);
|
||||||
|
|
||||||
return ma;
|
return ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<Material> getFood() {
|
private static ArrayList<Material> getFood() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
for (Material m : Material.values()) {
|
for (Material m : Material.values()) {
|
||||||
if (m.isEdible()) {
|
if (m.isEdible()) {
|
||||||
if (m != Material.POTION) ma.add(m);
|
if (m != Material.POTION) ma.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ma;
|
return ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<Material> getPotions() {
|
private static ArrayList<Material> getPotions() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
ma.add(Material.POTION);
|
ma.add(Material.POTION);
|
||||||
ma.add(Material.SPLASH_POTION);
|
ma.add(Material.SPLASH_POTION);
|
||||||
ma.add(Material.LINGERING_POTION);
|
ma.add(Material.LINGERING_POTION);
|
||||||
|
|
||||||
return ma;
|
return ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<Material> getBlocks() {
|
private static ArrayList<Material> getBlocks() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
for (Material m : Material.values()) {
|
for (Material m : Material.values()) {
|
||||||
if (m.isBlock()) {
|
if (m.isBlock()) {
|
||||||
ma.add(m);
|
ma.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ma;
|
return ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<Material> getOthers() {
|
private static ArrayList<Material> getOthers() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
for (Material m : Material.values()) {
|
for (Material m : Material.values()) {
|
||||||
if (!(getArmor().contains(m) || getTools().contains(m) || getWeapons().contains(m) || getFood().contains(m) || getPotions().contains(m) || getBlocks().contains(m))) {
|
if (!(getArmor().contains(m) || getTools().contains(m) || getWeapons().contains(m) || getFood().contains(m) || getPotions().contains(m) || getBlocks().contains(m))) {
|
||||||
ma.add(m);
|
ma.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ma;
|
return ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,10 +171,10 @@ public enum Category {
|
|||||||
* @return Returns the type name as a string.
|
* @return Returns the type name as a string.
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Material> getItems() {
|
public ArrayList<Material> getItems() {
|
||||||
return items;
|
return this.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,6 +31,6 @@ public enum ShopType {
|
|||||||
* @return Returns the type name as a string.
|
* @return Returns the type name as a string.
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -42,14 +42,14 @@ public class AuctionBuyEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPrice() {
|
public long getPrice() {
|
||||||
return price;
|
return this.price;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -59,22 +59,22 @@ public class AuctionCancelledEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OfflinePlayer getOfflinePlayer() {
|
public OfflinePlayer getOfflinePlayer() {
|
||||||
return offlinePlayer;
|
return this.offlinePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getOnlinePlayer() {
|
public Player getOnlinePlayer() {
|
||||||
return onlinePlayer;
|
return this.onlinePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnline() {
|
public boolean isOnline() {
|
||||||
return isOnline;
|
return this.isOnline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reasons getReason() {
|
public Reasons getReason() {
|
||||||
return reason;
|
return this.reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,18 +55,18 @@ public class AuctionExpireEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OfflinePlayer getOfflinePlayer() {
|
public OfflinePlayer getOfflinePlayer() {
|
||||||
return offlinePlayer;
|
return this.offlinePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getOnlinePlayer() {
|
public Player getOnlinePlayer() {
|
||||||
return onlinePlayer;
|
return this.onlinePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnline() {
|
public boolean isOnline() {
|
||||||
return isOnline;
|
return this.isOnline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return this.item;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,18 +45,18 @@ public class AuctionListEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopType getShopType() {
|
public ShopType getShopType() {
|
||||||
return shop;
|
return this.shop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPrice() {
|
public long getPrice() {
|
||||||
return price;
|
return this.price;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,14 +38,14 @@ public class AuctionNewBidEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getBid() {
|
public long getBid() {
|
||||||
return bid;
|
return this.bid;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,14 +41,14 @@ public class AuctionWinBidEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getBid() {
|
public long getBid() {
|
||||||
return bid;
|
return this.bid;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,6 +43,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +54,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
if (config.contains("Settings.Category-Page-Opens-First")) {
|
if (config.contains("Settings.Category-Page-Opens-First")) {
|
||||||
if (config.getBoolean("Settings.Category-Page-Opens-First")) {
|
if (config.getBoolean("Settings.Category-Page-Opens-First")) {
|
||||||
GuiListener.openCategories(player, ShopType.SELL);
|
GuiListener.openCategories(player, ShopType.SELL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,6 +76,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Messages.HELP.getMessage(sender));
|
sender.sendMessage(Messages.HELP.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +91,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
this.crazyManager.load();
|
this.crazyManager.load();
|
||||||
|
|
||||||
sender.sendMessage(Messages.RELOAD.getMessage(sender));
|
sender.sendMessage(Messages.RELOAD.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,15 +102,18 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
GuiListener.openViewer(player, args[1], 1);
|
GuiListener.openViewer(player, args[1], 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Messages.CRAZYAUCTIONS_VIEW.getMessage(sender));
|
sender.sendMessage(Messages.CRAZYAUCTIONS_VIEW.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,10 +124,12 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiListener.openPlayersExpiredList(player, 1);
|
GuiListener.openPlayersExpiredList(player, 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,16 +138,19 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiListener.openPlayersCurrentList(player, 1);
|
GuiListener.openPlayersCurrentList(player, 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "sell", "bid" -> {
|
case "sell", "bid" -> {
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +158,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("sell")) {
|
if (args[0].equalsIgnoreCase("sell")) {
|
||||||
if (!crazyManager.isSellingEnabled()) {
|
if (!crazyManager.isSellingEnabled()) {
|
||||||
player.sendMessage(Messages.SELLING_DISABLED.getMessage(sender));
|
player.sendMessage(Messages.SELLING_DISABLED.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +168,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("bid")) {
|
if (args[0].equalsIgnoreCase("bid")) {
|
||||||
if (!crazyManager.isBiddingEnabled()) {
|
if (!crazyManager.isBiddingEnabled()) {
|
||||||
player.sendMessage(Messages.BIDDING_DISABLED.getMessage(sender));
|
player.sendMessage(Messages.BIDDING_DISABLED.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,28 +180,34 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
if (!Methods.isInt(args[2])) {
|
if (!Methods.isInt(args[2])) {
|
||||||
HashMap<String, String> placeholders = new HashMap<>();
|
Map<String, String> placeholders = new HashMap<>();
|
||||||
placeholders.put("%Arg%", args[2]);
|
placeholders.put("%Arg%", args[2]);
|
||||||
placeholders.put("%arg%", args[2]);
|
placeholders.put("%arg%", args[2]);
|
||||||
|
|
||||||
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(sender, placeholders));
|
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(sender, placeholders));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
amount = Integer.parseInt(args[2]);
|
amount = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
if (amount <= 0) amount = 1;
|
if (amount <= 0) amount = 1;
|
||||||
if (amount > item.getAmount()) amount = item.getAmount();
|
if (amount > item.getAmount()) amount = item.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Methods.isLong(args[1])) {
|
if (!Methods.isLong(args[1])) {
|
||||||
HashMap<String, String> placeholders = new HashMap<>();
|
Map<String, String> placeholders = new HashMap<>();
|
||||||
placeholders.put("%Arg%", args[1]);
|
placeholders.put("%Arg%", args[1]);
|
||||||
placeholders.put("%arg%", args[1]);
|
placeholders.put("%arg%", args[1]);
|
||||||
|
|
||||||
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(sender, placeholders));
|
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(sender, placeholders));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.getItemInHand(player).getType() == Material.AIR) {
|
if (Methods.getItemInHand(player).getType() == Material.AIR) {
|
||||||
player.sendMessage(Messages.DOESNT_HAVE_ITEM_IN_HAND.getMessage(sender));
|
player.sendMessage(Messages.DOESNT_HAVE_ITEM_IN_HAND.getMessage(sender));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,20 +216,24 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("bid")) {
|
if (args[0].equalsIgnoreCase("bid")) {
|
||||||
if (price < config.getLong("Settings.Minimum-Bid-Price", 100)) {
|
if (price < config.getLong("Settings.Minimum-Bid-Price", 100)) {
|
||||||
player.sendMessage(Messages.BID_PRICE_TO_LOW.getMessage(sender));
|
player.sendMessage(Messages.BID_PRICE_TO_LOW.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (price > config.getLong("Settings.Max-Beginning-Bid-Price", 1000000)) {
|
if (price > config.getLong("Settings.Max-Beginning-Bid-Price", 1000000)) {
|
||||||
player.sendMessage(Messages.BID_PRICE_TO_HIGH.getMessage(sender));
|
player.sendMessage(Messages.BID_PRICE_TO_HIGH.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (price < config.getLong("Settings.Minimum-Sell-Price", 10)) {
|
if (price < config.getLong("Settings.Minimum-Sell-Price", 10)) {
|
||||||
player.sendMessage(Messages.SELL_PRICE_TO_LOW.getMessage(sender));
|
player.sendMessage(Messages.SELL_PRICE_TO_LOW.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (price > config.getLong("Settings.Max-Beginning-Sell-Price", 1000000)) {
|
if (price > config.getLong("Settings.Max-Beginning-Sell-Price", 1000000)) {
|
||||||
player.sendMessage(Messages.SELL_PRICE_TO_HIGH.getMessage(sender));
|
player.sendMessage(Messages.SELL_PRICE_TO_HIGH.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,6 +257,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (perm.startsWith("crazyauctions.bid.")) {
|
if (perm.startsWith("crazyauctions.bid.")) {
|
||||||
perm = perm.replace("crazyauctions.bid.", "");
|
perm = perm.replace("crazyauctions.bid.", "");
|
||||||
|
|
||||||
if (Methods.isInt(perm)) {
|
if (Methods.isInt(perm)) {
|
||||||
if (Integer.parseInt(perm) > BidLimit) {
|
if (Integer.parseInt(perm) > BidLimit) {
|
||||||
BidLimit = Integer.parseInt(perm);
|
BidLimit = Integer.parseInt(perm);
|
||||||
@ -258,6 +283,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("sell")) {
|
if (args[0].equalsIgnoreCase("sell")) {
|
||||||
if (crazyManager.getItems(player, ShopType.SELL).size() >= SellLimit) {
|
if (crazyManager.getItems(player, ShopType.SELL).size() >= SellLimit) {
|
||||||
player.sendMessage(Messages.MAX_ITEMS.getMessage(sender));
|
player.sendMessage(Messages.MAX_ITEMS.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,6 +291,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("bid")) {
|
if (args[0].equalsIgnoreCase("bid")) {
|
||||||
if (crazyManager.getItems(player, ShopType.BID).size() >= BidLimit) {
|
if (crazyManager.getItems(player, ShopType.BID).size() >= BidLimit) {
|
||||||
player.sendMessage(Messages.MAX_ITEMS.getMessage(sender));
|
player.sendMessage(Messages.MAX_ITEMS.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,6 +299,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (config.getStringList("Settings.BlackList").contains(item.getType().getKey().getKey())) {
|
if (config.getStringList("Settings.BlackList").contains(item.getType().getKey().getKey())) {
|
||||||
player.sendMessage(Messages.ITEM_BLACKLISTED.getMessage(sender));
|
player.sendMessage(Messages.ITEM_BLACKLISTED.getMessage(sender));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,10 +366,10 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
this.plugin.getServer().getPluginManager().callEvent(new AuctionListEvent(player, type, stack, price));
|
this.plugin.getServer().getPluginManager().callEvent(new AuctionListEvent(player, type, stack, price));
|
||||||
|
|
||||||
HashMap<String, String> placeholders = new HashMap<>();
|
Map<String, String> placeholders = new HashMap<>();
|
||||||
|
|
||||||
placeholders.put("%Price%", String.valueOf(price));
|
placeholders.put("%Price%", String.valueOf(price));
|
||||||
placeholders.put("%price%", String.valueOf(price));
|
placeholders.put("%price%", String.valueOf(price));
|
||||||
|
|
||||||
player.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(sender, placeholders));
|
player.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(sender, placeholders));
|
||||||
|
|
||||||
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
|
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
|
||||||
@ -358,6 +386,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
default -> {
|
default -> {
|
||||||
sender.sendMessage(Methods.getPrefix("&cPlease do /crazyauctions help for more information."));
|
sender.sendMessage(Methods.getPrefix("&cPlease do /crazyauctions help for more information."));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,6 +397,7 @@ public class AuctionCommand implements CommandExecutor {
|
|||||||
|
|
||||||
private ArrayList<Material> getDamageableItems() {
|
private ArrayList<Material> getDamageableItems() {
|
||||||
ArrayList<Material> ma = new ArrayList<>();
|
ArrayList<Material> ma = new ArrayList<>();
|
||||||
|
|
||||||
ma.add(Material.GOLDEN_HELMET);
|
ma.add(Material.GOLDEN_HELMET);
|
||||||
ma.add(Material.GOLDEN_CHESTPLATE);
|
ma.add(Material.GOLDEN_CHESTPLATE);
|
||||||
ma.add(Material.GOLDEN_LEGGINGS);
|
ma.add(Material.GOLDEN_LEGGINGS);
|
||||||
|
@ -18,6 +18,7 @@ public class AuctionTab implements TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) {
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
if (args.length == 1) { // /voucher
|
if (args.length == 1) { // /voucher
|
||||||
if (hasPermission(sender, "access")) {
|
if (hasPermission(sender, "access")) {
|
||||||
completions.add("help");
|
completions.add("help");
|
||||||
@ -25,17 +26,20 @@ public class AuctionTab implements TabCompleter {
|
|||||||
completions.add("expired");
|
completions.add("expired");
|
||||||
completions.add("listed");
|
completions.add("listed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPermission(sender, "test")) completions.add("test");
|
if (hasPermission(sender, "test")) completions.add("test");
|
||||||
if (hasPermission(sender, "admin")) completions.add("reload");
|
if (hasPermission(sender, "admin")) completions.add("reload");
|
||||||
if (hasPermission(sender, "view")) completions.add("view");
|
if (hasPermission(sender, "view")) completions.add("view");
|
||||||
if (hasPermission(sender, "sell")) completions.add("sell");
|
if (hasPermission(sender, "sell")) completions.add("sell");
|
||||||
if (hasPermission(sender, "bid")) completions.add("bid");
|
if (hasPermission(sender, "bid")) completions.add("bid");
|
||||||
|
|
||||||
return StringUtil.copyPartialMatches(args[0], completions, new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[0], completions, new ArrayList<>());
|
||||||
} else if (args.length == 2) { // /crazyauctions arg0
|
} else if (args.length == 2) { // /crazyauctions arg0
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "bid", "sell" -> completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
|
case "bid", "sell" -> completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
|
||||||
case "view" -> completions.addAll(this.plugin.getServer().getOnlinePlayers().stream().map(Player::getName).toList());
|
case "view" -> completions.addAll(this.plugin.getServer().getOnlinePlayers().stream().map(Player::getName).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtil.copyPartialMatches(args[1], completions, new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[1], completions, new ArrayList<>());
|
||||||
} else if (args.length == 3) { // /crazyauctions arg0 arg1
|
} else if (args.length == 3) { // /crazyauctions arg0 arg1
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
|
@ -12,7 +12,6 @@ import com.badbones69.crazyauctions.api.enums.ShopType;
|
|||||||
import com.badbones69.crazyauctions.api.events.AuctionBuyEvent;
|
import com.badbones69.crazyauctions.api.events.AuctionBuyEvent;
|
||||||
import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent;
|
import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent;
|
||||||
import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
|
import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -39,15 +38,16 @@ public class GuiListener implements Listener {
|
|||||||
private static final CrazyAuctions plugin = CrazyAuctions.get();
|
private static final CrazyAuctions plugin = CrazyAuctions.get();
|
||||||
private static final CrazyManager crazyManager = plugin.getCrazyManager();
|
private static final CrazyManager crazyManager = plugin.getCrazyManager();
|
||||||
|
|
||||||
private static final HashMap<UUID, Integer> bidding = new HashMap<>();
|
private static final Map<UUID, Integer> bidding = new HashMap<>();
|
||||||
private static final HashMap<UUID, String> biddingID = new HashMap<>();
|
private static final Map<UUID, String> biddingID = new HashMap<>();
|
||||||
private static final HashMap<UUID, ShopType> shopType = new HashMap<>(); // Shop Type
|
private static final Map<UUID, ShopType> shopType = new HashMap<>(); // Shop Type
|
||||||
private static final HashMap<UUID, Category> shopCategory = new HashMap<>(); // Category Type
|
private static final Map<UUID, Category> shopCategory = new HashMap<>(); // Category Type
|
||||||
private static final HashMap<UUID, List<Integer>> List = new HashMap<>();
|
private static final Map<UUID, List<Integer>> List = new HashMap<>();
|
||||||
private static final HashMap<UUID, String> IDs = new HashMap<>();
|
private static final Map<UUID, String> IDs = new HashMap<>();
|
||||||
|
|
||||||
public static void openShop(Player player, ShopType sell, Category cat, int page) {
|
public static void openShop(Player player, ShopType sell, Category cat, int page) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
@ -55,6 +55,7 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (!data.contains("Items")) {
|
if (!data.contains("Items")) {
|
||||||
data.set("Items.Clear", null);
|
data.set("Items.Clear", null);
|
||||||
|
|
||||||
Files.data.save();
|
Files.data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,11 +203,13 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
for (ItemStack item : Methods.getPage(items, page)) {
|
for (ItemStack item : Methods.getPage(items, page)) {
|
||||||
int slot = inv.firstEmpty();
|
int slot = inv.firstEmpty();
|
||||||
|
|
||||||
inv.setItem(slot, item);
|
inv.setItem(slot, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
||||||
List.put(player.getUniqueId(), Id);
|
List.put(player.getUniqueId(), Id);
|
||||||
|
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +218,7 @@ public class GuiListener implements Listener {
|
|||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
|
|
||||||
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.Categories")));
|
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.Categories")));
|
||||||
|
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
|
|
||||||
options.add("OtherSettings.Back");
|
options.add("OtherSettings.Back");
|
||||||
@ -254,14 +258,17 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
public static void openPlayersCurrentList(Player player, int page) {
|
public static void openPlayersCurrentList(Player player, int page) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
|
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
List<Integer> ID = new ArrayList<>();
|
List<Integer> ID = new ArrayList<>();
|
||||||
|
|
||||||
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.Players-Current-Items")));
|
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.Players-Current-Items")));
|
||||||
|
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
|
|
||||||
options.add("Back");
|
options.add("Back");
|
||||||
options.add("WhatIsThis.CurrentItems");
|
options.add("WhatIsThis.CurrentItems");
|
||||||
|
|
||||||
@ -317,14 +324,18 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
||||||
|
|
||||||
List.put(player.getUniqueId(), Id);
|
List.put(player.getUniqueId(), Id);
|
||||||
|
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openPlayersExpiredList(Player player, int page) {
|
public static void openPlayersExpiredList(Player player, int page) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
|
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
List<Integer> ID = new ArrayList<>();
|
List<Integer> ID = new ArrayList<>();
|
||||||
|
|
||||||
@ -357,11 +368,12 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int maxPage = Methods.getMaxPage(items);
|
int maxPage = Methods.getMaxPage(items);
|
||||||
|
|
||||||
for (; page > maxPage; page--);
|
for (; page > maxPage; page--);
|
||||||
|
|
||||||
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.Cancelled/Expired-Items") + " #" + page));
|
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.Cancelled/Expired-Items") + " #" + page));
|
||||||
List<String> options = new ArrayList<>();
|
|
||||||
|
|
||||||
|
List<String> options = new ArrayList<>();
|
||||||
options.add("Back");
|
options.add("Back");
|
||||||
options.add("PreviousPage");
|
options.add("PreviousPage");
|
||||||
options.add("Return");
|
options.add("Return");
|
||||||
@ -390,11 +402,14 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
for (ItemStack item : Methods.getPage(items, page)) {
|
for (ItemStack item : Methods.getPage(items, page)) {
|
||||||
int slot = inv.firstEmpty();
|
int slot = inv.firstEmpty();
|
||||||
|
|
||||||
inv.setItem(slot, item);
|
inv.setItem(slot, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
||||||
|
|
||||||
List.put(player.getUniqueId(), Id);
|
List.put(player.getUniqueId(), Id);
|
||||||
|
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,13 +421,16 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (!data.contains("Items." + ID)) {
|
if (!data.contains("Items." + ID)) {
|
||||||
openShop(player, ShopType.SELL, shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, ShopType.SELL, shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inv = Bukkit.createInventory(null, 9, Methods.color(config.getString("Settings.Buying-Item")));
|
Inventory inv = plugin.getServer().createInventory(null, 9, Methods.color(config.getString("Settings.Buying-Item")));
|
||||||
|
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
|
|
||||||
options.add("Confirm");
|
options.add("Confirm");
|
||||||
options.add("Cancel");
|
options.add("Cancel");
|
||||||
|
|
||||||
@ -472,21 +490,26 @@ public class GuiListener implements Listener {
|
|||||||
inv.setItem(4, itemBuilder.build());
|
inv.setItem(4, itemBuilder.build());
|
||||||
|
|
||||||
IDs.put(player.getUniqueId(), ID);
|
IDs.put(player.getUniqueId(), ID);
|
||||||
|
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openBidding(Player player, String ID) {
|
public static void openBidding(Player player, String ID) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
|
|
||||||
if (!data.contains("Items." + ID)) {
|
if (!data.contains("Items." + ID)) {
|
||||||
openShop(player, ShopType.BID, shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, ShopType.BID, shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inv = plugin.getServer().createInventory(null, 27, Methods.color(config.getString("Settings.Bidding-On-Item")));
|
Inventory inv = plugin.getServer().createInventory(null, 27, Methods.color(config.getString("Settings.Bidding-On-Item")));
|
||||||
|
|
||||||
if (!bidding.containsKey(player.getUniqueId())) bidding.put(player.getUniqueId(), 0);
|
if (!bidding.containsKey(player.getUniqueId())) bidding.put(player.getUniqueId(), 0);
|
||||||
|
|
||||||
inv.setItem(9, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+1").setAmount(1).build());
|
inv.setItem(9, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+1").setAmount(1).build());
|
||||||
@ -512,11 +535,13 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
|
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
List<Integer> ID = new ArrayList<>();
|
List<Integer> ID = new ArrayList<>();
|
||||||
|
|
||||||
if (!data.contains("Items")) {
|
if (!data.contains("Items")) {
|
||||||
data.set("Items.Clear", null);
|
data.set("Items.Clear", null);
|
||||||
|
|
||||||
Files.data.save();
|
Files.data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,11 +603,13 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int maxPage = Methods.getMaxPage(items);
|
int maxPage = Methods.getMaxPage(items);
|
||||||
|
|
||||||
for (; page > maxPage; page--);
|
for (; page > maxPage; page--);
|
||||||
|
|
||||||
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.GUIName") + " #" + page));
|
Inventory inv = plugin.getServer().createInventory(null, 54, Methods.color(config.getString("Settings.GUIName") + " #" + page));
|
||||||
|
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
|
|
||||||
options.add("WhatIsThis.Viewing");
|
options.add("WhatIsThis.Viewing");
|
||||||
|
|
||||||
for (String o : options) {
|
for (String o : options) {
|
||||||
@ -607,10 +634,12 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
for (ItemStack item : Methods.getPage(items, page)) {
|
for (ItemStack item : Methods.getPage(items, page)) {
|
||||||
int slot = inv.firstEmpty();
|
int slot = inv.firstEmpty();
|
||||||
|
|
||||||
inv.setItem(slot, item);
|
inv.setItem(slot, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
List.put(player.getUniqueId(), new ArrayList<>(Methods.getPageInts(ID, page)));
|
List.put(player.getUniqueId(), new ArrayList<>(Methods.getPageInts(ID, page)));
|
||||||
|
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,6 +657,7 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (config.contains("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
|
if (config.contains("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
for (String l : config.getStringList("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
|
for (String l : config.getStringList("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
|
||||||
lore.add(l.replace("%Bid%", String.valueOf(bid))
|
lore.add(l.replace("%Bid%", String.valueOf(bid))
|
||||||
.replace("%bid%", String.valueOf(bid))
|
.replace("%bid%", String.valueOf(bid))
|
||||||
@ -644,7 +674,9 @@ public class GuiListener implements Listener {
|
|||||||
private static ItemStack getBiddingItem(String ID) {
|
private static ItemStack getBiddingItem(String ID) {
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
|
|
||||||
ItemStack item = Methods.fromBase64(data.getString("Items." + ID + ".Item"));
|
ItemStack item = Methods.fromBase64(data.getString("Items." + ID + ".Item"));
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
String price = Methods.getPrice(ID, false);
|
String price = Methods.getPrice(ID, false);
|
||||||
@ -698,7 +730,9 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
private void playSoldSound(@NotNull Player player) {
|
private void playSoldSound(@NotNull Player player) {
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
|
|
||||||
String sound = config.getString("Settings.Sold-Item-Sound", "");
|
String sound = config.getString("Settings.Sold-Item-Sound", "");
|
||||||
|
|
||||||
if (sound.isEmpty()) return;
|
if (sound.isEmpty()) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -709,6 +743,7 @@ public class GuiListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInvClose(InventoryCloseEvent e) {
|
public void onInvClose(InventoryCloseEvent e) {
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
|
|
||||||
Player player = (Player) e.getPlayer();
|
Player player = (Player) e.getPlayer();
|
||||||
|
|
||||||
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Bidding-On-Item")))) bidding.remove(player);
|
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Bidding-On-Item")))) bidding.remove(player);
|
||||||
@ -718,6 +753,7 @@ public class GuiListener implements Listener {
|
|||||||
public void onInvClick(InventoryClickEvent e) {
|
public void onInvClick(InventoryClickEvent e) {
|
||||||
FileConfiguration config = Files.config.getConfiguration();
|
FileConfiguration config = Files.config.getConfiguration();
|
||||||
FileConfiguration data = Files.data.getConfiguration();
|
FileConfiguration data = Files.data.getConfiguration();
|
||||||
|
|
||||||
Player player = (Player) e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
final Inventory inv = e.getClickedInventory();
|
final Inventory inv = e.getClickedInventory();
|
||||||
|
|
||||||
@ -735,13 +771,17 @@ public class GuiListener implements Listener {
|
|||||||
for (Category cat : Category.values()) {
|
for (Category cat : Category.values()) {
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.Category-Settings." + cat.getName() + ".Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.Category-Settings." + cat.getName() + ".Name")))) {
|
||||||
openShop(player, shopType.get(player.getUniqueId()), cat, 1);
|
openShop(player, shopType.get(player.getUniqueId()), cat, 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -767,24 +807,30 @@ public class GuiListener implements Listener {
|
|||||||
String topBidder = data.getString("Items." + ID + ".TopBidder");
|
String topBidder = data.getString("Items." + ID + ".TopBidder");
|
||||||
|
|
||||||
if (plugin.getSupport().getMoney(player) < bid) {
|
if (plugin.getSupport().getMoney(player) < bid) {
|
||||||
HashMap<String, String> placeholders = new HashMap<>();
|
Map<String, String> placeholders = new HashMap<>();
|
||||||
|
|
||||||
placeholders.put("%Money_Needed%", (bid - plugin.getSupport().getMoney(player)) + "");
|
placeholders.put("%Money_Needed%", (bid - plugin.getSupport().getMoney(player)) + "");
|
||||||
placeholders.put("%money_needed%", (bid - plugin.getSupport().getMoney(player)) + "");
|
placeholders.put("%money_needed%", (bid - plugin.getSupport().getMoney(player)) + "");
|
||||||
|
|
||||||
player.sendMessage(Messages.NEED_MORE_MONEY.getMessage(player, placeholders));
|
player.sendMessage(Messages.NEED_MORE_MONEY.getMessage(player, placeholders));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.getLong("Items." + ID + ".Price") > bid) {
|
if (data.getLong("Items." + ID + ".Price") > bid) {
|
||||||
player.sendMessage(Messages.BID_MORE_MONEY.getMessage(player));
|
player.sendMessage(Messages.BID_MORE_MONEY.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.getLong("Items." + ID + ".Price") >= bid && !topBidder.equalsIgnoreCase("None")) {
|
if (data.getLong("Items." + ID + ".Price") >= bid && !topBidder.equalsIgnoreCase("None")) {
|
||||||
player.sendMessage(Messages.BID_MORE_MONEY.getMessage(player));
|
player.sendMessage(Messages.BID_MORE_MONEY.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new AuctionNewBidEvent(player, Methods.fromBase64(data.getString("Items." + ID + ".Item")), bid));
|
plugin.getServer().getPluginManager().callEvent(new AuctionNewBidEvent(player, Methods.fromBase64(data.getString("Items." + ID + ".Item")), bid));
|
||||||
|
|
||||||
data.set("Items." + ID + ".Price", bid);
|
data.set("Items." + ID + ".Price", bid);
|
||||||
data.set("Items." + ID + ".TopBidder", player.getUniqueId().toString());
|
data.set("Items." + ID + ".TopBidder", player.getUniqueId().toString());
|
||||||
|
|
||||||
@ -815,13 +861,19 @@ public class GuiListener implements Listener {
|
|||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(price))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(price))) {
|
||||||
try {
|
try {
|
||||||
bidding.put(player.getUniqueId(), (bidding.get(player.getUniqueId()) + priceEdits.get(price)));
|
bidding.put(player.getUniqueId(), (bidding.get(player.getUniqueId()) + priceEdits.get(price)));
|
||||||
|
|
||||||
inv.setItem(4, getBiddingItem(biddingID.get(player.getUniqueId())));
|
inv.setItem(4, getBiddingItem(biddingID.get(player.getUniqueId())));
|
||||||
|
|
||||||
inv.setItem(13, getBiddingGlass(player, biddingID.get(player.getUniqueId())));
|
inv.setItem(13, getBiddingGlass(player, biddingID.get(player.getUniqueId())));
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|
||||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -844,62 +896,87 @@ public class GuiListener implements Listener {
|
|||||||
if (item.getItemMeta().hasDisplayName()) {
|
if (item.getItemMeta().hasDisplayName()) {
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.NextPage.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.NextPage.Name")))) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page + 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page + 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.PreviousPage.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.PreviousPage.Name")))) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||||
|
|
||||||
if (page == 1) page++;
|
if (page == 1) page++;
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page - 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page - 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Refesh.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Refesh.Name")))) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Selling.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Selling.Name")))) {
|
||||||
openShop(player, ShopType.BID, shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, ShopType.BID, shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Bidding.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Bidding.Name")))) {
|
||||||
openShop(player, ShopType.SELL, shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, ShopType.SELL, shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cancelled/ExpiredItems.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cancelled/ExpiredItems.Name")))) {
|
||||||
openPlayersExpiredList(player, 1);
|
openPlayersExpiredList(player, 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.SellingItems.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.SellingItems.Name")))) {
|
||||||
openPlayersCurrentList(player, 1);
|
openPlayersCurrentList(player, 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category1.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category1.Name")))) {
|
||||||
openCategories(player, shopType.get(player.getUniqueId()));
|
openCategories(player, shopType.get(player.getUniqueId()));
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category2.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category2.Name")))) {
|
||||||
openCategories(player, shopType.get(player.getUniqueId()));
|
openCategories(player, shopType.get(player.getUniqueId()));
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,7 +1006,8 @@ public class GuiListener implements Listener {
|
|||||||
if (player.hasPermission("crazyauctions.admin") || player.hasPermission("crazyauctions.force-end")) {
|
if (player.hasPermission("crazyauctions.admin") || player.hasPermission("crazyauctions.force-end")) {
|
||||||
if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
||||||
int num = 1;
|
int num = 1;
|
||||||
for (; data.contains("OutOfTime/Cancelled." + num); num++) ;
|
for (; data.contains("OutOfTime/Cancelled." + num); num++);
|
||||||
|
|
||||||
String seller = data.getString("Items." + i + ".Seller");
|
String seller = data.getString("Items." + i + ".Seller");
|
||||||
Player sellerPlayer = Methods.getPlayer(seller);
|
Player sellerPlayer = Methods.getPlayer(seller);
|
||||||
|
|
||||||
@ -938,17 +1016,24 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AuctionCancelledEvent event = new AuctionCancelledEvent((sellerPlayer != null ? sellerPlayer : Methods.getOfflinePlayer(seller)), Methods.fromBase64(data.getString("Items." + ID + ".Item")), Reasons.ADMIN_FORCE_CANCEL);
|
AuctionCancelledEvent event = new AuctionCancelledEvent((sellerPlayer != null ? sellerPlayer : Methods.getOfflinePlayer(seller)), Methods.fromBase64(data.getString("Items." + ID + ".Item")), Reasons.ADMIN_FORCE_CANCEL);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
||||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time"));
|
data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time"));
|
||||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + ID + ".Item"));
|
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + ID + ".Item"));
|
||||||
data.set("Items." + i, null);
|
data.set("Items." + i, null);
|
||||||
|
|
||||||
Files.data.save();
|
Files.data.save();
|
||||||
|
|
||||||
player.sendMessage(Messages.ADMIN_FORCE_CANCELLED.getMessage(player));
|
player.sendMessage(Messages.ADMIN_FORCE_CANCELLED.getMessage(player));
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -966,8 +1051,11 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inv.setItem(slot, itemBuilder.build());
|
inv.setItem(slot, itemBuilder.build());
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,7 +1073,9 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
inv.setItem(slot, itemBuilder.build());
|
inv.setItem(slot, itemBuilder.build());
|
||||||
playClick(player);
|
playClick(player);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,16 +1091,21 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inv.setItem(slot, itemBuilder.build());
|
inv.setItem(slot, itemBuilder.build());
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openBidding(player, i);
|
openBidding(player, i);
|
||||||
|
|
||||||
biddingID.put(player.getUniqueId(), i);
|
biddingID.put(player.getUniqueId(), i);
|
||||||
} else {
|
} else {
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openBuying(player, i);
|
openBuying(player, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,8 +1116,11 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (!T) {
|
if (!T) {
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1049,25 +1147,33 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (!data.contains("Items." + ID)) {
|
if (!data.contains("Items." + ID)) {
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.isInvFull(player)) {
|
if (Methods.isInvFull(player)) {
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.sendMessage(Messages.INVENTORY_FULL.getMessage(player));
|
player.sendMessage(Messages.INVENTORY_FULL.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getSupport().getMoney(player) < cost) {
|
if (plugin.getSupport().getMoney(player) < cost) {
|
||||||
playClick(player);
|
playClick(player);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
HashMap<String, String> placeholders = new HashMap<>();
|
|
||||||
|
Map<String, String> placeholders = new HashMap<>();
|
||||||
placeholders.put("%Money_Needed%", (cost - plugin.getSupport().getMoney(player)) + "");
|
placeholders.put("%Money_Needed%", (cost - plugin.getSupport().getMoney(player)) + "");
|
||||||
placeholders.put("%money_needed%", (cost - plugin.getSupport().getMoney(player)) + "");
|
placeholders.put("%money_needed%", (cost - plugin.getSupport().getMoney(player)) + "");
|
||||||
|
|
||||||
player.sendMessage(Messages.NEED_MORE_MONEY.getMessage(player, placeholders));
|
player.sendMessage(Messages.NEED_MORE_MONEY.getMessage(player, placeholders));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1077,7 +1183,7 @@ public class GuiListener implements Listener {
|
|||||||
plugin.getSupport().removeMoney(player, cost);
|
plugin.getSupport().removeMoney(player, cost);
|
||||||
plugin.getSupport().addMoney(Methods.getOfflinePlayer(seller), cost);
|
plugin.getSupport().addMoney(Methods.getOfflinePlayer(seller), cost);
|
||||||
|
|
||||||
HashMap<String, String> placeholders = new HashMap<>();
|
Map<String, String> placeholders = new HashMap<>();
|
||||||
|
|
||||||
String price = Methods.getPrice(ID, false);
|
String price = Methods.getPrice(ID, false);
|
||||||
|
|
||||||
@ -1098,16 +1204,22 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.getInventory().addItem(i);
|
player.getInventory().addItem(i);
|
||||||
|
|
||||||
data.set("Items." + ID, null);
|
data.set("Items." + ID, null);
|
||||||
Files.data.save();
|
Files.data.save();
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cancel.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cancel.Name")))) {
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1118,6 +1230,7 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Players-Current-Items")))) {
|
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Players-Current-Items")))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
int slot = e.getRawSlot();
|
int slot = e.getRawSlot();
|
||||||
|
|
||||||
if (slot <= inv.getSize()) {
|
if (slot <= inv.getSize()) {
|
||||||
@ -1128,7 +1241,9 @@ public class GuiListener implements Listener {
|
|||||||
if (item.getItemMeta().hasDisplayName()) {
|
if (item.getItemMeta().hasDisplayName()) {
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1142,18 +1257,26 @@ public class GuiListener implements Listener {
|
|||||||
int ID = data.getInt("Items." + i + ".StoreID");
|
int ID = data.getInt("Items." + i + ".StoreID");
|
||||||
if (id == ID) {
|
if (id == ID) {
|
||||||
player.sendMessage(Messages.CANCELLED_ITEM.getMessage(player));
|
player.sendMessage(Messages.CANCELLED_ITEM.getMessage(player));
|
||||||
|
|
||||||
AuctionCancelledEvent event = new AuctionCancelledEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")), Reasons.PLAYER_FORCE_CANCEL);
|
AuctionCancelledEvent event = new AuctionCancelledEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")), Reasons.PLAYER_FORCE_CANCEL);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
int num = 1;
|
int num = 1;
|
||||||
for (; data.contains("OutOfTime/Cancelled." + num); num++) ;
|
for (; data.contains("OutOfTime/Cancelled." + num); num++) ;
|
||||||
|
|
||||||
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
||||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time"));
|
data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time"));
|
||||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + i + ".Item"));
|
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + i + ".Item"));
|
||||||
|
|
||||||
data.set("Items." + i, null);
|
data.set("Items." + i, null);
|
||||||
|
|
||||||
Files.data.save();
|
Files.data.save();
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openPlayersCurrentList(player, 1);
|
openPlayersCurrentList(player, 1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1161,8 +1284,11 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (!T) {
|
if (!T) {
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1174,39 +1300,54 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Cancelled/Expired-Items")))) {
|
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Cancelled/Expired-Items")))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
final int slot = e.getRawSlot();
|
final int slot = e.getRawSlot();
|
||||||
|
|
||||||
if (slot <= inv.getSize()) {
|
if (slot <= inv.getSize()) {
|
||||||
if (e.getCurrentItem() != null) {
|
if (e.getCurrentItem() != null) {
|
||||||
final ItemStack item = e.getCurrentItem();
|
final ItemStack item = e.getCurrentItem();
|
||||||
|
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
if (item.getItemMeta().hasDisplayName()) {
|
if (item.getItemMeta().hasDisplayName()) {
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.PreviousPage.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.PreviousPage.Name")))) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||||
|
|
||||||
if (page == 1) page++;
|
if (page == 1) page++;
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openPlayersExpiredList(player, (page - 1));
|
openPlayersExpiredList(player, (page - 1));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Return.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Return.Name")))) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||||
|
|
||||||
if (data.contains("OutOfTime/Cancelled")) {
|
if (data.contains("OutOfTime/Cancelled")) {
|
||||||
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
||||||
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
|
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
|
||||||
if (Methods.isInvFull(player)) {
|
if (Methods.isInvFull(player)) {
|
||||||
player.sendMessage(Messages.INVENTORY_FULL.getMessage(player));
|
player.sendMessage(Messages.INVENTORY_FULL.getMessage(player));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
player.getInventory().addItem(Methods.fromBase64(data.getString("OutOfTime/Cancelled." + i + ".Item")));
|
player.getInventory().addItem(Methods.fromBase64(data.getString("OutOfTime/Cancelled." + i + ".Item")));
|
||||||
|
|
||||||
data.set("OutOfTime/Cancelled." + i, null);
|
data.set("OutOfTime/Cancelled." + i, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1214,17 +1355,25 @@ public class GuiListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(Messages.GOT_ITEM_BACK.getMessage(player));
|
player.sendMessage(Messages.GOT_ITEM_BACK.getMessage(player));
|
||||||
|
|
||||||
Files.data.save();
|
Files.data.save();
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openPlayersExpiredList(player, page);
|
openPlayersExpiredList(player, page);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.NextPage.Name")))) {
|
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.NextPage.Name")))) {
|
||||||
Methods.updateAuction();
|
Methods.updateAuction();
|
||||||
|
|
||||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openPlayersExpiredList(player, (page + 1));
|
openPlayersExpiredList(player, (page + 1));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1232,21 +1381,30 @@ public class GuiListener implements Listener {
|
|||||||
if (List.containsKey(player.getUniqueId())) {
|
if (List.containsKey(player.getUniqueId())) {
|
||||||
if (List.get(player.getUniqueId()).size() >= slot) {
|
if (List.get(player.getUniqueId()).size() >= slot) {
|
||||||
int id = List.get(player.getUniqueId()).get(slot);
|
int id = List.get(player.getUniqueId()).get(slot);
|
||||||
|
|
||||||
boolean T = false;
|
boolean T = false;
|
||||||
|
|
||||||
if (data.contains("OutOfTime/Cancelled")) {
|
if (data.contains("OutOfTime/Cancelled")) {
|
||||||
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
||||||
int ID = data.getInt("OutOfTime/Cancelled." + i + ".StoreID");
|
int ID = data.getInt("OutOfTime/Cancelled." + i + ".StoreID");
|
||||||
|
|
||||||
if (id == ID) {
|
if (id == ID) {
|
||||||
if (!Methods.isInvFull(player)) {
|
if (!Methods.isInvFull(player)) {
|
||||||
player.sendMessage(Messages.GOT_ITEM_BACK.getMessage(player));
|
player.sendMessage(Messages.GOT_ITEM_BACK.getMessage(player));
|
||||||
|
|
||||||
player.getInventory().addItem(Methods.fromBase64(data.getString("OutOfTime/Cancelled." + i + ".Item")));
|
player.getInventory().addItem(Methods.fromBase64(data.getString("OutOfTime/Cancelled." + i + ".Item")));
|
||||||
|
|
||||||
data.set("OutOfTime/Cancelled." + i, null);
|
data.set("OutOfTime/Cancelled." + i, null);
|
||||||
|
|
||||||
Files.data.save();
|
Files.data.save();
|
||||||
|
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openPlayersExpiredList(player, 1);
|
openPlayersExpiredList(player, 1);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Messages.INVENTORY_FULL.getMessage(player));
|
player.sendMessage(Messages.INVENTORY_FULL.getMessage(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1254,7 +1412,9 @@ public class GuiListener implements Listener {
|
|||||||
|
|
||||||
if (!T) {
|
if (!T) {
|
||||||
playClick(player);
|
playClick(player);
|
||||||
|
|
||||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||||
|
|
||||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,32 +14,32 @@ public class VaultSupport {
|
|||||||
private Economy vault = null;
|
private Economy vault = null;
|
||||||
|
|
||||||
public Economy getVault() {
|
public Economy getVault() {
|
||||||
return vault;
|
return this.vault;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadVault() {
|
public void loadVault() {
|
||||||
RegisteredServiceProvider<Economy> serviceProvider = this.plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> serviceProvider = this.plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
|
||||||
if (serviceProvider != null) vault = serviceProvider.getProvider();
|
if (serviceProvider != null) this.vault = serviceProvider.getProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getMoney(@NotNull Player player) {
|
public long getMoney(@NotNull Player player) {
|
||||||
return (long) vault.getBalance(player);
|
return (long) this.vault.getBalance(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMoney(@NotNull Player player, Long amount) {
|
public void removeMoney(@NotNull Player player, long amount) {
|
||||||
vault.withdrawPlayer(player, amount);
|
this.vault.withdrawPlayer(player, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMoney(@NotNull OfflinePlayer player, Long amount) {
|
public void removeMoney(@NotNull OfflinePlayer player, long amount) {
|
||||||
vault.withdrawPlayer(player, amount);
|
this.vault.withdrawPlayer(player, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMoney(Player player, Long amount) {
|
public void addMoney(Player player, long amount) {
|
||||||
vault.depositPlayer(player, amount);
|
this.vault.depositPlayer(player, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMoney(OfflinePlayer player, Long amount) {
|
public void addMoney(OfflinePlayer player, long amount) {
|
||||||
vault.depositPlayer(player, amount);
|
this.vault.depositPlayer(player, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user