mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Fixed them all
Former-commit-id: b75fcbe5e55c68c7eba41a9e535498ffa6787ed4
This commit is contained in:
1 parent
4ace9954eb
commit
f7339cea6e
4 files changed
+62
-13
No files matched your search
@@ -199,6 +199,7 @@ public class QuickShop extends JavaPlugin {
|
||||
private ShopContainerWatcher shopContainerWatcher;
|
||||
private DisplayDupeRemoverWatcher displayDupeRemoverWatcher;
|
||||
private BukkitAPIWrapper bukkitAPIWrapper;
|
||||
private boolean isUtilInited = false;
|
||||
|
||||
/**
|
||||
* Get the Player's Shop limit.
|
||||
@@ -351,11 +352,14 @@ public class QuickShop extends JavaPlugin {
|
||||
replaceLogger();
|
||||
|
||||
this.bootError = null;
|
||||
getLogger().info("Loading up integration modules.");
|
||||
this.integrationHelper = new IntegrationHelper();
|
||||
this.integrationHelper.callIntegrationsLoad(IntegrateStage.onLoadBegin);
|
||||
if(getConfig().getBoolean("integration.worldguard.enable")){
|
||||
Plugin wg = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
if(wg != null && wg.isEnabled()){
|
||||
Util.debugLogHeavy("Check WG plugin...");
|
||||
if(wg != null){
|
||||
Util.debugLogHeavy("Loading WG modules.");
|
||||
this.integrationHelper.register(new WorldGuardIntegration(this)); //WG require register flags when onLoad called.
|
||||
}
|
||||
}
|
||||
@@ -480,6 +484,7 @@ public class QuickShop extends JavaPlugin {
|
||||
/* Initalize the Utils */
|
||||
itemMatcher = new ItemMatcher(this);
|
||||
Util.initialize();
|
||||
this.isUtilInited = true;
|
||||
try {
|
||||
MsgUtil.loadCfgMessages();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.maxgamer.quickshop.Util;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -28,15 +29,15 @@ import org.maxgamer.quickshop.PluginsIntegration.IntegrationStage;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
public class IntegrationHelper {
|
||||
Set<IntegratedPlugin> integrations = new HashSet<>();
|
||||
private Set<IntegratedPlugin> integrations = new HashSet<>();
|
||||
|
||||
public void register(@NotNull IntegratedPlugin clazz) {
|
||||
if (!isIntegrationClass(clazz)) {
|
||||
throw new InvaildIntegratedPluginClass();
|
||||
}
|
||||
Util.debugLog("Registering "+clazz.getName());
|
||||
Util.debugLogHeavy("Registering "+clazz.getName());
|
||||
integrations.add(clazz);
|
||||
|
||||
}
|
||||
@@ -45,15 +46,17 @@ public class IntegrationHelper {
|
||||
if (!isIntegrationClass(clazz)) {
|
||||
throw new InvaildIntegratedPluginClass();
|
||||
}
|
||||
Util.debugLog("Unregistering "+clazz.getName());
|
||||
Util.debugLogHeavy("Unregistering "+clazz.getName());
|
||||
integrations.remove(clazz);
|
||||
}
|
||||
|
||||
public void callIntegrationsLoad(@NotNull IntegrateStage stage) {
|
||||
integrations.forEach(integratedPlugin -> {
|
||||
if (integratedPlugin.getClass().getDeclaredAnnotation(IntegrationStage.class).loadStage() == stage) {
|
||||
Util.debugLog("Calling for load "+integratedPlugin.getName());
|
||||
Util.debugLogHeavy("Calling for load "+integratedPlugin.getName());
|
||||
integratedPlugin.load();
|
||||
}else{
|
||||
Util.debugLogHeavy("Ignored calling because "+integratedPlugin.getName()+" stage is "+integratedPlugin.getClass().getDeclaredAnnotation(IntegrationStage.class).loadStage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -61,7 +64,7 @@ public class IntegrationHelper {
|
||||
public void callIntegrationsUnload(@NotNull IntegrateStage stage) {
|
||||
integrations.forEach(integratedPlugin -> {
|
||||
if (integratedPlugin.getClass().getDeclaredAnnotation(IntegrationStage.class).loadStage() == stage) {
|
||||
Util.debugLog("Calling for unload "+integratedPlugin.getName());
|
||||
Util.debugLogHeavy("Calling for unload "+integratedPlugin.getName());
|
||||
integratedPlugin.unload();
|
||||
}
|
||||
});
|
||||
@@ -70,7 +73,7 @@ public class IntegrationHelper {
|
||||
public boolean callIntegrationsCanCreate(@NotNull Player player, @NotNull Location location) {
|
||||
for (IntegratedPlugin integratedPlugin : integrations) {
|
||||
if (!integratedPlugin.canCreateShopHere(player, location)) {
|
||||
Util.debugLog("Integration " + integratedPlugin.getName() + " denied the player " + player.getName() + " at " + location + " shop creation.");
|
||||
Util.debugLogHeavy("Integration " + integratedPlugin.getName() + " denied the player " + player.getName() + " at " + location + " shop creation.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +83,7 @@ public class IntegrationHelper {
|
||||
public boolean callIntegrationsCanTrade(@NotNull Player player, @NotNull Location location) {
|
||||
for (IntegratedPlugin integratedPlugin : integrations) {
|
||||
if (!integratedPlugin.canTradeShopHere(player, location)) {
|
||||
Util.debugLog("Integration " + integratedPlugin.getName() + " denied the player " + player.getName() + " at " + location + " shop trading.");
|
||||
Util.debugLogHeavy("Integration " + integratedPlugin.getName() + " denied the player " + player.getName() + " at " + location + " shop trading.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +91,7 @@ public class IntegrationHelper {
|
||||
}
|
||||
|
||||
private boolean isIntegrationClass(@NotNull IntegratedPlugin clazz) {
|
||||
return clazz.getClass().getAnnotation(IntegrationStage.class) != null;
|
||||
return clazz.getClass().getDeclaredAnnotation(IntegrationStage.class) != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,9 @@ public class Paste {
|
||||
finalReport.append("\tOnlineMode: ").append(Bukkit.getOnlineMode()).append("\n");
|
||||
finalReport.append("\tBukkitVersion: ").append(Bukkit.getVersion()).append("\n");
|
||||
finalReport.append("\tWorldContainer: ").append(Bukkit.getWorldContainer()).append("\n");
|
||||
List<String> modules = new ArrayList<>();;
|
||||
plugin.getIntegrationHelper().getIntegrations().forEach(m->modules.add(m.getName()));
|
||||
finalReport.append("\tLoaded Integrations: ").append(Util.list2String(modules)).append("\n");
|
||||
finalReport.append("================================================\n");
|
||||
finalReport.append("Worlds:\n");
|
||||
finalReport.append("\tTotal: ").append(Bukkit.getWorlds().size()).append("\n");
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.Database.MySQLCore;
|
||||
import org.maxgamer.quickshop.NonQuickShopStuffs.de.Keyle.MyPet.api.util.Colorizer;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.DisplayItem;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
@@ -66,14 +67,14 @@ public class Util {
|
||||
private static EnumSet<Material> blacklist = EnumSet.noneOf(Material.class);
|
||||
@Getter
|
||||
private static List<String> debugLogs = new LinkedList<>();
|
||||
private static boolean devMode;
|
||||
private static boolean devMode = true;
|
||||
private static QuickShop plugin;
|
||||
private static EnumMap<Material, Entry<Double, Double>> restrictedPrices = new EnumMap<>(Material.class);
|
||||
private static Object serverInstance;
|
||||
private static EnumSet<Material> shoppables = EnumSet.noneOf(Material.class);
|
||||
private static Field tpsField;
|
||||
private static List<String> worldBlacklist = new ArrayList<>();
|
||||
private static boolean disableDebugLogger;
|
||||
private static boolean disableDebugLogger = false;
|
||||
|
||||
/**
|
||||
* Convert strArray to String.
|
||||
@@ -198,6 +199,7 @@ public class Util {
|
||||
*
|
||||
* @param logs logs
|
||||
*/
|
||||
|
||||
public static void debugLog(@NotNull String... logs) {
|
||||
if (!devMode) {
|
||||
if (disableDebugLogger) {
|
||||
@@ -220,7 +222,7 @@ public class Util {
|
||||
|
||||
for (String log : logs) {
|
||||
String text = "["+ChatColor.DARK_GREEN + ChatColor.BOLD + "DEBUG" + ChatColor.RESET + "] [" + ChatColor.DARK_GREEN + className + ChatColor.RESET + "]" + " [" + ChatColor.DARK_GREEN + methodName + ChatColor.RESET + "] (" + ChatColor.DARK_GREEN + codeLine + ChatColor.RESET + ") " + log;
|
||||
debugLogs.add(text);
|
||||
debugLogs.add(Colorizer.stripColors(text));
|
||||
if (debugLogs.size() > 500000) /* Keep debugLogs max can have 500k lines. */ {
|
||||
debugLogs.remove(0);
|
||||
}
|
||||
@@ -241,6 +243,42 @@ public class Util {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Print debug log when plugin running on dev mode.
|
||||
*
|
||||
* @param logs logs
|
||||
*/
|
||||
|
||||
public static void debugLogHeavy(@NotNull String... logs) {
|
||||
if (!QuickShop.instance.getConfig().getBoolean("dev-mode")) {
|
||||
return;
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
String className = Thread.currentThread().getStackTrace()[2].getClassName();
|
||||
try {
|
||||
Class<?> c = Class.forName(className);
|
||||
className = c.getSimpleName();
|
||||
if (!c.getSimpleName().isEmpty()) {
|
||||
className = c.getSimpleName();
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
//Ignore
|
||||
}
|
||||
String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
int codeLine = Thread.currentThread().getStackTrace()[2].getLineNumber();
|
||||
|
||||
for (String log : logs) {
|
||||
String text = "["+ChatColor.DARK_GREEN + ChatColor.BOLD + "DEBUG" + ChatColor.RESET + "] [" + ChatColor.DARK_GREEN + className + ChatColor.RESET + "]" + " [" + ChatColor.DARK_GREEN + methodName + ChatColor.RESET + "] (" + ChatColor.DARK_GREEN + codeLine + ChatColor.RESET + ") " + log;
|
||||
debugLogs.add(Colorizer.stripColors(text));
|
||||
if (debugLogs.size() > 500000) /* Keep debugLogs max can have 500k lines. */ {
|
||||
debugLogs.remove(0);
|
||||
}
|
||||
if (QuickShop.instance.getConfig().getBoolean("dev-mode")) {
|
||||
QuickShop.instance.getLogger().info(text);
|
||||
}
|
||||
}
|
||||
long debugLogCost = System.currentTimeMillis() - startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Covert YAML string to ItemStack.
|
||||
|
||||
Reference in new issue
Block a user