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/ /.idea/
*.iml *.iml
/target/ /target/
src/main/resources/build.properties server/src/main/resources/build.properties
# OS # OS
.DS_Store .DS_Store

View file

@ -1,46 +1,5 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <state>
<JavaCodeStyleSettings> <option name="USE_PER_PROJECT_SETTINGS" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" /> </state>
<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>
</component> </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.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 PlexPlayer plexPlayer; private final IPlexPlayer plexPlayer;
public static HandlerList getHandlerList() 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.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 PlexPlayer plexPlayer; private final IPlexPlayer plexPlayer;
public static HandlerList getHandlerList() 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.api.player.IPlexPlayer;
import dev.plex.rank.enums.Rank; import dev.plex.api.rank.IRank;
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 PlexPlayer plexPlayer; private final IPlexPlayer plexPlayer;
/** /**
* The rank the player was set to * The rank the player was set to
*/ */
private final Rank rank; private final IRank rank;
public static HandlerList getHandlerList() public static HandlerList getHandlerList()
{ {

View file

@ -1,4 +1,4 @@
package dev.plex.event; package dev.plex.api.event;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
@Data @Data
public class GameModeUpdateEvent extends Event public class GameModeUpdateEvent extends Event
{ {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final CommandSender sender; 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.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 PlexPlayer punishedPlayer; protected IPlexPlayer 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 PlexPlayer * @see IPlexPlayer
*/ */
protected PunishedPlayerEvent(PlexPlayer punishedPlayer) protected PunishedPlayerEvent(IPlexPlayer 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.event; package dev.plex.api.event;
import dev.plex.player.PlexPlayer; import dev.plex.api.player.IPlexPlayer;
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(PlexPlayer punishedPlayer, boolean frozen) public PunishedPlayerFreezeEvent(IPlexPlayer punishedPlayer, boolean frozen)
{ {
super(punishedPlayer); super(punishedPlayer);
this.frozen = frozen; 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 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(PlexPlayer punishedPlayer, boolean lockedUp) public PunishedPlayerLockupEvent(IPlexPlayer punishedPlayer, boolean lockedUp)
{ {
super(punishedPlayer); super(punishedPlayer);
this.lockedUp = lockedUp; 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 lombok.Getter;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -11,6 +11,7 @@ import org.bukkit.event.HandlerList;
@Getter @Getter
public class PunishedPlayerMuteEvent extends PunishedPlayerEvent implements Cancellable public class PunishedPlayerMuteEvent extends PunishedPlayerEvent implements Cancellable
{ {
private static final HandlerList handlers = new HandlerList(); 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 punishedPlayer The player who was punished
* @param muted The new muted status * @param muted The new muted status
*/ */
public PunishedPlayerMuteEvent(PlexPlayer punishedPlayer, boolean muted) public PunishedPlayerMuteEvent(IPlexPlayer punishedPlayer, boolean muted)
{ {
super(punishedPlayer); super(punishedPlayer);
this.muted = muted; 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-base:3.0.0"
implementation "org.bstats:bstats-bukkit:3.0.0" implementation "org.bstats:bstats-bukkit:3.0.0"
implementation project(":api")
} }
group = "dev.plex" group = "dev.plex"
@ -68,7 +69,7 @@ shadowJar {
bukkit { bukkit {
name = "Plex" name = "Plex"
version = rootProject.version version = project.version
description = "Plex provides a new experience for freedom servers." description = "Plex provides a new experience for freedom servers."
main = "dev.plex.Plex" main = "dev.plex.Plex"
website = "https://plex.us.org" website = "https://plex.us.org"
@ -110,7 +111,7 @@ static def getDate() {
} }
task buildProperties { 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: "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: "buildNumber", value: System.getenv("JENKINS_URL") != null ? System.getenv("BUILD_NUMBER") + " (Jenkins)" : getBuildNumber())
entry(key: "buildDate", value: getDate()) 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