Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(spigot): legacy paper modern velocity forwarding not being detected #385

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}
Loading