diff --git a/pom.xml b/pom.xml index 32906c61f..29bea88a2 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ QuickShop - 4.0.9.5 + 4.0.9.7 org.maxgamer.quickshop Ghost-chu UTF-8 @@ -890,7 +890,7 @@ org.slf4j slf4j-nop - 1.7.30 + 1.7.31 diff --git a/src/main/java/org/maxgamer/quickshop/database/DatabaseManager.java b/src/main/java/org/maxgamer/quickshop/database/DatabaseManager.java index 448e83485..ecc7f2fc8 100644 --- a/src/main/java/org/maxgamer/quickshop/database/DatabaseManager.java +++ b/src/main/java/org/maxgamer/quickshop/database/DatabaseManager.java @@ -148,7 +148,6 @@ public class DatabaseManager { * Internal method, runTasks in queue. */ private synchronized void runTask() { // synchronized for QUICKSHOP-WX - synchronized (sqlQueue) { if (sqlQueue.isEmpty()) { return; } @@ -199,7 +198,6 @@ public class DatabaseManager { } finally { dbconnection.release(); } - } // try { // this.database.getConnection().commit(); @@ -229,9 +227,7 @@ public class DatabaseManager { */ public void addDelayTask(DatabaseTask task) { if (useQueue) { - synchronized (sqlQueue) { - sqlQueue.offer(task); - } + sqlQueue.offer(task); } else { runInstantTask(task); } diff --git a/src/main/java/org/maxgamer/quickshop/listener/LockListener.java b/src/main/java/org/maxgamer/quickshop/listener/LockListener.java index ca16c78d4..3e2ecbd50 100644 --- a/src/main/java/org/maxgamer/quickshop/listener/LockListener.java +++ b/src/main/java/org/maxgamer/quickshop/listener/LockListener.java @@ -24,7 +24,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; -import org.bukkit.block.data.type.WallSign; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -114,7 +113,7 @@ public class LockListener extends ProtectionListenerBase { @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onSignPlace(BlockPlaceEvent event) { Block placedBlock = event.getBlock(); - if (!(placedBlock.getBlockData() instanceof WallSign)) { + if (!(placedBlock.getState() instanceof Sign)) { return; } Block posShopBlock = Util.getAttached(placedBlock); diff --git a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java index 1fe9ce4c0..8daa1e723 100644 --- a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java +++ b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java @@ -676,12 +676,6 @@ public class ContainerShop implements Shop { public void setSignText(@NotNull String[] lines) { Util.ensureThread(false); List signs = this.getSigns(); - boolean signGlowing = plugin.getConfig().getBoolean("shop.sign-glowing"); - DyeColor dyeColor = null; - try { - dyeColor = DyeColor.valueOf(plugin.getConfig().getString("shop.sign-dye-color")); - } catch (IllegalArgumentException ignored) { - } for (Sign sign : signs) { if (Arrays.equals(sign.getLines(), lines)) { continue; @@ -689,11 +683,15 @@ public class ContainerShop implements Shop { for (int i = 0; i < lines.length; i++) { sign.setLine(i, lines[i]); } - if (plugin.getGameVersion().isSignTextDyeSupport() && dyeColor != null) { - sign.setColor(dyeColor); + if (plugin.getGameVersion().isSignTextDyeSupport()) { + DyeColor dyeColor = Util.getDyeColor(); + if (dyeColor != null) { + sign.setColor(dyeColor); + } } - if (signGlowing && plugin.getGameVersion().isSignGlowingSupport()) { - sign.setGlowingText(true); + if (plugin.getGameVersion().isSignGlowingSupport()) { + boolean isGlowing = plugin.getConfig().getBoolean("shop.sign-glowing"); + sign.setGlowingText(isGlowing); } sign.update(true); plugin.getServer().getPluginManager().callEvent(new ShopSignUpdateEvent(this, sign)); diff --git a/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java index 81c19565d..8a50e4e00 100644 --- a/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java @@ -66,6 +66,7 @@ public class ShopManager { private final QuickShop plugin; @Getter + @Nullable private final Trader cacheTaxAccount; @Getter private final Trader cacheUnlimitedShopAccount; diff --git a/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java b/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java index 9924db7ca..c54753835 100644 --- a/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java +++ b/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java @@ -27,6 +27,7 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.injector.server.TemporaryPlayer; import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.utility.MinecraftVersion; import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedDataWatcher; import org.bukkit.Chunk; @@ -462,7 +463,12 @@ public class VirtualDisplayItem extends DisplayItem { fakeItemDestroyPacket.getIntegerArrays().write(0, new int[]{entityID}); } else { //1.17+ - if (protocolManager.getMinecraftVersion().getMinor() >= 1) { + MinecraftVersion minecraftVersion = protocolManager.getMinecraftVersion(); + if (minecraftVersion.getMajor() == 1 && minecraftVersion.getMinor() == 17 && minecraftVersion.getBuild() == 0) { + //On 1.17, just need to write a int + //Entity to remove + fakeItemDestroyPacket.getIntegers().write(0, entityID); + } else { //On 1.17.1 (may be 1.17.1+? it's enough, Mojang, stop the changes), we need add the int list //Entity to remove try { @@ -470,10 +476,6 @@ public class VirtualDisplayItem extends DisplayItem { } catch (NoSuchMethodError e) { throw new RuntimeException("Unable to initialize packet, ProtocolLib update needed", e); } - } else { - //On 1.17, just need to write a int - //Entity to remove - fakeItemDestroyPacket.getIntegers().write(0, entityID); } } return fakeItemDestroyPacket; diff --git a/src/main/java/org/maxgamer/quickshop/util/Util.java b/src/main/java/org/maxgamer/quickshop/util/Util.java index c1995533d..f451b9d76 100644 --- a/src/main/java/org/maxgamer/quickshop/util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/util/Util.java @@ -84,6 +84,9 @@ public class Util { private static List worldBlacklist = new ArrayList<>(5); @Getter private static boolean disableDebugLogger = false; + @Getter + @Nullable + private static DyeColor dyeColor = null; private static boolean currencySymbolOnRight; private static String alternateCurrencySymbol; private static boolean disableVaultFormat; @@ -675,7 +678,10 @@ public class Util { } worldBlacklist = plugin.getConfig().getStringList("shop.blacklist-world"); disableDebugLogger = plugin.getConfig().getBoolean("debug.disable-debuglogger", false); - + try { + dyeColor = DyeColor.valueOf(plugin.getConfig().getString("shop.sign-dye-color")); + } catch (Exception ignored) { + } currencySymbolOnRight = plugin.getConfig().getBoolean("shop.currency-symbol-on-right", false); alternateCurrencySymbol = plugin.getConfig().getString("shop.alternate-currency-symbol", "$"); disableVaultFormat = plugin.getConfig().getBoolean("shop.disable-vault-format", false); diff --git a/src/main/java/org/maxgamer/quickshop/watcher/OngoingFeeWatcher.java b/src/main/java/org/maxgamer/quickshop/watcher/OngoingFeeWatcher.java index ffab355cc..4fd431516 100644 --- a/src/main/java/org/maxgamer/quickshop/watcher/OngoingFeeWatcher.java +++ b/src/main/java/org/maxgamer/quickshop/watcher/OngoingFeeWatcher.java @@ -26,6 +26,7 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.economy.EconomyTransaction; +import org.maxgamer.quickshop.economy.Trader; import org.maxgamer.quickshop.shop.Shop; import org.maxgamer.quickshop.util.MsgUtil; import org.maxgamer.quickshop.util.Util; @@ -67,13 +68,14 @@ public class OngoingFeeWatcher extends BukkitRunnable { World world = location.getWorld(); //We must check balance manually to avoid shop missing hell when tax account broken if (allowLoan || plugin.getEconomy().getBalance(shopOwner, Objects.requireNonNull(world), shop.getCurrency()) >= cost) { + Trader trader = plugin.getShopManager().getCacheTaxAccount(); Util.mainThreadRun(() -> { EconomyTransaction transaction = EconomyTransaction.builder() .allowLoan(allowLoan) .currency(shop.getCurrency()) .core(plugin.getEconomy()) .world(world) - .to(plugin.getShopManager().getCacheTaxAccount().getUniqueId()) + .to(trader == null ? null : trader.getUniqueId()) .from(shopOwner).build(); boolean success = transaction.failSafeCommit(); diff --git a/src/main/resources/lang/es-ES/messages.json b/src/main/resources/lang/es-ES/messages.json index 106224cc6..7fe9fc327 100644 --- a/src/main/resources/lang/es-ES/messages.json +++ b/src/main/resources/lang/es-ES/messages.json @@ -34,7 +34,7 @@ "negative-amount": "&cNo puedes comerciar con valores negativos", "not-a-number": "&cSolo puedes introducir un número, tu entrada era {0}.", "exceeded-maximum": "&cEl valor excedió el valor máximo en Java.", - "not-a-integer": "&cYou must input a integer, your input was {0}.", + "not-a-integer": "&cSolo puedes introducir un número, tu entrada era {0}.", "player-bought-from-your-store": "&c{0} ha comprado {1} {2} en tu tienda, y has pagado {3} en impuestos.", "shop-out-of-stock": "&5Tu tienda en {0}, {1}, {2} se ha quedado sin {3}!", "shop-has-no-space": "&cLa tienda sólo tiene espacio para {0} más {1}.",