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 {
dependsOn(":api:clean")
dependsOn(":server:clean")
dependsOn(":proxy:clean")
}

View File

@ -42,5 +42,4 @@ dependencies {
compileOnly("org.json:json:20220320")
compileOnly("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-bukkit:3.0.0"
implementation project(":api")
}
group = rootProject.group

View File

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

View File

@ -155,7 +155,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
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()));
return true;
@ -191,7 +191,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
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()));
return true;
@ -206,7 +206,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
try
{
Component component = this.execute(sender, isConsole(sender) ? null : (Player) sender, args);
Component component = this.execute(sender, isConsole(sender) ? null : (Player)sender, args);
if (component != null)
{
send(sender, component);
@ -292,7 +292,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
{
if (!isConsole(sender))
{
return checkRank((Player) sender, rank, permission);
return checkRank((Player)sender, rank, permission);
}
if (!sender.getName().equalsIgnoreCase("console"))
{
@ -310,7 +310,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
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));
}
@ -348,7 +348,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
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));
}
@ -369,7 +369,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{
return !perms.permission().isEmpty() && plugin.getPermissionHandler().hasPermission(player, permission);
return !perms.permission().isEmpty() && player.hasPermission(permission);
}
return false;
}
@ -387,7 +387,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
{
if (!isConsole(sender))
{
return checkTab((Player) sender, rank, permission);
return checkTab((Player)sender, rank, permission);
}
return true;
}
@ -410,7 +410,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
{
return !perms.permission().isEmpty() && plugin.getPermissionHandler().hasPermission(player, permission);
return !perms.permission().isEmpty() && player.hasPermission(permission);
}
return true;
}

View File

@ -1,9 +1,6 @@
package dev.plex.command.impl;
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.command.PlexCommand;
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.PlayerNotFoundException;
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.rank.enums.Rank;
import dev.plex.util.PlexUtils;

View File

@ -45,7 +45,7 @@ public class AdminChatCMD extends PlexCommand
}
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));
}

View File

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

View File

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

View File

@ -1,11 +1,11 @@
package dev.plex.command.impl;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
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.format.NamedTextColor;
import net.kyori.adventure.title.Title;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;

View File

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

View File

