Remove the API component - closes #51

This commit is contained in:
Focusvity 2022-08-02 22:08:52 +10:00
parent f806470fd5
commit d6b44863aa
No known key found for this signature in database
GPG Key ID: 85AD157561ABE94B
63 changed files with 191 additions and 492 deletions

View File

@ -1,32 +0,0 @@
group = rootProject.group
version = rootProject.version
description = "Plex-API"
jar {
archiveBaseName.set("Plex-API")
}
tasks {
jar {
finalizedBy(rootProject.tasks.copyJars)
}
shadowJar {
enabled = false
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
dependencies {
compileOnly "org.projectlombok:lombok:1.18.24"
annotationProcessor "org.projectlombok:lombok:1.18.24"
compileOnly "io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT"
compileOnly "org.json:json:20220320"
}

View File

@ -1,11 +0,0 @@
package dev.plex.api;
import java.util.Map;
import java.util.UUID;
public interface IPlayerCache<T>
{
Map<UUID, T> getPlexPlayerMap();
T getPlexPlayer(UUID uuid);
}

View File

@ -1,6 +0,0 @@
package dev.plex.api;
public interface PlexApi
{
IPlayerCache<?> getPlayerCache();
}

View File

@ -1,6 +0,0 @@
package dev.plex.api;
public interface PlexApiProvider
{
PlexApi getApi();
}

View File

@ -1,8 +0,0 @@
package dev.plex.api.chat;
import io.papermc.paper.event.player.AsyncChatEvent;
public interface IChatHandler
{
void doChat(AsyncChatEvent event);
}

View File

@ -1,32 +0,0 @@
package dev.plex.api.permission;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface IPermissionHandler
{
default boolean hasPermission(@NotNull Player player, @Nullable String permission)
{
if (permission == null)
{
return true;
}
return player.hasPermission(permission);
}
default boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission)
{
if (permission == null)
{
return true;
}
if (player.isOnline() && Bukkit.getPlayer(player.getUniqueId()) != null)
{
return Bukkit.getPlayer(player.getUniqueId()).hasPermission(permission);
}
throw new UnsupportedOperationException("Not implemented yet");
}
}

View File

@ -1,67 +0,0 @@
package dev.plex.api.player;
import java.util.List;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
public interface IPlexPlayer
{
String getId();
UUID getUuid();
String getName();
Player getPlayer();
void setPlayer(Player player);
String getLoginMessage();
void setLoginMessage(String message);
String getPrefix();
void setPrefix(String prefix);
boolean isVanished();
void setVanished(boolean vanished);
boolean isCommandSpy();
void setCommandSpy(boolean commandSpy);
boolean isFrozen();
void setFrozen(boolean frozen);
boolean isMuted();
void setMuted(boolean muted);
boolean isLockedUp();
void setLockedUp(boolean lockedUp);
boolean isAdminActive();
void setAdminActive(boolean active);
long getCoins();
void setCoins(long coins);
String getRank();
void setRank(String rank);
List<String> getIps();
void setIps(List<String> ips);
PermissionAttachment getPermissionAttachment();
void setPermissionAttachment(PermissionAttachment attachment);
}

View File

@ -1,30 +0,0 @@
package dev.plex.api.plugin;
import dev.plex.api.chat.IChatHandler;
import dev.plex.api.permission.IPermissionHandler;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
@Setter
public abstract class PlexPlugin extends JavaPlugin
{
@Setter(AccessLevel.NONE)
private static PlexPlugin plugin;
private IChatHandler chatHandler;
private IPermissionHandler permissionHandler;
@Override
public void onLoad()
{
plugin = this;
}
public static PlexPlugin get()
{
return plugin;
}
}

View File

@ -1,26 +0,0 @@
package dev.plex.api.rank;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.json.JSONObject;
public interface IRank<T>
{
int getLevel();
String getLoginMessage();
void setLoginMessage(String message);
String getReadable();
Component getPrefix();
void setPrefix(String prefix);
NamedTextColor getColor();
boolean isAtLeast(T rank);
JSONObject toJSON();
}

View File

@ -60,7 +60,6 @@ subprojects {
} }
clean { clean {
dependsOn(":api:clean")
dependsOn(":server:clean") dependsOn(":server:clean")
dependsOn(":proxy:clean") dependsOn(":proxy:clean")
} }

View File

@ -42,5 +42,4 @@ dependencies {
compileOnly("org.json:json:20220320") compileOnly("org.json:json:20220320")
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT") compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
implementation(project(":api"))
} }

View File

