Move Plex to API-driven plugin and fix NoClassDefFoundError on startup

This commit is contained in:
Focusvity 2022-04-24 14:16:14 +10:00
parent edeecb51f4
commit f9a577035b
No known key found for this signature in database
GPG Key ID: 85AD157561ABE94B
346 changed files with 736 additions and 118 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
/.idea/
*.iml
/target/
src/main/resources/build.properties
server/src/main/resources/build.properties
# OS
.DS_Store

View File

@ -1,46 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="BRACE_STYLE" value="2" />
<option name="CLASS_BRACE_STYLE" value="2" />
<option name="METHOD_BRACE_STYLE" value="2" />
<option name="LAMBDA_BRACE_STYLE" value="2" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
</codeStyleSettings>
</code_scheme>
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

21
api/build.gradle Normal file
View File

@ -0,0 +1,21 @@
plugins {
id 'java'
}
group 'dev.plex'
version '1.1-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
maven {
url = uri("https://papermc.io/repo/repository/maven-public/")
}
}
dependencies {
compileOnly "org.projectlombok:lombok:1.18.22"
annotationProcessor "org.projectlombok:lombok:1.18.22"
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
compileOnly "org.json:json:20220320"
}

Binary file not shown.

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0

View File

@ -1,6 +1,6 @@
package dev.plex.event;
package dev.plex.api.event;
import dev.plex.player.PlexPlayer;
import dev.plex.api.player.IPlexPlayer;
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 PlexPlayer plexPlayer;
private final IPlexPlayer plexPlayer;
public static HandlerList getHandlerList()
{

View File

@ -1,6 +1,6 @@
package dev.plex.event;
package dev.plex.api.event;
import dev.plex.player.PlexPlayer;
import dev.plex.api.player.IPlexPlayer;
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 PlexPlayer plexPlayer;
private final IPlexPlayer plexPlayer;
public static HandlerList getHandlerList()
{

View File

@ -1,7 +1,7 @@
package dev.plex.event;
package dev.plex.api.event;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import dev.plex.api.player.IPlexPlayer;
import dev.plex.api.rank.IRank;
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 PlexPlayer plexPlayer;
private final IPlexPlayer plexPlayer;
/**
* The rank the player was set to
*/
private final Rank rank;
private final IRank rank;
public static HandlerList getHandlerList()
{

View File

@ -1,4 +1,4 @@
package dev.plex.event;
package dev.plex.api.event;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
@Data
public class GameModeUpdateEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private final CommandSender sender;

View File

@ -1,6 +1,6 @@
package dev.plex.event;
package dev.plex.api.event;
import dev.plex.player.PlexPlayer;
import dev.plex.api.player.IPlexPlayer;
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 PlexPlayer punishedPlayer;
protected IPlexPlayer 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 PlexPlayer
* @see IPlexPlayer
*/
protected PunishedPlayerEvent(PlexPlayer punishedPlayer)
protected PunishedPlayerEvent(IPlexPlayer punishedPlayer)
{
super(Bukkit.getPlayer(punishedPlayer.getUuid()));
this.punishedPlayer = punishedPlayer;

View File

@ -1,6 +1,6 @@
package dev.plex.event;
package dev.plex.api.event;
import dev.plex.player.PlexPlayer;
import dev.plex.api.player.IPlexPlayer;
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(PlexPlayer punishedPlayer, boolean frozen)
public PunishedPlayerFreezeEvent(IPlexPlayer punishedPlayer, boolean frozen)
{
super(punishedPlayer);
this.frozen = frozen;

View File

@ -1,6 +1,6 @@
package dev.plex.event;
package dev.plex.api.event;
import dev.plex.player.PlexPlayer;
import dev.plex.api.player.IPlexPlayer;
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(PlexPlayer punishedPlayer, boolean lockedUp)
public PunishedPlayerLockupEvent(IPlexPlayer punishedPlayer, boolean lockedUp)
{
super(punishedPlayer);
this.lockedUp = lockedUp;

View File

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

View File

@ -0,0 +1,68 @@
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

@ -0,0 +1,27 @@
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
{
int getLevel();
String getLoginMessage();
void setLoginMessage(String message);
String getReadable();
Component getPrefix();
void setPrefix(String prefix);
NamedTextColor getColor();
boolean isAtLeast(IRank rank);
JSONObject toJSON();
}

View File

@ -55,6 +55,7 @@ dependencies {
}
implementation "org.bstats:bstats-base:3.0.0"
implementation "org.bstats:bstats-bukkit:3.0.0"
implementation project(":api")
}
group = "dev.plex"
@ -68,7 +69,7 @@ shadowJar {
bukkit {
name = "Plex"
version = rootProject.version
version = project.version
description = "Plex provides a new experience for freedom servers."
main = "dev.plex.Plex"
website = "https://plex.us.org"
@ -110,7 +111,7 @@ static def getDate() {
}
task buildProperties {
ant.propertyfile(file: "$project.rootDir/src/main/resources/build.properties") {
ant.propertyfile(file: "$project.projectDir/src/main/resources/build.properties") {
entry(key: "buildAuthor", default: System.getenv("JENKINS_URL") != null ? "jenkins" : "unknown")
entry(key: "buildNumber", value: System.getenv("JENKINS_URL") != null ? System.getenv("BUILD_NUMBER") + " (Jenkins)" : getBuildNumber())
entry(key: "buildDate", value: getDate())

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More