1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Don't yell if Floodgate cannot remove the injection

This commit is contained in:
Camotoy
2021-06-06 20:04:35 -04:00
parent 4403868633
commit 6af0c80162
5 changed files with 22 additions and 2 deletions

View File

@@ -42,6 +42,16 @@ public interface PlatformInjector {
*/ */
boolean inject() throws Exception; boolean inject() throws Exception;
/**
* Some platforms may not be able to remove their injection process. If so, this method will
* return false.
*
* @return true if it is safe to attempt to remove our injection performed in {@link #inject()}.
*/
default boolean canRemoveInjection() {
return true;
}
/** /**
* Removes the injection from the server. Please note that this function should only be used * Removes the injection from the server. Please note that this function should only be used
* internally (on plugin shutdown). This method will also remove every added addon. * internally (on plugin shutdown). This method will also remove every added addon.

View File

@@ -65,6 +65,11 @@ public final class BungeeInjector extends CommonPlatformInjector {
} }
} }
@Override
public boolean canRemoveInjection() {
return false;
}
@Override @Override
public boolean removeInjection() { public boolean removeInjection() {
logger.error("Floodgate cannot remove itself from Bungee without a reboot"); logger.error("Floodgate cannot remove itself from Bungee without a reboot");

View File

@@ -127,7 +127,7 @@ public class FloodgatePlatform {
} }
public boolean disable() { public boolean disable() {
if (injector != null) { if (injector != null && injector.canRemoveInjection()) {
try { try {
if (!injector.removeInjection()) { if (!injector.removeInjection()) {
logger.error("Failed to remove the injection!"); logger.error("Failed to remove the injection!");

View File

@@ -75,6 +75,11 @@ public final class VelocityInjector extends CommonPlatformInjector {
return injected = true; return injected = true;
} }
@Override
public boolean canRemoveInjection() {
return false;
}
@Override @Override
public boolean removeInjection() { public boolean removeInjection() {
logger.error("Floodgate cannot remove itself from Bungee without a reboot"); logger.error("Floodgate cannot remove itself from Bungee without a reboot");