@ -28,7 +28,6 @@ dependencies {
} }
implementation "org.bstats:bstats-base:3.0.0" implementation "org.bstats:bstats-base:3.0.0"
implementation "org.bstats:bstats-bukkit:3.0.0" implementation "org.bstats:bstats-bukkit:3.0.0"
implementation project(":api")
} }
group = rootProject.group group = rootProject.group

View File

@ -2,19 +2,12 @@ package dev.plex;
import dev.plex.admin.Admin; import dev.plex.admin.Admin;
import dev.plex.admin.AdminList; import dev.plex.admin.AdminList;
import dev.plex.api.PlexApi;
import dev.plex.api.PlexApiProvider;
import dev.plex.api.plugin.PlexPlugin;
import dev.plex.cache.DataUtils; import dev.plex.cache.DataUtils;
import dev.plex.cache.PlayerCache; import dev.plex.cache.PlayerCache;
import dev.plex.config.Config; import dev.plex.config.Config;
import dev.plex.handlers.CommandHandler; import dev.plex.handlers.CommandHandler;
import dev.plex.handlers.ListenerHandler; import dev.plex.handlers.ListenerHandler;
import dev.plex.hook.VaultHook;
import dev.plex.listener.impl.ChatListener;
import dev.plex.module.ModuleManager; import dev.plex.module.ModuleManager;
import dev.plex.permission.handler.NativePermissionHandler;
import dev.plex.permission.handler.VaultPermissionHandler;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.punishment.PunishmentManager; import dev.plex.punishment.PunishmentManager;
import dev.plex.rank.RankManager; import dev.plex.rank.RankManager;
@ -37,29 +30,26 @@ import dev.plex.world.CustomWorld;
import java.io.File; import java.io.File;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.bson.conversions.Bson; import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
@Getter @Getter
@Setter @Setter
public class Plex extends PlexPlugin implements PlexApiProvider public class Plex extends JavaPlugin
{ {
public static final BuildInfo build = new BuildInfo();
private static Plex plugin; private static Plex plugin;
public Config config; public Config config;
public Config messages; public Config messages;
public Config indefBans; public Config indefBans;
public Config commands; public Config commands;
public Config toggles; public Config toggles;
private PlexProvider provider;
public File modulesFolder; public File modulesFolder;
private StorageType storageType = StorageType.SQLITE; private StorageType storageType = StorageType.SQLITE;
public static final BuildInfo build = new BuildInfo();
private SQLConnection sqlConnection; private SQLConnection sqlConnection;
private MongoConnection mongoConnection; private MongoConnection mongoConnection;
private RedisConnection redisConnection; private RedisConnection redisConnection;
@ -82,6 +72,9 @@ public class Plex extends PlexPlugin implements PlexApiProvider
private UpdateChecker updateChecker; private UpdateChecker updateChecker;
private String system; private String system;
private Permission permissions;
private Chat chat;
public static Plex get() public static Plex get()
{ {
@ -110,8 +103,7 @@ public class Plex extends PlexPlugin implements PlexApiProvider
moduleManager.loadAllModules(); moduleManager.loadAllModules();
moduleManager.loadModules(); moduleManager.loadModules();
this.setChatHandler(new ChatListener.ChatHandlerImpl()); //this.setChatHandler(new ChatListener.ChatHandlerImpl());
} }
@Override @Override
@ -145,21 +137,15 @@ public class Plex extends PlexPlugin implements PlexApiProvider
e.printStackTrace(); e.printStackTrace();
} }
boolean permissions = false; if (system.equals("permissions"))
if (getServer().getPluginManager().isPluginEnabled("Vault"))
{ {
VaultPermissionHandler handler = new VaultPermissionHandler(); if (!getServer().getPluginManager().isPluginEnabled("Vault"))
if (VaultHook.getPermission() != null)
{ {
this.setPermissionHandler(handler); throw new RuntimeException("Vault is required to run on the server if you use permissions!");
permissions = true;
PlexLog.debug("Enabling Vault support for permissions with a permission plugin: " + VaultHook.getPermission().getName());
}
} }
if (!permissions) permissions = setupPermissions();
{ chat = setupChat();
this.setPermissionHandler(new NativePermissionHandler());
} }
updateChecker = new UpdateChecker(); updateChecker = new UpdateChecker();
@ -221,8 +207,6 @@ public class Plex extends PlexPlugin implements PlexApiProvider
} }
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
provider = new PlexProvider();
moduleManager.enableModules(); moduleManager.enableModules();
} }
@ -284,9 +268,17 @@ public class Plex extends PlexPlugin implements PlexApiProvider
}); });
} }
@Override private Permission setupPermissions()
public PlexApi getApi()
{ {
return provider; RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);
permissions = rsp.getProvider();
return permissions;
}
private Chat setupChat()
{
RegisteredServiceProvider<Chat> rsp = Bukkit.getServicesManager().getRegistration(Chat.class);
chat = rsp.getProvider();
return chat;
} }
} }

