diff --git a/worldguard-bukkit/build.gradle.kts b/worldguard-bukkit/build.gradle.kts index 5a03aa8aa..38a014749 100644 --- a/worldguard-bukkit/build.gradle.kts +++ b/worldguard-bukkit/build.gradle.kts @@ -20,8 +20,8 @@ configurations { dependencies { "api"(project(":worldguard-core")) - "compileOnly"("io.papermc.paper:paper-api:1.20-R0.1-SNAPSHOT") - "runtimeOnly"("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") { + "compileOnly"("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") + "runtimeOnly"("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT") { exclude("junit", "junit") } "api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false } diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java index 3e898e197..7428a3306 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java @@ -34,8 +34,9 @@ public class BukkitConfigurationManager extends YamlConfigurationManager { @Unreported private WorldGuardPlugin plugin; @Unreported private ConcurrentMap worlds = new ConcurrentHashMap<>(); - + private boolean isFreshInstall; private boolean hasCommandBookGodMode; + boolean disableGeneralCommands; boolean extraStats; /** @@ -56,6 +57,8 @@ public Collection getWorldConfigs() { public void load() { super.load(); this.extraStats = getConfig().getBoolean("custom-metrics-charts", true); + // Disable legacy commands for fresh installs + this.disableGeneralCommands = getConfig().getBoolean("disable-general-commands", isFreshInstall); } @Override @@ -66,7 +69,7 @@ public File getDataFolder() { @Override public void copyDefaults() { // Create the default configuration file - plugin.createDefaultConfiguration(new File(plugin.getDataFolder(), "config.yml"), "config.yml"); + isFreshInstall = plugin.createDefaultConfiguration(new File(plugin.getDataFolder(), "config.yml"), "config.yml"); } @Override diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java index 3ba997921..ca3bf0984 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java @@ -160,7 +160,7 @@ public void onEnable() { reg.register(ToggleCommands.class); reg.register(ProtectionCommands.class); - if (!platform.getGlobalStateManager().hasCommandBookGodMode()) { + if (!platform.getGlobalStateManager().disableGeneralCommands && !platform.getGlobalStateManager().hasCommandBookGodMode()) { reg.register(GeneralCommands.class); } @@ -488,7 +488,7 @@ private void configureLogger() { * @param actual The destination file * @param defaultName The name of the file inside the jar's defaults folder */ - public void createDefaultConfiguration(File actual, String defaultName) { + public boolean createDefaultConfiguration(File actual, String defaultName) { // Make parent directories File parent = actual.getParentFile(); @@ -497,7 +497,7 @@ public void createDefaultConfiguration(File actual, String defaultName) { } if (actual.exists()) { - return; + return false; } try (InputStream stream = getResource("defaults/" + defaultName)){ @@ -506,7 +506,7 @@ public void createDefaultConfiguration(File actual, String defaultName) { } catch (IOException e) { getLogger().severe("Unable to read default configuration: " + defaultName); } - + return true; } private void copyDefaultConfig(InputStream input, File actual, String name) { diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index d35483d43..3c7af7762 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -47,6 +47,7 @@ import com.sk89q.worldguard.config.WorldConfiguration; import com.sk89q.worldguard.protection.flags.Flags; import io.papermc.lib.PaperLib; +import io.papermc.paper.event.player.PlayerOpenSignEvent; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.GameMode; @@ -1266,5 +1267,13 @@ private class PaperListener implements Listener { public void onEntityTransform(EntityZapEvent event) { Events.fireToCancel(event, new DamageEntityEvent(event, create(event.getBolt()), event.getEntity())); } + + @EventHandler(ignoreCancelled = true) + public void onSignOpen(PlayerOpenSignEvent event) { + if (event.getCause() == PlayerOpenSignEvent.Cause.INTERACT) { + // other cases are handled by other events + Events.fireToCancel(event, new UseBlockEvent(event, create(event.getPlayer()), event.getSign().getBlock())); + } + } } } diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/PlayerMoveListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/PlayerMoveListener.java index 0db9cf825..11c5631c4 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/PlayerMoveListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/PlayerMoveListener.java @@ -60,7 +60,7 @@ public void registerEvents() { } } - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerRespawn(PlayerRespawnEvent event) { LocalPlayer player = getPlugin().wrapPlayer(event.getPlayer()); diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java index 1f87de9a7..c99fa0a63 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java @@ -1343,7 +1343,8 @@ public static boolean isConsideredBuildingIfUsed(Material type) { || type == Material.DRAGON_EGG || Tag.FLOWER_POTS.isTagged(type) || Tag.CANDLES.isTagged(type) - || Tag.CANDLE_CAKES.isTagged(type); + || Tag.CANDLE_CAKES.isTagged(type) + || Tag.ALL_SIGNS.isTagged(type); } /**