Few formatting things + it compiles

This commit is contained in:
Telesphoreo 2022-03-31 02:06:34 -05:00
parent e0a14df84e
commit 30a037b0f5
5 changed files with 37 additions and 23 deletions

View File

@ -3,12 +3,15 @@ plugins {
`maven-publish` `maven-publish`
} }
group "dev.plex" group = "dev.plex"
version "0.1" description = "Module-BukkitTelnet"
version = "1.0"
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven { maven {
url = uri("https://papermc.io/repo/repository/maven-public/") url = uri("https://papermc.io/repo/repository/maven-public/")
} }
@ -20,6 +23,7 @@ repositories {
maven { maven {
url = uri("https://nexus.telesphoreo.me/repository/totalfreedom") url = uri("https://nexus.telesphoreo.me/repository/totalfreedom")
} }
maven { maven {
url = uri("https://jitpack.io") url = uri("https://jitpack.io")
} }
@ -63,6 +67,6 @@ publishing {
} }
tasks.getByName<Jar>("jar") { tasks.getByName<Jar>("jar") {
archiveBaseName.set("Plex-BukkitTelnet") archiveBaseName.set("Module-BukkitTelnet")
} }

View File

@ -1,2 +1,2 @@
rootProject.name = "plex-bukkittelnet" rootProject.name = "Module-BukkitTelnet"

View File

@ -3,13 +3,12 @@ package dev.plex;
import dev.plex.listener.BukkitTelnetListener; import dev.plex.listener.BukkitTelnetListener;
import dev.plex.module.PlexModule; import dev.plex.module.PlexModule;
import lombok.Getter; import lombok.Getter;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
public class BukkitTelnetModule extends PlexModule { public class BukkitTelnetModule extends PlexModule
{
@Getter @Getter
private static BukkitTelnetModule module; private static BukkitTelnetModule module;
@ -17,13 +16,16 @@ public class BukkitTelnetModule extends PlexModule {
private Permission permissions = null; private Permission permissions = null;
@Override @Override
public void load() { public void load()
{
module = this; module = this;
} }
@Override @Override
public void enable() { public void enable()
if (!setupPermissions() && getPlex().getSystem().equalsIgnoreCase("permissions") && !Bukkit.getPluginManager().isPluginEnabled("Vault")) { {
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!"); 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 @Override
public void disable() { public void disable()
{
} }
private boolean setupPermissions() { private boolean setupPermissions()
{
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class); RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);
permissions = rsp.getProvider(); permissions = rsp.getProvider();
return permissions != null; return permissions != null;

View File

@ -5,31 +5,38 @@ import dev.plex.cache.DataUtils;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import java.util.UUID;
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent; import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import java.util.UUID; public class BukkitTelnetListener extends PlexListener
{
public class BukkitTelnetListener extends PlexListener {
@EventHandler @EventHandler
public void onPreLogin(TelnetPreLoginEvent event) { public void onPreLogin(TelnetPreLoginEvent event)
{
final String ip = event.getIp(); final String ip = event.getIp();
final PlexPlayer player = DataUtils.getPlayerByIP(ip); final PlexPlayer player = DataUtils.getPlayerByIP(ip);
if (player == null) return; if (player == null)
{
return;
}
if (plugin.getSystem().equalsIgnoreCase("ranks")) if (plugin.getSystem().equalsIgnoreCase("ranks"))
{ {
PlexLog.debug("Plex-BukkitTelnet using ranks check"); PlexLog.debug("Plex-BukkitTelnet using ranks check");
if (player.getRankFromString().isAtLeast(Rank.ADMIN)) { if (player.getRankFromString().isAtLeast(Rank.ADMIN))
{
event.setBypassPassword(true); event.setBypassPassword(true);
event.setName(player.getName()); event.setName(player.getName());
} }
} else if (plugin.getSystem().equalsIgnoreCase("permissions")) }
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
PlexLog.debug("Plex-BukkitTelnet using permissions check"); PlexLog.debug("Plex-BukkitTelnet using permissions check");
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(player.getUuid())); 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.setBypassPassword(true);
event.setName(player.getName()); event.setName(player.getName());
} }

View File

@ -1,4 +1,4 @@
name: Plex-BukkitTelnet name: Plex-BukkitTelnet
main: dev.plex.BukkitTelnetModule main: dev.plex.BukkitTelnetModule
description: The plex module for BukkitTelnet description: The Plex module for BukkitTelnet
version: 0.1 version: 1.0