diff --git a/build.gradle.kts b/build.gradle.kts index c579ef2..feab28d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,12 +3,15 @@ plugins { `maven-publish` } -group "dev.plex" -version "0.1" +group = "dev.plex" +description = "Module-BukkitTelnet" +version = "1.0" repositories { mavenLocal() + mavenCentral() + maven { url = uri("https://papermc.io/repo/repository/maven-public/") } @@ -20,6 +23,7 @@ repositories { maven { url = uri("https://nexus.telesphoreo.me/repository/totalfreedom") } + maven { url = uri("https://jitpack.io") } @@ -63,6 +67,6 @@ publishing { } tasks.getByName("jar") { - archiveBaseName.set("Plex-BukkitTelnet") + archiveBaseName.set("Module-BukkitTelnet") } diff --git a/settings.gradle.kts b/settings.gradle.kts index c598925..999db6c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,2 +1,2 @@ -rootProject.name = "plex-bukkittelnet" +rootProject.name = "Module-BukkitTelnet" diff --git a/src/main/java/dev/plex/BukkitTelnetModule.java b/src/main/java/dev/plex/BukkitTelnetModule.java index 916edca..44f944e 100644 --- a/src/main/java/dev/plex/BukkitTelnetModule.java +++ b/src/main/java/dev/plex/BukkitTelnetModule.java @@ -3,13 +3,12 @@ package dev.plex; import dev.plex.listener.BukkitTelnetListener; import dev.plex.module.PlexModule; import lombok.Getter; -import net.kyori.adventure.text.minimessage.MiniMessage; import net.milkbowl.vault.permission.Permission; import org.bukkit.Bukkit; import org.bukkit.plugin.RegisteredServiceProvider; -public class BukkitTelnetModule extends PlexModule { - +public class BukkitTelnetModule extends PlexModule +{ @Getter private static BukkitTelnetModule module; @@ -17,13 +16,16 @@ public class BukkitTelnetModule extends PlexModule { private Permission permissions = null; @Override - public void load() { + public void load() + { module = this; } @Override - public void enable() { - if (!setupPermissions() && getPlex().getSystem().equalsIgnoreCase("permissions") && !Bukkit.getPluginManager().isPluginEnabled("Vault")) { + public void enable() + { + if (!setupPermissions() && 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!"); } @@ -31,11 +33,12 @@ public class BukkitTelnetModule extends PlexModule { } @Override - public void disable() { - + public void disable() + { } - private boolean setupPermissions() { + 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 e6b5570..0a4823d 100644 --- a/src/main/java/dev/plex/listener/BukkitTelnetListener.java +++ b/src/main/java/dev/plex/listener/BukkitTelnetListener.java @@ -5,31 +5,38 @@ import dev.plex.cache.DataUtils; import dev.plex.player.PlexPlayer; import dev.plex.rank.enums.Rank; import dev.plex.util.PlexLog; +import java.util.UUID; import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.event.EventHandler; -import java.util.UUID; - -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 (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")) + } + 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")) { + if (BukkitTelnetModule.getModule().getPermissions().playerHas(null, offlinePlayer, "plex.telnet.autoconnect")) + { event.setBypassPassword(true); event.setName(player.getName()); } diff --git a/src/main/resources/module.yml b/src/main/resources/module.yml index aa378f2..5ff6920 100644 --- a/src/main/resources/module.yml +++ b/src/main/resources/module.yml @@ -1,4 +1,4 @@ name: Plex-BukkitTelnet main: dev.plex.BukkitTelnetModule -description: The plex module for BukkitTelnet -version: 0.1 \ No newline at end of file +description: The Plex module for BukkitTelnet +version: 1.0 \ No newline at end of file