From bb29a49e5aae1723c9f343d156e45e4449bfda45 Mon Sep 17 00:00:00 2001
From: Ghost_chu <2908803755@qq.com>
Date: Fri, 13 Dec 2019 16:38:29 +0800
Subject: [PATCH 1/6] Remove useless comments
Former-commit-id: 5bb21a5ea58d1d806eb555b588b5c94bb1a2fd8f
---
.../Permission/PermissionManager.java | 26 -------------------
.../org/maxgamer/quickshop/QuickShop.java | 5 ----
.../maxgamer/quickshop/Shop/DisplayItem.java | 10 -------
.../maxgamer/quickshop/Shop/ShopManager.java | 15 -----------
.../quickshop/Util/ChatSheetPrinter.java | 1 -
5 files changed, 57 deletions(-)
diff --git a/src/main/java/org/maxgamer/quickshop/Permission/PermissionManager.java b/src/main/java/org/maxgamer/quickshop/Permission/PermissionManager.java
index b3517ec77..36898d909 100644
--- a/src/main/java/org/maxgamer/quickshop/Permission/PermissionManager.java
+++ b/src/main/java/org/maxgamer/quickshop/Permission/PermissionManager.java
@@ -29,7 +29,6 @@ import org.maxgamer.quickshop.Util.Util;
public class PermissionManager {
private QuickShop plugin;
private PermissionProvider provider;
- //private PermissionProviderType providerType;
/**
* The manager to call permission providers
@@ -38,32 +37,7 @@ public class PermissionManager {
*/
public PermissionManager(QuickShop plugin) {
this.plugin = plugin;
-// try {
-// this.providerType = PermissionProviderType.fromID(plugin.getConfig().getInt("permission-type"));
-// } catch (IllegalArgumentException e) {
-// plugin.getLogger().warning("Falling back to Bukkit permission provider...");
-// this.providerType = PermissionProviderType.BUKKIT;
-// }
-// try {
-// switch (providerType) {
-// case BUKKIT:
provider = new BukkitPermsProvider();
-// break;
-// case VAULT:
-// provider = new VaultPermissionProvider();
-// break;
-// default:
-// provider = new BukkitPermsProvider();
-// break;
-// }
-// } catch (ProviderIsEmptyException empty) {
-// plugin.getLogger().warning("Provider " + providerType.name() + " doesn't work, falling back to BUKKIT.");
-// provider = new BukkitPermsProvider();
-// } catch (Throwable th) {
-// th.printStackTrace();
-// plugin.getLogger().warning("Provider " + providerType.name() + " failed loading, falling back to BUKKIT.");
-// provider = new BukkitPermsProvider();
-// }
plugin.getLogger().info("Selected permission provider: " + provider.getName());
}
diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java
index 1efd0df59..f9c98b19b 100644
--- a/src/main/java/org/maxgamer/quickshop/QuickShop.java
+++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java
@@ -557,11 +557,6 @@ public class QuickShop extends JavaPlugin {
getLogger().severe("FATAL: Old QuickShop is installed, You must remove old quickshop jar from plugins folder!");
throw new RuntimeException("FATAL: Old QuickShop is installed, You must remove old quickshop jar from plugins folder!");
}
-// if (!Util.isClassAvailable("org.apache.http.impl.client.HttpClients")) {
-// getLogger()
-// .severe("FATAL: Broken QuickShop build, please download from SpigotMC not Github if you didn't know should download which one.");
-// throw new RuntimeException("Broken QuickShop build, please download from SpigotMC not Github if you didn't know should download which one.");
-// }
try {
getServer().spigot();
} catch (Throwable e) {
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java
index 54f452a07..7feb04feb 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java
@@ -40,11 +40,6 @@ import java.util.Objects;
*/
public interface DisplayItem {
-// /**
-// * constant literal to check if item is quickshop display item
-// */
-// static final String QUICKSHOP_DISPLAY_ITEM = "quickshop display item";
-
/**
* Check the itemStack is contains protect flag.
*
@@ -61,11 +56,6 @@ public interface DisplayItem {
return false;
}
ItemMeta iMeta = itemStack.getItemMeta();
-// if (iMeta.hasDisplayName()) {
-// if (iMeta.getDisplayName().toLowerCase().contains(QUICKSHOP_DISPLAY_ITEM)) {
-// return true;
-// }
-// }
if (!Objects.requireNonNull(iMeta).hasLore()) {
return false;
}
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
index 2f6a08085..1b319970b 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
@@ -589,17 +589,6 @@ public class ShopManager {
* @return True if they're allowed to place a shop there.
*/
public boolean canBuildShop(@NotNull Player p, @NotNull Block b, @NotNull BlockFace bf) {
- RegisteredListener openInvRegisteredListener = null; // added for compatibility reasons with OpenInv - see https://github.com/KaiKikuchi/QuickShop/issues/139
- // try {
- // if (plugin.openInvPlugin != null) {
- // for (RegisteredListener listener : PlayerInteractEvent.getHandlerList().getRegisteredListeners()) {
- // if (listener.getPlugin().getName().equals(plugin.openInvPlugin.getName())) {
- // openInvRegisteredListener = listener;
- // PlayerInteractEvent.getHandlerList().unregister(listener);
- // break;
- // }
- // }
- // }
try {
plugin.getCompatibilityTool().toggleProtectionListeners(false, p);
@@ -626,7 +615,6 @@ public class ShopManager {
int max = plugin.getShopLimit(p);
if (owned + 1 > max) {
- //p.sendMessage(ChatColor.RED + "You have already created a maximum of " + owned + "/" + max + " shops!");
p.sendMessage(MsgUtil.getMessage("reached-maximum-can-create", p, String.valueOf(owned), String.valueOf(max)));
return false;
}
@@ -641,9 +629,6 @@ public class ShopManager {
return false;
}
} finally {
- // if (plugin.openInvPlugin != null && openInvRegisteredListener != null) {
- // PlayerInteractEvent.getHandlerList().register(openInvRegisteredListener);
- // }
plugin.getCompatibilityTool().toggleProtectionListeners(true, p);
}
diff --git a/src/main/java/org/maxgamer/quickshop/Util/ChatSheetPrinter.java b/src/main/java/org/maxgamer/quickshop/Util/ChatSheetPrinter.java
index ce7aeb026..3a5634de2 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/ChatSheetPrinter.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/ChatSheetPrinter.java
@@ -38,7 +38,6 @@ import org.jetbrains.annotations.NotNull;
*/
public class ChatSheetPrinter {
final ChatColor chatColor = ChatColor.DARK_PURPLE;
- //StringBuffer buffer = new StringBuffer();
private CommandSender p;
public void printCenterLine(@NotNull String text) {
From ab51291f93875e22f84851ef157b87910f3a453c Mon Sep 17 00:00:00 2001
From: Ghost_chu <2908803755@qq.com>
Date: Fri, 13 Dec 2019 16:42:32 +0800
Subject: [PATCH 2/6] Use project.version
Former-commit-id: 1e94ad6acdbad99e327130aa4a05b1a40375b1c3
---
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 93352f6c5..75e9c1cf6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,9 +24,9 @@
- https://github.com/${developer}/${version}
- scm:git:git://github.com/${developer}/${version}.git
- scm:git:git@github.com:${developer}/${version}.git
+ https://github.com/${developer}/${project.version}
+ scm:git:git://github.com/${developer}/${project.version}.git
+ scm:git:git@github.com:${developer}/${project.version}.git
From 8c841c301375be00dada6920762bd06462faf8a8 Mon Sep 17 00:00:00 2001
From: Ghost_chu <2908803755@qq.com>
Date: Fri, 13 Dec 2019 16:44:38 +0800
Subject: [PATCH 3/6] Fix error on 1.13 and 1.14 early spigot build.
Former-commit-id: c7d003532abc139d911f4560280495828a5e78f9
---
.../org/maxgamer/quickshop/Shop/ArmorStandDisplayItem.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ArmorStandDisplayItem.java b/src/main/java/org/maxgamer/quickshop/Shop/ArmorStandDisplayItem.java
index 6c1cdbb34..1ecabe8a1 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/ArmorStandDisplayItem.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/ArmorStandDisplayItem.java
@@ -149,7 +149,9 @@ public class ArmorStandDisplayItem implements DisplayItem {
//Set item protect in the armorstand's hand
this.guardedIstack = DisplayItem.createGuardItemStack(this.originalItemStack, this.shop);
armorStand.setItemInHand(guardedIstack);
- armorStand.getPersistentDataContainer().set(new NamespacedKey(plugin,"displayMark"),DisplayItemPersistentDataType.INSTANCE,DisplayItem.createShopProtectionFlag(this.originalItemStack,shop));
+ try {
+ armorStand.getPersistentDataContainer().set(new NamespacedKey(plugin, "displayMark"), DisplayItemPersistentDataType.INSTANCE, DisplayItem.createShopProtectionFlag(this.originalItemStack, shop));
+ }catch (Throwable ignored){}
Util.debugLog("Successfully safeGuard ArmorStand: " + armorStand.getLocation());
}
From 299803d1fe8b2d271987d821f63d574e78590cea Mon Sep 17 00:00:00 2001
From: Ghost_chu <2908803755@qq.com>
Date: Fri, 13 Dec 2019 16:53:53 +0800
Subject: [PATCH 4/6] Do not copy defaults and force convert the String to
Integer
Former-commit-id: fbb19dd73c93b9c94e62cd111d56c8d147774d7e
---
.../java/org/maxgamer/quickshop/Util/MsgUtil.java | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java
index b853508d6..a38d7b551 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java
@@ -257,7 +257,7 @@ public class MsgUtil {
return Util.prettifyText(potionString);
}
- public static void loadCfgMessages(@NotNull String... reload) {
+ public static void loadCfgMessages() {
/* Check & Load & Create default messages.yml */
// Use try block to hook any possible exception, make sure not effect our cfgMessnages code.
try {
@@ -288,21 +288,18 @@ public class MsgUtil {
plugin.getLanguage().saveFile(Objects.requireNonNull(plugin.getConfig().getString("language")), "messages", "messages.yml");
}
messagei18n = YamlConfiguration.loadConfiguration(messageFile);
- messagei18n.options().copyDefaults(true);
- YamlConfiguration messagei18nYAML = YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getLanguage()
- .getFile(plugin.getConfig().getString("language"), "messages")));
- messagei18n.setDefaults(messagei18nYAML);
+ messagei18n.options().copyDefaults(false);
+ messagei18n.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getLanguage()
+ .getFile(plugin.getConfig().getString("language"), "messages"))));
/* Set default language vesion and update messages.yml */
- if (messagei18n.getInt("language-version") == 0) {
+ if (Integer.parseInt(messagei18n.getString("language-version","0")) == 0) {
messagei18n.set("language-version", 1);
}
- if (reload.length == 0) {
try {
updateMessages(messagei18n.getInt("language-version"));
} catch (IOException e1) {
e1.printStackTrace();
}
- }
Util.parseColours(messagei18n);
From c5a624b331d3cc1f8e69c10cd37335cb7fb6de4d Mon Sep 17 00:00:00 2001
From: Ghost_chu <2908803755@qq.com>
Date: Fri, 13 Dec 2019 17:04:17 +0800
Subject: [PATCH 5/6] Add stats for debugLogger, optimize debugLogger
performance.
Former-commit-id: 7f87073d8d553d91b3202910f5b27020980c070b
---
src/main/java/org/maxgamer/quickshop/QuickShop.java | 3 +++
src/main/java/org/maxgamer/quickshop/Util/Util.java | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java
index f9c98b19b..4617489ed 100644
--- a/src/main/java/org/maxgamer/quickshop/QuickShop.java
+++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java
@@ -681,6 +681,8 @@ public class QuickShop extends JavaPlugin {
String useEnhanceDisplayProtect = String.valueOf(getConfig().getBoolean("shop.enchance-display-protect"));
String useEnhanceShopProtect = String.valueOf(getConfig().getBoolean("shop.enchance-shop-protect"));
String useOngoingFee = String.valueOf(getConfig().getBoolean("shop.ongoing-fee.enable"));
+ String disableDebugLoggger = String.valueOf(getConfig().getBoolean("disable-debuglogger"));
+
// Version
metrics.addCustomChart(new Metrics.SimplePie("server_version", () -> serverVer));
metrics.addCustomChart(new Metrics.SimplePie("bukkit_version", () -> bukkitVer));
@@ -695,6 +697,7 @@ public class QuickShop extends JavaPlugin {
metrics.addCustomChart(new Metrics.SimplePie("use_enhance_display_protect", () -> useEnhanceDisplayProtect));
metrics.addCustomChart(new Metrics.SimplePie("use_enhance_shop_protect", () -> useEnhanceShopProtect));
metrics.addCustomChart(new Metrics.SimplePie("use_ongoing_fee", () -> useOngoingFee));
+ metrics.addCustomChart(new Metrics.SimplePie("disable_background_debug_logger", ()->disableDebugLoggger));
// Exp for stats, maybe i need improve this, so i add this.
metrics.submitData(); // Submit now!
getLogger().info("Metrics submitted.");
diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java
index 61a39ade0..274c41018 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/Util.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java
@@ -67,6 +67,7 @@ public class Util {
private static EnumSet shoppables = EnumSet.noneOf(Material.class);
private static Field tpsField;
private static List worldBlacklist = new ArrayList<>();
+ private static boolean disableDebugLogger;
/**
* Convert strArray to String.
@@ -193,7 +194,7 @@ public class Util {
*/
public static void debugLog(@NotNull String... logs) {
if (!devMode) {
- if (QuickShop.instance.getConfig().getBoolean("disable-debuglogger", false)) {
+ if (disableDebugLogger) {
return;
}
}
@@ -227,6 +228,7 @@ public class Util {
tookLongTimeCostTimes++;
if (tookLongTimeCostTimes > 30) {
QuickShop.instance.getConfig().set("disable-debuglogger", true);
+ disableDebugLogger = true;
QuickShop.instance.saveConfig();
QuickShop.instance.getLogger().warning("Detected the debug logger tooked time keep too lang, QuickShop already auto-disable debug logger, your server performance should back to normal. But you must re-enable it if you want to report any bugs.");
}
@@ -591,6 +593,7 @@ public class Util {
}
}
worldBlacklist = plugin.getConfig().getStringList("shop.blacklist-world");
+ disableDebugLogger = plugin.getConfig().getBoolean("disable-debuglogger",false);
}
From ff8542242b87ab4abcbdee44a624a2cf56b412e3 Mon Sep 17 00:00:00 2001
From: Ghost_chu <2908803755@qq.com>
Date: Fri, 13 Dec 2019 17:08:08 +0800
Subject: [PATCH 6/6] Just a little changes
Former-commit-id: 1d8ef020abbc943e7ba34a9513eec01a804f3831
---
src/main/java/org/maxgamer/quickshop/Util/Util.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java
index 274c41018..0c8bf143a 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/Util.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java
@@ -977,7 +977,7 @@ public class Util {
if (filtered.startsWith("MemorySection")) {
continue;
}
- filtered = ChatColor.translateAlternateColorCodes('&', filtered);
+ filtered = parseColours(filtered);
config.set(key, filtered);
}
}