fix(chunkloader): release tickets on disable/toggle, fix BlueMap world matching, and prevent item loss on remove
This commit is contained in:
@@ -147,8 +147,12 @@ final class BlueMapBridge {
|
|||||||
}
|
}
|
||||||
String mapId = map.getId().toLowerCase(java.util.Locale.ROOT);
|
String mapId = map.getId().toLowerCase(java.util.Locale.ROOT);
|
||||||
String w = world.toLowerCase(java.util.Locale.ROOT);
|
String w = world.toLowerCase(java.util.Locale.ROOT);
|
||||||
if (w.contains("nether")) return mapId.contains("nether");
|
if (w.endsWith("_nether") || w.equals("nether") || w.equals("world_nether")) {
|
||||||
if (w.contains("the_end") || w.contains("end")) return mapId.contains("end");
|
return mapId.contains("nether");
|
||||||
|
}
|
||||||
|
if (w.endsWith("_the_end") || w.equals("the_end") || w.equals("world_the_end") || w.equals("end")) {
|
||||||
|
return mapId.contains("end");
|
||||||
|
}
|
||||||
return !mapId.contains("nether") && !mapId.contains("end");
|
return !mapId.contains("nether") && !mapId.contains("end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,11 @@ public final class Canalhandia extends JavaPlugin implements Listener {
|
|||||||
if (poll != null) {
|
if (poll != null) {
|
||||||
poll.hide();
|
poll.hide();
|
||||||
}
|
}
|
||||||
|
if (chunkLoaders != null) {
|
||||||
|
chunkLoaders.unloadAllTickets();
|
||||||
|
chunkLoaders.close();
|
||||||
|
ChunkAnchorItem.unregisterRecipe(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings settings() {
|
Settings settings() {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -566,6 +567,16 @@ final class CanalhandiaCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
boolean on = args[1].equalsIgnoreCase("on");
|
boolean on = args[1].equalsIgnoreCase("on");
|
||||||
plugin.settings().moduleEnabled(module, on);
|
plugin.settings().moduleEnabled(module, on);
|
||||||
|
if (module == Module.CHUNKLOADER) {
|
||||||
|
if (on) {
|
||||||
|
plugin.chunkLoaders().loadAllTickets();
|
||||||
|
ChunkAnchorItem.registerRecipe(plugin);
|
||||||
|
} else {
|
||||||
|
plugin.chunkLoaders().unloadAllTickets();
|
||||||
|
ChunkAnchorItem.unregisterRecipe(plugin);
|
||||||
|
}
|
||||||
|
plugin.blueMap().syncChunkLoaders();
|
||||||
|
}
|
||||||
plugin.rescheduleTimer();
|
plugin.rescheduleTimer();
|
||||||
plugin.rescheduleMilestones();
|
plugin.rescheduleMilestones();
|
||||||
Msg.ok(sender, "Módulo " + module.label() + " " + (on ? "ativado" : "desativado") + ".");
|
Msg.ok(sender, "Módulo " + module.label() + " " + (on ? "ativado" : "desativado") + ".");
|
||||||
@@ -1930,10 +1941,22 @@ final class CanalhandiaCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player player) {
|
if (sender instanceof Player player) {
|
||||||
player.getInventory().addItem(ChunkAnchorItem.create(plugin, 1));
|
Map<Integer, ItemStack> overflow = player.getInventory().addItem(ChunkAnchorItem.create(plugin, 1));
|
||||||
|
for (ItemStack drop : overflow.values()) {
|
||||||
|
player.getWorld().dropItemNaturally(player.getLocation(), drop);
|
||||||
|
}
|
||||||
|
Msg.ok(sender, "Âncora de Chunk #" + id + " desativada e devolvida ao inventário.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
org.bukkit.World w = Bukkit.getWorld(loader.world());
|
||||||
|
if (w != null) {
|
||||||
|
w.dropItemNaturally(new Location(w, loader.x() + 0.5, loader.y() + 0.5, loader.z() + 0.5),
|
||||||
|
ChunkAnchorItem.create(plugin, 1));
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
Msg.ok(sender, "Âncora de Chunk #" + id + " desativada e dropada em " + loader.place() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg.ok(sender, "Âncora de Chunk #" + id + " desativada e devolvida ao inventário.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chunkloaderRecipe(CommandSender sender) {
|
private void chunkloaderRecipe(CommandSender sender) {
|
||||||
|
|||||||
@@ -281,4 +281,9 @@ final class ChunkLoaders {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void close() {
|
||||||
|
flush();
|
||||||
|
io.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user