From c55bc8c05f49d5697a1284a1f88a4246290a6c05 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sat, 23 Oct 2021 19:36:59 +0200 Subject: [PATCH] refactor: Move update checker to core feat: Add permission for tracing --- .../sk89q/worldedit/bukkit/WorldEditListener.java | 2 +- .../sk89q/worldedit/bukkit/WorldEditPlugin.java | 2 +- .../core}/util/UpdateNotification.java | 15 ++++++--------- .../worldedit/command/WorldEditCommands.java | 3 +++ .../command/util/CommandPermissions.java | 2 ++ 5 files changed, 13 insertions(+), 11 deletions(-) rename {worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit => worldedit-core/src/main/java/com/fastasyncworldedit/core}/util/UpdateNotification.java (89%) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java index 654d444d4..abdd4c16f 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java @@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit; -import com.fastasyncworldedit.bukkit.util.UpdateNotification; +import com.fastasyncworldedit.core.util.UpdateNotification; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 43a597f4d..6e93f0c19 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit; import com.fastasyncworldedit.bukkit.BukkitPermissionAttachmentManager; import com.fastasyncworldedit.bukkit.FaweBukkit; -import com.fastasyncworldedit.bukkit.util.UpdateNotification; +import com.fastasyncworldedit.core.util.UpdateNotification; import com.fastasyncworldedit.core.Fawe; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/UpdateNotification.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java similarity index 89% rename from worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/UpdateNotification.java rename to worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java index 8ac088d90..14a987396 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/UpdateNotification.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java @@ -1,10 +1,10 @@ -package com.fastasyncworldedit.bukkit.util; +package com.fastasyncworldedit.core.util; import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.FaweVersion; import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Settings; -import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; @@ -15,9 +15,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.net.URL; -/** - * - */ public class UpdateNotification { private static final Logger LOGGER = LogManagerCompat.getLogger(); @@ -63,14 +60,14 @@ public class UpdateNotification { /** * Trigger an update notification based on captions. Useful to notify server administrators ingame. * - * @param player The player to notify. + * @param actor The player to notify. */ - public static void doUpdateNotification(Player player) { + public static void doUpdateNotification(Actor actor) { if (Settings.IMP.ENABLED_COMPONENTS.UPDATE_NOTIFICATIONS) { - if (player.hasPermission("fawe.admin") && UpdateNotification.hasUpdate) { + if (actor.hasPermission("fawe.admin") && UpdateNotification.hasUpdate) { FaweVersion faweVersion = Fawe.get().getVersion(); int versionDifference = Integer.parseInt(UpdateNotification.faweVersion) - faweVersion.build; - player.print(Caption.of("fawe.info.update-available", versionDifference, faweVersion.toString(), + actor.print(Caption.of("fawe.info.update-available", versionDifference, faweVersion.toString(), faweVersion.getSimpleVersionName() + "-" + UpdateNotification.faweVersion, TextComponent .of("https://www.spigotmc.org/resources/13932/") diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 9fe5922cf..2c767fad2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -23,6 +23,7 @@ import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.FaweVersion; import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Settings; +import com.fastasyncworldedit.core.util.UpdateNotification; import com.intellectualsites.paster.IncendoPaster; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -98,6 +99,7 @@ public class WorldEditCommands { } actor.printInfo(TextComponent.of("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/wiki")); + UpdateNotification.doUpdateNotification(actor); //FAWE end PlatformManager pm = we.getPlatformManager(); @@ -187,6 +189,7 @@ public class WorldEditCommands { name = "trace", desc = "Toggles trace hook" ) + @CommandPermissions(value = "worldedit.trace", queued = false) void trace( Actor actor, LocalSession session, @Arg(desc = "The mode to set the trace hook to", def = "") diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandPermissions.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandPermissions.java index d174d18f6..219758c79 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandPermissions.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandPermissions.java @@ -36,6 +36,8 @@ public @interface CommandPermissions { */ String[] value() default {}; + //FAWE start boolean queued() default true; + //FAWE end }