View File

@ -1,14 +0,0 @@
package dev.plex;
import dev.plex.api.IPlayerCache;
import dev.plex.api.PlexApi;
import dev.plex.player.PlexPlayer;
public class PlexProvider implements PlexApi
{
@Override
public IPlayerCache<PlexPlayer> getPlayerCache()
{
return Plex.get().getPlayerCache();
}
}

View File

@ -1,7 +1,6 @@
package dev.plex.cache; package dev.plex.cache;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import dev.plex.api.IPlayerCache;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -10,7 +9,7 @@ import java.util.UUID;
* Cache storage * Cache storage
*/ */
public class PlayerCache implements IPlayerCache<PlexPlayer> public class PlayerCache
{ {
/** /**
* A key/value pair where the key is the unique ID of the Plex Player * A key/value pair where the key is the unique ID of the Plex Player

View File

@ -155,7 +155,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
} }
else if (plugin.getSystem().equalsIgnoreCase("permissions")) else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(player, perms.permission())) if (!perms.permission().isEmpty() && !player.hasPermission(perms.permission()))
{ {
send(sender, messageComponent("noPermissionNode", perms.permission())); send(sender, messageComponent("noPermissionNode", perms.permission()));
return true; return true;
@ -191,7 +191,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
} }
else if (plugin.getSystem().equalsIgnoreCase("permissions")) else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(Bukkit.getOfflinePlayer(plexPlayer.getName()), perms.permission())) if (!perms.permission().isEmpty() && !plugin.getPermissions().playerHas(null, Bukkit.getPlayer(plexPlayer.getName()), perms.permission()))
{ {
send(sender, messageComponent("noPermissionNode", perms.permission())); send(sender, messageComponent("noPermissionNode", perms.permission()));
return true; return true;
@ -310,7 +310,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
} }
else if (plugin.getSystem().equalsIgnoreCase("permissions")) else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(Bukkit.getOfflinePlayer(plexPlayer.getName()), perms.permission())) if (!perms.permission().isEmpty() && !plugin.getPermissions().playerHas(null, Bukkit.getOfflinePlayer(plexPlayer.getName()), perms.permission()))
{ {
throw new CommandFailException(PlexUtils.messageString("noPermissionNode", permission)); throw new CommandFailException(PlexUtils.messageString("noPermissionNode", permission));
} }
@ -348,7 +348,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
} }
else if (plugin.getSystem().equalsIgnoreCase("permissions")) else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(player, permission)) if (!perms.permission().isEmpty() && !player.hasPermission(perms.permission()))
{ {
throw new CommandFailException(PlexUtils.messageString("noPermissionNode", permission)); throw new CommandFailException(PlexUtils.messageString("noPermissionNode", permission));
} }
@ -369,7 +369,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
} }
else if (plugin.getSystem().equalsIgnoreCase("permissions")) else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
return !perms.permission().isEmpty() && plugin.getPermissionHandler().hasPermission(player, permission); return !perms.permission().isEmpty() && player.hasPermission(permission);
} }
return false; return false;
} }
@ -410,7 +410,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
} }
else if (plugin.getSystem().equalsIgnoreCase("permissions")) else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
return !perms.permission().isEmpty() && plugin.getPermissionHandler().hasPermission(player, permission); return !perms.permission().isEmpty() && player.hasPermission(permission);
} }
return true; return true;
} }

View File

@ -1,9 +1,6 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.api.event.AdminAddEvent;
import dev.plex.api.event.AdminRemoveEvent;
import dev.plex.api.event.AdminSetRankEvent;
import dev.plex.cache.DataUtils; import dev.plex.cache.DataUtils;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
@ -12,6 +9,9 @@ import dev.plex.command.annotation.System;
import dev.plex.command.exception.ConsoleOnlyException; import dev.plex.command.exception.ConsoleOnlyException;
import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.AdminAddEvent;
import dev.plex.event.AdminRemoveEvent;
import dev.plex.event.AdminSetRankEvent;
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.PlexUtils; import dev.plex.util.PlexUtils;

View File

@ -45,7 +45,7 @@ public class AdminChatCMD extends PlexCommand
} }
else if (plugin.getSystem().equalsIgnoreCase("permissions")) else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
if (plugin.getPermissionHandler().hasPermission(player, "plex.adminchat")) if (player.hasPermission("plex.adminchat"))
{ {
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message)); player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
} }

View File

@ -1,12 +1,12 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException; import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;

View File

@ -1,12 +1,12 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException; import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;

View File

@ -1,11 +1,11 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException; import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.Arrays; import java.util.Arrays;

View File

@ -17,8 +17,8 @@ import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.title.Title; import net.kyori.adventure.title.Title;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;

View File

@ -1,12 +1,12 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException; import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;

View File

@ -1,12 +1,12 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException; import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;

View File

@ -1,6 +1,6 @@
package dev.plex.api.event; package dev.plex.event;
import dev.plex.api.player.IPlexPlayer; import dev.plex.player.PlexPlayer;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -24,7 +24,7 @@ public class AdminAddEvent extends Event
/** /**
* The PlexPlayer that was added * The PlexPlayer that was added
*/ */
private final IPlexPlayer plexPlayer; private final PlexPlayer plexPlayer;
public static HandlerList getHandlerList() public static HandlerList getHandlerList()
{ {

View File

@ -1,6 +1,6 @@
package dev.plex.api.event; package dev.plex.event;
import dev.plex.api.player.IPlexPlayer; import dev.plex.player.PlexPlayer;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -24,7 +24,7 @@ public class AdminRemoveEvent extends Event
/** /**
* The PlexPlayer that was removed * The PlexPlayer that was removed
*/ */
private final IPlexPlayer plexPlayer; private final PlexPlayer plexPlayer;
public static HandlerList getHandlerList() public static HandlerList getHandlerList()
{ {

View File

@ -1,7 +1,7 @@
package dev.plex.api.event; package dev.plex.event;
import dev.plex.api.player.IPlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.api.rank.IRank; import dev.plex.rank.enums.Rank;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -25,12 +25,12 @@ public class AdminSetRankEvent extends Event
/** /**
* The PlexPlayer that was removed * The PlexPlayer that was removed
*/ */
private final IPlexPlayer plexPlayer; private final PlexPlayer plexPlayer;
/** /**
* The rank the player was set to * The rank the player was set to
*/ */
private final IRank rank; private final Rank rank;
public static HandlerList getHandlerList() public static HandlerList getHandlerList()
{ {

View File

@ -1,4 +1,4 @@
package dev.plex.api.event; package dev.plex.event;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;

View File

@ -1,6 +1,6 @@
package dev.plex.api.event; package dev.plex.event;
import dev.plex.api.player.IPlexPlayer; import dev.plex.player.PlexPlayer;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -16,7 +16,7 @@ public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancell
/** /**
* The player who was punished * The player who was punished
*/ */
protected IPlexPlayer punishedPlayer; protected PlexPlayer punishedPlayer;
/** /**
* Whether the event was cancelled * Whether the event was cancelled
@ -28,9 +28,9 @@ public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancell
* Creates an event object * Creates an event object
* *
* @param punishedPlayer The player who was punished * @param punishedPlayer The player who was punished
* @see IPlexPlayer * @see PlexPlayer
*/ */
protected PunishedPlayerEvent(IPlexPlayer punishedPlayer) protected PunishedPlayerEvent(PlexPlayer punishedPlayer)
{ {
super(Bukkit.getPlayer(punishedPlayer.getUuid())); super(Bukkit.getPlayer(punishedPlayer.getUuid()));
this.punishedPlayer = punishedPlayer; this.punishedPlayer = punishedPlayer;

View File

@ -1,6 +1,6 @@
package dev.plex.api.event; package dev.plex.event;
import dev.plex.api.player.IPlexPlayer; import dev.plex.player.PlexPlayer;
import lombok.Getter; import lombok.Getter;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -24,7 +24,7 @@ public class PunishedPlayerFreezeEvent extends PunishedPlayerEvent implements Ca
* @param punishedPlayer The player who was punished * @param punishedPlayer The player who was punished
* @param frozen The new frozen status * @param frozen The new frozen status
*/ */
public PunishedPlayerFreezeEvent(IPlexPlayer punishedPlayer, boolean frozen) public PunishedPlayerFreezeEvent(PlexPlayer punishedPlayer, boolean frozen)
{ {
super(punishedPlayer); super(punishedPlayer);
this.frozen = frozen; this.frozen = frozen;

View File

@ -1,6 +1,6 @@
package dev.plex.api.event; package dev.plex.event;
import dev.plex.api.player.IPlexPlayer; import dev.plex.player.PlexPlayer;
import lombok.Getter; import lombok.Getter;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -24,7 +24,7 @@ public class PunishedPlayerLockupEvent extends PunishedPlayerEvent implements Ca
* @param punishedPlayer The player who was punished * @param punishedPlayer The player who was punished
* @param lockedUp The new muted status * @param lockedUp The new muted status
*/ */
public PunishedPlayerLockupEvent(IPlexPlayer punishedPlayer, boolean lockedUp) public PunishedPlayerLockupEvent(PlexPlayer punishedPlayer, boolean lockedUp)
{ {
super(punishedPlayer); super(punishedPlayer);
this.lockedUp = lockedUp; this.lockedUp = lockedUp;

View File

@ -1,6 +1,6 @@
package dev.plex.api.event; package dev.plex.event;
import dev.plex.api.player.IPlexPlayer; import dev.plex.player.PlexPlayer;
import lombok.Getter; import lombok.Getter;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -24,7 +24,7 @@ public class PunishedPlayerMuteEvent extends PunishedPlayerEvent implements Canc
* @param punishedPlayer The player who was punished * @param punishedPlayer The player who was punished
* @param muted The new muted status * @param muted The new muted status
*/ */
public PunishedPlayerMuteEvent(IPlexPlayer punishedPlayer, boolean muted) public PunishedPlayerMuteEvent(PlexPlayer punishedPlayer, boolean muted)
{ {
super(punishedPlayer); super(punishedPlayer);
this.muted = muted; this.muted = muted;

View File

@ -1,9 +1,9 @@
package dev.plex.listener.impl; package dev.plex.listener.impl;
import dev.plex.api.event.AdminAddEvent;
import dev.plex.api.event.AdminRemoveEvent;
import dev.plex.api.event.AdminSetRankEvent;
import dev.plex.cache.DataUtils; import dev.plex.cache.DataUtils;
import dev.plex.event.AdminAddEvent;
import dev.plex.event.AdminRemoveEvent;
import dev.plex.event.AdminSetRankEvent;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;

View File

@ -16,13 +16,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class BlockListener extends PlexListener public class BlockListener extends PlexListener
{ {
public List<String> blockedPlayers = new ArrayList<>();
private static final List<Material> blockedBlocks = new ArrayList<>(); private static final List<Material> blockedBlocks = new ArrayList<>();
private static List<String> cachedBlockedBlocksConfig = null;
private static final List<Material> SIGNS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SIGN")).toList(); private static final List<Material> SIGNS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SIGN")).toList();
private static List<String> cachedBlockedBlocksConfig = null;
public List<String> blockedPlayers = new ArrayList<>();
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(BlockPlaceEvent event) public void onBlockPlace(BlockPlaceEvent event)

View File

@ -1,6 +1,5 @@
package dev.plex.listener.impl; package dev.plex.listener.impl;
import dev.plex.api.chat.IChatHandler;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.listener.annotation.Toggleable; import dev.plex.listener.annotation.Toggleable;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
@ -21,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
@Toggleable("chat.enabled") @Toggleable("chat.enabled")
public class ChatListener extends PlexListener public class ChatListener extends PlexListener
{ {
private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig
.builder() .builder()
.match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]") .match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]")
@ -29,19 +29,10 @@ public class ChatListener extends PlexListener
.clickEvent(ClickEvent.openUrl( .clickEvent(ClickEvent.openUrl(
matchResult.group() matchResult.group()
))).build(); ))).build();
private final PlexChatRenderer renderer = new PlexChatRenderer();
@EventHandler @EventHandler
public void onChat(AsyncChatEvent event) public void onChat(AsyncChatEvent event)
{
plugin.getChatHandler().doChat(event);
}
public static class ChatHandlerImpl implements IChatHandler
{
private final PlexChatRenderer renderer = new PlexChatRenderer();
@Override
public void doChat(AsyncChatEvent event)
{ {
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(event.getPlayer().getUniqueId()); PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(event.getPlayer().getUniqueId());
Component prefix = plugin.getRankManager().getPrefix(plexPlayer); Component prefix = plugin.getRankManager().getPrefix(plexPlayer);
@ -59,7 +50,6 @@ public class ChatListener extends PlexListener
event.renderer(renderer); event.renderer(renderer);
} }
}
public static class PlexChatRenderer implements ChatRenderer public static class PlexChatRenderer implements ChatRenderer
{ {

View File

@ -1,6 +1,6 @@
package dev.plex.listener.impl; package dev.plex.listener.impl;
import dev.plex.api.event.GameModeUpdateEvent; import dev.plex.event.GameModeUpdateEvent;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -28,6 +28,27 @@ public class MobListener extends PlexListener
{ {
private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList(); private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
private static EntityType spawnEggToEntityType(Material mat)
{
EntityType eggType;
try
{
if (mat == Material.MOOSHROOM_SPAWN_EGG)
{
eggType = EntityType.MUSHROOM_COW;
}
else
{
eggType = EntityType.valueOf(mat.name().substring(0, mat.name().length() - 10));
}
}
catch (IllegalArgumentException ignored)
{
return null;
}
return eggType;
}
@EventHandler @EventHandler
public void onEntitySpawn(EntitySpawnEvent event) public void onEntitySpawn(EntitySpawnEvent event)
{ {
@ -108,25 +129,4 @@ public class MobListener extends PlexListener
} }
} }
} }
private static EntityType spawnEggToEntityType(Material mat)
{
EntityType eggType;
try
{
if (mat == Material.MOOSHROOM_SPAWN_EGG)
{
eggType = EntityType.MUSHROOM_COW;
}
else
{
eggType = EntityType.valueOf(mat.name().substring(0, mat.name().length() - 10));
}
}
catch (IllegalArgumentException ignored)
{
return null;
}
return eggType;
}
} }

View File

@ -7,10 +7,8 @@ import dev.plex.storage.StorageType;
import dev.plex.util.PermissionsUtil; import dev.plex.util.PermissionsUtil;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -36,7 +34,8 @@ public class PlayerListener<T> extends PlexListener
{ {
player.setOp(true); player.setOp(true);
PlexLog.debug("Automatically opped " + player.getName() + " since ranks are enabled."); PlexLog.debug("Automatically opped " + player.getName() + " since ranks are enabled.");
} else if (plugin.getSystem().equalsIgnoreCase("permissions")) }
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{ {
player.setOp(false); player.setOp(false);
PlexLog.debug("Automatically deopped " + player.getName() + " since ranks are disabled."); PlexLog.debug("Automatically deopped " + player.getName() + " since ranks are disabled.");
@ -49,7 +48,8 @@ public class PlayerListener<T> extends PlexListener
plexPlayer.setName(player.getName()); // set the name of the player plexPlayer.setName(player.getName()); // set the name of the player
plexPlayer.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips plexPlayer.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
DataUtils.insert(plexPlayer); // insert data in some wack db DataUtils.insert(plexPlayer); // insert data in some wack db
} else }
else
{ {
plexPlayer = DataUtils.getPlayer(player.getUniqueId()); plexPlayer = DataUtils.getPlayer(player.getUniqueId());
List<String> ips = plexPlayer.getIps(); List<String> ips = plexPlayer.getIps();

View File

@ -1,9 +1,9 @@
package dev.plex.listener.impl; package dev.plex.listener.impl;
import dev.plex.api.event.AdminAddEvent;
import dev.plex.api.event.AdminRemoveEvent;
import dev.plex.api.event.AdminSetRankEvent;
import dev.plex.cache.DataUtils; import dev.plex.cache.DataUtils;
import dev.plex.event.AdminAddEvent;
import dev.plex.event.AdminRemoveEvent;
import dev.plex.event.AdminSetRankEvent;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;

View File

@ -154,7 +154,7 @@ public class WorldListener extends PlexListener
{ {
return true; return true;
} }
if (plugin.getPermissionHandler().hasPermission(player, permission)) if (player.hasPermission(permission))
{ {
return true; return true;
} }
@ -188,6 +188,7 @@ public class WorldListener extends PlexListener
/** /**
* Check if a Player has the ability to enter the requested world * Check if a Player has the ability to enter the requested world
*
* @param player The player who wants to enter the world * @param player The player who wants to enter the world
* @return Returns true if the person has the ability to enter the world * @return Returns true if the person has the ability to enter the world
*/ */
@ -202,7 +203,7 @@ public class WorldListener extends PlexListener
{ {
return true; return true;
} }
if (plugin.getPermissionHandler().hasPermission(player, permission)) if (player.hasPermission(permission))
{ {
return true; return true;
} }

View File

@ -1,7 +0,0 @@
package dev.plex.permission.handler;
import dev.plex.api.permission.IPermissionHandler;
public class NativePermissionHandler implements IPermissionHandler
{
}

View File

@ -1,28 +0,0 @@
package dev.plex.permission.handler;
import dev.plex.api.permission.IPermissionHandler;
import dev.plex.hook.VaultHook;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Getter
public class VaultPermissionHandler implements IPermissionHandler
{
@Override
public boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission)
{
if (!Bukkit.getPluginManager().isPluginEnabled("Vault"))
{
return IPermissionHandler.super.hasPermission(player, permission);
}
if (VaultHook.getPermission() == null)
{
return IPermissionHandler.super.hasPermission(player, permission);
}
return VaultHook.getPermission().playerHas(null, player, permission);
}
}

View File

@ -7,7 +7,6 @@ import dev.morphia.annotations.Id;
import dev.morphia.annotations.IndexOptions; import dev.morphia.annotations.IndexOptions;
import dev.morphia.annotations.Indexed; import dev.morphia.annotations.Indexed;
import dev.plex.Plex; import dev.plex.Plex;
import dev.plex.api.player.IPlexPlayer;
import dev.plex.permission.Permission; import dev.plex.permission.Permission;
import dev.plex.punishment.Punishment; import dev.plex.punishment.Punishment;
import dev.plex.punishment.extra.Note; import dev.plex.punishment.extra.Note;
@ -30,7 +29,7 @@ import org.bukkit.permissions.PermissionAttachment;
@Getter @Getter
@Setter @Setter
@Entity(value = "players", useDiscriminator = false) @Entity(value = "players", useDiscriminator = false)
public class PlexPlayer implements IPlexPlayer public class PlexPlayer
{ {
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
@Id @Id

View File

@ -11,7 +11,6 @@ import dev.plex.storage.StorageType;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import dev.plex.util.TimeUtils; import dev.plex.util.TimeUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -23,7 +22,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -107,7 +105,8 @@ public class PunishmentManager implements PlexBase
{ {
DataUtils.update(plexPlayer); DataUtils.update(plexPlayer);
}); });
} else }
else
{ {
Plex.get().getSqlPunishment().insertPunishment(punishment); Plex.get().getSqlPunishment().insertPunishment(punishment);
} }
@ -118,7 +117,8 @@ public class PunishmentManager implements PlexBase
try try
{ {
return !FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim().isEmpty(); return !FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim().isEmpty();
} catch (IOException e) }
catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
@ -164,7 +164,8 @@ public class PunishmentManager implements PlexBase
List<PlexPlayer> players = Plex.get().getMongoPlayerData().getPlayers(); List<PlexPlayer> players = Plex.get().getMongoPlayerData().getPlayers();
return players.stream().map(PlexPlayer::getPunishments).flatMap(Collection::stream).filter(Punishment::isActive).filter(punishment -> punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN).toList(); return players.stream().map(PlexPlayer::getPunishments).flatMap(Collection::stream).filter(Punishment::isActive).filter(punishment -> punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN).toList();
}); });
} else }
else
{ {
//PlexLog.debug("Checking active bans mysql"); //PlexLog.debug("Checking active bans mysql");
CompletableFuture<List<Punishment>> future = new CompletableFuture<>(); CompletableFuture<List<Punishment>> future = new CompletableFuture<>();
@ -195,7 +196,8 @@ public class PunishmentManager implements PlexBase
.peek(punishment -> punishment.setActive(false)).collect(Collectors.toList())); .peek(punishment -> punishment.setActive(false)).collect(Collectors.toList()));
DataUtils.update(plexPlayer); DataUtils.update(plexPlayer);
}); });
} else }
else
{ {
return Plex.get().getSqlPunishment().removeBan(uuid); return Plex.get().getSqlPunishment().removeBan(uuid);
} }
@ -223,7 +225,8 @@ public class PunishmentManager implements PlexBase
Bukkit.broadcast(PlexUtils.messageComponent("unfrozePlayer", "Plex", Bukkit.getOfflinePlayer(player.getUuid()).getName())); Bukkit.broadcast(PlexUtils.messageComponent("unfrozePlayer", "Plex", Bukkit.getOfflinePlayer(player.getUuid()).getName()));
} }
}.runTaskLater(Plex.get(), 20 * seconds); }.runTaskLater(Plex.get(), 20 * seconds);
} else if (punishment.getType() == PunishmentType.MUTE) }
else if (punishment.getType() == PunishmentType.MUTE)
{ {
player.setMuted(true); player.setMuted(true);
ZonedDateTime now = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)); ZonedDateTime now = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));

