mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
DatabaseManager refactor - s1
Former-commit-id: c23f457d2a7862dece89bbf640e6593954868f1c
This commit is contained in:
1 parent
12452c9ba0
commit
5469e2e75e
43 files changed
+334
-256
No files matched your search
@@ -42,7 +42,7 @@ public class SubCommand_About implements CommandProcesser {
|
||||
public void onCommand(
|
||||
@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
sender.sendMessage(
|
||||
ChatColor.AQUA + "QuickShop " + ChatColor.YELLOW + QuickShop.instance.getFork());
|
||||
ChatColor.AQUA + "QuickShop " + ChatColor.YELLOW + QuickShop.getFork());
|
||||
sender.sendMessage(
|
||||
ChatColor.AQUA
|
||||
+ "Ver "
|
||||
|
||||
@@ -125,47 +125,50 @@ public class DatabaseHelper {
|
||||
* @return Create failed or successed.
|
||||
* @throws SQLException If the connection is invalid
|
||||
*/
|
||||
private boolean createMessagesTable() throws SQLException {
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String createTable = "CREATE TABLE " + QuickShop.instance.getDbPrefix()
|
||||
+ "messages (owner VARCHAR(255) NOT NULL, message TEXT(25) NOT NULL, time BIGINT(32) NOT NULL );";
|
||||
if (plugin.getDatabase().getCore() instanceof MySQLCore) {
|
||||
createTable = "CREATE TABLE " + QuickShop.instance.getDbPrefix()
|
||||
+ "messages (owner VARCHAR(255) NOT NULL, message TEXT(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL , time BIGINT(32) NOT NULL );";
|
||||
}
|
||||
return st.execute(createTable);
|
||||
}
|
||||
|
||||
public void createShop(@NotNull String owner, double price, @NotNull ItemStack item, int unlimited, int shopType, @NotNull String world, int x, int y, int z) {
|
||||
private void createMessagesTable() throws SQLException {
|
||||
plugin.getDatabaseManager().add(() -> {
|
||||
try {
|
||||
removeShop(x, y, z, world); //First purge old exist shop before create new shop.
|
||||
String sqlString = "INSERT INTO " + QuickShop.instance
|
||||
.getDbPrefix() + "shops (owner, price, itemConfig, x, y, z, world, unlimited, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
//QuickShop.instance.getDB().execute(q, owner, price, Util.serialize(item), x, y, z, world, unlimited, shopType);
|
||||
PreparedStatement ps = db.getConnection().prepareStatement(sqlString);
|
||||
ps.setString(1, owner);
|
||||
ps.setDouble(2, price);
|
||||
ps.setString(3, Util.serialize(item));
|
||||
ps.setInt(4, x);
|
||||
ps.setInt(5, y);
|
||||
ps.setInt(6, z);
|
||||
ps.setString(7, world);
|
||||
ps.setInt(8, unlimited);
|
||||
ps.setInt(9, shopType);
|
||||
ps.execute();
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String createTable = "CREATE TABLE " + QuickShop.instance.getDbPrefix()
|
||||
+ "messages (owner VARCHAR(255) NOT NULL, message TEXT(25) NOT NULL, time BIGINT(32) NOT NULL );";
|
||||
if (plugin.getDatabase().getCore() instanceof MySQLCore) {
|
||||
createTable = "CREATE TABLE " + QuickShop.instance.getDbPrefix()
|
||||
+ "messages (owner VARCHAR(255) NOT NULL, message TEXT(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL , time BIGINT(32) NOT NULL );";
|
||||
}
|
||||
st.execute(createTable);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean createShop(@NotNull String owner, double price, @NotNull ItemStack item, int unlimited, int shopType, @NotNull String world, int x, int y, int z) {
|
||||
try {
|
||||
removeShop(x, y, z, world); //First purge old exist shop before create new shop.
|
||||
String sqlString = "INSERT INTO " + QuickShop.instance
|
||||
.getDbPrefix() + "shops (owner, price, itemConfig, x, y, z, world, unlimited, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
//QuickShop.instance.getDB().execute(q, owner, price, Util.serialize(item), x, y, z, world, unlimited, shopType);
|
||||
PreparedStatement ps = db.getConnection().prepareStatement(sqlString);
|
||||
ps.setString(1, owner);
|
||||
ps.setDouble(2, price);
|
||||
ps.setString(3, Util.serialize(item));
|
||||
ps.setInt(4, x);
|
||||
ps.setInt(5, y);
|
||||
ps.setInt(6, z);
|
||||
ps.setString(7, world);
|
||||
ps.setInt(8, unlimited);
|
||||
ps.setInt(9, shopType);
|
||||
return ps.execute();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the database table 'shops'.
|
||||
*
|
||||
* @throws SQLException If the connection is invalid.
|
||||
*/
|
||||
private void createShopsTable() throws SQLException {
|
||||
private void createShopsTable() {
|
||||
plugin.getDatabaseManager().add(() -> {
|
||||
try {
|
||||
Statement st = db.getConnection().createStatement();
|
||||
@@ -178,22 +181,29 @@ public class DatabaseHelper {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean removeShop(int x, int y, int z, @NotNull String worldName) throws SQLException {
|
||||
public void removeShop(int x, int y, int z, @NotNull String worldName) throws SQLException {
|
||||
// db.getConnection().createStatement()
|
||||
// .executeUpdate("DELETE FROM " + QuickShop.instance.getDbPrefix() + "shops WHERE x = " + x + " AND y = " + y
|
||||
// + " AND z = " + z + " AND world = \"" + worldName + "\""
|
||||
// + (db.getCore() instanceof MySQLCore ? " LIMIT 1" : ""));
|
||||
String sqlString = "DELETE FROM " + QuickShop.instance
|
||||
.getDbPrefix() + "shops WHERE x = ? AND y = ? AND z = ? AND world = ?" + (db.getCore() instanceof MySQLCore ?
|
||||
" LIMIT 1" :
|
||||
"");
|
||||
plugin.getDatabaseManager().add(() -> {
|
||||
try {
|
||||
String sqlString = "DELETE FROM " + QuickShop.instance
|
||||
.getDbPrefix() + "shops WHERE x = ? AND y = ? AND z = ? AND world = ?" + (db.getCore() instanceof MySQLCore ?
|
||||
" LIMIT 1" :
|
||||
"");
|
||||
|
||||
PreparedStatement ps = db.getConnection().prepareStatement(sqlString);
|
||||
ps.setInt(1, x);
|
||||
ps.setInt(2, y);
|
||||
ps.setInt(3, z);
|
||||
ps.setString(4, worldName);
|
||||
return ps.execute();
|
||||
PreparedStatement ps = db.getConnection().prepareStatement(sqlString);
|
||||
ps.setInt(1, x);
|
||||
ps.setInt(2, y);
|
||||
ps.setInt(3, z);
|
||||
ps.setString(4, worldName);
|
||||
ps.execute();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public ResultSet selectAllMessages() throws SQLException {
|
||||
@@ -225,8 +235,7 @@ public class DatabaseHelper {
|
||||
});
|
||||
}
|
||||
|
||||
public void updateOwner2UUID(@NotNull String ownerUUID, int x, int y, int z, @NotNull String worldName)
|
||||
throws SQLException {
|
||||
public void updateOwner2UUID(@NotNull String ownerUUID, int x, int y, int z, @NotNull String worldName) {
|
||||
//QuickShop.instance.getDB().getConnection().createStatement()
|
||||
// .executeUpdate("UPDATE " + QuickShop.instance.getDbPrefix() + "shops SET owner = \"" + ownerUUID.toString()
|
||||
// + "\" WHERE x = " + x + " AND y = " + y + " AND z = " + z
|
||||
|
||||
@@ -32,17 +32,26 @@ import org.maxgamer.quickshop.Util.Timer;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
import org.maxgamer.quickshop.Util.WarningSender;
|
||||
|
||||
/** Queued database manager. Use queue to solve run SQL make server lagg issue. */
|
||||
/**
|
||||
* Queued database manager. Use queue to solve run SQL make server lagg issue.
|
||||
*/
|
||||
public class DatabaseManager {
|
||||
|
||||
private final Queue<Runnable> sqlQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
@NotNull private final Database database;
|
||||
@NotNull
|
||||
private final Database database;
|
||||
|
||||
@NotNull private final QuickShop plugin;
|
||||
@NotNull private final WarningSender warningSender;
|
||||
@Nullable private BukkitTask task;
|
||||
private boolean useQueue;
|
||||
@NotNull
|
||||
private final QuickShop plugin;
|
||||
|
||||
@NotNull
|
||||
private final WarningSender warningSender;
|
||||
|
||||
@Nullable
|
||||
private BukkitTask task;
|
||||
|
||||
private final boolean useQueue;
|
||||
|
||||
/**
|
||||
* Queued database manager. Use queue to solve run SQL make server lagg issue.
|
||||
|
||||
@@ -32,7 +32,7 @@ public enum EconomyType {
|
||||
RESERVE(1),
|
||||
MIXED(2);
|
||||
|
||||
private int id;
|
||||
private final int id;
|
||||
|
||||
EconomyType(int id) {
|
||||
this.id = id;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
public class Economy_Mixed implements EconomyCore {
|
||||
EconomyCore core;
|
||||
final EconomyCore core;
|
||||
|
||||
public Economy_Mixed() {
|
||||
core = new Economy_Vault();
|
||||
|
||||
@@ -23,7 +23,7 @@ public enum ProtectionCheckStatus {
|
||||
BEGIN(0),
|
||||
END(1);
|
||||
|
||||
int statusCode;
|
||||
final int statusCode;
|
||||
|
||||
ProtectionCheckStatus(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.maxgamer.quickshop.Util.Copied;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
public class Language {
|
||||
private QuickShop plugin;
|
||||
private final QuickShop plugin;
|
||||
// private List<String> languages = new ArrayList<>();
|
||||
|
||||
Language(QuickShop plugin) {
|
||||
|
||||
@@ -35,21 +35,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.inventory.BrewingStandFuelEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
@@ -67,8 +54,9 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class DisplayProtectionListener implements Listener {
|
||||
private QuickShop plugin;
|
||||
private boolean useEnhanceProtection;
|
||||
private final QuickShop plugin;
|
||||
|
||||
private final boolean useEnhanceProtection;
|
||||
|
||||
public DisplayProtectionListener(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -205,7 +205,7 @@ public class ShopProtectionListener implements Listener {
|
||||
MsgUtil.sendGlobalAlert("[DisplayGuard] Defened a item steal action at" + location);
|
||||
}
|
||||
}
|
||||
private boolean sendProtectionAlert = QuickShop.instance.getConfig().getBoolean("send-shop-protection-alert",false);
|
||||
private final boolean sendProtectionAlert = QuickShop.instance.getConfig().getBoolean("send-shop-protection-alert", false);
|
||||
|
||||
// Protect Entity pickup shop
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.bukkit.ChatColor;
|
||||
|
||||
public class Colorizer {
|
||||
|
||||
private static Map<String, String> colorCodes = new HashMap<>();
|
||||
private static final Map<String, String> colorCodes = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (ChatColor color : ChatColor.values()) {
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.maxgamer.quickshop.Permission;
|
||||
public enum PermissionProviderType {
|
||||
// BUKKIT(0), VAULT(1), LUCKPERMS(2), PERMISSIONEX(3), GROUPMANAGER(4);
|
||||
BUKKIT(0);
|
||||
int id;
|
||||
final int id;
|
||||
|
||||
PermissionProviderType(int id) {
|
||||
this.id = id;
|
||||
|
||||
+35
-18
@@ -35,24 +35,41 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
|
||||
public class FactionsUUIDIntegration implements IntegratedPlugin {
|
||||
private List<String> createFlags;
|
||||
private List<String> tradeFlags;
|
||||
private boolean createRequireOpen;
|
||||
private boolean createRequireNormal;
|
||||
private boolean createRequireWilderness;
|
||||
private boolean createRequirePeaceful;
|
||||
private boolean createRequirePermanent;
|
||||
private boolean createRequireSafeZone;
|
||||
private boolean createRequireOwn;
|
||||
private boolean createRequireWarZone;
|
||||
private boolean tradeRequireOpen;
|
||||
private boolean tradeRequireNormal;
|
||||
private boolean tradeRequireWilderness;
|
||||
private boolean tradeRequirePeaceful;
|
||||
private boolean tradeRequirePermanent;
|
||||
private boolean tradeRequireSafeZone;
|
||||
private boolean tradeRequireOwn;
|
||||
private boolean tradeRequireWarZone;
|
||||
private final List<String> createFlags;
|
||||
|
||||
private final List<String> tradeFlags;
|
||||
|
||||
private final boolean createRequireOpen;
|
||||
|
||||
private final boolean createRequireNormal;
|
||||
|
||||
private final boolean createRequireWilderness;
|
||||
|
||||
private final boolean createRequirePeaceful;
|
||||
|
||||
private final boolean createRequirePermanent;
|
||||
|
||||
private final boolean createRequireSafeZone;
|
||||
|
||||
private final boolean createRequireOwn;
|
||||
|
||||
private final boolean createRequireWarZone;
|
||||
|
||||
private final boolean tradeRequireOpen;
|
||||
|
||||
private final boolean tradeRequireNormal;
|
||||
|
||||
private final boolean tradeRequireWilderness;
|
||||
|
||||
private final boolean tradeRequirePeaceful;
|
||||
|
||||
private final boolean tradeRequirePermanent;
|
||||
|
||||
private final boolean tradeRequireSafeZone;
|
||||
|
||||
private final boolean tradeRequireOwn;
|
||||
|
||||
private final boolean tradeRequireWarZone;
|
||||
|
||||
public FactionsUUIDIntegration(QuickShop plugin) {
|
||||
this.createFlags = plugin.getConfig().getStringList("integration.factions.create.flags");
|
||||
|
||||
+3
-1
@@ -36,8 +36,10 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
|
||||
public class PlotSquaredIntegration implements IntegratedPlugin {
|
||||
private BooleanFlag createFlag;
|
||||
|
||||
private BooleanFlag tradeFlag;
|
||||
private QuickShop plugin;
|
||||
|
||||
private final QuickShop plugin;
|
||||
|
||||
public PlotSquaredIntegration(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
+3
-2
@@ -35,8 +35,9 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
|
||||
public class ResidenceIntegration implements IntegratedPlugin {
|
||||
List<String> createLimits;
|
||||
List<String> tradeLimits;
|
||||
final List<String> createLimits;
|
||||
|
||||
final List<String> tradeLimits;
|
||||
|
||||
public ResidenceIntegration(QuickShop plugin) {
|
||||
this.createLimits = plugin.getConfig().getStringList("integration.residence.create");
|
||||
|
||||
@@ -32,8 +32,9 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
|
||||
public class TownyIntegration implements IntegratedPlugin {
|
||||
private List<TownyFlags> createFlags;
|
||||
private List<TownyFlags> tradeFlags;
|
||||
private final List<TownyFlags> createFlags;
|
||||
|
||||
private final List<TownyFlags> tradeFlags;
|
||||
|
||||
public TownyIntegration(QuickShop plugin) {
|
||||
createFlags =
|
||||
|
||||
+9
-5
@@ -43,11 +43,15 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@IntegrationStage(loadStage = IntegrateStage.onLoadAfter)
|
||||
public class WorldGuardIntegration implements IntegratedPlugin {
|
||||
private List<WorldGuardFlags> createFlags;
|
||||
private List<WorldGuardFlags> tradeFlags;
|
||||
private StateFlag createFlag = new StateFlag("quickshop-create", false);
|
||||
private StateFlag tradeFlag = new StateFlag("quickshop-trade", true);
|
||||
private QuickShop plugin;
|
||||
private final List<WorldGuardFlags> createFlags;
|
||||
|
||||
private final List<WorldGuardFlags> tradeFlags;
|
||||
|
||||
private final StateFlag createFlag = new StateFlag("quickshop-create", false);
|
||||
|
||||
private final StateFlag tradeFlag = new StateFlag("quickshop-trade", true);
|
||||
|
||||
private final QuickShop plugin;
|
||||
|
||||
public WorldGuardIntegration(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -663,7 +663,6 @@ public class QuickShop extends JavaPlugin {
|
||||
Bukkit.getPluginManager().registerEvents(customInventoryListener, this);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(shopProtectListener, this);
|
||||
;
|
||||
Bukkit.getPluginManager().registerEvents(internalListener, this);
|
||||
|
||||
if (isDisplay() && DisplayItem.getNowUsing() != DisplayType.VIRTUALITEM) {
|
||||
|
||||
@@ -33,18 +33,24 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
/**
|
||||
* @author Netherfoam A display item, that spawns a block above the chest and cannot be interacted
|
||||
* with.
|
||||
* with.
|
||||
*/
|
||||
public abstract class DisplayItem {
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
@Nullable protected ItemStack guardedIstack;
|
||||
protected ItemStack originalItemStack;
|
||||
protected static QuickShop plugin = QuickShop.instance;
|
||||
protected Shop shop;
|
||||
|
||||
@Nullable
|
||||
protected ItemStack guardedIstack;
|
||||
|
||||
protected final ItemStack originalItemStack;
|
||||
|
||||
protected static final QuickShop plugin = QuickShop.instance;
|
||||
|
||||
protected final Shop shop;
|
||||
|
||||
private boolean pendingRemoval;
|
||||
|
||||
protected DisplayItem(Shop shop){
|
||||
protected DisplayItem(Shop shop) {
|
||||
this.shop = shop;
|
||||
this.originalItemStack = new ItemStack(shop.getItem());
|
||||
this.originalItemStack.setAmount(1);
|
||||
|
||||
@@ -30,7 +30,8 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
public class DisplayItemPersistentDataType
|
||||
implements PersistentDataType<String, ShopProtectionFlag> {
|
||||
static final DisplayItemPersistentDataType INSTANCE = new DisplayItemPersistentDataType();
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
@Override
|
||||
public @NotNull Class<String> getPrimitiveType() {
|
||||
|
||||
@@ -34,7 +34,7 @@ public enum DisplayType {
|
||||
ARMORSTAND(1),
|
||||
VIRTUALITEM(2);
|
||||
|
||||
private int id;
|
||||
private final int id;
|
||||
|
||||
DisplayType(int id) {
|
||||
this.id = id;
|
||||
|
||||
@@ -26,7 +26,7 @@ public enum MatcherWorkMode {
|
||||
BUKKITMATCHER(1),
|
||||
JAVAMATCHER(2);
|
||||
|
||||
private int id;
|
||||
private final int id;
|
||||
|
||||
MatcherWorkMode(int id) {
|
||||
this.id = id;
|
||||
|
||||
@@ -39,18 +39,30 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.Timer;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
/** A class allow plugin load shops fast and simply. */
|
||||
/**
|
||||
* A class allow plugin load shops fast and simply.
|
||||
*/
|
||||
public class ShopLoader {
|
||||
private final ArrayList<Long> loadTimes = new ArrayList<>();
|
||||
private Map<Timer, Double> costCache = new HashMap<>();
|
||||
|
||||
private final Map<Timer, Double> costCache = new HashMap<>();
|
||||
|
||||
private int errors;
|
||||
|
||||
private int loadAfterChunkLoaded = 0;
|
||||
|
||||
private int loadAfterWorldLoaded = 0;
|
||||
private QuickShop plugin;
|
||||
|
||||
private final QuickShop plugin;
|
||||
|
||||
private int totalLoaded = 0;
|
||||
|
||||
/* This may contains broken shop, must use null check before load it. */
|
||||
@Getter private List<Shop> shopsInDatabase = new ArrayList<>();
|
||||
@Getter private List<ShopDatabaseInfoOrigin> originShopsInDatabase = new ArrayList<>();
|
||||
@Getter
|
||||
private List<Shop> shopsInDatabase = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private List<ShopDatabaseInfoOrigin> originShopsInDatabase = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The shop load allow plugin load shops fast and simply.
|
||||
|
||||
@@ -55,9 +55,9 @@ public class ShopManager {
|
||||
|
||||
private final Set<Shop> loadedShops = QuickShop.instance.isEnabledAsyncDisplayDespawn() ? Sets.newConcurrentHashSet() : Sets.newHashSet();
|
||||
|
||||
private HashMap<UUID, Info> actions = new HashMap<>();
|
||||
private final HashMap<UUID, Info> actions = new HashMap<>();
|
||||
|
||||
private QuickShop plugin;
|
||||
private final QuickShop plugin;
|
||||
|
||||
private boolean useFastShopSearchAlgorithm = false;
|
||||
|
||||
@@ -680,13 +680,11 @@ public class ShopManager {
|
||||
return;
|
||||
}
|
||||
Location loc = shop.getLocation();
|
||||
try {
|
||||
// Write it to the database
|
||||
plugin.getDatabaseHelper().createShop(ShopModerator.serialize(shop.getModerator()), shop.getPrice(), shop.getItem(), (shop.isUnlimited() ? 1 : 0), shop.getShopType().toID(), Objects.requireNonNull(loc.getWorld()).getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
// Add it to the world
|
||||
|
||||
if (plugin.getDatabaseHelper().createShop(ShopModerator.serialize(shop.getModerator()), shop.getPrice(), shop.getItem(), (shop.isUnlimited() ? 1 : 0), shop.getShopType().toID(), Objects.requireNonNull(loc.getWorld()).getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||
addShop(loc.getWorld().getName(), shop);
|
||||
} catch (SQLException error) {
|
||||
plugin.getLogger().warning("SQLException detected, trying to auto fix the database...");
|
||||
} else {
|
||||
plugin.getLogger().warning("Shop create failed, trying to auto fix the database...");
|
||||
boolean backupSuccess = Util.backupDatabase();
|
||||
try {
|
||||
if (backupSuccess) {
|
||||
@@ -699,7 +697,6 @@ public class ShopManager {
|
||||
plugin.getLogger().warning("Failed to autofix the database, all changes will revert after a reboot.");
|
||||
error2.printStackTrace();
|
||||
}
|
||||
error.printStackTrace();
|
||||
}
|
||||
// Create sign
|
||||
if (info.getSignBlock() != null && plugin.getConfig().getBoolean("shop.auto-sign")) {
|
||||
@@ -838,10 +835,8 @@ public class ShopManager {
|
||||
// Found some shops in this chunk
|
||||
if (inChunk != null) {
|
||||
shop = inChunk.get(attachedBlock.getLocation());
|
||||
if (shop != null) {
|
||||
// Okay, shop was founded.
|
||||
return shop;
|
||||
}
|
||||
// Okay, shop was founded.
|
||||
return shop;
|
||||
// Oooops, no any shops matched.
|
||||
}
|
||||
}
|
||||
@@ -1043,7 +1038,7 @@ public class ShopManager {
|
||||
|
||||
private Iterator<Shop> shops;
|
||||
|
||||
private Iterator<HashMap<ShopChunk, HashMap<Location, Shop>>> worlds;
|
||||
private final Iterator<HashMap<ShopChunk, HashMap<Location, Shop>>> worlds;
|
||||
|
||||
public ShopIterator() {
|
||||
//noinspection unchecked
|
||||
|
||||
@@ -26,7 +26,7 @@ public enum ShopType {
|
||||
SELLING(0),
|
||||
BUYING(1);
|
||||
|
||||
private int id;
|
||||
private final int id;
|
||||
|
||||
ShopType(int id) {
|
||||
this.id = id;
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
public class VirtualDisplayItem extends DisplayItem {
|
||||
|
||||
|
||||
private static ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
private static final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
private volatile boolean isDisplay;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
private static final String version = Util.getNMSVersion();
|
||||
|
||||
//unique EntityID
|
||||
private int entityID = counter.decrementAndGet();
|
||||
private final int entityID = counter.decrementAndGet();
|
||||
|
||||
//packets
|
||||
private PacketContainer fakeItemPacket;
|
||||
@@ -74,9 +74,9 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
private ShopChunk chunkLocation;
|
||||
|
||||
//The List which store packet sender
|
||||
private Set<UUID> packetSenders = new ConcurrentSkipListSet<>();
|
||||
private final Set<UUID> packetSenders = new ConcurrentSkipListSet<>();
|
||||
|
||||
private Queue<Runnable> asyncPacketSendQueue = new LinkedList<>();
|
||||
private final Queue<Runnable> asyncPacketSendQueue = new LinkedList<>();
|
||||
|
||||
@Nullable
|
||||
private BukkitTask asyncSendingTask;
|
||||
|
||||
@@ -233,37 +233,47 @@ class LunarCalendar {
|
||||
/** 农历数据, 1901 ~ 2100 年之间正确 */
|
||||
static final long[] lunarInfo =
|
||||
new long[] {
|
||||
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
|
||||
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
|
||||
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
|
||||
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
|
||||
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
|
||||
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,
|
||||
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
|
||||
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,
|
||||
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
|
||||
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
|
||||
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
|
||||
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
|
||||
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
|
||||
0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
|
||||
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0
|
||||
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
|
||||
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
|
||||
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
|
||||
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
|
||||
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
|
||||
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,
|
||||
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
|
||||
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,
|
||||
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
|
||||
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
|
||||
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
|
||||
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
|
||||
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
|
||||
0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
|
||||
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0
|
||||
};
|
||||
/** 中文日期格式 */
|
||||
static SimpleDateFormat chineseDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
||||
|
||||
private int year; // 农历年
|
||||
/**
|
||||
* 中文日期格式
|
||||
*/
|
||||
static final SimpleDateFormat chineseDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
||||
|
||||
private final int year; // 农历年
|
||||
|
||||
// 上面4个值在构造方法中根据传入日期计算所得
|
||||
private int month; // 农历月
|
||||
private int day; // 农历日
|
||||
private final int month; // 农历月
|
||||
|
||||
private final int day; // 农历日
|
||||
|
||||
private boolean leap; // 农历闰年
|
||||
|
||||
/** 构造一个表示当前日期的农历日历 */
|
||||
/**
|
||||
* 构造一个表示当前日期的农历日历
|
||||
*/
|
||||
public LunarCalendar() {
|
||||
this(Calendar.getInstance());
|
||||
}
|
||||
|
||||
/** 构造一个表示指定日期的农历日历 */
|
||||
/**
|
||||
* 构造一个表示指定日期的农历日历
|
||||
*/
|
||||
public LunarCalendar(Date date) {
|
||||
this(date2calendar(date));
|
||||
}
|
||||
@@ -346,37 +356,47 @@ class LunarCalendar {
|
||||
}
|
||||
|
||||
// ====== 传回农历 y年的总天数
|
||||
private static final int yearDays(int y) {
|
||||
private static int yearDays(int y) {
|
||||
int i, sum = 348;
|
||||
for (i = 0x8000; i > 0x8; i >>= 1) {
|
||||
if ((lunarInfo[y - 1900] & i) != 0) sum += 1;
|
||||
if ((lunarInfo[y - 1900] & i) != 0) {
|
||||
sum += 1;
|
||||
}
|
||||
}
|
||||
return (sum + leapDays(y));
|
||||
}
|
||||
|
||||
// ====== 传回农历 y年闰月的天数
|
||||
private static final int leapDays(int y) {
|
||||
private static int leapDays(int y) {
|
||||
if (leapMonth(y) != 0) {
|
||||
if ((lunarInfo[y - 1900] & 0x10000) != 0) return 30;
|
||||
else return 29;
|
||||
} else return 0;
|
||||
if ((lunarInfo[y - 1900] & 0x10000) != 0) {
|
||||
return 30;
|
||||
} else {
|
||||
return 29;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 传回农历 y年闰哪个月 1-12 , 没闰传回 0
|
||||
private static final int leapMonth(int y) {
|
||||
private static int leapMonth(int y) {
|
||||
return (int) (lunarInfo[y - 1900] & 0xf);
|
||||
}
|
||||
|
||||
// ====== 传回农历 y年m月的总天数
|
||||
private static final int monthDays(int y, int m) {
|
||||
if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0) return 29;
|
||||
else return 30;
|
||||
private static int monthDays(int y, int m) {
|
||||
if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0) {
|
||||
return 29;
|
||||
} else {
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 传入 月日的offset 传回干支, 0=甲子
|
||||
private static final String cyclicalm(int num) {
|
||||
final String[] Gan = new String[] {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
|
||||
final String[] Zhi = new String[] {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
|
||||
private static String cyclicalm(int num) {
|
||||
final String[] Gan = new String[]{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
|
||||
final String[] Zhi = new String[]{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
|
||||
return (Gan[num % 10] + Zhi[num % 12]);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.maxgamer.quickshop.Util.MojangAPI.MojangAPI;
|
||||
public class GameLanguage extends Thread {
|
||||
private @Nullable JsonObject lang;
|
||||
|
||||
private GameLanguageLoadThread loadThread;
|
||||
private final GameLanguageLoadThread loadThread;
|
||||
|
||||
@SneakyThrows
|
||||
public GameLanguage(@NotNull String languageCode) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.NonQuickShopStuffs.com.sk89q.worldedit.util.net.HttpRequest;
|
||||
|
||||
public class GithubAPI {
|
||||
private Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
private final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
|
||||
@Nullable
|
||||
public ReleaseJsonContainer.AssetsBean getLatestRelease() throws Exception {
|
||||
|
||||
@@ -29,10 +29,13 @@ import org.bukkit.potion.PotionData;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
/** A util allow quickshop check item matches easy and quick. */
|
||||
/**
|
||||
* A util allow quickshop check item matches easy and quick.
|
||||
*/
|
||||
public class ItemMatcher {
|
||||
private ItemMetaMatcher itemMetaMatcher;
|
||||
private QuickShop plugin;
|
||||
private final ItemMetaMatcher itemMetaMatcher;
|
||||
|
||||
private final QuickShop plugin;
|
||||
|
||||
public ItemMatcher(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -98,21 +101,32 @@ public class ItemMatcher {
|
||||
private boolean typeMatches(ItemStack requireStack, ItemStack givenStack) {
|
||||
return requireStack.getType().equals(givenStack.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ItemMetaMatcher {
|
||||
|
||||
private boolean banner;
|
||||
private boolean repaircost;
|
||||
private boolean attributes;
|
||||
private boolean custommodeldata;
|
||||
private boolean damage;
|
||||
private boolean displayname;
|
||||
private boolean enchs;
|
||||
private boolean itemflags;
|
||||
private boolean lores;
|
||||
private boolean potions;
|
||||
private boolean book;
|
||||
private final boolean banner;
|
||||
|
||||
private final boolean repaircost;
|
||||
|
||||
private final boolean attributes;
|
||||
|
||||
private final boolean custommodeldata;
|
||||
|
||||
private final boolean damage;
|
||||
|
||||
private final boolean displayname;
|
||||
|
||||
private final boolean enchs;
|
||||
|
||||
private final boolean itemflags;
|
||||
|
||||
private final boolean lores;
|
||||
|
||||
private final boolean potions;
|
||||
|
||||
private final boolean book;
|
||||
|
||||
public ItemMetaMatcher(ConfigurationSection itemMatcherConfig) {
|
||||
this.damage = itemMatcherConfig.getBoolean("damage");
|
||||
|
||||
@@ -16,29 +16,8 @@
|
||||
|
||||
package org.maxgamer.quickshop.Util.Logger;
|
||||
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.BLACK;
|
||||
import static org.bukkit.ChatColor.BLUE;
|
||||
import static org.bukkit.ChatColor.BOLD;
|
||||
import static org.bukkit.ChatColor.DARK_AQUA;
|
||||
import static org.bukkit.ChatColor.DARK_BLUE;
|
||||
import static org.bukkit.ChatColor.DARK_GRAY;
|
||||
import static org.bukkit.ChatColor.DARK_GREEN;
|
||||
import static org.bukkit.ChatColor.DARK_PURPLE;
|
||||
import static org.bukkit.ChatColor.DARK_RED;
|
||||
import static org.bukkit.ChatColor.GOLD;
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
import static org.bukkit.ChatColor.GREEN;
|
||||
import static org.bukkit.ChatColor.ITALIC;
|
||||
import static org.bukkit.ChatColor.LIGHT_PURPLE;
|
||||
import static org.bukkit.ChatColor.MAGIC;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
import static org.bukkit.ChatColor.RESET;
|
||||
import static org.bukkit.ChatColor.STRIKETHROUGH;
|
||||
import static org.bukkit.ChatColor.UNDERLINE;
|
||||
import static org.bukkit.ChatColor.WHITE;
|
||||
import static org.bukkit.ChatColor.YELLOW;
|
||||
|
||||
import static org.bukkit.ChatColor.*;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -55,9 +34,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginLogger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.NonQuickShopStuffs.de.Keyle.MyPet.api.util.ReflectionUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/*
|
||||
* Originally take from Mypet which is a awesome project, extends PluginLogger in order to replace
|
||||
@@ -94,19 +70,24 @@ public class QuickShopLogger extends PluginLogger {
|
||||
}
|
||||
|
||||
// below are non-static for secret optimization
|
||||
/** Regex that indicates the case insensitive */
|
||||
|
||||
/**
|
||||
* Regex that indicates the case insensitive
|
||||
*/
|
||||
private String IGNORE_CASE;
|
||||
|
||||
// private FileHandler debugLogFileHandler = null;
|
||||
private boolean hasAnsi = true;
|
||||
|
||||
private boolean hasJline = true;
|
||||
private boolean useLog4j;
|
||||
|
||||
private final boolean useLog4j;
|
||||
|
||||
@SneakyThrows
|
||||
public QuickShopLogger(Plugin plugin) {
|
||||
super(plugin);
|
||||
registerStyles();
|
||||
|
||||
|
||||
// Logger re-naming
|
||||
String prefix = plugin.getDescription().getPrefix();
|
||||
String pluginName = (useLog4j = plugin.getConfig().getBoolean("enable-log4j")) ?
|
||||
|
||||
@@ -30,7 +30,9 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
public class AssetJson {
|
||||
final String pathTemplate = "minecraft/lang/{0}.json";
|
||||
@NotNull String gameAssets;
|
||||
|
||||
@NotNull
|
||||
final String gameAssets;
|
||||
|
||||
public AssetJson(@NotNull String json) {
|
||||
this.gameAssets = json;
|
||||
@@ -38,7 +40,7 @@ public class AssetJson {
|
||||
|
||||
@Nullable
|
||||
public String getLanguageHash(@NotNull String languageCode) {
|
||||
languageCode = languageCode.replace("-","_").toLowerCase().trim();
|
||||
languageCode = languageCode.replace("-", "_").toLowerCase().trim();
|
||||
JsonObject json = new JsonParser().parse(this.gameAssets).getAsJsonObject();
|
||||
if (json == null || json.isJsonNull()) {
|
||||
Util.debugLog("Cannot parse the json: " + this.gameAssets);
|
||||
|
||||
@@ -59,16 +59,25 @@ import org.maxgamer.quickshop.Shop.Shop;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class MsgUtil {
|
||||
public static String invaildMsg = "Invaild message";
|
||||
public static final String invaildMsg = "Invaild message";
|
||||
|
||||
private static YamlConfiguration enchi18n;
|
||||
|
||||
private static boolean inited;
|
||||
|
||||
private static YamlConfiguration itemi18n;
|
||||
|
||||
private static IFile messagei18n;
|
||||
private static HashMap<UUID, LinkedList<String>> player_messages = new HashMap<>();
|
||||
private static QuickShop plugin = QuickShop.instance;
|
||||
|
||||
private static final HashMap<UUID, LinkedList<String>> player_messages = new HashMap<>();
|
||||
|
||||
private static final QuickShop plugin = QuickShop.instance;
|
||||
|
||||
private static YamlConfiguration potioni18n;
|
||||
private static DecimalFormat decimalFormat =
|
||||
|
||||
private static final DecimalFormat decimalFormat =
|
||||
new DecimalFormat(Objects.requireNonNull(plugin.getConfig().getString("decimal-format")));
|
||||
|
||||
private static GameLanguage gameLanguage;
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Paste {
|
||||
finalReport.append("================================================\n");
|
||||
finalReport.append("QuickShop:\n");
|
||||
finalReport.append("\tVersion: ").append(QuickShop.getVersion()).append("\n");
|
||||
finalReport.append("\tFork: ").append(plugin.getFork()).append("\n");
|
||||
finalReport.append("\tFork: ").append(QuickShop.getFork()).append("\n");
|
||||
finalReport.append("\tServer ID: ").append(plugin.getServerUniqueID()).append("\n");
|
||||
finalReport
|
||||
.append("\tOpenInv Hook: ")
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.maxgamer.quickshop.Util;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -33,11 +34,10 @@ import org.maxgamer.quickshop.Event.ProtectionCheckStatus;
|
||||
import org.maxgamer.quickshop.Event.ShopProtectionCheckEvent;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class PermissionChecker {
|
||||
private QuickShop plugin;
|
||||
private boolean usePermissionChecker;
|
||||
private final QuickShop plugin;
|
||||
|
||||
private final boolean usePermissionChecker;
|
||||
|
||||
public PermissionChecker(@NotNull QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -55,31 +55,31 @@ public class SentryErrorReporter {
|
||||
|
||||
private final ArrayList<String> reported = new ArrayList<>();
|
||||
|
||||
private Context context;
|
||||
private final Context context;
|
||||
|
||||
private boolean disable;
|
||||
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
|
||||
private List<Class<?>> ignoredException = new ArrayList<>();
|
||||
private final List<Class<?>> ignoredException = new ArrayList<>();
|
||||
|
||||
private QuickShop plugin;
|
||||
private final QuickShop plugin;
|
||||
|
||||
/* Pre-init it if it called before the we create it... */
|
||||
private SentryClient sentryClient;
|
||||
private final SentryClient sentryClient;
|
||||
|
||||
private boolean tempDisable;
|
||||
|
||||
private String lastPaste;
|
||||
|
||||
private IncompatibleChecker checker = new IncompatibleChecker();
|
||||
private final IncompatibleChecker checker = new IncompatibleChecker();
|
||||
|
||||
public SentryErrorReporter(@NotNull QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
// sentryClient = Sentry.init(dsn);
|
||||
Util.debugLog("Loading SentryErrorReporter");
|
||||
sentryClient = SentryClientFactory.sentryClient(dsn);;
|
||||
sentryClient = SentryClientFactory.sentryClient(dsn);
|
||||
context = sentryClient.getContext();
|
||||
Util.debugLog("Setting basic report data...");
|
||||
// context.addTag("plugin_version", QuickShop.getVersion());
|
||||
|
||||
@@ -59,23 +59,33 @@ import org.maxgamer.quickshop.Watcher.InventoryEditContainer;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
/** @author MACHENIKE */
|
||||
/**
|
||||
* @author MACHENIKE
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class Util {
|
||||
static short tookLongTimeCostTimes;
|
||||
private static EnumSet<Material> blacklist = EnumSet.noneOf(Material.class);
|
||||
|
||||
@Getter
|
||||
private static List<String> debugLogs = Collections.synchronizedList(new LinkedList<>());
|
||||
private static final EnumSet<Material> blacklist = EnumSet.noneOf(Material.class);
|
||||
|
||||
@Getter
|
||||
private static List<String> debugLogs = Collections.synchronizedList(new LinkedList<>());
|
||||
|
||||
private static boolean devMode = false;
|
||||
|
||||
private static boolean devMode = false;
|
||||
private static QuickShop plugin;
|
||||
private static EnumMap<Material, Entry<Double, Double>> restrictedPrices =
|
||||
|
||||
private static final 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 final EnumSet<Material> shoppables = EnumSet.noneOf(Material.class);
|
||||
|
||||
private static Field tpsField;
|
||||
|
||||
private static List<String> worldBlacklist = new ArrayList<>();
|
||||
|
||||
private static boolean disableDebugLogger = false;
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.maxgamer.quickshop.Shop.DisplayItem;
|
||||
*/
|
||||
@Deprecated
|
||||
public class DisplayDupeRemoverWatcher extends BukkitRunnable {
|
||||
private Queue<DisplayItem> checkQueue = new LinkedList<>();
|
||||
private final Queue<DisplayItem> checkQueue = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public @Deprecated void run() {
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
|
||||
package org.maxgamer.quickshop.Watcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -37,8 +33,10 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
public class LogWatcher extends BukkitRunnable {
|
||||
private Queue<String> logs = new ConcurrentLinkedQueue<>();
|
||||
private final Queue<String> logs = new ConcurrentLinkedQueue<>();
|
||||
|
||||
private FileWriter logFileWriter = null;
|
||||
|
||||
private PrintWriter pw;
|
||||
|
||||
public LogWatcher(QuickShop plugin, File log) {
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.maxgamer.quickshop.Watcher;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,15 +29,12 @@ import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Check the shops after server booted up, make sure shop can correct self-deleted when container
|
||||
* lost.
|
||||
*/
|
||||
public class OngoingFeeWatcher extends BukkitRunnable {
|
||||
private QuickShop plugin;
|
||||
private final QuickShop plugin;
|
||||
|
||||
public OngoingFeeWatcher(@NotNull QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.maxgamer.quickshop.Shop.Shop;
|
||||
// unused, pending to remove
|
||||
public class ShopContainerWatcher extends BukkitRunnable {
|
||||
// private QuickShop plugin;
|
||||
private Queue<Shop> checkQueue = new LinkedList<>();
|
||||
private final Queue<Shop> checkQueue = new LinkedList<>();
|
||||
|
||||
public ShopContainerWatcher(@NotNull QuickShop plugin) {
|
||||
// this.plugin = plugin;
|
||||
|
||||
@@ -34,8 +34,9 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
// unused, pending to remove
|
||||
@Deprecated
|
||||
public class ShopVaildWatcher extends BukkitRunnable {
|
||||
private QuickShop plugin;
|
||||
private Queue<Shop> checkQueue = new LinkedList<>();
|
||||
private final QuickShop plugin;
|
||||
|
||||
private final Queue<Shop> checkQueue = new LinkedList<>();
|
||||
|
||||
public ShopVaildWatcher(@NotNull QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.maxgamer.quickshop.Shop.Shop;
|
||||
|
||||
public class SignUpdateWatcher extends BukkitRunnable {
|
||||
// private QuickShop plugin;
|
||||
private Queue<Shop> signUpdateQueue = new LinkedList<>();
|
||||
private final Queue<Shop> signUpdateQueue = new LinkedList<>();
|
||||
|
||||
public SignUpdateWatcher(QuickShop plugin) {
|
||||
// this.plugin = plugin;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class UpdateWatcher implements Listener {
|
||||
private static UpdateInfomation info = null;
|
||||
|
||||
public static String fixVer(@NotNull String originalVer) {
|
||||
originalVer = originalVer.replaceAll(QuickShop.instance.getFork(), "");
|
||||
originalVer = originalVer.replaceAll(QuickShop.getFork(), "");
|
||||
originalVer = originalVer.trim();
|
||||
return originalVer;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user