From a3fac0a8ad929cd6b1d3c7a0d9a638e5e3148653 Mon Sep 17 00:00:00 2001 From: Taah Date: Sun, 10 Apr 2022 22:01:34 -0700 Subject: [PATCH] update bukkit telnet --- build.gradle.kts | 7 +++---- .../java/dev/plex/BukkitTelnetModule.java | 14 ++++--------- .../plex/listener/BukkitTelnetListener.java | 20 ++----------------- 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6c6c0cc..4f682b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,6 +8,7 @@ version "0.1" repositories { mavenCentral() + mavenLocal() maven { url = uri("https://papermc.io/repo/repository/maven-public/") } @@ -29,12 +30,9 @@ dependencies { annotationProcessor("org.projectlombok:lombok:1.18.22") compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT") compileOnly("dev.plex:Plex:1.0.1-SNAPSHOT") - compileOnly("me.totalfreedom:BukkitTelnet:4.7") { + compileOnly("me.totalfreedom:bukkittelnet:4.8-SNAPSHOT") { exclude("org.spigotmc", "spigot-api") } - compileOnly("com.github.MilkBowl:VaultAPI:1.7") { - exclude("org.bukkit", "bukkit") - } } tasks { @@ -65,5 +63,6 @@ publishing { tasks.getByName("jar") { archiveBaseName.set("Plex-BukkitTelnet") + archiveVersion.set("") } diff --git a/src/main/java/dev/plex/BukkitTelnetModule.java b/src/main/java/dev/plex/BukkitTelnetModule.java index 44f944e..0ac272e 100644 --- a/src/main/java/dev/plex/BukkitTelnetModule.java +++ b/src/main/java/dev/plex/BukkitTelnetModule.java @@ -3,6 +3,7 @@ package dev.plex; import dev.plex.listener.BukkitTelnetListener; import dev.plex.module.PlexModule; import lombok.Getter; +import me.totalfreedom.bukkittelnet.BukkitTelnet; import net.milkbowl.vault.permission.Permission; import org.bukkit.Bukkit; import org.bukkit.plugin.RegisteredServiceProvider; @@ -12,8 +13,7 @@ public class BukkitTelnetModule extends PlexModule @Getter private static BukkitTelnetModule module; - @Getter - private Permission permissions = null; + private BukkitTelnet bukkitTelnet; @Override public void load() @@ -24,23 +24,17 @@ public class BukkitTelnetModule extends PlexModule @Override public void enable() { - if (!setupPermissions() && getPlex().getSystem().equalsIgnoreCase("permissions") && !Bukkit.getPluginManager().isPluginEnabled("Vault")) + if (getPlex().getSystem().equalsIgnoreCase("permissions") && !Bukkit.getPluginManager().isPluginEnabled("Vault")) { throw new RuntimeException("Plex-BukkitTelnet requires the 'Vault' plugin as well as a Permissions plugin that hooks into 'Vault.' We recommend LuckPerms!"); } this.registerListener(new BukkitTelnetListener()); + this.bukkitTelnet = BukkitTelnet.getPlugin(); } @Override public void disable() { } - - private boolean setupPermissions() - { - RegisteredServiceProvider rsp = Bukkit.getServicesManager().getRegistration(Permission.class); - permissions = rsp.getProvider(); - return permissions != null; - } } diff --git a/src/main/java/dev/plex/listener/BukkitTelnetListener.java b/src/main/java/dev/plex/listener/BukkitTelnetListener.java index 45d5782..0f7825d 100644 --- a/src/main/java/dev/plex/listener/BukkitTelnetListener.java +++ b/src/main/java/dev/plex/listener/BukkitTelnetListener.java @@ -1,20 +1,15 @@ package dev.plex.listener; -import dev.plex.BukkitTelnetModule; import dev.plex.cache.DataUtils; import dev.plex.player.PlexPlayer; import dev.plex.rank.enums.Rank; import dev.plex.util.PlexLog; +import me.totalfreedom.bukkittelnet.BukkitTelnet; import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent; import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.PluginCommandYamlParser; import org.bukkit.event.EventHandler; -import org.jetbrains.annotations.NotNull; - -import java.util.List; public class BukkitTelnetListener extends PlexListener { @@ -35,8 +30,7 @@ public class BukkitTelnetListener extends PlexListener } else if (plugin.getSystem().equalsIgnoreCase("permissions")) { PlexLog.debug("Plex-BukkitTelnet using permissions check"); - final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.getUuid()); - if (BukkitTelnetModule.getModule().getPermissions().playerHas(null, offlinePlayer, "plex.telnet.autoconnect")) + if (BukkitTelnet.getPlugin().handler.hasPermission(player.getName(), "plex.telnet.autoconnect")) { event.setBypassPassword(true); event.setName(player.getName()); @@ -45,14 +39,4 @@ public class BukkitTelnetListener extends PlexListener } - @EventHandler - public void onCommand(TelnetCommandEvent event) - { - if (!plugin.getSystem().equalsIgnoreCase("permissions")) - { - return; - } - //TODO: check players perms - } - }