From 4fe9bce9cde468da96534aac92d11b3ca9a7e4f2 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Fri, 19 Jan 2024 22:16:07 +0800 Subject: [PATCH 01/57] =?UTF-8?q?=E6=B7=BB=E5=8A=A0cleardata=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BlockDataController.java | 45 ++++++++++ .../subcommands/ClearDataCommand.java | 85 +++++++++++++++++++ .../subcommands/SlimefunSubCommands.java | 1 + 3 files changed, 131 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index c71b6a4103..ffec078433 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -750,4 +750,49 @@ private void clearBlockCacheAndTasks(SlimefunBlockData blockData) { removeDelayedBlockDataUpdates(scopeKey); abortScopeTask(scopeKey); } + public Set getAllBlockLocations(){ + Set toReturn = new HashSet<>(); + var key = new RecordKey(DataScope.BLOCK_RECORD); + key.addField(FieldKey.LOCATION); + key.addField(FieldKey.SLIMEFUN_ID); + + getData(key).forEach(block -> { + var lKey = block.get(FieldKey.LOCATION); + Location location = LocationUtils.toLocation(lKey); + toReturn.add(location); + }); + return toReturn; + } + + public Set getAllBlockLocations(World world){ + Set toReturn = new HashSet<>(); + var key = new RecordKey(DataScope.BLOCK_RECORD); + key.addField(FieldKey.LOCATION); + key.addField(FieldKey.SLIMEFUN_ID); + + getData(key).forEach(block -> { + var lKey = block.get(FieldKey.LOCATION); + Location location = LocationUtils.toLocation(lKey); + if(location.getWorld() == world) toReturn.add(location); + }); + return toReturn; + } + + public Set getAllChunks(World world){ + Set toReturn = new HashSet<>(); + var key = new RecordKey(DataScope.CHUNK_DATA); + key.addField(FieldKey.CHUNK); + key.addCondition(FieldKey.CHUNK, world.getName() + ";%"); + getData(key).forEach(result ->{ + toReturn.add(LocationUtils.toChunk(world, result.get(FieldKey.CHUNK))); + }); + return toReturn; + } + + public Set getAllChunkDatas(World world){ + Set chunks = getAllChunks(world); + Set toReturn = new HashSet<>(); + chunks.forEach(x -> toReturn.add(getChunkData(x))); + return toReturn; + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java new file mode 100644 index 0000000000..b1af7db1b4 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -0,0 +1,85 @@ +package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; + +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.BlockDataController; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunChunkData; +import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.core.config.SlimefunDatabaseManager; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.*; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; + +public class ClearDataCommand extends SubCommand { + @ParametersAreNonnullByDefault + public ClearDataCommand(Slimefun plugin, SlimefunCommand cmd) { + super(plugin, cmd, "cleardata", false); + } + + @Override + public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { + if (sender.hasPermission("slimefun.command.cleardata") || sender instanceof ConsoleCommandSender) { + if (args.length >= 3) { + String arg1 = args[1]; + String arg2 = args[2]; + List worlds = new ArrayList<>(); + List availableClearTypes = List.of("block", "oil"); + List clearTypes = new ArrayList<>(); + SlimefunDatabaseManager database = Slimefun.getDatabaseManager(); + BlockDataController controller = database.getBlockDataController(); + if (arg1.equals("*")) { + worlds.addAll(Bukkit.getWorlds()); + } else { + World toAdd = Bukkit.getWorld(arg1); + if (toAdd == null) { + sender.sendMessage(ChatColor.RED + "未找到世界", arg1); + return; + } + } + + if (arg2.equals("*")) { + clearTypes.addAll(availableClearTypes); + } else if (availableClearTypes.contains(arg2)) { + clearTypes.add(arg2); + } + + if (args.length == 3) { + for (World world : worlds) { + for (String cleartype : clearTypes) { + if (cleartype.equals("block")) { + Set locations = controller.getAllBlockLocations(world); + locations.forEach(controller::removeBlock); + } else if (cleartype.equals("oil")) { + GEOResource oil = null; + for (GEOResource resource : + Slimefun.getRegistry().getGEOResources().values()) { + if (resource.getKey() + .toString() + .equals(new NamespacedKey(Slimefun.instance(), "oil"))) { + oil = resource; + } + } + Set datas = controller.getAllChunkDatas(world); + GEOResource finalOil = oil; + datas.forEach(x -> x.removeData( + finalOil.getKey().toString().replace(":", "-"))); + } + } + } + } + + return; + } + Slimefun.getLocalization() + .sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf ")); + } else { + Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java index 497ae5562f..4a211cef09 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java @@ -46,6 +46,7 @@ public static Collection getAllCommands(@Nonnull SlimefunCommand cmd commands.add(new BlockDataCommand(plugin, cmd)); commands.add(new BanItemCommand(plugin, cmd)); commands.add(new UnbanItemCommand(plugin, cmd)); + commands.add(new ClearDataCommand(plugin, cmd)); return commands; } } From c83f662654a43ed2fce3dcc8f400ae3c28f78fd0 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Fri, 19 Jan 2024 22:18:45 +0800 Subject: [PATCH 02/57] Complete cleardata Command --- .../controller/BlockDataController.java | 32 ++++++++++++ .../subcommands/ClearDataCommand.java | 51 ++++++++++--------- 2 files changed, 58 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index ffec078433..cc2029c327 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -550,6 +550,16 @@ public void removeAllDataInChunk(Chunk chunk) { deleteChunkAndBlockDataDirectly(cKey); } + /** + * 移除指定数据 + */ + public void removeDataInChunk(Chunk chunk, String key) { + var cKey = LocationUtils.getChunkKey(chunk); + var cache = loadedChunk.remove(cKey); + + deleteChunkDataDirectly(cKey, key); + } + public void removeAllDataInChunkAsync(Chunk chunk, Runnable onFinishedCallback) { scheduleWriteTask(() -> { removeAllDataInChunk(chunk); @@ -576,6 +586,14 @@ public void removeAllDataInWorld(World world) { loadedChunk.entrySet().removeIf(entry -> entry.getKey().startsWith(prefix)); } + public void removeDataInWorld(World world, String key) { + var re = new RecordKey(DataScope.CHUNK_DATA); + re.addCondition(FieldKey.CHUNK, world.getName() + ";%"); + re.addCondition(FieldKey.DATA_KEY, key); + + deleteData(re); + } + public void removeAllDataInWorldAsync(World world, Runnable onFinishedCallback) { scheduleWriteTask(() -> { removeAllDataInWorld(world); @@ -583,6 +601,13 @@ public void removeAllDataInWorldAsync(World world, Runnable onFinishedCallback) }); } + public void removeDataInWorldAsync(World world, String key, Runnable onFinishedCallback) { + scheduleWriteTask(() -> { + removeDataInWorld(world, key); + onFinishedCallback.run(); + }); + } + public Set getAllLoadedChunkData(World world) { var prefix = world.getName() + ";"; var re = new HashSet(); @@ -739,6 +764,13 @@ private void deleteChunkAndBlockDataDirectly(String cKey) { deleteData(req); } + private void deleteChunkDataDirectly(String cKey, String key) { + var req = new RecordKey(DataScope.CHUNK_DATA); + req.addCondition(FieldKey.CHUNK, cKey); + req.addCondition(FieldKey.DATA_KEY, key); + deleteData(req); + } + private void clearBlockCacheAndTasks(SlimefunBlockData blockData) { var l = blockData.getLocation(); if (blockData.isDataLoaded() && Slimefun.getRegistry().getTickerBlocks().contains(blockData.getSfId())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index b1af7db1b4..20b23ceda7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -1,7 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; import com.xzavier0722.mc.plugin.slimefun4.storage.controller.BlockDataController; -import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunChunkData; import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; @@ -9,7 +8,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.ArrayList; import java.util.List; -import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.*; @@ -25,7 +23,7 @@ public ClearDataCommand(Slimefun plugin, SlimefunCommand cmd) { @Override public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (sender.hasPermission("slimefun.command.cleardata") || sender instanceof ConsoleCommandSender) { - if (args.length >= 3) { + if (args.length == 3) { String arg1 = args[1]; String arg2 = args[2]; List worlds = new ArrayList<>(); @@ -49,35 +47,38 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { clearTypes.add(arg2); } - if (args.length == 3) { - for (World world : worlds) { - for (String cleartype : clearTypes) { - if (cleartype.equals("block")) { - Set locations = controller.getAllBlockLocations(world); - locations.forEach(controller::removeBlock); - } else if (cleartype.equals("oil")) { - GEOResource oil = null; - for (GEOResource resource : - Slimefun.getRegistry().getGEOResources().values()) { - if (resource.getKey() - .toString() - .equals(new NamespacedKey(Slimefun.instance(), "oil"))) { - oil = resource; - } + for (World world : worlds) { + for (String cleartype : clearTypes) { + if (cleartype.equals("block")) { + controller.removeAllDataInWorldAsync( + world, + () -> Slimefun.runSync(() -> sender.sendMessage(ChatColor.GREEN + "已清除" + + ChatColor.YELLOW + world.getName() + ChatColor.GREEN + "的方块数据"))); + } else if (cleartype.equals("oil")) { + GEOResource oil = null; + for (GEOResource resource : + Slimefun.getRegistry().getGEOResources().values()) { + if (resource.getKey() + .toString() + .equals(new NamespacedKey(Slimefun.instance(), "oil").toString())) { + oil = resource; } - Set datas = controller.getAllChunkDatas(world); - GEOResource finalOil = oil; - datas.forEach(x -> x.removeData( - finalOil.getKey().toString().replace(":", "-"))); } + controller.removeDataInWorldAsync( + world, + oil.getKey().toString().replace(":", "-"), + () -> Slimefun.runSync(() -> sender.sendMessage(ChatColor.GREEN + "已清除" + + ChatColor.YELLOW + world.getName() + ChatColor.GREEN + "的石油数据"))); } } } - - return; } Slimefun.getLocalization() - .sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf ")); + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf cleardata ")); } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } From 1cf372b257e62b6cdbc908ccc4e764ed487e2c5d Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Fri, 19 Jan 2024 22:19:24 +0800 Subject: [PATCH 03/57] Complete cleardata TabCompleter --- .../slimefun4/core/commands/SlimefunTabCompleter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java index 7feb962fa0..eacfecf15b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java @@ -12,9 +12,11 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; +import org.bukkit.generator.WorldInfo; class SlimefunTabCompleter implements TabCompleter { @@ -38,6 +40,11 @@ public List onTabComplete(CommandSender sender, Command cmd, String labe .map(SlimefunItem::getId) .collect(Collectors.toList()); return createReturnList(list, args[1]); + } else if (args[0].equalsIgnoreCase("cleardata")) { + List list = + Bukkit.getWorlds().stream().map(WorldInfo::getName).toList(); + list.add("*"); + return createReturnList(list, args[1]); } return null; } else if (args.length == 3) { @@ -55,6 +62,8 @@ public List onTabComplete(CommandSender sender, Command cmd, String labe } return createReturnList(suggestions, args[2]); + } else if (args[0].equalsIgnoreCase("cleardata")) { + return createReturnList(List.of("block", "oil", "*"), args[2]); } else { // Returning null will make it fallback to the default arguments (all online players) return null; From da48bf2b811f599c7ed5bc54abc1cb9f6f3b01fa Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Fri, 19 Jan 2024 22:23:47 +0800 Subject: [PATCH 04/57] Remove useless methods --- .../controller/BlockDataController.java | 62 ------------------- 1 file changed, 62 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index cc2029c327..2c8b620d7f 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -550,16 +550,6 @@ public void removeAllDataInChunk(Chunk chunk) { deleteChunkAndBlockDataDirectly(cKey); } - /** - * 移除指定数据 - */ - public void removeDataInChunk(Chunk chunk, String key) { - var cKey = LocationUtils.getChunkKey(chunk); - var cache = loadedChunk.remove(cKey); - - deleteChunkDataDirectly(cKey, key); - } - public void removeAllDataInChunkAsync(Chunk chunk, Runnable onFinishedCallback) { scheduleWriteTask(() -> { removeAllDataInChunk(chunk); @@ -764,13 +754,6 @@ private void deleteChunkAndBlockDataDirectly(String cKey) { deleteData(req); } - private void deleteChunkDataDirectly(String cKey, String key) { - var req = new RecordKey(DataScope.CHUNK_DATA); - req.addCondition(FieldKey.CHUNK, cKey); - req.addCondition(FieldKey.DATA_KEY, key); - deleteData(req); - } - private void clearBlockCacheAndTasks(SlimefunBlockData blockData) { var l = blockData.getLocation(); if (blockData.isDataLoaded() && Slimefun.getRegistry().getTickerBlocks().contains(blockData.getSfId())) { @@ -782,49 +765,4 @@ private void clearBlockCacheAndTasks(SlimefunBlockData blockData) { removeDelayedBlockDataUpdates(scopeKey); abortScopeTask(scopeKey); } - public Set getAllBlockLocations(){ - Set toReturn = new HashSet<>(); - var key = new RecordKey(DataScope.BLOCK_RECORD); - key.addField(FieldKey.LOCATION); - key.addField(FieldKey.SLIMEFUN_ID); - - getData(key).forEach(block -> { - var lKey = block.get(FieldKey.LOCATION); - Location location = LocationUtils.toLocation(lKey); - toReturn.add(location); - }); - return toReturn; - } - - public Set getAllBlockLocations(World world){ - Set toReturn = new HashSet<>(); - var key = new RecordKey(DataScope.BLOCK_RECORD); - key.addField(FieldKey.LOCATION); - key.addField(FieldKey.SLIMEFUN_ID); - - getData(key).forEach(block -> { - var lKey = block.get(FieldKey.LOCATION); - Location location = LocationUtils.toLocation(lKey); - if(location.getWorld() == world) toReturn.add(location); - }); - return toReturn; - } - - public Set getAllChunks(World world){ - Set toReturn = new HashSet<>(); - var key = new RecordKey(DataScope.CHUNK_DATA); - key.addField(FieldKey.CHUNK); - key.addCondition(FieldKey.CHUNK, world.getName() + ";%"); - getData(key).forEach(result ->{ - toReturn.add(LocationUtils.toChunk(world, result.get(FieldKey.CHUNK))); - }); - return toReturn; - } - - public Set getAllChunkDatas(World world){ - Set chunks = getAllChunks(world); - Set toReturn = new HashSet<>(); - chunks.forEach(x -> toReturn.add(getChunkData(x))); - return toReturn; - } } From cac0a0d8bf1b4f3bf553ab076d4696ad8eb864b6 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 08:35:49 +0800 Subject: [PATCH 05/57] =?UTF-8?q?=E6=95=B4=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slimefun4/storage/controller/BlockDataController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index 2c8b620d7f..9c83370818 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -577,6 +577,10 @@ public void removeAllDataInWorld(World world) { } public void removeDataInWorld(World world, String key) { + // remove data in cache + for (SlimefunChunkData data : loadedChunk.values()) { + data.removeData(key); + } var re = new RecordKey(DataScope.CHUNK_DATA); re.addCondition(FieldKey.CHUNK, world.getName() + ";%"); re.addCondition(FieldKey.DATA_KEY, key); From 2a29b1ad0949a0ab8fd95ec2e1c357d157e469ec Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 09:09:21 +0800 Subject: [PATCH 06/57] Multi-language support --- .../subcommands/ClearDataCommand.java | 26 +++++++++++++------ .../resources/languages/zh-CN/messages.yml | 6 +++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index 20b23ceda7..2715cea317 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -29,6 +29,8 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { List worlds = new ArrayList<>(); List availableClearTypes = List.of("block", "oil"); List clearTypes = new ArrayList<>(); + String block = Slimefun.getLocalization().getMessage("commands.cleardata.block"); + String oil = Slimefun.getLocalization().getMessage("commands.cleardata.oil"); SlimefunDatabaseManager database = Slimefun.getDatabaseManager(); BlockDataController controller = database.getBlockDataController(); if (arg1.equals("*")) { @@ -36,7 +38,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { } else { World toAdd = Bukkit.getWorld(arg1); if (toAdd == null) { - sender.sendMessage(ChatColor.RED + "未找到世界", arg1); + Slimefun.getLocalization().sendMessage(sender, "commands.cleardata.worldNotFound", true); return; } } @@ -52,23 +54,31 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (cleartype.equals("block")) { controller.removeAllDataInWorldAsync( world, - () -> Slimefun.runSync(() -> sender.sendMessage(ChatColor.GREEN + "已清除" - + ChatColor.YELLOW + world.getName() + ChatColor.GREEN + "的方块数据"))); + () -> Slimefun.runSync(() -> Slimefun.getLocalization() + .sendMessage( + sender, + "commands.cleardata.success", + true, + msg -> String.format(msg, world.getName(), block)))); } else if (cleartype.equals("oil")) { - GEOResource oil = null; + GEOResource oilresource = null; for (GEOResource resource : Slimefun.getRegistry().getGEOResources().values()) { if (resource.getKey() .toString() .equals(new NamespacedKey(Slimefun.instance(), "oil").toString())) { - oil = resource; + oilresource = resource; } } controller.removeDataInWorldAsync( world, - oil.getKey().toString().replace(":", "-"), - () -> Slimefun.runSync(() -> sender.sendMessage(ChatColor.GREEN + "已清除" - + ChatColor.YELLOW + world.getName() + ChatColor.GREEN + "的石油数据"))); + oilresource.getKey().toString().replace(":", "-"), + () -> Slimefun.runSync(() -> Slimefun.getLocalization() + .sendMessage( + sender, + "commands.cleardata.success", + true, + msg -> String.format(msg, world.getName(), oil)))); } } } diff --git a/src/main/resources/languages/zh-CN/messages.yml b/src/main/resources/languages/zh-CN/messages.yml index 82224b2ba5..757fdad7fe 100644 --- a/src/main/resources/languages/zh-CN/messages.yml +++ b/src/main/resources/languages/zh-CN/messages.yml @@ -11,6 +11,12 @@ commands: stats: 查看玩家的统计数据 transform: 将物品转换为英文物品 id: 获取手持物品的 Slimefun ID + cleardata: + description: 清理世界数据 + success: '&a已清除&c{0}&a的&c{1}&a数据' + block: 方块 + oil: 石油 + worldNotFound: '&c未找到世界' banitem: description: 禁用 Slimefun 物品 success: '&a禁用成功' From 3bb0537d737f461c5a4fcc43b48bcb6b825b7eb1 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 10:13:18 +0800 Subject: [PATCH 07/57] Add description --- .../core/commands/subcommands/ClearDataCommand.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index 2715cea317..18439ae9fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -93,4 +93,9 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } } + @Nonnull + @Override + public String getDescription(){ + return "commands.cleardata.description"; + } } From a5cc4eec03b6529b8cae97bf86212f9e8d833b34 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 10:21:33 +0800 Subject: [PATCH 08/57] User need to confirm when use command cleardata --- .../core/commands/subcommands/ClearDataCommand.java | 9 +++++++-- src/main/resources/languages/zh-CN/messages.yml | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index 18439ae9fd..fbaaae656f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -23,7 +23,7 @@ public ClearDataCommand(Slimefun plugin, SlimefunCommand cmd) { @Override public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (sender.hasPermission("slimefun.command.cleardata") || sender instanceof ConsoleCommandSender) { - if (args.length == 3) { + if (args.length == 4 && args[3].equalsIgnoreCase("confirm")) { String arg1 = args[1]; String arg2 = args[2]; List worlds = new ArrayList<>(); @@ -83,6 +83,10 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { } } } + else if (args.length == 3){ + Slimefun.getLocalization().sendMessage(sender, "commands.cleardata.confirm", true); + return; + } Slimefun.getLocalization() .sendMessage( sender, @@ -93,9 +97,10 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } } + @Nonnull @Override - public String getDescription(){ + public String getDescription() { return "commands.cleardata.description"; } } diff --git a/src/main/resources/languages/zh-CN/messages.yml b/src/main/resources/languages/zh-CN/messages.yml index 757fdad7fe..ef8e7df0d5 100644 --- a/src/main/resources/languages/zh-CN/messages.yml +++ b/src/main/resources/languages/zh-CN/messages.yml @@ -17,6 +17,7 @@ commands: block: 方块 oil: 石油 worldNotFound: '&c未找到世界' + confirm: '&e 输入命令/sf cleardata confirm 来确认操作 %c此操作不可恢复!' banitem: description: 禁用 Slimefun 物品 success: '&a禁用成功' From 845f17fc0f7994a6c3411e2021bbb40c2fd71cf9 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 10:23:46 +0800 Subject: [PATCH 09/57] Format codes --- .../slimefun4/core/commands/subcommands/ClearDataCommand.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index fbaaae656f..49566ea4f6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -82,8 +82,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { } } } - } - else if (args.length == 3){ + } else if (args.length == 3) { Slimefun.getLocalization().sendMessage(sender, "commands.cleardata.confirm", true); return; } From fe9f1f75453854a6535702d07f1ce109e8fdd3a9 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 22:33:04 +0800 Subject: [PATCH 10/57] fix a bug of TabCompleter --- .../slimefun4/core/commands/SlimefunTabCompleter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java index eacfecf15b..c0d47f9487 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java @@ -42,7 +42,7 @@ public List onTabComplete(CommandSender sender, Command cmd, String labe return createReturnList(list, args[1]); } else if (args[0].equalsIgnoreCase("cleardata")) { List list = - Bukkit.getWorlds().stream().map(WorldInfo::getName).toList(); + new ArrayList<>(Bukkit.getWorlds().stream().map(WorldInfo::getName).toList()); list.add("*"); return createReturnList(list, args[1]); } From 45234c60d47fd300ec273ee204008473a7f9e9c4 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 22:36:43 +0800 Subject: [PATCH 11/57] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E7=AC=94=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/languages/zh-CN/messages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/languages/zh-CN/messages.yml b/src/main/resources/languages/zh-CN/messages.yml index ef8e7df0d5..2473f1c9eb 100644 --- a/src/main/resources/languages/zh-CN/messages.yml +++ b/src/main/resources/languages/zh-CN/messages.yml @@ -13,11 +13,11 @@ commands: id: 获取手持物品的 Slimefun ID cleardata: description: 清理世界数据 - success: '&a已清除&c{0}&a的&c{1}&a数据' + success: '&a已清除&c {0} &a的&c {1} &a数据' block: 方块 oil: 石油 worldNotFound: '&c未找到世界' - confirm: '&e 输入命令/sf cleardata confirm 来确认操作 %c此操作不可恢复!' + confirm: '&e 输入命令/sf cleardata confirm 来确认操作 &c此操作不可恢复!' banitem: description: 禁用 Slimefun 物品 success: '&a禁用成功' From 548332d8282c601babc62041e1fde8b290b394cf Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 22:39:33 +0800 Subject: [PATCH 12/57] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slimefun4/core/commands/subcommands/ClearDataCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index 49566ea4f6..4f20ddd630 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -59,7 +59,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { sender, "commands.cleardata.success", true, - msg -> String.format(msg, world.getName(), block)))); + msg -> msg.replace("{0}", world.getName()).replace("{1}", block)))); } else if (cleartype.equals("oil")) { GEOResource oilresource = null; for (GEOResource resource : @@ -78,7 +78,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { sender, "commands.cleardata.success", true, - msg -> String.format(msg, world.getName(), oil)))); + msg -> msg.replace("{0}", world.getName()).replace("{1}", oil)))); } } } From dd9652de32ec53d7078701f94dc0c26a1d8de20b Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 20 Jan 2024 22:48:46 +0800 Subject: [PATCH 13/57] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/commands/SlimefunTabCompleter.java | 4 ++-- .../commands/subcommands/ClearDataCommand.java | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java index c0d47f9487..b3ee3a0ee5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java @@ -41,8 +41,8 @@ public List onTabComplete(CommandSender sender, Command cmd, String labe .collect(Collectors.toList()); return createReturnList(list, args[1]); } else if (args[0].equalsIgnoreCase("cleardata")) { - List list = - new ArrayList<>(Bukkit.getWorlds().stream().map(WorldInfo::getName).toList()); + List list = new ArrayList<>( + Bukkit.getWorlds().stream().map(WorldInfo::getName).toList()); list.add("*"); return createReturnList(list, args[1]); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index 4f20ddd630..ae4115fada 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -55,11 +55,9 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { controller.removeAllDataInWorldAsync( world, () -> Slimefun.runSync(() -> Slimefun.getLocalization() - .sendMessage( - sender, - "commands.cleardata.success", - true, - msg -> msg.replace("{0}", world.getName()).replace("{1}", block)))); + .sendMessage(sender, "commands.cleardata.success", true, msg -> msg.replace( + "{0}", world.getName()) + .replace("{1}", block)))); } else if (cleartype.equals("oil")) { GEOResource oilresource = null; for (GEOResource resource : @@ -74,11 +72,9 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { world, oilresource.getKey().toString().replace(":", "-"), () -> Slimefun.runSync(() -> Slimefun.getLocalization() - .sendMessage( - sender, - "commands.cleardata.success", - true, - msg -> msg.replace("{0}", world.getName()).replace("{1}", oil)))); + .sendMessage(sender, "commands.cleardata.success", true, msg -> msg.replace( + "{0}", world.getName()) + .replace("{1}", oil)))); } } } From 95c934e018290cb2b5acdb45372fb6b82eaac9b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:58:12 +0000 Subject: [PATCH 14/57] =?UTF-8?q?=F0=9F=94=A7=20Bump=20com.diffplug.spotle?= =?UTF-8?q?ss:spotless-maven-plugin=20from=202.40.0=20to=202.43.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) from 2.40.0 to 2.43.0. - [Changelog](https://github.com/diffplug/spotless/blob/main/CHANGES.md) - [Commits](https://github.com/diffplug/spotless/compare/lib/2.40.0...lib/2.43.0) --- updated-dependencies: - dependency-name: com.diffplug.spotless:spotless-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f363c3a17..a81a4be205 100644 --- a/pom.xml +++ b/pom.xml @@ -184,7 +184,7 @@ com.diffplug.spotless spotless-maven-plugin - 2.40.0 + 2.43.0 From eac2fd9f3f49af04f2db8ae8d356c32253c3c59e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:58:21 +0000 Subject: [PATCH 15/57] =?UTF-8?q?=F0=9F=94=A7=20Bump=20com.sk89q.worldedit?= =?UTF-8?q?:worldedit-bukkit=20from=207.2.17=20to=207.2.19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps com.sk89q.worldedit:worldedit-bukkit from 7.2.17 to 7.2.19. --- updated-dependencies: - dependency-name: com.sk89q.worldedit:worldedit-bukkit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f363c3a17..5db3f99d7b 100644 --- a/pom.xml +++ b/pom.xml @@ -335,7 +335,7 @@ com.sk89q.worldedit worldedit-bukkit - 7.2.17 + 7.2.19 provided From b0594739f4349172bf50a203c4c179875ab8d44a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:58:27 +0000 Subject: [PATCH 16/57] =?UTF-8?q?=F0=9F=94=A7=20Bump=20com.sk89q.worldedit?= =?UTF-8?q?:worldedit-core=20from=207.2.17=20to=207.2.18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps com.sk89q.worldedit:worldedit-core from 7.2.17 to 7.2.18. --- updated-dependencies: - dependency-name: com.sk89q.worldedit:worldedit-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f363c3a17..08dd4b52cb 100644 --- a/pom.xml +++ b/pom.xml @@ -321,7 +321,7 @@ com.sk89q.worldedit worldedit-core - 7.2.17 + 7.2.18 provided From af6f6e82f5b59d4622ee90a3b2adf6e4a1639155 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:58:31 +0000 Subject: [PATCH 17/57] =?UTF-8?q?=F0=9F=94=A7=20Bump=20org.postgresql:post?= =?UTF-8?q?gresql=20from=2042.6.0=20to=2042.7.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [org.postgresql:postgresql](https://github.com/pgjdbc/pgjdbc) from 42.6.0 to 42.7.1. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.6.0...REL42.7.1) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f363c3a17..9ce9cd6814 100644 --- a/pom.xml +++ b/pom.xml @@ -313,7 +313,7 @@ org.postgresql postgresql - 42.6.0 + 42.7.1 compile From 08edf4fe5b14ab7c2752127f38218ab91c15359b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 12:01:09 +0000 Subject: [PATCH 18/57] =?UTF-8?q?=F0=9F=94=A7=20Bump=20org.apache.maven.pl?= =?UTF-8?q?ugins:maven-compiler-plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.11.0 to 3.12.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.11.0...maven-compiler-plugin-3.12.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f363c3a17..b1f019d22e 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 From f4ccf73e34ed3967aba2eedb2ebd32f64a3bc8d2 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Wed, 7 Feb 2024 13:58:02 +0800 Subject: [PATCH 19/57] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=B8=AD=E6=89=80=E6=9C=89ChunkData=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slimefun4/storage/controller/BlockDataController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index 9c83370818..f4833e353c 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -579,7 +579,7 @@ public void removeAllDataInWorld(World world) { public void removeDataInWorld(World world, String key) { // remove data in cache for (SlimefunChunkData data : loadedChunk.values()) { - data.removeData(key); + if (LocationUtils.isSameWorld(data.getChunk().getWorld(), world)) data.removeData(key); } var re = new RecordKey(DataScope.CHUNK_DATA); re.addCondition(FieldKey.CHUNK, world.getName() + ";%"); From ba86c1deac3aab18108c71df9e0dfb40e3d1902f Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Wed, 7 Feb 2024 14:16:05 +0800 Subject: [PATCH 20/57] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E7=9A=84return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slimefun4/core/commands/subcommands/ClearDataCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index ae4115fada..3a1dbe1b9b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -78,6 +78,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { } } } + return; } else if (args.length == 3) { Slimefun.getLocalization().sendMessage(sender, "commands.cleardata.confirm", true); return; From 612a83c8759d043227a39c3fb5b3520201722c07 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Mon, 12 Feb 2024 06:18:52 +0800 Subject: [PATCH 21/57] fix(sql): remove outdated default hikari config --- .../adapter/sqlcommon/SqlCommonConfig.java | 19 ------------------- .../storage/adapter/sqlite/SqliteConfig.java | 10 ---------- 2 files changed, 29 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index 31b8001a0d..9cfb609b1f 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -49,29 +49,10 @@ public HikariDataSource createDataSource() { } config.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), maxConnection)); - config.setMaxLifetime(TimeUnit.MINUTES.toMillis(10)); - config.setLeakDetectionThreshold(TimeUnit.MINUTES.toMillis(1)); - - config.setDataSourceProperties(getProperties()); return new HikariDataSource(config); } - private static Properties getProperties() { - var props = new Properties(); - props.setProperty("dataSource.cachePrepStmts", "true"); - props.setProperty("dataSource.prepStmtCacheSize", "250"); - props.setProperty("dataSource.prepStmtCacheSqlLimit", "2048"); - props.setProperty("dataSource.useServerPrepStmts", "true"); - props.setProperty("dataSource.useLocalSessionState", "true"); - props.setProperty("dataSource.rewriteBatchedStatements", "true"); - props.setProperty("dataSource.cacheResultSetMetadata", "true"); - props.setProperty("dataSource.cacheServerConfiguration", "true"); - props.setProperty("dataSource.elideSetAutoCommits", "true"); - props.setProperty("dataSource.maintainTimeStats", "false"); - return props; - } - public String tablePrefix() { return tablePrefix; } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index a71b05dfe4..ea2d7ec2b3 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -14,16 +14,6 @@ public HikariDataSource createDataSource() { config.setPoolName("SlimefunHikariPool"); config.setMaximumPoolSize(maxConnection); - config.setMaxLifetime(TimeUnit.MINUTES.toMillis(10)); - - var props = new Properties(); - props.setProperty("dataSource.cachePrepStmts", "true"); - props.setProperty("dataSource.prepStmtCacheSize", "250"); - props.setProperty("dataSource.prepStmtCacheSqlLimit", "2048"); - props.setProperty("dataSource.maintainTimeStats", "false"); - - config.setDataSourceProperties(props); - return new HikariDataSource(config); } From 2bbb66533218b245f9ee329a12b8a0e543b52a15 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Mon, 12 Feb 2024 06:24:00 +0800 Subject: [PATCH 22/57] chore(hikari): adjust hikari config --- .../storage/adapter/sqlcommon/SqlCommonConfig.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index 9cfb609b1f..199c6160b1 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -50,9 +50,22 @@ public HikariDataSource createDataSource() { config.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), maxConnection)); + config.setDataSourceProperties(getProperties()); + return new HikariDataSource(config); } + private static Properties getProperties() { + var props = new Properties(); + props.setProperty("dataSource.useLocalSessionState", "true"); + props.setProperty("dataSource.rewriteBatchedStatements", "true"); + props.setProperty("dataSource.cacheResultSetMetadata", "true"); + props.setProperty("dataSource.cacheServerConfiguration", "true"); + props.setProperty("dataSource.elideSetAutoCommits", "true"); + props.setProperty("dataSource.maintainTimeStats", "false"); + return props; + } + public String tablePrefix() { return tablePrefix; } From 13779f5b791471881f0c212a5c9d20272700ac31 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Mon, 12 Feb 2024 06:29:26 +0800 Subject: [PATCH 23/57] chore(hikari): adjust hikari config --- .../slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java | 2 ++ .../plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index 199c6160b1..5e29bd2743 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -2,6 +2,7 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; +import java.sql.Time; import java.util.Properties; import java.util.concurrent.TimeUnit; @@ -49,6 +50,7 @@ public HikariDataSource createDataSource() { } config.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), maxConnection)); + config.setLeakDetectionThreshold(5000); config.setDataSourceProperties(getProperties()); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index ea2d7ec2b3..400a25fd48 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -13,6 +13,7 @@ public HikariDataSource createDataSource() { config.setJdbcUrl(jdbcUrl()); config.setPoolName("SlimefunHikariPool"); config.setMaximumPoolSize(maxConnection); + config.setLeakDetectionThreshold(5000); return new HikariDataSource(config); } From 7650bc9345c7e021fcae9db9e54861f33111554e Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Mon, 12 Feb 2024 06:38:59 +0800 Subject: [PATCH 24/57] chore(hikari): use `addDataSourceProperty` --- .../adapter/sqlcommon/SqlCommonConfig.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index 5e29bd2743..d54ece72e3 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -51,23 +51,16 @@ public HikariDataSource createDataSource() { config.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), maxConnection)); config.setLeakDetectionThreshold(5000); - - config.setDataSourceProperties(getProperties()); + config.addDataSourceProperty("useLocalSessionState", "true"); + config.addDataSourceProperty("rewriteBatchedStatements", "true"); + config.addDataSourceProperty("cacheResultSetMetadata", "true"); + config.addDataSourceProperty("cacheServerConfiguration", "true"); + config.addDataSourceProperty("elideSetAutoCommits", "true"); + config.addDataSourceProperty("maintainTimeStats", "false"); return new HikariDataSource(config); } - private static Properties getProperties() { - var props = new Properties(); - props.setProperty("dataSource.useLocalSessionState", "true"); - props.setProperty("dataSource.rewriteBatchedStatements", "true"); - props.setProperty("dataSource.cacheResultSetMetadata", "true"); - props.setProperty("dataSource.cacheServerConfiguration", "true"); - props.setProperty("dataSource.elideSetAutoCommits", "true"); - props.setProperty("dataSource.maintainTimeStats", "false"); - return props; - } - public String tablePrefix() { return tablePrefix; } From f1a867af65c56bc30cec576138c8ecab09909b94 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Mon, 12 Feb 2024 10:31:23 +0800 Subject: [PATCH 25/57] fix(hikari): do not interrupt pool size in config --- .../storage/adapter/sqlcommon/SqlCommonConfig.java | 2 +- .../slimefun4/storage/migrator/BlockStorageMigrator.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index d54ece72e3..6d97d7075f 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -49,7 +49,7 @@ public HikariDataSource createDataSource() { config.setPassword(passwd); } - config.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), maxConnection)); + config.setMaximumPoolSize(maxConnection); config.setLeakDetectionThreshold(5000); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java index 0627990e31..0700d6b20f 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java @@ -11,12 +11,14 @@ import java.nio.file.StandardCopyOption; import java.util.Map; import java.util.logging.Level; +import lombok.Getter; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; public class BlockStorageMigrator implements IMigrator { + @Getter private static final BlockStorageMigrator instance = new BlockStorageMigrator(); private static final File invFolder = new File("data-storage/Slimefun/stored-inventories/"); @@ -27,10 +29,6 @@ public class BlockStorageMigrator implements IMigrator { private BlockStorageMigrator() {} - public static BlockStorageMigrator getInstance() { - return instance; - } - @Override public String getName() { return "BlockStorage"; From cbb5dd5ed4ac290fe50040755f3f53a7c36305d8 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Mon, 12 Feb 2024 10:34:32 +0800 Subject: [PATCH 26/57] fix(hikari): use lower connection timeout to avoid watchdog --- .../slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java | 1 + .../mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index 6d97d7075f..f74f06dfb6 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -50,6 +50,7 @@ public HikariDataSource createDataSource() { } config.setMaximumPoolSize(maxConnection); + config.setConnectionTimeout(29000); // set below 30s to avoid paper watchdog config.setLeakDetectionThreshold(5000); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index 400a25fd48..c7516bc4d8 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -13,6 +13,7 @@ public HikariDataSource createDataSource() { config.setJdbcUrl(jdbcUrl()); config.setPoolName("SlimefunHikariPool"); config.setMaximumPoolSize(maxConnection); + config.setConnectionTimeout(29000); // set below 30s to avoid paper watchdog config.setLeakDetectionThreshold(5000); return new HikariDataSource(config); From c17a0b70124507a96c3e2b6ad4eb7cfc05e11e7e Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Wed, 7 Feb 2024 13:40:17 +0800 Subject: [PATCH 27/57] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Not90DegreeRotatable=20?= =?UTF-8?q?NotDiagonallyRotatable=20NotRotatable=20=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=89=A9=E5=93=81=E6=97=8B=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slimefun4/storage/util/LocationUtils.java | 17 ++++++++++++++ .../core/attributes/Not90DegreeRotatable.java | 12 ++++++++++ .../attributes/NotDiagonallyRotatable.java | 12 ++++++++++ .../core/attributes/NotRotatable.java | 17 ++++++++++++++ .../items/androids/ProgrammableAndroid.java | 4 +++- .../items/autocrafters/ArmorAutoCrafter.java | 3 ++- .../autocrafters/EnhancedAutoCrafter.java | 3 ++- .../autocrafters/VanillaAutoCrafter.java | 3 ++- .../items/cargo/CargoConnectorNode.java | 3 ++- .../items/cargo/CargoManager.java | 3 ++- .../implementation/items/cargo/TrashCan.java | 3 ++- .../items/electric/EnergyConnector.java | 3 ++- .../items/electric/EnergyRegulator.java | 3 ++- .../electric/generators/CoalGenerator.java | 3 ++- .../generators/CombustionGenerator.java | 3 ++- .../electric/generators/LavaGenerator.java | 3 ++- .../generators/MagnesiumGenerator.java | 3 ++- .../electric/machines/ElectricPress.java | 3 ++- .../machines/entities/ExpCollector.java | 3 ++- .../implementation/items/geo/GEOMiner.java | 8 +++---- .../implementation/items/geo/GEOScanner.java | 3 ++- .../implementation/items/geo/OilPump.java | 3 ++- .../items/gps/GPSControlPanel.java | 3 ++- .../items/gps/GPSTransmitter.java | 4 +++- .../listeners/BlockListener.java | 23 +++++++++++++++++++ 25 files changed, 124 insertions(+), 24 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotRotatable.java diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index 72945573db..108eb23e05 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -4,6 +4,7 @@ import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.block.BlockFace; public class LocationUtils { public static String getLocKey(Location l) { @@ -61,4 +62,20 @@ public static String locationToString(Location location) { + location.getZ() + "]"; } + + public static BlockFace angelToNot90DegreeBlockFace(double angel) { + if (0 < angel && angel <= 90) return BlockFace.SOUTH_WEST; + else if (90 < angel && angel <= 180) return BlockFace.NORTH_WEST; + else if (-180 <= angel && angel <= -90) return BlockFace.NORTH_EAST; + else if (-90 < angel && angel <= 0) return BlockFace.SOUTH_EAST; + throw new IllegalArgumentException("angel is a number between -180 to 180"); + } + + public static BlockFace angelToNotDiagonallyBlockFace(double angel) { + if (-45 < angel && angel <= 45) return BlockFace.SOUTH; + else if (45 < angel && angel <= 135) return BlockFace.WEST; + else if ((135 < angel && angel <= 180) || (-180 <= angel && angel <= -135)) return BlockFace.NORTH; + else if (-135 < angel && angel <= -45) return BlockFace.EAST; + throw new IllegalArgumentException("angel is a number between -180 to 180"); + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java new file mode 100644 index 0000000000..d526c9e15b --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java @@ -0,0 +1,12 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; + +/** + * Implement this interface for any {@link SlimefunItem} to prevent + * that {@link SlimefunItem} from being 90 degree rotated. + * + * @author Ddggdd135 + * + */ +public interface Not90DegreeRotatable extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java new file mode 100644 index 0000000000..becd113438 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java @@ -0,0 +1,12 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; + +/** + * Implement this interface for any {@link SlimefunItem} to prevent + * that {@link SlimefunItem} from being diagonally rotated. + * + * @author Ddggdd135 + * + */ +public interface NotDiagonallyRotatable extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotRotatable.java new file mode 100644 index 0000000000..b8b9f26f89 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotRotatable.java @@ -0,0 +1,17 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import org.bukkit.block.BlockFace; + +/** + * Implement this interface for any {@link SlimefunItem} to prevent + * that {@link SlimefunItem} from being rotated. + * + * @author Ddggdd135 + * + */ +public interface NotRotatable extends ItemAttribute { + default BlockFace getRotation() { + return BlockFace.NORTH; + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 340137fa85..274925d1c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -14,6 +14,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; @@ -65,7 +66,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, RecipeDisplayItem { +public class ProgrammableAndroid extends SlimefunItem + implements InventoryBlock, RecipeDisplayItem, NotDiagonallyRotatable { private static final List POSSIBLE_ROTATIONS = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/ArmorAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/ArmorAutoCrafter.java index 4a4fd602ac..1db215b68e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/ArmorAutoCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/ArmorAutoCrafter.java @@ -3,6 +3,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.ArmorForge; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; @@ -19,7 +20,7 @@ * @see SlimefunItemRecipe * */ -public class ArmorAutoCrafter extends SlimefunAutoCrafter { +public class ArmorAutoCrafter extends SlimefunAutoCrafter implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public ArmorAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/EnhancedAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/EnhancedAutoCrafter.java index f4f273c415..9c8d72a952 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/EnhancedAutoCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/EnhancedAutoCrafter.java @@ -3,6 +3,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.EnhancedCraftingTable; import io.github.thebusybiscuit.slimefun4.implementation.listeners.AutoCrafterListener; import javax.annotation.ParametersAreNonnullByDefault; @@ -20,7 +21,7 @@ * @see AutoCrafterListener * */ -public class EnhancedAutoCrafter extends SlimefunAutoCrafter { +public class EnhancedAutoCrafter extends SlimefunAutoCrafter implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public EnhancedAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java index 05d0a930e4..a141837ee0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java @@ -6,6 +6,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService; import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; @@ -47,7 +48,7 @@ * @see VanillaRecipe * */ -public class VanillaAutoCrafter extends AbstractAutoCrafter { +public class VanillaAutoCrafter extends AbstractAutoCrafter implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public VanillaAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java index 197f436a16..821214896c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java @@ -3,6 +3,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; @@ -23,7 +24,7 @@ * @see CargoNet * */ -public class CargoConnectorNode extends SimpleSlimefunItem { +public class CargoConnectorNode extends SimpleSlimefunItem implements NotRotatable { @ParametersAreNonnullByDefault public CargoConnectorNode( diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java index ecb79840bb..967f2e4a27 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java @@ -8,6 +8,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; @@ -21,7 +22,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public class CargoManager extends SlimefunItem implements HologramOwner { +public class CargoManager extends SlimefunItem implements HologramOwner, NotRotatable { @ParametersAreNonnullByDefault public CargoManager(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java index cbe8c0c503..1b24c6aa63 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java @@ -6,6 +6,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotRotatable; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; @@ -23,7 +24,7 @@ * @author TheBusyBiscuit * */ -public class TrashCan extends SlimefunItem implements InventoryBlock { +public class TrashCan extends SlimefunItem implements InventoryBlock, NotRotatable { private final int[] border = {0, 1, 2, 3, 5, 4, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}; private final ItemStack background = new CustomItemStack(Material.RED_STAINED_GLASS_PANE, " "); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java index 17446db456..3793dae395 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java @@ -5,6 +5,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; @@ -25,7 +26,7 @@ * @see EnergyNetComponent * */ -public class EnergyConnector extends SimpleSlimefunItem implements EnergyNetComponent { +public class EnergyConnector extends SimpleSlimefunItem implements EnergyNetComponent, NotRotatable { @ParametersAreNonnullByDefault public EnergyConnector( diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java index 857006de0a..fd79a39c8e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java @@ -7,6 +7,7 @@ import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; @@ -28,7 +29,7 @@ * @see EnergyNetComponent * */ -public class EnergyRegulator extends SlimefunItem implements HologramOwner { +public class EnergyRegulator extends SlimefunItem implements HologramOwner, NotRotatable { @ParametersAreNonnullByDefault public EnergyRegulator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java index d67c53058f..f44b2d1ffa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java @@ -3,6 +3,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -11,7 +12,7 @@ import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; -public class CoalGenerator extends AGenerator { +public class CoalGenerator extends AGenerator implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public CoalGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java index d34e7c0354..e3704158e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java @@ -3,6 +3,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -10,7 +11,7 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -public class CombustionGenerator extends AGenerator { +public class CombustionGenerator extends AGenerator implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public CombustionGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java index d5024f5458..965ff85d61 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java @@ -3,13 +3,14 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -public class LavaGenerator extends AGenerator { +public class LavaGenerator extends AGenerator implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public LavaGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java index 073d3387bb..ea3a4852cc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java @@ -3,6 +3,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -10,7 +11,7 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -public class MagnesiumGenerator extends AGenerator { +public class MagnesiumGenerator extends AGenerator implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public MagnesiumGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java index 863f6f85cb..505d4a1a7a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java @@ -5,6 +5,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; @@ -20,7 +21,7 @@ * @author TheBusyBiscuit * */ -public class ElectricPress extends AContainer implements RecipeDisplayItem { +public class ElectricPress extends AContainer implements RecipeDisplayItem, NotDiagonallyRotatable { @ParametersAreNonnullByDefault public ElectricPress(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java index 70d2bb904d..8b9b5c0887 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java @@ -9,6 +9,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; @@ -36,7 +37,7 @@ * @author TheBusyBiscuit * */ -public class ExpCollector extends SlimefunItem implements InventoryBlock, EnergyNetComponent { +public class ExpCollector extends SlimefunItem implements InventoryBlock, EnergyNetComponent, NotDiagonallyRotatable { private final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java index 1bc1f2b338..c100c8aca7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java @@ -12,10 +12,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun4.core.attributes.*; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; @@ -56,7 +53,8 @@ public class GEOMiner extends SlimefunItem EnergyNetComponent, InventoryBlock, HologramOwner, - MachineProcessHolder { + MachineProcessHolder, + NotDiagonallyRotatable { private static final int[] BORDER = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 53 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java index d86d235a32..ac5ccaec46 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java @@ -4,6 +4,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -14,7 +15,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public class GEOScanner extends SimpleSlimefunItem { +public class GEOScanner extends SimpleSlimefunItem implements NotDiagonallyRotatable { public GEOScanner(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java index e28d88dfdd..6b5d9b0545 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java @@ -5,6 +5,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; @@ -24,7 +25,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public class OilPump extends AContainer implements RecipeDisplayItem { +public class OilPump extends AContainer implements RecipeDisplayItem, NotDiagonallyRotatable { private final GEOResource oil; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java index 950bedfc76..ea0cd06f6a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java @@ -4,6 +4,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -14,7 +15,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public class GPSControlPanel extends SimpleSlimefunItem { +public class GPSControlPanel extends SimpleSlimefunItem implements NotDiagonallyRotatable { @ParametersAreNonnullByDefault public GPSControlPanel(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java index dd532beb26..eb8603509c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java @@ -7,6 +7,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; @@ -23,7 +24,8 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -public abstract class GPSTransmitter extends SimpleSlimefunItem implements EnergyNetComponent { +public abstract class GPSTransmitter extends SimpleSlimefunItem + implements EnergyNetComponent, NotDiagonallyRotatable { private final int capacity; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 63a6f60d1d..b45bb374b7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -2,6 +2,7 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback; import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils; import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import io.github.bakedlibs.dough.protection.Interaction; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; @@ -9,7 +10,10 @@ import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockBreakEvent; import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockPlaceEvent; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.core.attributes.Not90DegreeRotatable; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotRotatable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; @@ -29,6 +33,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Rotatable; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -116,6 +121,24 @@ public void onBlockPlace(BlockPlaceEvent e) { if (!sfItem.canUse(e.getPlayer(), true)) { e.setCancelled(true); } else { + if (e.getBlock().getBlockData() instanceof Rotatable rotatable + && !(rotatable.getRotation() == BlockFace.UP || rotatable.getRotation() == BlockFace.DOWN)) { + if (sfItem instanceof Not90DegreeRotatable && sfItem instanceof NotDiagonallyRotatable) { + rotatable.setRotation(BlockFace.NORTH); + e.getBlock().setBlockData(rotatable); + } else if (sfItem instanceof NotRotatable notRotatable) { + rotatable.setRotation(notRotatable.getRotation()); + e.getBlock().setBlockData(rotatable); + } else if (sfItem instanceof Not90DegreeRotatable) { + rotatable.setRotation(LocationUtils.angelToNot90DegreeBlockFace( + e.getPlayer().getLocation().getYaw())); + e.getBlock().setBlockData(rotatable); + } else if (sfItem instanceof NotDiagonallyRotatable) { + rotatable.setRotation(LocationUtils.angelToNotDiagonallyBlockFace( + e.getPlayer().getLocation().getYaw())); + e.getBlock().setBlockData(rotatable); + } + } var placeEvent = new SlimefunBlockPlaceEvent(e.getPlayer(), item, e.getBlock(), sfItem); Bukkit.getPluginManager().callEvent(placeEvent); From e149e50fb582e0872e5a9be40013f9230dca2918 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sun, 11 Feb 2024 09:02:45 +0800 Subject: [PATCH 28/57] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E6=98=93?= =?UTF-8?q?=E8=AF=BB=E7=9A=84=E7=B1=BB=E5=90=8D=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=94=99=E5=88=AB=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slimefun4/storage/util/LocationUtils.java | 20 +++++++++---------- .../core/attributes/Not90DegreeRotatable.java | 12 ----------- .../attributes/NotCardinallyRotatable.java | 17 ++++++++++++++++ .../attributes/NotDiagonallyRotatable.java | 7 ++++++- .../listeners/BlockListener.java | 10 +++++----- 5 files changed, 38 insertions(+), 28 deletions(-) delete mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index 108eb23e05..9c938e6630 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -63,19 +63,19 @@ public static String locationToString(Location location) { + "]"; } - public static BlockFace angelToNot90DegreeBlockFace(double angel) { - if (0 < angel && angel <= 90) return BlockFace.SOUTH_WEST; - else if (90 < angel && angel <= 180) return BlockFace.NORTH_WEST; - else if (-180 <= angel && angel <= -90) return BlockFace.NORTH_EAST; - else if (-90 < angel && angel <= 0) return BlockFace.SOUTH_EAST; + public static BlockFace angleToNot90DegreeBlockFace(double angle) { + if (0 < angle && angle <= 90) return BlockFace.SOUTH_WEST; + else if (90 < angle && angle <= 180) return BlockFace.NORTH_WEST; + else if (-180 <= angle && angle <= -90) return BlockFace.NORTH_EAST; + else if (-90 < angle && angle <= 0) return BlockFace.SOUTH_EAST; throw new IllegalArgumentException("angel is a number between -180 to 180"); } - public static BlockFace angelToNotDiagonallyBlockFace(double angel) { - if (-45 < angel && angel <= 45) return BlockFace.SOUTH; - else if (45 < angel && angel <= 135) return BlockFace.WEST; - else if ((135 < angel && angel <= 180) || (-180 <= angel && angel <= -135)) return BlockFace.NORTH; - else if (-135 < angel && angel <= -45) return BlockFace.EAST; + public static BlockFace angleToNotDiagonallyBlockFace(double angle) { + if (-45 < angle && angle <= 45) return BlockFace.SOUTH; + else if (45 < angle && angle <= 135) return BlockFace.WEST; + else if ((135 < angle && angle <= 180) || (-180 <= angle && angle <= -135)) return BlockFace.NORTH; + else if (-135 < angle && angle <= -45) return BlockFace.EAST; throw new IllegalArgumentException("angel is a number between -180 to 180"); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java deleted file mode 100644 index d526c9e15b..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Not90DegreeRotatable.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; - -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - -/** - * Implement this interface for any {@link SlimefunItem} to prevent - * that {@link SlimefunItem} from being 90 degree rotated. - * - * @author Ddggdd135 - * - */ -public interface Not90DegreeRotatable extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java new file mode 100644 index 0000000000..72ebcd8969 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java @@ -0,0 +1,17 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import org.bukkit.block.BlockFace; + +/** + * Implement this interface for any {@link SlimefunItem} to prevent + * that {@link SlimefunItem} from being rotated to + * {@link BlockFace}.NORTH + * {@link BlockFace}.EAST + * {@link BlockFace}.SOUTH + * {@link BlockFace}.WEST + * + * @author Ddggdd135 + * + */ +public interface NotCardinallyRotatable extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java index becd113438..6fdd4d0ed8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java @@ -1,10 +1,15 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import org.bukkit.block.BlockFace; /** * Implement this interface for any {@link SlimefunItem} to prevent - * that {@link SlimefunItem} from being diagonally rotated. + * that {@link SlimefunItem} from being rotated to + * {@link BlockFace}.NORTH_EAST + * {@link BlockFace}.NORTH_WEST + * {@link BlockFace}.SOUTH_EAST + * {@link BlockFace}.SOUTH_WEST * * @author Ddggdd135 * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index b45bb374b7..641135de36 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -10,7 +10,7 @@ import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockBreakEvent; import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockPlaceEvent; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.Not90DegreeRotatable; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotCardinallyRotatable; import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.attributes.NotRotatable; @@ -123,18 +123,18 @@ public void onBlockPlace(BlockPlaceEvent e) { } else { if (e.getBlock().getBlockData() instanceof Rotatable rotatable && !(rotatable.getRotation() == BlockFace.UP || rotatable.getRotation() == BlockFace.DOWN)) { - if (sfItem instanceof Not90DegreeRotatable && sfItem instanceof NotDiagonallyRotatable) { + if (sfItem instanceof NotCardinallyRotatable && sfItem instanceof NotDiagonallyRotatable) { rotatable.setRotation(BlockFace.NORTH); e.getBlock().setBlockData(rotatable); } else if (sfItem instanceof NotRotatable notRotatable) { rotatable.setRotation(notRotatable.getRotation()); e.getBlock().setBlockData(rotatable); - } else if (sfItem instanceof Not90DegreeRotatable) { - rotatable.setRotation(LocationUtils.angelToNot90DegreeBlockFace( + } else if (sfItem instanceof NotCardinallyRotatable) { + rotatable.setRotation(LocationUtils.angleToNot90DegreeBlockFace( e.getPlayer().getLocation().getYaw())); e.getBlock().setBlockData(rotatable); } else if (sfItem instanceof NotDiagonallyRotatable) { - rotatable.setRotation(LocationUtils.angelToNotDiagonallyBlockFace( + rotatable.setRotation(LocationUtils.angleToNotDiagonallyBlockFace( e.getPlayer().getLocation().getYaw())); e.getBlock().setBlockData(rotatable); } From 4337a9dc44c975ab9f8db16d9338e7640a8754d0 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <66861021+JWJUN233233@users.noreply.github.com> Date: Tue, 13 Feb 2024 17:13:22 +0800 Subject: [PATCH 29/57] Update src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java Co-authored-by: NoRainCity --- .../mc/plugin/slimefun4/storage/util/LocationUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index 9c938e6630..4a895bb878 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -68,7 +68,7 @@ public static BlockFace angleToNot90DegreeBlockFace(double angle) { else if (90 < angle && angle <= 180) return BlockFace.NORTH_WEST; else if (-180 <= angle && angle <= -90) return BlockFace.NORTH_EAST; else if (-90 < angle && angle <= 0) return BlockFace.SOUTH_EAST; - throw new IllegalArgumentException("angel is a number between -180 to 180"); + throw new IllegalArgumentException("angle must be number from -180 to 180"); } public static BlockFace angleToNotDiagonallyBlockFace(double angle) { @@ -76,6 +76,6 @@ public static BlockFace angleToNotDiagonallyBlockFace(double angle) { else if (45 < angle && angle <= 135) return BlockFace.WEST; else if ((135 < angle && angle <= 180) || (-180 <= angle && angle <= -135)) return BlockFace.NORTH; else if (-135 < angle && angle <= -45) return BlockFace.EAST; - throw new IllegalArgumentException("angel is a number between -180 to 180"); + throw new IllegalArgumentException("angle must be number from -180 to 180"); } } From 1b4c293fdc2eda179a3a440573f73df225624ca1 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Wed, 14 Feb 2024 21:25:20 +0800 Subject: [PATCH 30/57] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/plugin/slimefun4/storage/util/LocationUtils.java | 2 +- .../slimefun4/implementation/listeners/BlockListener.java | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index 4a895bb878..d7a06aeb30 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -74,7 +74,7 @@ public static BlockFace angleToNot90DegreeBlockFace(double angle) { public static BlockFace angleToNotDiagonallyBlockFace(double angle) { if (-45 < angle && angle <= 45) return BlockFace.SOUTH; else if (45 < angle && angle <= 135) return BlockFace.WEST; - else if ((135 < angle && angle <= 180) || (-180 <= angle && angle <= -135)) return BlockFace.NORTH; + else if (135 < Math.abs(angle) && Math.abs(angle) <= 180) return BlockFace.NORTH; else if (-135 < angle && angle <= -45) return BlockFace.EAST; throw new IllegalArgumentException("angle must be number from -180 to 180"); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 641135de36..9c73e65359 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -125,19 +125,16 @@ public void onBlockPlace(BlockPlaceEvent e) { && !(rotatable.getRotation() == BlockFace.UP || rotatable.getRotation() == BlockFace.DOWN)) { if (sfItem instanceof NotCardinallyRotatable && sfItem instanceof NotDiagonallyRotatable) { rotatable.setRotation(BlockFace.NORTH); - e.getBlock().setBlockData(rotatable); } else if (sfItem instanceof NotRotatable notRotatable) { rotatable.setRotation(notRotatable.getRotation()); - e.getBlock().setBlockData(rotatable); } else if (sfItem instanceof NotCardinallyRotatable) { rotatable.setRotation(LocationUtils.angleToNot90DegreeBlockFace( e.getPlayer().getLocation().getYaw())); - e.getBlock().setBlockData(rotatable); } else if (sfItem instanceof NotDiagonallyRotatable) { rotatable.setRotation(LocationUtils.angleToNotDiagonallyBlockFace( e.getPlayer().getLocation().getYaw())); - e.getBlock().setBlockData(rotatable); } + e.getBlock().setBlockData(rotatable); } var placeEvent = new SlimefunBlockPlaceEvent(e.getPlayer(), item, e.getBlock(), sfItem); Bukkit.getPluginManager().callEvent(placeEvent); From d9b5ce7d22eb52e77e9ceac93b8effb8546e2b47 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Wed, 14 Feb 2024 21:48:33 +0800 Subject: [PATCH 31/57] style: spotless --- .../slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java | 3 --- .../plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index f74f06dfb6..83070dc5d9 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -2,9 +2,6 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import java.sql.Time; -import java.util.Properties; -import java.util.concurrent.TimeUnit; public abstract class SqlCommonConfig implements ISqlCommonConfig { protected final String host; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index c7516bc4d8..9ed0a57967 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -3,8 +3,6 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.ISqlCommonConfig; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import java.util.Properties; -import java.util.concurrent.TimeUnit; public record SqliteConfig(String path, int maxConnection) implements ISqlCommonConfig { public HikariDataSource createDataSource() { From ec6e8151c7887a02f256076c102f76a43d9d1be3 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 17 Feb 2024 23:37:47 +0800 Subject: [PATCH 32/57] chore: cleanup code --- .../slimefun4/storage/util/LocationUtils.java | 16 -------------- .../attributes/NotCardinallyRotatable.java | 10 ++++++++- .../attributes/NotDiagonallyRotatable.java | 10 ++++++++- .../listeners/BlockListener.java | 22 +++++++++++-------- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index d7a06aeb30..ad3ba3185e 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -62,20 +62,4 @@ public static String locationToString(Location location) { + location.getZ() + "]"; } - - public static BlockFace angleToNot90DegreeBlockFace(double angle) { - if (0 < angle && angle <= 90) return BlockFace.SOUTH_WEST; - else if (90 < angle && angle <= 180) return BlockFace.NORTH_WEST; - else if (-180 <= angle && angle <= -90) return BlockFace.NORTH_EAST; - else if (-90 < angle && angle <= 0) return BlockFace.SOUTH_EAST; - throw new IllegalArgumentException("angle must be number from -180 to 180"); - } - - public static BlockFace angleToNotDiagonallyBlockFace(double angle) { - if (-45 < angle && angle <= 45) return BlockFace.SOUTH; - else if (45 < angle && angle <= 135) return BlockFace.WEST; - else if (135 < Math.abs(angle) && Math.abs(angle) <= 180) return BlockFace.NORTH; - else if (-135 < angle && angle <= -45) return BlockFace.EAST; - throw new IllegalArgumentException("angle must be number from -180 to 180"); - } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java index 72ebcd8969..a4ebd320c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotCardinallyRotatable.java @@ -14,4 +14,12 @@ * @author Ddggdd135 * */ -public interface NotCardinallyRotatable extends ItemAttribute {} +public interface NotCardinallyRotatable extends ItemAttribute { + default BlockFace getRotation(double angle) { + if (0 < angle && angle <= 90) return BlockFace.SOUTH_WEST; + else if (90 < angle && angle <= 180) return BlockFace.NORTH_WEST; + else if (-180 <= angle && angle <= -90) return BlockFace.NORTH_EAST; + else if (-90 < angle && angle <= 0) return BlockFace.SOUTH_EAST; + throw new IllegalArgumentException("angle must be number from -180 to 180"); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java index 6fdd4d0ed8..478dfee1b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotDiagonallyRotatable.java @@ -14,4 +14,12 @@ * @author Ddggdd135 * */ -public interface NotDiagonallyRotatable extends ItemAttribute {} +public interface NotDiagonallyRotatable extends ItemAttribute { + default BlockFace getRotation(double angle) { + if (-45 < angle && angle <= 45) return BlockFace.SOUTH; + else if (45 < angle && angle <= 135) return BlockFace.WEST; + else if (135 < Math.abs(angle) && Math.abs(angle) <= 180) return BlockFace.NORTH; + else if (-135 < angle && angle <= -45) return BlockFace.EAST; + throw new IllegalArgumentException("angle must be number from -180 to 180"); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 9c73e65359..895fe1b2a0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -123,18 +123,22 @@ public void onBlockPlace(BlockPlaceEvent e) { } else { if (e.getBlock().getBlockData() instanceof Rotatable rotatable && !(rotatable.getRotation() == BlockFace.UP || rotatable.getRotation() == BlockFace.DOWN)) { + BlockFace rotation = null; + if (sfItem instanceof NotCardinallyRotatable && sfItem instanceof NotDiagonallyRotatable) { - rotatable.setRotation(BlockFace.NORTH); + rotation = BlockFace.NORTH; } else if (sfItem instanceof NotRotatable notRotatable) { - rotatable.setRotation(notRotatable.getRotation()); - } else if (sfItem instanceof NotCardinallyRotatable) { - rotatable.setRotation(LocationUtils.angleToNot90DegreeBlockFace( - e.getPlayer().getLocation().getYaw())); - } else if (sfItem instanceof NotDiagonallyRotatable) { - rotatable.setRotation(LocationUtils.angleToNotDiagonallyBlockFace( - e.getPlayer().getLocation().getYaw())); + rotation = notRotatable.getRotation(); + } else if (sfItem instanceof NotCardinallyRotatable notRotatable) { + rotation = notRotatable.getRotation(e.getPlayer().getLocation().getYaw()); + } else if (sfItem instanceof NotDiagonallyRotatable notRotatable) { + rotation = notRotatable.getRotation(e.getPlayer().getLocation().getYaw()); + } + + if (rotation != null) { + rotatable.setRotation(rotation); + e.getBlock().setBlockData(rotatable); } - e.getBlock().setBlockData(rotatable); } var placeEvent = new SlimefunBlockPlaceEvent(e.getPlayer(), item, e.getBlock(), sfItem); Bukkit.getPluginManager().callEvent(placeEvent); From 61ce8fb4ff82618cc144f89701a8e9571b96e8d8 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 17 Feb 2024 23:44:02 +0800 Subject: [PATCH 33/57] fix(block): completion upstream patch --- .../slimefun4/implementation/listeners/BlockListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 895fe1b2a0..9c2e4984a7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -354,7 +354,7 @@ public void onResult(SlimefunBlockData result) { */ @ParametersAreNonnullByDefault private void checkForSensitiveBlocks(Block block, Integer count, boolean isDropItems) { - if (count >= Bukkit.getServer().getMaxChainedNeighborUpdates()) { + /**if (count >= Bukkit.getServer().getMaxChainedNeighborUpdates()) { return; } @@ -375,6 +375,7 @@ private void checkForSensitiveBlocks(Block block, Integer count, boolean isDropI // Set the BlockData back: this makes it so containers and spawners drop correctly. This is a hacky fix. block.setBlockData(state.getBlockData(), false); state.update(true, false); + */ } /** From f2eea24f77612db9e76ff0cc80c501b46dd55375 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 17 Feb 2024 23:51:09 +0800 Subject: [PATCH 34/57] chore: spotless --- .../slimefun4/storage/util/LocationUtils.java | 1 - .../listeners/BlockListener.java | 48 +++++++++---------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index ad3ba3185e..72945573db 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -4,7 +4,6 @@ import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.block.BlockFace; public class LocationUtils { public static String getLocKey(Location l) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 9c2e4984a7..03f3c99983 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -2,7 +2,6 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback; import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; -import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils; import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import io.github.bakedlibs.dough.protection.Interaction; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; @@ -31,7 +30,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Rotatable; import org.bukkit.enchantments.Enchantment; @@ -130,9 +128,11 @@ public void onBlockPlace(BlockPlaceEvent e) { } else if (sfItem instanceof NotRotatable notRotatable) { rotation = notRotatable.getRotation(); } else if (sfItem instanceof NotCardinallyRotatable notRotatable) { - rotation = notRotatable.getRotation(e.getPlayer().getLocation().getYaw()); + rotation = notRotatable.getRotation( + e.getPlayer().getLocation().getYaw()); } else if (sfItem instanceof NotDiagonallyRotatable notRotatable) { - rotation = notRotatable.getRotation(e.getPlayer().getLocation().getYaw()); + rotation = notRotatable.getRotation( + e.getPlayer().getLocation().getYaw()); } if (rotation != null) { @@ -355,26 +355,26 @@ public void onResult(SlimefunBlockData result) { @ParametersAreNonnullByDefault private void checkForSensitiveBlocks(Block block, Integer count, boolean isDropItems) { /**if (count >= Bukkit.getServer().getMaxChainedNeighborUpdates()) { - return; - } - - BlockState state = block.getState(); - // We set the block to air to make use of BlockData#isSupported. - block.setType(Material.AIR, false); - for (BlockFace face : CARDINAL_BLOCKFACES) { - if (!isSupported(block.getRelative(face).getBlockData(), block.getRelative(face))) { - Block relative = block.getRelative(face); - if (!isDropItems) { - for (ItemStack drop : relative.getDrops()) { - block.getWorld().dropItemNaturally(relative.getLocation(), drop); - } - } - checkForSensitiveBlocks(relative, ++count, isDropItems); - } - } - // Set the BlockData back: this makes it so containers and spawners drop correctly. This is a hacky fix. - block.setBlockData(state.getBlockData(), false); - state.update(true, false); + * return; + * } + * + * BlockState state = block.getState(); + * // We set the block to air to make use of BlockData#isSupported. + * block.setType(Material.AIR, false); + * for (BlockFace face : CARDINAL_BLOCKFACES) { + * if (!isSupported(block.getRelative(face).getBlockData(), block.getRelative(face))) { + * Block relative = block.getRelative(face); + * if (!isDropItems) { + * for (ItemStack drop : relative.getDrops()) { + * block.getWorld().dropItemNaturally(relative.getLocation(), drop); + * } + * } + * checkForSensitiveBlocks(relative, ++count, isDropItems); + * } + * } + * // Set the BlockData back: this makes it so containers and spawners drop correctly. This is a hacky fix. + * block.setBlockData(state.getBlockData(), false); + * state.update(true, false); */ } From 537a04f6f85103d277d84d60100f7951bb7cb5e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 11:55:23 +0000 Subject: [PATCH 35/57] =?UTF-8?q?=F0=9F=94=A7=20Bump=20com.sk89q.worldedit?= =?UTF-8?q?:worldedit-core=20from=207.2.18=20to=207.2.19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps com.sk89q.worldedit:worldedit-core from 7.2.18 to 7.2.19. --- updated-dependencies: - dependency-name: com.sk89q.worldedit:worldedit-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2128521904..dd4874e6fe 100644 --- a/pom.xml +++ b/pom.xml @@ -321,7 +321,7 @@ com.sk89q.worldedit worldedit-core - 7.2.18 + 7.2.19 provided From 342db8d996afcb34339119c0b4eb38d22ff8da31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 08:11:19 +0800 Subject: [PATCH 36/57] chore(deps): bump org.postgresql:postgresql from 42.6.0 to 42.7.2 (cherry picked from commit 5f642d0346a1362b9c66d6b7c214c7b663024fb5) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dd4874e6fe..af10908f36 100644 --- a/pom.xml +++ b/pom.xml @@ -313,7 +313,7 @@ org.postgresql postgresql - 42.7.1 + 42.7.2 compile From 2af5301e5cc02bb69c976fe25aa4d756ffab9bad Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Fri, 23 Feb 2024 20:41:04 +0800 Subject: [PATCH 37/57] fix(hikari): use lower connection timeout --- .../slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java | 4 ++-- .../plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index 83070dc5d9..ae386ab666 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -47,8 +47,8 @@ public HikariDataSource createDataSource() { } config.setMaximumPoolSize(maxConnection); - config.setConnectionTimeout(29000); // set below 30s to avoid paper watchdog - config.setLeakDetectionThreshold(5000); + config.setConnectionTimeout(8000); // set below 30s to avoid watchdog + config.setLeakDetectionThreshold(2500); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index 9ed0a57967..9018468fab 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -11,8 +11,8 @@ public HikariDataSource createDataSource() { config.setJdbcUrl(jdbcUrl()); config.setPoolName("SlimefunHikariPool"); config.setMaximumPoolSize(maxConnection); - config.setConnectionTimeout(29000); // set below 30s to avoid paper watchdog - config.setLeakDetectionThreshold(5000); + config.setConnectionTimeout(9000); // set below 10s to avoid watchdog + config.setLeakDetectionThreshold(2500); return new HikariDataSource(config); } From 444c4590635ae37594f4fc05b2c6f36a315485ce Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Mon, 26 Feb 2024 17:20:01 +0800 Subject: [PATCH 38/57] fix(cargo): return invalid value if block data is not loaded --- .../slimefun4/core/networks/cargo/CargoNet.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java index 48e3d33bc6..0c7363a966 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java @@ -190,6 +190,9 @@ public void tick(@Nonnull Block b, SlimefunBlockData blockData) { for (Location node : outputNodes) { int frequency = getFrequency(node); + if (frequency == -1) { + continue; + } if (frequency != lastFrequency && lastFrequency != -1) { output.merge(lastFrequency, list, (prev, next) -> { @@ -227,18 +230,18 @@ public void tick(@Nonnull Block b, SlimefunBlockData blockData) { private static int getFrequency(@Nonnull Location node) { var data = StorageCacheUtils.getBlock(node); if (data == null) { - return 0; + return -1; } if (!data.isDataLoaded()) { StorageCacheUtils.requestLoad(data); - return 0; + return -1; } String frequency = data.getData("frequency"); if (frequency == null) { - return 0; + return -1; } else if (!CommonPatterns.NUMERIC.matcher(frequency).matches()) { Slimefun.logger() .log( @@ -253,7 +256,7 @@ private static int getFrequency(@Nonnull Location node) { + node.getBlockZ() + "): " + frequency); - return 0; + return -1; } else { return Integer.parseInt(frequency); } From e552440e8abb7dc1e588c130eb3da37ad84e02b9 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 3 Mar 2024 20:41:25 +0800 Subject: [PATCH 39/57] feat(core): add option to bypass env check --- .../city/norain/slimefun4/SlimefunExtended.java | 14 +++++++++++++- .../core/commands/subcommands/VersionsCommand.java | 6 ++++++ .../core/config/SlimefunConfigManager.java | 4 ++++ src/main/resources/config.yml | 4 +++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/city/norain/slimefun4/SlimefunExtended.java b/src/main/java/city/norain/slimefun4/SlimefunExtended.java index 691a6d8861..e743da823f 100644 --- a/src/main/java/city/norain/slimefun4/SlimefunExtended.java +++ b/src/main/java/city/norain/slimefun4/SlimefunExtended.java @@ -22,7 +22,19 @@ public static boolean checkEnvironment(@Nonnull Slimefun sf) { return false; } - return !EnvironmentChecker.checkIncompatiblePlugins(sf.getLogger()); + if (Slimefun.getConfigManager().isBypassEnvironmentCheck()) { + sf.getLogger().log(Level.WARNING, "#######################################################"); + sf.getLogger().log(Level.WARNING, ""); + sf.getLogger().log(Level.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + sf.getLogger().log(Level.WARNING, "检测到你禁用了环境兼容性检查!"); + sf.getLogger().log(Level.WARNING, "未通过兼容性检查将无法受到反馈支持."); + sf.getLogger().log(Level.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + sf.getLogger().log(Level.WARNING, ""); + sf.getLogger().log(Level.WARNING, "#######################################################"); + return true; + } else { + return !EnvironmentChecker.checkIncompatiblePlugins(sf.getLogger()); + } } public static void register(@Nonnull Slimefun sf) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java index b73c744cae..4a5e9addfe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java @@ -85,6 +85,12 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { .append("\n请不要将此版本信息截图到 Discord/Github 反馈 Bug" + "\n优先到汉化页面反馈" + "\n") .color(ChatColor.RED); + if (Slimefun.getConfigManager().isBypassEnvironmentCheck()) { + builder.append("\n").event((HoverEvent) null); + builder.append("\n已禁用环境兼容性检查") + .color(ChatColor.RED); + } + builder.append("\n").event((HoverEvent) null); addPluginVersions(builder); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java index 67299d764e..f7d045f755 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java @@ -65,6 +65,9 @@ public class SlimefunConfigManager { @Getter private boolean researchAutoConvert; + @Getter + private boolean bypassEnvironmentCheck; + public SlimefunConfigManager(@Nonnull Slimefun plugin) { Validate.notNull(plugin, "The Plugin instance cannot be null"); @@ -114,6 +117,7 @@ public boolean load(boolean reload) { showVanillaRecipes = pluginConfig.getBoolean("guide.show-vanilla-recipes"); showHiddenItemGroupsInSearch = pluginConfig.getBoolean("guide.show-hidden-item-groups-in-search"); autoUpdate = pluginConfig.getBoolean("options.auto-update"); + bypassEnvironmentCheck = pluginConfig.getBoolean("options.bypass-environment-check"); researchesConfig.setDefaultValue("researches.currency-cost-convert-rate", 25.0); researchCurrencyCostConvertRate = researchesConfig.getDouble("researches.currency-cost-convert-rate"); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c77d960358..ecf77ee0ac 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -10,11 +10,12 @@ # language - 粘液科技文本语言 (不包括物品) # enable-translations - 多语言功能 # backwards-compatibility - 物品向后兼容模式, 关闭后物品会使用新版物品系统 -# 将会提升服务器性能 +# 将会提升性能 # log-duplicate-block-entries - 是否输出发现重复方块的警告 # burn-players-when-radioactive - 是否在当玩家暴露在辐射中时灼烧玩家 # drop-excess-sf-give-items - 是否在背包已满时使用命令给予 Slimefun 物品直接掉落溢出的物品 # backup-data - 自动备份数据 +# bypass-environment-check - 跳过兼容性检查 (注意: 打开后将不予接受问题反馈) options: auto-update: true chat-prefix: '&a&lSlimefun 4 &7> ' @@ -35,6 +36,7 @@ options: drop-excess-sf-give-items: false backup-data: true drop-block-creative: true + bypass-environment-check: false guide: # 是否在指南中展示原版物品合成配方 From 451840d9d4af210dc981d77ececeb2257a65ba08 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 3 Mar 2024 20:43:10 +0800 Subject: [PATCH 40/57] chore: update incomp plugin list --- src/main/java/city/norain/slimefun4/EnvironmentChecker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/city/norain/slimefun4/EnvironmentChecker.java b/src/main/java/city/norain/slimefun4/EnvironmentChecker.java index 46c1f42320..4a66ade9a7 100644 --- a/src/main/java/city/norain/slimefun4/EnvironmentChecker.java +++ b/src/main/java/city/norain/slimefun4/EnvironmentChecker.java @@ -9,7 +9,7 @@ class EnvironmentChecker { private static final List UNSUPPORTED_PLUGINS = - List.of("BedrockTechnology", "SlimefunFix", "SlimefunBugFixer", "Slimefunbookfix", "MiraiMC"); + List.of("BedrockTechnology", "SlimefunFix", "SlimefunBugFixer", "Slimefunbookfix", "PlaceItemsOnGroundRebuilt"); static boolean checkIncompatiblePlugins(@Nonnull Logger logger) { List plugins = UNSUPPORTED_PLUGINS.stream() From 0c9ebfc222c45fac8e388eee39d1d3fec9060d4e Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 3 Mar 2024 21:29:02 +0800 Subject: [PATCH 41/57] chore: spotless --- src/main/java/city/norain/slimefun4/EnvironmentChecker.java | 4 ++-- .../slimefun4/core/commands/subcommands/VersionsCommand.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/city/norain/slimefun4/EnvironmentChecker.java b/src/main/java/city/norain/slimefun4/EnvironmentChecker.java index 4a66ade9a7..f44cd80c7c 100644 --- a/src/main/java/city/norain/slimefun4/EnvironmentChecker.java +++ b/src/main/java/city/norain/slimefun4/EnvironmentChecker.java @@ -8,8 +8,8 @@ import org.bukkit.Bukkit; class EnvironmentChecker { - private static final List UNSUPPORTED_PLUGINS = - List.of("BedrockTechnology", "SlimefunFix", "SlimefunBugFixer", "Slimefunbookfix", "PlaceItemsOnGroundRebuilt"); + private static final List UNSUPPORTED_PLUGINS = List.of( + "BedrockTechnology", "SlimefunFix", "SlimefunBugFixer", "Slimefunbookfix", "PlaceItemsOnGroundRebuilt"); static boolean checkIncompatiblePlugins(@Nonnull Logger logger) { List plugins = UNSUPPORTED_PLUGINS.stream() diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java index 4a5e9addfe..193f5c8ee4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java @@ -87,8 +87,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (Slimefun.getConfigManager().isBypassEnvironmentCheck()) { builder.append("\n").event((HoverEvent) null); - builder.append("\n已禁用环境兼容性检查") - .color(ChatColor.RED); + builder.append("\n已禁用环境兼容性检查").color(ChatColor.RED); } builder.append("\n").event((HoverEvent) null); From b0acc20ea6f512350375a47b8f112c46d5f1edee Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Mon, 4 Mar 2024 15:54:53 +0800 Subject: [PATCH 42/57] feat(controller): add remove data from all chunk in world if --- .../storage/controller/BlockDataController.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index 777a6bd949..7002760749 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -415,7 +415,6 @@ private void loadChunkData(SlimefunChunkData chunkData) { if (chunkData.isDataLoaded()) { return; } - getData(key) .forEach(data -> chunkData.setCacheInternal( data.get(FieldKey.DATA_KEY), @@ -593,6 +592,21 @@ public Set getAllLoadedChunkData(World world) { return re; } + public void removeFromAllChunkInWorld(World world, String key) { + var req = new RecordKey(DataScope.CHUNK_DATA); + req.addCondition(FieldKey.CHUNK, world.getName() + ";%"); + req.addCondition(FieldKey.DATA_KEY, key); + deleteData(req); + getAllLoadedChunkData(world).forEach(data -> data.removeData(key)); + } + + public void removeFromAllChunkInWorldAsync(World world, String key, Runnable onFinishedCallback) { + scheduleWriteTask(() -> { + removeFromAllChunkInWorld(world, key); + onFinishedCallback.run(); + }); + } + private void scheduleDelayedBlockInvUpdate(SlimefunBlockData blockData, int slot) { var scopeKey = new LocationKey(DataScope.NONE, blockData.getLocation()); var reqKey = new RecordKey(DataScope.BLOCK_INVENTORY); From 7b809546b9b8e063938a98ac4b6dfde784e52737 Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Sat, 9 Mar 2024 20:45:31 +0800 Subject: [PATCH 43/57] fix(controller): wrong data scope used for delete chunk data --- .../slimefun4/storage/controller/BlockDataController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index 7002760749..27685e2ff5 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -743,7 +743,7 @@ private SlimefunChunkData getChunkDataCache(Chunk chunk, boolean createOnNotExis } private void deleteChunkAndBlockDataDirectly(String cKey) { - var req = new RecordKey(DataScope.BLOCK_DATA); + var req = new RecordKey(DataScope.BLOCK_RECORD); req.addCondition(FieldKey.CHUNK, cKey); deleteData(req); From 5b560b36e921a7dee134a6b5f304bf0b9b699cf3 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <66861021+JWJUN233233@users.noreply.github.com> Date: Thu, 14 Mar 2024 22:22:00 +0800 Subject: [PATCH 44/57] chore: clean up codes --- .../subcommands/ClearDataCommand.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index 3a1dbe1b9b..b321309bfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -15,6 +15,7 @@ import org.bukkit.command.ConsoleCommandSender; public class ClearDataCommand extends SubCommand { + public static final List ValidClearTypes = List.of("block", "oil"); @ParametersAreNonnullByDefault public ClearDataCommand(Slimefun plugin, SlimefunCommand cmd) { super(plugin, cmd, "cleardata", false); @@ -24,29 +25,25 @@ public ClearDataCommand(Slimefun plugin, SlimefunCommand cmd) { public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (sender.hasPermission("slimefun.command.cleardata") || sender instanceof ConsoleCommandSender) { if (args.length == 4 && args[3].equalsIgnoreCase("confirm")) { - String arg1 = args[1]; - String arg2 = args[2]; List worlds = new ArrayList<>(); - List availableClearTypes = List.of("block", "oil"); List clearTypes = new ArrayList<>(); String block = Slimefun.getLocalization().getMessage("commands.cleardata.block"); String oil = Slimefun.getLocalization().getMessage("commands.cleardata.oil"); - SlimefunDatabaseManager database = Slimefun.getDatabaseManager(); - BlockDataController controller = database.getBlockDataController(); - if (arg1.equals("*")) { + BlockDataController controller = Slimefun.getDatabaseManager().getBlockDataController(); + if (args[1].equals("*")) { worlds.addAll(Bukkit.getWorlds()); } else { - World toAdd = Bukkit.getWorld(arg1); + World toAdd = Bukkit.getWorld(args[1]); if (toAdd == null) { Slimefun.getLocalization().sendMessage(sender, "commands.cleardata.worldNotFound", true); return; } } - if (arg2.equals("*")) { - clearTypes.addAll(availableClearTypes); - } else if (availableClearTypes.contains(arg2)) { - clearTypes.add(arg2); + if (args[2].equals("*")) { + clearTypes.addAll(ValidClearTypes); + } else if (ValidClearTypes.contains(args[2])) { + clearTypes.add(args[2]); } for (World world : worlds) { From 9242164298c08b3ac0e56f69889dbb079b3cca82 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 16 Mar 2024 05:23:07 +0800 Subject: [PATCH 45/57] style: spotless --- .../slimefun4/core/commands/subcommands/ClearDataCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index b321309bfc..17c79cfda4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -4,7 +4,6 @@ import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.config.SlimefunDatabaseManager; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.ArrayList; import java.util.List; @@ -16,6 +15,7 @@ public class ClearDataCommand extends SubCommand { public static final List ValidClearTypes = List.of("block", "oil"); + @ParametersAreNonnullByDefault public ClearDataCommand(Slimefun plugin, SlimefunCommand cmd) { super(plugin, cmd, "cleardata", false); From b87beb3c5f01dba7192b283a5c99afc7d519c2e3 Mon Sep 17 00:00:00 2001 From: Ddggdd135 <1306334428@qq.com> Date: Sat, 16 Mar 2024 21:55:18 +0800 Subject: [PATCH 46/57] chore: remove useless method remove "removeDataInWorld" remove "removeDataInWorldAsync" --- .../controller/BlockDataController.java | 19 ------------------- .../subcommands/ClearDataCommand.java | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index a9f130f62a..27685e2ff5 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -574,18 +574,6 @@ public void removeAllDataInWorld(World world) { loadedChunk.entrySet().removeIf(entry -> entry.getKey().startsWith(prefix)); } - public void removeDataInWorld(World world, String key) { - // remove data in cache - for (SlimefunChunkData data : loadedChunk.values()) { - if (LocationUtils.isSameWorld(data.getChunk().getWorld(), world)) data.removeData(key); - } - var re = new RecordKey(DataScope.CHUNK_DATA); - re.addCondition(FieldKey.CHUNK, world.getName() + ";%"); - re.addCondition(FieldKey.DATA_KEY, key); - - deleteData(re); - } - public void removeAllDataInWorldAsync(World world, Runnable onFinishedCallback) { scheduleWriteTask(() -> { removeAllDataInWorld(world); @@ -593,13 +581,6 @@ public void removeAllDataInWorldAsync(World world, Runnable onFinishedCallback) }); } - public void removeDataInWorldAsync(World world, String key, Runnable onFinishedCallback) { - scheduleWriteTask(() -> { - removeDataInWorld(world, key); - onFinishedCallback.run(); - }); - } - public Set getAllLoadedChunkData(World world) { var prefix = world.getName() + ";"; var re = new HashSet(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java index 17c79cfda4..6201a7e79b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java @@ -65,7 +65,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { oilresource = resource; } } - controller.removeDataInWorldAsync( + controller.removeFromAllChunkInWorldAsync( world, oilresource.getKey().toString().replace(":", "-"), () -> Slimefun.runSync(() -> Slimefun.getLocalization() From 2856acc87b8c48f2ac9d69970fca1e9dad8ea801 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 24 Mar 2024 18:48:55 +0800 Subject: [PATCH 47/57] fix(backup): error when backup folder contain invalid file --- .../slimefun4/core/services/BackupService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java index a64354d6c9..a86f73a675 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java @@ -130,17 +130,17 @@ private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directo * An {@link IOException} is thrown if a {@link File} could not be deleted */ private void purgeBackups(@Nonnull List backups) throws IOException { - Collections.sort(backups, (a, b) -> { + var matchedBackup = backups.stream().filter(f -> f.getName().matches("^\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}$")).sorted((a, b) -> { LocalDateTime time1 = LocalDateTime.parse(a.getName().substring(0, a.getName().length() - 4), format); LocalDateTime time2 = LocalDateTime.parse(b.getName().substring(0, b.getName().length() - 4), format); return time2.compareTo(time1); - }); + }).toList(); - for (int i = backups.size() - MAX_BACKUPS; i > 0; i--) { - Files.delete(backups.get(i).toPath()); + for (int i = matchedBackup.size() - MAX_BACKUPS; i > 0; i--) { + Files.delete(matchedBackup.get(i).toPath()); } } } From 5d336ec7efc2a18d52b9cc4c78e3eb7d88827b97 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 24 Mar 2024 18:55:57 +0800 Subject: [PATCH 48/57] =?UTF-8?q?fix(block):=20=E9=9D=9E=E5=B8=B8=E5=9D=8F?= =?UTF-8?q?=E6=9C=AB=E5=BD=B1=E4=BA=BA=20=E4=BD=BF=E6=88=91=E7=9A=84?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E6=8A=A5=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implementation/listeners/BlockPhysicsListener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index b5de686b58..c846e4a8cc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -97,6 +97,9 @@ public void onResult(SlimefunBlockData result) { block.setType(Material.AIR); } } + + // Don't move my machine :| + case ENDERMAN -> e.setCancelled(true); } } From 8db96a5af4823c8784bdc2c389e5fa77fb80f702 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 24 Mar 2024 19:08:11 +0800 Subject: [PATCH 49/57] chore: spotless --- .git-hooks/pre-commit | 19 ++++++------------ .../core/services/BackupService.java | 20 ++++++++++--------- .../listeners/BlockPhysicsListener.java | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 8b45be1ff0..6b17c8c3c5 100644 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -2,18 +2,11 @@ echo "[pre-commit check]" -STAGED_FILES=$(git --no-pager diff --name-only --staged --line-prefix=$(git rev-parse --show-toplevel)/ | paste -sd ',') - -if [ ! -z "$STAGED_FILES" ] +echo -n "Checking code format with spotless: " +mvn spotless:apply > /tmp/spotless.out 2>&1 +RETURN_VALUE=$? +if [ $RETURN_VALUE -gt 0 ] then - echo -n "Checking code format with spotless: " - mvn spotless:check -DspotlessFiles=$STAGED_FILES > /tmp/spotless.out 2>&1 - RETURN_VALUE=$? - if [ $RETURN_VALUE -gt 0 ] - then - echo "Please run 'mvn spotless:check' for more details or 'mvn spotless:apply' to automatically fix the violations." - fi - exit $RETURN_VALUE + echo "Please run 'mvn spotless:check' for more details or 'mvn spotless:apply' to automatically fix the violations." fi - -exit 0 \ No newline at end of file +exit $RETURN_VALUE \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java index a86f73a675..42b34889aa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java @@ -10,7 +10,6 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.logging.Level; @@ -130,14 +129,17 @@ private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directo * An {@link IOException} is thrown if a {@link File} could not be deleted */ private void purgeBackups(@Nonnull List backups) throws IOException { - var matchedBackup = backups.stream().filter(f -> f.getName().matches("^\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}$")).sorted((a, b) -> { - LocalDateTime time1 = - LocalDateTime.parse(a.getName().substring(0, a.getName().length() - 4), format); - LocalDateTime time2 = - LocalDateTime.parse(b.getName().substring(0, b.getName().length() - 4), format); - - return time2.compareTo(time1); - }).toList(); + var matchedBackup = backups.stream() + .filter(f -> f.getName().matches("^\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}$")) + .sorted((a, b) -> { + LocalDateTime time1 = LocalDateTime.parse( + a.getName().substring(0, a.getName().length() - 4), format); + LocalDateTime time2 = LocalDateTime.parse( + b.getName().substring(0, b.getName().length() - 4), format); + + return time2.compareTo(time1); + }) + .toList(); for (int i = matchedBackup.size() - MAX_BACKUPS; i > 0; i--) { Files.delete(matchedBackup.get(i).toPath()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index c846e4a8cc..4398191eee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -98,7 +98,7 @@ public void onResult(SlimefunBlockData result) { } } - // Don't move my machine :| + // Don't move my machine :| case ENDERMAN -> e.setCancelled(true); } } From 8244387e065c5b969994b67a6a927505a488e620 Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Sat, 30 Mar 2024 21:52:17 +0800 Subject: [PATCH 50/57] fix(util): do not generate chunk when getting chunk obj --- .../mc/plugin/slimefun4/storage/util/LocationUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index 72945573db..db03bc4585 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -39,7 +39,7 @@ public static boolean isSameLoc(Location l1, Location l2) { public static Chunk toChunk(World w, String cKey) { var loc = cKey.split(";")[1].split(":"); - return w.getChunkAt(Integer.parseInt(loc[0]), Integer.parseInt(loc[1])); + return w.getChunkAt(Integer.parseInt(loc[0]), Integer.parseInt(loc[1]), false); } public static boolean isSameWorld(World w1, World w2) { From 2d2e290bcf58110c96f2d51bd9c3602429154c00 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 31 Mar 2024 16:15:23 +0800 Subject: [PATCH 51/57] feat(database): refactor database debug log --- .../norain/slimefun4/utils/SimpleTimer.java | 33 +++++++++++++++++++ .../adapter/sqlcommon/SqlCommonAdapter.java | 22 ++++++++----- .../adapter/sqlcommon/SqlCommonConfig.java | 3 +- .../storage/adapter/sqlcommon/SqlUtils.java | 6 ---- .../storage/adapter/sqlite/SqliteAdapter.java | 9 +++++ .../storage/adapter/sqlite/SqliteConfig.java | 3 +- .../storage/controller/ADataController.java | 10 +----- 7 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 src/main/java/city/norain/slimefun4/utils/SimpleTimer.java diff --git a/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java b/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java new file mode 100644 index 0000000000..95eb7615d6 --- /dev/null +++ b/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java @@ -0,0 +1,33 @@ +package city.norain.slimefun4.utils; + +import java.time.Duration; +import java.time.LocalDateTime; + +public class SimpleTimer { + private final LocalDateTime startTime; + private Duration snapshot = null; + + public SimpleTimer() { + startTime = LocalDateTime.now(); + } + + public Duration duration() { + var duration = Duration.between(startTime, LocalDateTime.now()); + snapshot = duration; + return duration; + } + + public String durationStr() { + var duration = duration(); + return String.format("%d:%02d:%02d", duration.toHours(), duration.toMinutesPart(), + duration.toSecondsPart()); + } + + public boolean isTimeout(Duration duration) { + if (snapshot == null) { + return false; + } + + return snapshot.compareTo(duration) > 0; + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java index 781ba5d789..925dd95394 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java @@ -1,5 +1,6 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon; +import city.norain.slimefun4.utils.SimpleTimer; import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter; import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; @@ -8,6 +9,7 @@ import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.sql.SQLException; +import java.time.Duration; import java.util.List; import java.util.logging.Level; @@ -24,25 +26,29 @@ public void prepare(T config) { } protected void executeSql(String sql) { + var timer = new SimpleTimer(); + try (var conn = ds.getConnection()) { SqlUtils.execSql(conn, sql); } catch (SQLException e) { - if (Debug.hasTestCase(TestCase.DATABASE)) { - throw new IllegalStateException("An exception thrown while executing sql: " + sql, e); - } else { - Slimefun.logger().log(Level.WARNING, "在操作数据库出现了问题, 原始 SQL 语句: {0}", sql); + throw new IllegalStateException("An exception thrown while executing sql: " + sql, e); + } finally { + if (timer.isTimeout(Duration.ofSeconds(2))) { // FIXME: hardcode slow sql check duration + Debug.log(TestCase.DATABASE, "Detected slow sql costs {}, sql: {}", timer.durationStr(), sql); } } } protected List executeQuery(String sql) { + var timer = new SimpleTimer(); + try (var conn = ds.getConnection()) { return SqlUtils.execQuery(conn, sql); } catch (SQLException e) { - if (Debug.hasTestCase(TestCase.DATABASE)) { - throw new IllegalStateException("An exception thrown while executing sql: " + sql, e); - } else { - throw new IllegalStateException("在操作数据库出现了问题, 原始 SQL 语句: " + sql); + throw new IllegalStateException("An exception thrown while executing sql: " + sql, e); + } finally { + if (timer.isTimeout(Duration.ofSeconds(2))) { // FIXME: hardcode slow sql check duration + Debug.log(TestCase.DATABASE, "Detected slow sql costs {}, sql: {}", timer.durationStr(), sql); } } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index ae386ab666..efc2afc17b 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -47,8 +47,7 @@ public HikariDataSource createDataSource() { } config.setMaximumPoolSize(maxConnection); - config.setConnectionTimeout(8000); // set below 30s to avoid watchdog - config.setLeakDetectionThreshold(2500); + config.setLeakDetectionThreshold(20000); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java index d3ed2b8c23..c6acf5c536 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java @@ -122,8 +122,6 @@ public static String toSqlValStr(FieldKey key, String val) { } public static List execQuery(Connection conn, String sql) throws SQLException { - Debug.log(TestCase.DATABASE, "Prepare execute sql query: {}", sql); - try (var stmt = conn.createStatement()) { try (var result = stmt.executeQuery(sql)) { List re = null; @@ -148,16 +146,12 @@ public static List execQuery(Connection conn, String sql) throws SQLE } public static void execSql(Connection conn, String sql) throws SQLException { - Debug.log(TestCase.DATABASE, "Prepare execute sql statement: {}", sql); - try (var stmt = conn.createStatement()) { stmt.execute(sql); } } public static int execUpdate(Connection conn, String sql) throws SQLException { - Debug.log(TestCase.DATABASE, "Prepare execute update statement: {}", sql); - try (var stmt = conn.createStatement()) { return stmt.executeUpdate(sql); } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java index fcc3f4de93..90e1379e57 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java @@ -15,13 +15,17 @@ import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_RESEARCH_KEY; import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_SLIMEFUN_ID; +import city.norain.slimefun4.utils.SimpleTimer; import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonAdapter; import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils; import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; +import io.github.thebusybiscuit.slimefun4.core.debug.Debug; +import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; import java.sql.SQLException; +import java.time.Duration; import java.util.List; public class SqliteAdapter extends SqlCommonAdapter { @@ -316,10 +320,15 @@ public synchronized void executeSql(String sql) { } private synchronized int executeUpdate(String sql) { + var timer = new SimpleTimer(); try (var conn = ds.getConnection()) { return SqlUtils.execUpdate(conn, sql); } catch (SQLException e) { throw new IllegalStateException("An exception thrown while executing sql: " + sql, e); + } finally { + if (timer.isTimeout(Duration.ofSeconds(2))) { // FIXME: hardcode slow sql check duration + Debug.log(TestCase.DATABASE, "Detected slow sql costs {}, sql: {}", timer.durationStr(), sql); + } } } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index 9018468fab..70f0e44ff4 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -11,8 +11,7 @@ public HikariDataSource createDataSource() { config.setJdbcUrl(jdbcUrl()); config.setPoolName("SlimefunHikariPool"); config.setMaximumPoolSize(maxConnection); - config.setConnectionTimeout(9000); // set below 10s to avoid watchdog - config.setLeakDetectionThreshold(2500); + config.setLeakDetectionThreshold(20000); return new HikariDataSource(config); } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java index ca9b67a09d..79a9526af0 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java @@ -76,28 +76,20 @@ public void shutdown() { } protected void scheduleDeleteTask(ScopeKey scopeKey, RecordKey key, boolean forceScopeKey) { - Debug.log(TestCase.DATABASE, "Scheduled remove task for key = {}", key); - scheduleWriteTask( scopeKey, key, () -> { dataAdapter.deleteData(key); - Debug.log(TestCase.DATABASE, "Data from key {} deleted.", key); }, forceScopeKey); } protected void scheduleWriteTask(ScopeKey scopeKey, RecordKey key, RecordSet data, boolean forceScopeKey) { - Debug.log(TestCase.DATABASE, "Scheduled write task for key = {}, record set = {}", key, data.getAll()); - scheduleWriteTask( scopeKey, key, - () -> { - dataAdapter.setData(key, data); - Debug.log(TestCase.DATABASE, "Data from key {} set, with record set {}", key, data.getAll()); - }, + () -> dataAdapter.setData(key, data), forceScopeKey); } From 875f3bbb4f8929cec8a3c086e847c46d88f41e00 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 31 Mar 2024 16:38:25 +0800 Subject: [PATCH 52/57] fix: spotless lint --- .git-hooks/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 6b17c8c3c5..d234525d79 100644 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -3,7 +3,7 @@ echo "[pre-commit check]" echo -n "Checking code format with spotless: " -mvn spotless:apply > /tmp/spotless.out 2>&1 +mvn spotless:check > /tmp/spotless.out 2>&1 RETURN_VALUE=$? if [ $RETURN_VALUE -gt 0 ] then From fac61a0bc037d30fdd1ff4132b44cd8b0256b9e6 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 31 Mar 2024 16:39:04 +0800 Subject: [PATCH 53/57] chore: spotless --- .../java/city/norain/slimefun4/utils/SimpleTimer.java | 3 +-- .../storage/adapter/sqlcommon/SqlCommonAdapter.java | 2 -- .../slimefun4/storage/adapter/sqlcommon/SqlUtils.java | 2 -- .../slimefun4/storage/controller/ADataController.java | 8 +------- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java b/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java index 95eb7615d6..bf8bd4cb64 100644 --- a/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java +++ b/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java @@ -19,8 +19,7 @@ public Duration duration() { public String durationStr() { var duration = duration(); - return String.format("%d:%02d:%02d", duration.toHours(), duration.toMinutesPart(), - duration.toSecondsPart()); + return String.format("%d:%02d:%02d", duration.toHours(), duration.toMinutesPart(), duration.toSecondsPart()); } public boolean isTimeout(Duration duration) { diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java index 925dd95394..8d3ebe53ff 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonAdapter.java @@ -7,11 +7,9 @@ import com.zaxxer.hikari.HikariDataSource; import io.github.thebusybiscuit.slimefun4.core.debug.Debug; import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.sql.SQLException; import java.time.Duration; import java.util.List; -import java.util.logging.Level; public abstract class SqlCommonAdapter implements IDataSourceAdapter { protected HikariDataSource ds; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java index c6acf5c536..02cab7d1d2 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java @@ -28,8 +28,6 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.common.FieldMapper; import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; import io.github.bakedlibs.dough.collections.Pair; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; import java.sql.Connection; import java.sql.ResultSetMetaData; import java.sql.SQLException; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java index 79a9526af0..354b7466ec 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java @@ -8,8 +8,6 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.common.ScopeKey; import com.xzavier0722.mc.plugin.slimefun4.storage.task.DatabaseThreadFactory; import com.xzavier0722.mc.plugin.slimefun4.storage.task.QueuedWriteTask; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.List; import java.util.Map; @@ -86,11 +84,7 @@ protected void scheduleDeleteTask(ScopeKey scopeKey, RecordKey key, boolean forc } protected void scheduleWriteTask(ScopeKey scopeKey, RecordKey key, RecordSet data, boolean forceScopeKey) { - scheduleWriteTask( - scopeKey, - key, - () -> dataAdapter.setData(key, data), - forceScopeKey); + scheduleWriteTask(scopeKey, key, () -> dataAdapter.setData(key, data), forceScopeKey); } protected void scheduleWriteTask(ScopeKey scopeKey, RecordKey key, Runnable task, boolean forceScopeKey) { From 30350664003d9fb59306ea0c72a552717e6e538e Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 31 Mar 2024 16:53:13 +0800 Subject: [PATCH 54/57] fix(timer): fix duplicate calculate duration --- src/main/java/city/norain/slimefun4/utils/SimpleTimer.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java b/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java index bf8bd4cb64..6d6342ace7 100644 --- a/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java +++ b/src/main/java/city/norain/slimefun4/utils/SimpleTimer.java @@ -18,8 +18,11 @@ public Duration duration() { } public String durationStr() { - var duration = duration(); - return String.format("%d:%02d:%02d", duration.toHours(), duration.toMinutesPart(), duration.toSecondsPart()); + if (snapshot == null) { + snapshot = duration(); + } + + return String.format("%d:%02d:%02d", snapshot.toHours(), snapshot.toMinutesPart(), snapshot.toSecondsPart()); } public boolean isTimeout(Duration duration) { From e616c2fe48658a74f394e1462285189a76b98f39 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 31 Mar 2024 20:13:28 +0800 Subject: [PATCH 55/57] chore: lower leak check duration --- .../adapter/sqlcommon/SqlCommonConfig.java | 2 +- .../storage/adapter/sqlite/SqliteConfig.java | 2 +- .../slimefun4/implementation/Slimefun.java | 24 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index efc2afc17b..30447042a3 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -47,7 +47,7 @@ public HikariDataSource createDataSource() { } config.setMaximumPoolSize(maxConnection); - config.setLeakDetectionThreshold(20000); + config.setLeakDetectionThreshold(3000); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index 70f0e44ff4..df28a6da4e 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -11,7 +11,7 @@ public HikariDataSource createDataSource() { config.setJdbcUrl(jdbcUrl()); config.setPoolName("SlimefunHikariPool"); config.setMaximumPoolSize(maxConnection); - config.setLeakDetectionThreshold(20000); + config.setLeakDetectionThreshold(3000); return new HikariDataSource(config); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java index 821cc9021f..031931e5ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -462,17 +462,19 @@ public void onDisable() { Bukkit.getScheduler().cancelTasks(this); // Finishes all started movements/removals of block data - try { - ticker.halt(); - ticker.run(); - } catch (Exception x) { - getLogger() - .log( - Level.SEVERE, - x, - () -> "Something went wrong while disabling the ticker task for Slimefun v" - + getDescription().getVersion()); - } + ticker.setPaused(true); + ticker.halt(); + /**try { + * ticker.halt(); + * ticker.run(); + * } catch (Exception x) { + * getLogger() + * .log( + * Level.SEVERE, + * x, + * () -> "Something went wrong while disabling the ticker task for Slimefun v" + * + getDescription().getVersion()); + * }*/ // Kill our Profiler Threads profiler.kill(); From d6f1a90a3585c497a43481375e3da2ab92ce39b1 Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Tue, 2 Apr 2024 13:15:12 +0800 Subject: [PATCH 56/57] fix(lang): add radiation actionbar text. fixes #852 --- src/main/resources/languages/zh-CN/messages.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/languages/zh-CN/messages.yml b/src/main/resources/languages/zh-CN/messages.yml index 2473f1c9eb..004b84933b 100644 --- a/src/main/resources/languages/zh-CN/messages.yml +++ b/src/main/resources/languages/zh-CN/messages.yml @@ -152,6 +152,10 @@ guide: wiki: '&3Wiki 编辑者' resourcepack: '&c材质制作者' translator: '&9翻译者' + +actionbar: + radiation: '&6辐射暴露等级:&c%level%&7/&e100' + messages: android-no-permission: "&c你的机器人在某个你没有权限的领地/地皮中无法工作, 机器人已自动暂停运行." transform: From d549937fb4c5ea397dc732962c0d57d3b9993ee3 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Tue, 2 Apr 2024 20:32:07 +0800 Subject: [PATCH 57/57] fix(block): `SlimefunPlaceEvent` is invalid --- .../implementation/listeners/BlockListener.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 03f3c99983..0b67a5e0a2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -143,10 +143,18 @@ public void onBlockPlace(BlockPlaceEvent e) { var placeEvent = new SlimefunBlockPlaceEvent(e.getPlayer(), item, e.getBlock(), sfItem); Bukkit.getPluginManager().callEvent(placeEvent); - Slimefun.getDatabaseManager() - .getBlockDataController() - .createBlock(e.getBlock().getLocation(), sfItem.getId()); - sfItem.callItemHandler(BlockPlaceHandler.class, handler -> handler.onPlayerPlace(e)); + if (placeEvent.isCancelled()) { + e.setCancelled(true); + } else { + if (Slimefun.getBlockDataService().isTileEntity(e.getBlock().getType())) { + Slimefun.getBlockDataService().setBlockData(e.getBlock(), sfItem.getId()); + } + + Slimefun.getDatabaseManager() + .getBlockDataController() + .createBlock(e.getBlock().getLocation(), sfItem.getId()); + sfItem.callItemHandler(BlockPlaceHandler.class, handler -> handler.onPlayerPlace(e)); + } } } }