View File

@ -1,6 +1,5 @@
package dev.plex.rank.enums; package dev.plex.rank.enums;
import dev.plex.api.rank.IRank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -9,7 +8,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
import org.json.JSONObject; import org.json.JSONObject;
@Getter @Getter
public enum Rank implements IRank<Rank> public enum Rank
{ {
IMPOSTOR(-1, "<aqua>an <yellow>Impostor<reset>", "Impostor", "<dark_gray>[<yellow>Imp<dark_gray>]", NamedTextColor.YELLOW), IMPOSTOR(-1, "<aqua>an <yellow>Impostor<reset>", "Impostor", "<dark_gray>[<yellow>Imp<dark_gray>]", NamedTextColor.YELLOW),
NONOP(0, "a <white>Non-Op<reset>", "Non-Op", "", NamedTextColor.WHITE), NONOP(0, "a <white>Non-Op<reset>", "Non-Op", "", NamedTextColor.WHITE),
@ -19,18 +18,14 @@ public enum Rank implements IRank<Rank>
EXECUTIVE(4, "an <red>Executive<reset>", "Executive", "<dark_gray>[<red>Exec<dark_gray>]", NamedTextColor.RED); EXECUTIVE(4, "an <red>Executive<reset>", "Executive", "<dark_gray>[<red>Exec<dark_gray>]", NamedTextColor.RED);
private final int level; private final int level;
@Setter
private String loginMessage;
@Setter
private String readable;
@Setter
private String prefix;
@Getter @Getter
private final NamedTextColor color; private final NamedTextColor color;
@Setter
private String loginMessage;
@Setter
private String readable;
@Setter
private String prefix;
Rank(int level, String loginMessage, String readable, String prefix, NamedTextColor color) Rank(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
{ {

View File

@ -15,18 +15,14 @@ public enum Title
OWNER(2, "<aqua>an <blue>Owner<reset>", "Owner", "<dark_gray>[<blue>Owner<dark_gray>]", NamedTextColor.BLUE); OWNER(2, "<aqua>an <blue>Owner<reset>", "Owner", "<dark_gray>[<blue>Owner<dark_gray>]", NamedTextColor.BLUE);
private final int level; private final int level;
@Setter
private String loginMessage;
@Setter
private String readable;
@Setter
private String prefix;
@Getter @Getter
private final NamedTextColor color; private final NamedTextColor color;
@Setter
private String loginMessage;
@Setter
private String readable;
@Setter
private String prefix;
Title(int level, String loginMessage, String readable, String prefix, NamedTextColor color) Title(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
{ {

View File

@ -1,7 +1,6 @@
package dev.plex.storage; package dev.plex.storage;
import com.mongodb.ConnectionString; import com.mongodb.ConnectionString;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientSettings; import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients; import com.mongodb.client.MongoClients;

View File

@ -1,15 +1,13 @@
package dev.plex.storage.codec; package dev.plex.storage.codec;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import org.bson.BsonReader; import org.bson.BsonReader;
import org.bson.BsonWriter; import org.bson.BsonWriter;
import org.bson.codecs.Codec; import org.bson.codecs.Codec;
import org.bson.codecs.DecoderContext; import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext; import org.bson.codecs.EncoderContext;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import static dev.plex.util.TimeUtils.TIMEZONE; import static dev.plex.util.TimeUtils.TIMEZONE;
public class ZonedDateTimeCodec implements Codec<ZonedDateTime> public class ZonedDateTimeCodec implements Codec<ZonedDateTime>

View File

@ -54,7 +54,8 @@ public class PlexUtils implements PlexBase
public static void disabledEffectMultiple(Player[] players, Location location) public static void disabledEffectMultiple(Player[] players, Location location)
{ {
if (players.length < 1) { if (players.length < 1)
{
return; return;
} }

View File

@ -13,7 +13,6 @@ import org.apache.commons.lang3.math.NumberUtils;
public class TimeUtils public class TimeUtils
{ {
public static String TIMEZONE = Plex.get().config.getString("server.timezone");
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a z"); private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a z");
private static final Set<String> TIMEZONES = Set.of(TimeZone.getAvailableIDs()); private static final Set<String> TIMEZONES = Set.of(TimeZone.getAvailableIDs());
private static final List<String> timeUnits = new ArrayList<>() private static final List<String> timeUnits = new ArrayList<>()
@ -26,6 +25,7 @@ public class TimeUtils
add("mo"); add("mo");
add("y"); add("y");
}}; }};
public static String TIMEZONE = Plex.get().config.getString("server.timezone");
private static int parseInteger(String s) throws NumberFormatException private static int parseInteger(String s) throws NumberFormatException
{ {

View File

@ -38,8 +38,8 @@ public class UpdateChecker implements PlexBase
* > 0 = Number of commits behind * > 0 = Number of commits behind
*/ */
private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/"; private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/";
private String BRANCH = plugin.config.getString("update_branch");
private final String REPO = plugin.config.getString("update_repo"); private final String REPO = plugin.config.getString("update_repo");
private String BRANCH = plugin.config.getString("update_branch");
private int distance = -4; private int distance = -4;
// Adapted from Paper // Adapted from Paper

View File

@ -1,5 +1,4 @@
rootProject.name = "Plex" rootProject.name = "Plex"
include 'api'
include 'server' include 'server'
include 'proxy' include 'proxy'