mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-03-09 13:09:09 +01:00
Change compatibility module config: allow disabling CB modules.
This commit is contained in:
parent
b91cfc7095
commit
79ed68efbd
@ -627,12 +627,19 @@ public abstract class ConfPaths {
|
||||
// Compatibility section (possibly temporary).
|
||||
@GlobalConfig
|
||||
public static final String COMPATIBILITY = "compatibility.";
|
||||
public static final String COMPATIBILITY_MANAGELISTENERS = COMPATIBILITY + "managelisteners";
|
||||
|
||||
public static final String COMPATIBILITY_EXEMPTIONS = COMPATIBILITY + "exemptions.";
|
||||
public static final String COMPATIBILITY_EXEMPTIONS_REMOVE = COMPATIBILITY_EXEMPTIONS + "remove.";
|
||||
public static final String COMPATIBILITY_EXEMPTIONS_REMOVE_JOIN = COMPATIBILITY_EXEMPTIONS_REMOVE + "join";
|
||||
public static final String COMPATIBILITY_EXEMPTIONS_REMOVE_LEAVE = COMPATIBILITY_EXEMPTIONS_REMOVE + "leave";
|
||||
public static final String COMPATIBILITY_MANAGELISTENERS = COMPATIBILITY + "managelisteners";
|
||||
public static final String COMPATIBILITY_BUKKITONLY = COMPATIBILITY + "bukkitapionly";
|
||||
|
||||
public static final String COMPATIBILITY_SERVER = COMPATIBILITY + "server.";
|
||||
public static final String COMPATIBILITY_SERVER_CBDEDICATED = COMPATIBILITY_SERVER + "cbdedicated.";
|
||||
public static final String COMPATIBILITY_SERVER_CBDEDICATED_ENABLE = COMPATIBILITY_SERVER_CBDEDICATED + "enable";
|
||||
public static final String COMPATIBILITY_SERVER_CBREFLECT = COMPATIBILITY_SERVER + "cbreflect.";
|
||||
public static final String COMPATIBILITY_SERVER_CBREFLECT_ENABLE = COMPATIBILITY_SERVER_CBREFLECT + "enable";
|
||||
|
||||
public static final String COMPATIBILITY_BLOCKS = COMPATIBILITY + "blocks.";
|
||||
|
||||
// Deprecated (don't use fields from above).
|
||||
@ -688,5 +695,7 @@ public abstract class ConfPaths {
|
||||
public static final String FIGHT_KNOCKBACK_ACTIONS = "checks.fight.knockback.actions";
|
||||
@Deprecated
|
||||
public static final String NET_FLYINGFREQUENCY_MAXPACKETS = "checks.net.flyingfrequency.maxpackets";
|
||||
@Deprecated
|
||||
public static final String COMPATIBILITY_BUKKITONLY = "compatibility.bukkitapionly";
|
||||
|
||||
}
|
||||
|
@ -529,10 +529,11 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.STRINGS + ".tempkick5", "ncp tempkick [player] 5 You have five minutes to think about it!");
|
||||
|
||||
// Compatibility settings.
|
||||
set(ConfPaths.COMPATIBILITY_MANAGELISTENERS, false);
|
||||
set(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_JOIN, true);
|
||||
set(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_LEAVE, true);
|
||||
set(ConfPaths.COMPATIBILITY_MANAGELISTENERS, false);
|
||||
set(ConfPaths.COMPATIBILITY_BUKKITONLY, false);
|
||||
set(ConfPaths.COMPATIBILITY_SERVER_CBDEDICATED_ENABLE, true);
|
||||
set(ConfPaths.COMPATIBILITY_SERVER_CBREFLECT_ENABLE, true);
|
||||
set(ConfPaths.COMPATIBILITY_BLOCKS + ConfPaths.SUB_IGNOREPASSABLE, Arrays.asList(
|
||||
Material.WOODEN_DOOR.name(), Material.IRON_DOOR_BLOCK.name(),
|
||||
Material.TRAP_DOOR.name(),
|
||||
|
@ -49,6 +49,7 @@ import fr.neatmonster.nocheatplus.command.admin.VersionCommand;
|
||||
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
|
||||
import fr.neatmonster.nocheatplus.compat.DefaultComponentFactory;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccessConfig;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccessFactory;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.BukkitVersion;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
|
||||
@ -1033,7 +1034,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
public MCAccess initMCAccess(final ConfigFile config) {
|
||||
// Reset MCAccess.
|
||||
// TODO: Might fire a NCPSetMCAccessFromFactoryEvent (include getting and setting)!
|
||||
final MCAccess mcAccess = new MCAccessFactory().getMCAccess(config.getBoolean(ConfPaths.COMPATIBILITY_BUKKITONLY));
|
||||
final MCAccess mcAccess = new MCAccessFactory().getMCAccess(new MCAccessConfig());
|
||||
setMCAccess(mcAccess);
|
||||
return mcAccess;
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package fr.neatmonster.nocheatplus.compat;
|
||||
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||
|
||||
public class MCAccessConfig {
|
||||
|
||||
public final boolean enableCBDedicated;
|
||||
public final boolean enableCBReflect;
|
||||
|
||||
public MCAccessConfig() {
|
||||
final ConfigFile config = ConfigManager.getConfigFile();
|
||||
this.enableCBDedicated = config.getBoolean(ConfPaths.COMPATIBILITY_SERVER_CBDEDICATED_ENABLE);
|
||||
this.enableCBReflect = config.getBoolean(ConfPaths.COMPATIBILITY_SERVER_CBREFLECT_ENABLE);
|
||||
}
|
||||
|
||||
}
|
@ -20,7 +20,7 @@ public class MCAccessFactory {
|
||||
|
||||
private final String[] updateLocs = new String[]{
|
||||
"[NoCheatPlus] Check for updates and support at BukkitDev: http://dev.bukkit.org/server-mods/nocheatplus/",
|
||||
"[NoCheatPlus] Development builds (unsupported by the Bukkit Staff, at your own risk): http://ci.md-5.net/job/NoCheatPlus/changes",
|
||||
"[NoCheatPlus] Development builds (unsupported by the Bukkit Staff, use at your own risk): http://ci.md-5.net/job/NoCheatPlus/changes",
|
||||
};
|
||||
|
||||
/**
|
||||
@ -29,49 +29,49 @@ public class MCAccessFactory {
|
||||
* @return
|
||||
* @throws RuntimeException if no access can be set.
|
||||
*/
|
||||
public MCAccess getMCAccess(final boolean bukkitOnly) {
|
||||
public MCAccess getMCAccess(final MCAccessConfig config) {
|
||||
final List<Throwable> throwables = new ArrayList<Throwable>();
|
||||
|
||||
MCAccess mcAccess = null;
|
||||
// Try to set up native access.
|
||||
if (!bukkitOnly) {
|
||||
// CraftBukkit (dedicated).
|
||||
MCAccess mcAccess = getMCAccessCraftBukkit(throwables);
|
||||
|
||||
// CraftBukkit (dedicated).
|
||||
if (config.enableCBDedicated) {
|
||||
mcAccess = getMCAccessCraftBukkit(throwables);
|
||||
if (mcAccess != null) {
|
||||
return mcAccess;
|
||||
}
|
||||
// CraftBukkit (reflection).
|
||||
}
|
||||
|
||||
// CraftBukkit (reflection).
|
||||
if (config.enableCBReflect) {
|
||||
try {
|
||||
return new MCAccessCBReflect();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throwables.add(t);
|
||||
}
|
||||
// Glowstone.
|
||||
try {
|
||||
return new MCAccessGlowstone();
|
||||
} catch(Throwable t) {
|
||||
throwables.add(t);
|
||||
};
|
||||
}
|
||||
|
||||
// Glowstone.
|
||||
try {
|
||||
return new MCAccessGlowstone();
|
||||
} catch(Throwable t) {
|
||||
throwables.add(t);
|
||||
};
|
||||
|
||||
// Try to set up api-only access (since 1.4.6).
|
||||
try{
|
||||
try {
|
||||
mcAccess = new MCAccessBukkit();
|
||||
final String msg;
|
||||
if (bukkitOnly) {
|
||||
msg = "[NoCheatPlus] The plugin is configured for Bukkit-API-only access.";
|
||||
}
|
||||
else{
|
||||
msg = "[NoCheatPlus] Could not set up native access for the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support.";
|
||||
for (String uMsg : updateLocs) {
|
||||
StaticLog.logWarning(uMsg);
|
||||
}
|
||||
}
|
||||
msg = "[NoCheatPlus] Running in Bukkit-API-only mode (" + Bukkit.getServer().getVersion() + "). If this is not intended, please check for updates and consider to request support.";
|
||||
StaticLog.logWarning(msg);
|
||||
final MCAccess mcAccess = new MCAccessBukkit();
|
||||
for (String uMsg : updateLocs) {
|
||||
StaticLog.logWarning(uMsg);
|
||||
}
|
||||
// if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_EXTENDED_STATUS)) {
|
||||
// log(throwables); // Maybe later activate with TRACE explicitly set
|
||||
// }
|
||||
StaticLog.logWarning("[NoCheatPlus] Bukkit-API-only access: Some features will likely not function properly, performance might suffer.");
|
||||
StaticLog.logWarning("[NoCheatPlus] Bukkit-API-only mode: Some features will likely not function properly, performance might suffer.");
|
||||
return mcAccess;
|
||||
}
|
||||
catch(Throwable t) {
|
||||
|
Loading…
Reference in New Issue
Block a user