Skip to content

Commit

Permalink
fix(spigot): legacy paper modern velocity forwarding not being detect…
Browse files Browse the repository at this point in the history
…ed (#385)

Fixes #380
  • Loading branch information
diogotcorreia authored Feb 1, 2024
1 parent 2007557 commit 80d3ee3
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions core/src/main/java/com/rexcantor64/triton/SpigotMLP.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void onEnable() {
}

if (getConf().isBungeecord()) {
if (!isSpigotProxyMode() && !isPaperProxyMode()) {
if (!isSpigotProxyMode() && !isPaperProxyMode() && !isLegacyPaperProxyMode()) {
getLogger().logError("DANGER! DANGER! DANGER!");
getLogger().logError("Proxy mode is enabled on Triton but disabled on Spigot!");
getLogger().logError("A malicious player can run ANY command as the server.");
Expand Down Expand Up @@ -260,7 +260,7 @@ public UUID getPlayerUUIDFromString(String input) {

/**
* Use reflection to check if this Spigot server has "bungeecord" mode enabled on spigot.yml.
* This is used to show a warning if Spigot is in proxy mode, but the server is not.
* This is used to show a warning if Triton is in proxy mode, but the server is not.
*
* @return Whether this Spigot server has bungeecord enabled on spigot.yml.
*/
Expand All @@ -283,9 +283,9 @@ public boolean isSpigotProxyMode() {

/**
* Use reflection to check if this Paper server has velocity modern forwarding enabled on paper-global.yml.
* This is used to show a warning if Paper is in proxy mode, but the server is not.
* This is used to show a warning if Triton is in proxy mode, but the server is not.
*
* @return Whether this Spigot server has velocity forwarding enabled on paper-global.yml.
* @return Whether this Paper server has velocity forwarding enabled on paper-global.yml.
*/
public boolean isPaperProxyMode() {
try {
Expand All @@ -303,4 +303,24 @@ public boolean isPaperProxyMode() {
return false;
}
}

/**
* Use reflection to check if this (legacy) Paper server has velocity modern forwarding enabled on paper.yml.
* This is used to show a warning if Triton is in proxy mode, but the server is not.
*
* @return Whether this (legacy) Paper server has velocity forwarding enabled on paper-global.yml.
*/
public boolean isLegacyPaperProxyMode() {
try {
Class<?> paperConfigClass = Class.forName("com.destroystokyo.paper.PaperConfig");

Object velocityEnabled = paperConfigClass.getField("velocitySupport").get(null);
if (velocityEnabled == null) {
return false;
}
return (boolean) velocityEnabled;
} catch (Exception e) {
return false;
}
}
}

0 comments on commit 80d3ee3

Please sign in to comment.