From 2c8622764a8f6f022af508904034f4d899fc7211 Mon Sep 17 00:00:00 2001 From: Taah Date: Sun, 10 Apr 2022 17:48:41 -0700 Subject: [PATCH] update plex --- build.gradle.kts | 9 +++--- .../plex/listener/BukkitTelnetListener.java | 30 +++++++++++++++---- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c579ef2..6c6c0cc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,14 +7,13 @@ group "dev.plex" version "0.1" repositories { - mavenLocal() mavenCentral() maven { url = uri("https://papermc.io/repo/repository/maven-public/") } maven { - url = uri("https://nexus.telesphoreo.me/repository/plex") + url = uri("https://nexus.telesphoreo.me/repository/plex-snapshots/") } maven { @@ -29,11 +28,13 @@ dependencies { compileOnly("org.projectlombok:lombok:1.18.22") annotationProcessor("org.projectlombok:lombok:1.18.22") compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT") - compileOnly("dev.plex:Plex:0.10-SNAPSHOT") + compileOnly("dev.plex:Plex:1.0.1-SNAPSHOT") compileOnly("me.totalfreedom:BukkitTelnet:4.7") { exclude("org.spigotmc", "spigot-api") } - compileOnly("com.github.MilkBowl:VaultAPI:1.7") + compileOnly("com.github.MilkBowl:VaultAPI:1.7") { + exclude("org.bukkit", "bukkit") + } } tasks { diff --git a/src/main/java/dev/plex/listener/BukkitTelnetListener.java b/src/main/java/dev/plex/listener/BukkitTelnetListener.java index e6b5570..45d5782 100644 --- a/src/main/java/dev/plex/listener/BukkitTelnetListener.java +++ b/src/main/java/dev/plex/listener/BukkitTelnetListener.java @@ -5,31 +5,39 @@ 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.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.UUID; +import java.util.List; -public class BukkitTelnetListener extends PlexListener { +public class BukkitTelnetListener extends PlexListener +{ @EventHandler - public void onPreLogin(TelnetPreLoginEvent event) { + public void onPreLogin(TelnetPreLoginEvent event) + { final String ip = event.getIp(); final PlexPlayer player = DataUtils.getPlayerByIP(ip); if (player == null) return; if (plugin.getSystem().equalsIgnoreCase("ranks")) { PlexLog.debug("Plex-BukkitTelnet using ranks check"); - if (player.getRankFromString().isAtLeast(Rank.ADMIN)) { + if (player.getRankFromString().isAtLeast(Rank.ADMIN)) + { event.setBypassPassword(true); event.setName(player.getName()); } } else if (plugin.getSystem().equalsIgnoreCase("permissions")) { PlexLog.debug("Plex-BukkitTelnet using permissions check"); - final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(player.getUuid())); - if (BukkitTelnetModule.getModule().getPermissions().playerHas(null, offlinePlayer, "plex.telnet.autoconnect")) { + final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.getUuid()); + if (BukkitTelnetModule.getModule().getPermissions().playerHas(null, offlinePlayer, "plex.telnet.autoconnect")) + { event.setBypassPassword(true); event.setName(player.getName()); } @@ -37,4 +45,14 @@ public class BukkitTelnetListener extends PlexListener { } + @EventHandler + public void onCommand(TelnetCommandEvent event) + { + if (!plugin.getSystem().equalsIgnoreCase("permissions")) + { + return; + } + //TODO: check players perms + } + }