Merge branch 'badbones69-master'

This commit is contained in:
Gabriele C 2021-09-02 21:53:43 +02:00
commit 4c1f9d45a3
6 changed files with 43 additions and 46 deletions

10
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>me.badbones69</groupId>
<artifactId>crazyauctions</artifactId>
<version>1.2.16-SNAPSHOT</version>
<version>1.2.17-SNAPSHOT</version>
<name>CrazyAuctions</name>
<properties>
@ -47,14 +47,8 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>

View File

@ -372,23 +372,17 @@ public class Main extends JavaPlugin implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent e) {
final Player player = e.getPlayer();
new BukkitRunnable() {
@Override
public void run() {
if (player.getName().equals("BadBones69")) {
player.sendMessage(Methods.getPrefix() + Methods.color("&7This server is running your Crazy Auctions Plugin. " + "&7It is running version &av" + Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions").getDescription().getVersion() + "&7."));
}
}
}.runTaskLater(this, 40);
if (player.getName().equalsIgnoreCase("BadBones69")) {
Bukkit.getScheduler().runTaskLater(this, () -> {
player.sendMessage(Methods.getPrefix() + Methods.color("&7This server is running your Crazy Auctions Plugin. " + "&7It is running version &av" + Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions").getDescription().getVersion() + "&7."));
}, 40);
}
}
private void startCheck() {
new BukkitRunnable() {
@Override
public void run() {
Methods.updateAuction();
}
}.runTaskTimer(this, 20, 5 * 20);
Bukkit.getScheduler().runTaskTimer(this, () -> {
Methods.updateAuction();
}, 20, 5 * 20);
}
private ArrayList<Material> getDamageableItems() {

View File

@ -17,14 +17,26 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Methods {
public static Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions");
private static FileManager fileManager = FileManager.getInstance();
public static String color(String msg) {
return ChatColor.translateAlternateColorCodes('&', msg);
public final static Pattern HEX_PATTERN = Pattern.compile("#[a-fA-F0-9]{6}");
public static String color(String message) {
if (Version.isNewer(Version.v1_15_R1)) {
Matcher matcher = HEX_PATTERN.matcher(message);
StringBuffer buffer = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(buffer, net.md_5.bungee.api.ChatColor.of(matcher.group()).toString());
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}
return ChatColor.translateAlternateColorCodes('&', message);
}
public static String getPrefix() {

View File

@ -6,18 +6,19 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.UUID;
public class CrazyAuctions {
private static CrazyAuctions instance = new CrazyAuctions();
private FileManager fileManager = FileManager.getInstance();
private Boolean sellingEnabled;
private Boolean biddingEnabled;
public static CrazyAuctions getInstance() {
return instance;
}
public void loadCrazyAuctions() {
if (Files.CONFIG.getFile().contains("Settings.Feature-Toggle.Selling")) {
this.sellingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Selling");
@ -30,34 +31,34 @@ public class CrazyAuctions {
this.biddingEnabled = true;
}
}
public Boolean isSellingEnabled() {
return sellingEnabled;
}
public Boolean isBiddingEnabled() {
return biddingEnabled;
}
public ArrayList<ItemStack> getItems(Player player) {
FileConfiguration data = Files.DATA.getFile();
ArrayList<ItemStack> items = new ArrayList<>();
if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
items.add(data.getItemStack("Items." + i + ".Item").clone());
}
}
}
return items;
}
public ArrayList<ItemStack> getItems(Player player, ShopType type) {
FileConfiguration data = Files.DATA.getFile();
ArrayList<ItemStack> items = new ArrayList<>();
if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
if (data.getBoolean("Items." + i + ".Biddable")) {
if (type == ShopType.BID) {
items.add(data.getItemStack("Items." + i + ".Item").clone());
@ -72,5 +73,5 @@ public class CrazyAuctions {
}
return items;
}
}

View File

@ -14,8 +14,7 @@ public enum Version {
v1_13_R2(1132),
v1_14_R1(1141),
v1_15_R1(1151),
v1_16_R1(1161),
v1_16_R2(1162),
v1_16_R1(1161), v1_16_R2(1162), v1_16_R3(1163),
TOO_NEW(-2);
private static Version currentVersion;

View File

@ -21,10 +21,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.*;
import java.util.logging.Level;
public class GUI implements Listener {
@ -194,7 +191,7 @@ public class GUI implements Listener {
}
if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
List<String> lore = new ArrayList<>();
for (String l : config.getStringList("Settings.GUISettings.CurrentLore")) {
lore.add(l.replace("%Price%", Methods.getPrice(i, false)).replace("%price%", Methods.getPrice(i, false)).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))));
@ -222,7 +219,7 @@ public class GUI implements Listener {
if (data.contains("OutOfTime/Cancelled")) {
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
if (data.getString("OutOfTime/Cancelled." + i + ".Seller") != null) {
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (UUID.fromString(data.getString("OutOfTime/Cancelled." + i + ".Seller")).equals(player.getUniqueId())) {
List<String> lore = new ArrayList<>();
for (String l : config.getStringList("Settings.GUISettings.Cancelled/ExpiredLore")) {
lore.add(l.replace("%Price%", Methods.getPrice(i, true)).replace("%price%", Methods.getPrice(i, true)).replace("%Time%", Methods.convertToTime(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"))).replace("%time%", Methods.convertToTime(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"))));
@ -534,7 +531,7 @@ public class GUI implements Listener {
}
Bukkit.getPluginManager().callEvent(new AuctionNewBidEvent(player, data.getItemStack("Items." + ID + ".Item"), bid));
data.set("Items." + ID + ".Price", bid);
data.set("Items." + ID + ".TopBidder", player.getName());
data.set("Items." + ID + ".TopBidder", player.getUniqueId().toString());
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Bid%", bid + "");
player.sendMessage(Messages.BID_MESSAGE.getMessage(placeholders));
@ -676,7 +673,7 @@ public class GUI implements Listener {
}
}
final Runnable runnable = () -> inv.setItem(slot, item);
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
String it = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
ItemStack I;
@ -706,7 +703,7 @@ public class GUI implements Listener {
return;
}
if (data.getBoolean("Items." + i + ".Biddable")) {
if (player.getName().equalsIgnoreCase(data.getString("Items." + i + ".TopBidder"))) {
if (player.getUniqueId().equals(UUID.fromString(data.getString("Items." + i + ".TopBidder")))) {
String it = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Name");
ItemStack I;
@ -885,7 +882,7 @@ public class GUI implements Listener {
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
if (data.contains("OutOfTime/Cancelled")) {
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (UUID.fromString(data.getString("OutOfTime/Cancelled." + i + ".Seller")).equals(player.getUniqueId())) {
if (Methods.isInvFull(player)) {
player.sendMessage(Messages.INVENTORY_FULL.getMessage());
break;