refactor: Move update checker to core

feat: Add permission for tracing
This commit is contained in:
NotMyFault 2021-10-23 19:36:59 +02:00
parent 3d70d9e496
commit c55bc8c05f
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
5 changed files with 13 additions and 11 deletions

View File

@ -21,7 +21,7 @@
package com.sk89q.worldedit.bukkit; 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.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;

View File

@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit;
import com.fastasyncworldedit.bukkit.BukkitPermissionAttachmentManager; import com.fastasyncworldedit.bukkit.BukkitPermissionAttachmentManager;
import com.fastasyncworldedit.bukkit.FaweBukkit; import com.fastasyncworldedit.bukkit.FaweBukkit;
import com.fastasyncworldedit.bukkit.util.UpdateNotification; import com.fastasyncworldedit.core.util.UpdateNotification;
import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.Fawe;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;

View File

@ -1,10 +1,10 @@
package com.fastasyncworldedit.bukkit.util; package com.fastasyncworldedit.core.util;
import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweVersion; import com.fastasyncworldedit.core.FaweVersion;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings; 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.internal.util.LogManagerCompat;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
@ -15,9 +15,6 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.net.URL; import java.net.URL;
/**
*
*/
public class UpdateNotification { public class UpdateNotification {
private static final Logger LOGGER = LogManagerCompat.getLogger(); 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. * 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 (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(); FaweVersion faweVersion = Fawe.get().getVersion();
int versionDifference = Integer.parseInt(UpdateNotification.faweVersion) - faweVersion.build; 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, faweVersion.getSimpleVersionName() + "-" + UpdateNotification.faweVersion,
TextComponent TextComponent
.of("https://www.spigotmc.org/resources/13932/") .of("https://www.spigotmc.org/resources/13932/")

View File

@ -23,6 +23,7 @@ import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweVersion; import com.fastasyncworldedit.core.FaweVersion;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.util.UpdateNotification;
import com.intellectualsites.paster.IncendoPaster; import com.intellectualsites.paster.IncendoPaster;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -98,6 +99,7 @@ public class WorldEditCommands {
} }
actor.printInfo(TextComponent.of("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/wiki")); actor.printInfo(TextComponent.of("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/wiki"));
UpdateNotification.doUpdateNotification(actor);
//FAWE end //FAWE end
PlatformManager pm = we.getPlatformManager(); PlatformManager pm = we.getPlatformManager();
@ -187,6 +189,7 @@ public class WorldEditCommands {
name = "trace", name = "trace",
desc = "Toggles trace hook" desc = "Toggles trace hook"
) )
@CommandPermissions(value = "worldedit.trace", queued = false)
void trace( void trace(
Actor actor, LocalSession session, Actor actor, LocalSession session,
@Arg(desc = "The mode to set the trace hook to", def = "") @Arg(desc = "The mode to set the trace hook to", def = "")

View File

@ -36,6 +36,8 @@ public @interface CommandPermissions {
*/ */
String[] value() default {}; String[] value() default {};
//FAWE start
boolean queued() default true; boolean queued() default true;
//FAWE end
} }