@ -1,12 +1,12 @@
package dev.plex.command.impl;
import com.google.common.collect.ImmutableList;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
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.EqualsAndHashCode;
import org.bukkit.command.CommandSender;
@ -24,7 +24,7 @@ public class AdminAddEvent extends Event
/**
* The PlexPlayer that was added
*/
private final IPlexPlayer plexPlayer;
private final PlexPlayer plexPlayer;
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.EqualsAndHashCode;
import org.bukkit.command.CommandSender;
@ -24,7 +24,7 @@ public class AdminRemoveEvent extends Event
/**
* The PlexPlayer that was removed
*/
private final IPlexPlayer plexPlayer;
private final PlexPlayer plexPlayer;
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.api.rank.IRank;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.bukkit.command.CommandSender;
@ -25,12 +25,12 @@ public class AdminSetRankEvent extends Event
/**
* The PlexPlayer that was removed
*/
private final IPlexPlayer plexPlayer;
private final PlexPlayer plexPlayer;
/**
* The rank the player was set to
*/
private final IRank rank;
private final Rank rank;
public static HandlerList getHandlerList()
{

View File

@ -1,4 +1,4 @@
package dev.plex.api.event;
package dev.plex.event;
import lombok.Data;
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.Setter;
import org.bukkit.Bukkit;
@ -16,7 +16,7 @@ public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancell
/**
* The player who was punished
*/
protected IPlexPlayer punishedPlayer;
protected PlexPlayer punishedPlayer;
/**
* Whether the event was cancelled
@ -28,9 +28,9 @@ public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancell
* Creates an event object
*
* @param punishedPlayer The player who was punished
* @see IPlexPlayer
* @see PlexPlayer
*/
protected PunishedPlayerEvent(IPlexPlayer punishedPlayer)
protected PunishedPlayerEvent(PlexPlayer punishedPlayer)
{
super(Bukkit.getPlayer(punishedPlayer.getUuid()));
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 org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -24,7 +24,7 @@ public class PunishedPlayerFreezeEvent extends PunishedPlayerEvent implements Ca
* @param punishedPlayer The player who was punished
* @param frozen The new frozen status
*/
public PunishedPlayerFreezeEvent(IPlexPlayer punishedPlayer, boolean frozen)
public PunishedPlayerFreezeEvent(PlexPlayer punishedPlayer, boolean frozen)
{
super(punishedPlayer);
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 org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -24,7 +24,7 @@ public class PunishedPlayerLockupEvent extends PunishedPlayerEvent implements Ca
* @param punishedPlayer The player who was punished
* @param lockedUp The new muted status
*/
public PunishedPlayerLockupEvent(IPlexPlayer punishedPlayer, boolean lockedUp)
public PunishedPlayerLockupEvent(PlexPlayer punishedPlayer, boolean lockedUp)
{
super(punishedPlayer);
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 org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -24,7 +24,7 @@ public class PunishedPlayerMuteEvent extends PunishedPlayerEvent implements Canc
* @param punishedPlayer The player who was punished
* @param muted The new muted status
*/
public PunishedPlayerMuteEvent(IPlexPlayer punishedPlayer, boolean muted)
public PunishedPlayerMuteEvent(PlexPlayer punishedPlayer, boolean muted)
{
super(punishedPlayer);
this.muted = muted;

View File

@ -1,9 +1,9 @@
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.event.AdminAddEvent;
import dev.plex.event.AdminRemoveEvent;
import dev.plex.event.AdminSetRankEvent;
import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
@ -17,7 +17,7 @@ public class AdminListener extends PlexListener
public void onAdminAdd(AdminAddEvent event)
{
String userSender = event.getSender().getName();
PlexPlayer target = (PlexPlayer) event.getPlexPlayer();
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
if (target.getRankFromString().isAtLeast(Rank.ADMIN))
{
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
@ -35,7 +35,7 @@ public class AdminListener extends PlexListener
public void onAdminRemove(AdminRemoveEvent event)
{
String userSender = event.getSender().getName();
PlexPlayer target = (PlexPlayer) event.getPlexPlayer();
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
target.setAdminActive(false);
DataUtils.update(target);
PlexUtils.broadcast(messageComponent("adminRemoved", userSender, target.getName()));
@ -45,8 +45,8 @@ public class AdminListener extends PlexListener
public void onAdminSetRank(AdminSetRankEvent event)
{
String userSender = event.getSender().getName();
PlexPlayer target = (PlexPlayer) event.getPlexPlayer();
Rank newRank = (Rank) event.getRank();
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
Rank newRank = (Rank)event.getRank();
target.setRank(newRank.name().toLowerCase());
DataUtils.update(target);
PlexUtils.broadcast(messageComponent("adminSetRank", userSender, target.getName(), newRank.getReadable()));

View File

@ -16,13 +16,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class BlockListener extends PlexListener
{
public List<String> blockedPlayers = 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 List<String> cachedBlockedBlocksConfig = null;
public List<String> blockedPlayers = new ArrayList<>();
@EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(BlockPlaceEvent event)
@ -60,7 +57,7 @@ public class BlockListener extends PlexListener
if (SIGNS.contains(block.getType()))
{
Sign sign = (Sign) block.getState();
Sign sign = (Sign)block.getState();
boolean anythingChanged = false;
for (int i = 0; i < sign.lines().size(); i++)
{

View File

@ -24,6 +24,6 @@ public class BookListener extends PlexListener
}
event.setNewBookMeta((BookMeta) event.getNewBookMeta().pages(pages));
event.setNewBookMeta((BookMeta)event.getNewBookMeta().pages(pages));
}
}

View File

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

View File

@ -1,6 +1,6 @@
package dev.plex.listener.impl;
import dev.plex.api.event.GameModeUpdateEvent;
import dev.plex.event.GameModeUpdateEvent;
import dev.plex.listener.PlexListener;
import dev.plex.util.PlexUtils;
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 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
public void onEntitySpawn(EntitySpawnEvent event)
{
@ -56,7 +77,7 @@ public class MobListener extends PlexListener
if (SPAWN_EGGS.contains(itemType))
{
Block block = event.getBlock();
Location blockLoc = BlockUtils.relative(block.getLocation(), ((Directional) block.getBlockData()).getFacing()).add(.5, 0, .5);
Location blockLoc = BlockUtils.relative(block.getLocation(), ((Directional)block.getBlockData()).getFacing()).add(.5, 0, .5);
EntityType eggType = spawnEggToEntityType(itemType);
if (eggType != null)
{
@ -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.PlexLog;
import dev.plex.util.PlexUtils;
import java.util.Arrays;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@ -36,7 +34,8 @@ public class PlayerListener<T> extends PlexListener
{
player.setOp(true);
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);
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.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
DataUtils.insert(plexPlayer); // insert data in some wack db
} else
}
else
{
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
List<String> ips = plexPlayer.getIps();

View File

@ -1,9 +1,9 @@
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.event.AdminAddEvent;
import dev.plex.event.AdminRemoveEvent;
import dev.plex.event.AdminSetRankEvent;
import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer;
import net.kyori.adventure.text.Component;
@ -25,7 +25,7 @@ public class TabListener extends PlexListener
@EventHandler(priority = EventPriority.HIGHEST)
public void onAdminAdd(AdminAddEvent event)
{
PlexPlayer plexPlayer = (PlexPlayer) event.getPlexPlayer();
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
Player player = event.getPlexPlayer().getPlayer();
if (player == null)
{
@ -37,7 +37,7 @@ public class TabListener extends PlexListener
@EventHandler(priority = EventPriority.HIGHEST)
public void onAdminRemove(AdminRemoveEvent event)
{
PlexPlayer plexPlayer = (PlexPlayer) event.getPlexPlayer();
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
Player player = event.getPlexPlayer().getPlayer();
if (player == null)
{
@ -49,7 +49,7 @@ public class TabListener extends PlexListener
@EventHandler(priority = EventPriority.HIGHEST)
public void onAdminSetRank(AdminSetRankEvent event)
{
PlexPlayer plexPlayer = (PlexPlayer) event.getPlexPlayer();
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
Player player = event.getPlexPlayer().getPlayer();
if (player == null)
{

View File

@ -76,8 +76,8 @@ public class WorldListener extends PlexListener
if (command != null)
{
// This does check for aliases
boolean isWeCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("WorldEdit"));
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
boolean isWeCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand)command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("WorldEdit"));
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand)command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
if (isWeCommand || isFaweCommand || EDIT_COMMANDS.contains(message.toLowerCase()))
{
event.getPlayer().sendMessage(Component.text("You do not have permission to use that command in this world.").color(NamedTextColor.RED));
@ -139,7 +139,7 @@ public class WorldListener extends PlexListener
/**
* Check if a Player has the ability to modify the world they are in
*
* @param player The player who wants to modify the world
* @param player The player who wants to modify the world
* @param showMessage Whether the message from the config.yml should be shown
* @return Returns true if the person has the ability to modify the world
*/
@ -154,7 +154,7 @@ public class WorldListener extends PlexListener
{
return true;
}
if (plugin.getPermissionHandler().hasPermission(player, permission))
if (player.hasPermission(permission))
{
return true;
}
@ -188,6 +188,7 @@ public class WorldListener extends PlexListener
/**
* Check if a Player has the ability to enter the requested world
*
* @param player The player who wants 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;
}
if (plugin.getPermissionHandler().hasPermission(player, permission))
if (player.hasPermission(permission))
{
return true;
}

View File

@ -134,7 +134,7 @@ public class PunishedPlayerMenu extends AbstractMenu
{
return;
}
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
}
else if (item.getItemMeta().displayName().equals(Component.text("Previous Page").color(NamedTextColor.LIGHT_PURPLE)))
{
@ -150,17 +150,17 @@ public class PunishedPlayerMenu extends AbstractMenu
{
return;
}
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
}
}
else if (item.getType() == Material.BARRIER)
{
new PunishmentMenu().openInv((Player) event.getWhoClicked(), 0);
new PunishmentMenu().openInv((Player)event.getWhoClicked(), 0);
}
else if (item.getType() == Material.PLAYER_HEAD)
{
SkullMeta meta = (SkullMeta) item.getItemMeta();
SkullMeta meta = (SkullMeta)item.getItemMeta();
OfflinePlayer player = meta.getOwningPlayer();
assert player != null;
PlexPlayer punishedPlayer = DataUtils.getPlayer(player.getUniqueId()) == null ? null : Plex.get().getPlayerCache().getPlexPlayer(player.getUniqueId());

View File

@ -71,7 +71,7 @@ public class PunishmentMenu extends AbstractMenu
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) item.getItemMeta();
SkullMeta meta = (SkullMeta)item.getItemMeta();
meta.setOwningPlayer(players);
meta.displayName(PlexUtils.mmDeserialize("<!italic><yellow>" + players.getName()));
item.setItemMeta(meta);
@ -121,7 +121,7 @@ public class PunishmentMenu extends AbstractMenu
{
return;
}
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
}
else if (item.getItemMeta().displayName().equals(PlexUtils.mmDeserialize("<light_purple>Previous Page")))
{
@ -137,13 +137,13 @@ public class PunishmentMenu extends AbstractMenu
{
return;
}
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
}
}
else if (item.getType() == Material.PLAYER_HEAD)
{
SkullMeta meta = (SkullMeta) item.getItemMeta();
SkullMeta meta = (SkullMeta)item.getItemMeta();
OfflinePlayer player = meta.getOwningPlayer();
assert player != null;
PlexPlayer punishedPlayer = DataUtils.getPlayer(player.getUniqueId());
@ -153,7 +153,7 @@ public class PunishmentMenu extends AbstractMenu
event.getWhoClicked().closeInventory();
return;
}
new PunishedPlayerMenu(punishedPlayer).openInv((Player) event.getWhoClicked(), 0);
new PunishedPlayerMenu(punishedPlayer).openInv((Player)event.getWhoClicked(), 0);
}
}

View File

@ -66,7 +66,7 @@ public class ModuleManager
PlexModuleFile plexModuleFile = new PlexModuleFile(name, main, description, version);
plexModuleFile.setLibraries(libraries);
Class<? extends PlexModule> module = (Class<? extends PlexModule>) Class.forName(main, true, loader);
Class<? extends PlexModule> module = (Class<? extends PlexModule>)Class.forName(main, true, loader);
PlexModule plexModule = module.getConstructor().newInstance();
plexModule.setPlex(Plex.get());
@ -141,7 +141,7 @@ public class ModuleManager
{
try
{
((URLClassLoader) module.getClass().getClassLoader()).close();
((URLClassLoader)module.getClass().getClassLoader()).close();
}
catch (IOException e)
{

View File

@ -105,7 +105,7 @@ public class LibraryLoader
DependencyResult result;
try
{
result = repository.resolveDependencies(session, new DependencyRequest(new CollectRequest((Dependency) null, dependencies, repositories), null));
result = repository.resolveDependencies(session, new DependencyRequest(new CollectRequest((Dependency)null, dependencies, repositories), null));
}
catch (DependencyResolutionException ex)
{

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

View File

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

View File

@ -1,6 +1,5 @@
package dev.plex.rank.enums;
import dev.plex.api.rank.IRank;
import dev.plex.util.PlexUtils;
import lombok.Getter;
import lombok.Setter;
@ -9,7 +8,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
import org.json.JSONObject;
@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),
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);
private final int level;
@Setter
private String loginMessage;
@Setter
private String readable;
@Setter
private String prefix;
@Getter
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)
{

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);
private final int level;
@Setter
private String loginMessage;
@Setter
private String readable;
@Setter
private String prefix;
@Getter
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)
{

View File

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

View File

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

View File

@ -27,8 +27,8 @@ public class GameRuleUtil
private static <T> void readGameRules(World world, String s)
{
String gameRule = s.split(";")[0];
T value = (T) s.split(";")[1];
GameRule<T> rule = (GameRule<T>) GameRule.getByName(gameRule);
T value = (T)s.split(";")[1];
GameRule<T> rule = (GameRule<T>)GameRule.getByName(gameRule);
if (rule != null && check(value).getClass().equals(rule.getType()))
{
world.setGameRule(rule, value);

View File

@ -38,7 +38,7 @@ public class MojangUtils
return null;
}
client.close();
AshconInfo ashconInfo = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer<ZonedDateTime>) (json1, typeOfT, context) ->
AshconInfo ashconInfo = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer<ZonedDateTime>)(json1, typeOfT, context) ->
ZonedDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_INSTANT.parse(json1.getAsJsonPrimitive().getAsString())), ZoneId.of(Plex.get().config.getString("server.timezone")))).create().fromJson(json, AshconInfo.class);
Arrays.sort(ashconInfo.getUsernameHistories(), (o1, o2) ->

View File

@ -54,14 +54,15 @@ public class PlexUtils implements PlexBase
public static void disabledEffectMultiple(Player[] players, Location location)
{
if (players.length < 1) {
if (players.length < 1)
{
return;
}
Particle.CLOUD.builder().location(location).receivers(players).extra(0).offset(0.5, 0.5, 0.5).count(5).spawn();
Particle.FLAME.builder().location(location).receivers(players).extra(0).offset(0.5, 0.5, 0.5).count(3).spawn();
Particle.SOUL_FIRE_FLAME.builder().location(location).receivers(players).offset(0.5, 0.5, 0.5).extra(0).count(2)
.spawn();
.spawn();
// note that the sound is played to everyone who is close enough to hear it
players[0].getWorld().playSound(location, org.bukkit.Sound.BLOCK_FIRE_EXTINGUISH, 0.5f, 0.5f);
}
@ -179,7 +180,7 @@ public class PlexUtils implements PlexBase
{
try
{
return ((TextComponent) component).content();
return ((TextComponent)component).content();
}
catch (Exception e)
{

View File

@ -49,7 +49,7 @@ public class ReflectionsUtil
{
if (clazz.getSuperclass() == subType || Arrays.asList(clazz.getInterfaces()).contains(subType))
{
classes.add((Class<? extends T>) clazz);
classes.add((Class<? extends T>)clazz);
}
});
return Collections.unmodifiableSet(classes);

View File

@ -13,7 +13,6 @@ import org.apache.commons.lang3.math.NumberUtils;
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 Set<String> TIMEZONES = Set.of(TimeZone.getAvailableIDs());
private static final List<String> timeUnits = new ArrayList<>()
@ -26,6 +25,7 @@ public class TimeUtils
add("mo");
add("y");
}};
public static String TIMEZONE = Plex.get().config.getString("server.timezone");
private static int parseInteger(String s) throws NumberFormatException
{

View File

@ -38,8 +38,8 @@ public class UpdateChecker implements PlexBase
* > 0 = Number of commits behind
*/
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 String BRANCH = plugin.config.getString("update_branch");
private int distance = -4;
// Adapted from Paper
@ -47,7 +47,7 @@ public class UpdateChecker implements PlexBase
{
try
{
HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
HttpURLConnection connection = (HttpURLConnection)new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
connection.connect();
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
{

View File

@ -17,7 +17,7 @@ public class WebUtils
try
{
URL u = new URL(url);
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
HttpURLConnection connection = (HttpURLConnection)u.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
@ -39,13 +39,13 @@ public class WebUtils
public static UUID getFromName(String name)
{
JSONObject profile;
profile = (JSONObject) simpleGET("https://api.ashcon.app/mojang/v2/user/" + name);
profile = (JSONObject)simpleGET("https://api.ashcon.app/mojang/v2/user/" + name);
if (profile == null)
{
PlexLog.error("Profile from Ashcon API returned null!");
return null;
}
String uuidString = (String) profile.get("uuid");
String uuidString = (String)profile.get("uuid");
return UUID.fromString(uuidString);
}
}

View File

@ -23,7 +23,7 @@ public abstract class NoiseChunkGenerator extends CustomChunkGenerator
{
for (int zz = 0; zz < 16; zz++)
{
height = (int) generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
height = (int)generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
createLoopChunkData(xx, height, zz, chunk);
}
}

View File

@ -24,7 +24,7 @@ public abstract class OctaveChunkGenerator extends CustomChunkGenerator
{
for (int zz = 0; zz < 16; zz++)
{
height = (int) generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
height = (int)generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
createLoopChunkData(xx, height, zz, chunk);
}
}

View File

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