Archiviert
13
0

Add the ability to set the default injection hook method.

This is useful for debugging.
Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-01-13 11:31:32 +01:00
Ursprung 17a5f59c0d
Commit 845f339a30
3 geänderte Dateien mit 49 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -23,6 +23,8 @@ import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks;
/** /**
* Represents the configuration of ProtocolLib. * Represents the configuration of ProtocolLib.
* *
@ -36,9 +38,10 @@ class ProtocolConfig {
private static final String METRICS_ENABLED = "metrics"; private static final String METRICS_ENABLED = "metrics";
private static final String IGNORE_VERSION_CHECK = "ignore version check"; private static final String IGNORE_VERSION_CHECK = "ignore version check";
private static final String BACKGROUND_COMPILER_ENABLED = "background compiler"; private static final String BACKGROUND_COMPILER_ENABLED = "background compiler";
private static final String INJECTION_METHOD = "injection method";
private static final String UPDATER_NOTIFY = "notify"; private static final String UPDATER_NOTIFY = "notify";
private static final String UPDATER_DOWNLAD = "download"; private static final String UPDATER_DOWNLAD = "download";
private static final String UPDATER_DELAY = "delay"; private static final String UPDATER_DELAY = "delay";
@ -234,6 +237,38 @@ class ProtocolConfig {
updater.set(UPDATER_LAST_TIME, lastTimeSeconds); updater.set(UPDATER_LAST_TIME, lastTimeSeconds);
} }
/**
* Retrieve the default injection method.
* @return Default method.
*/
public PlayerInjectHooks getDefaultMethod() {
return PlayerInjectHooks.NETWORK_SERVER_OBJECT;
}
/**
* Retrieve the injection method that has been set in the configuration, or use a default value.
* @return Injection method to use.
* @throws IllegalArgumentException If the configuration option is malformed.
*/
public PlayerInjectHooks getInjectionMethod() throws IllegalArgumentException {
String text = global.getString(INJECTION_METHOD);
// Default hook if nothing has been set
PlayerInjectHooks hook = getDefaultMethod();
if (text != null)
hook = PlayerInjectHooks.valueOf(text.toUpperCase().replace(" ", "_"));
return hook;
}
/**
* Set the starting injection method to use.
* @return Injection method.
*/
public void setInjectionMethod(PlayerInjectHooks hook) {
global.set(INJECTION_METHOD, hook.name());
}
/** /**
* Save the current configuration file. * Save the current configuration file.
*/ */

Datei anzeigen

@ -136,6 +136,13 @@ public class ProtocolLibrary extends JavaPlugin {
protocolManager = new PacketFilterManager(getClassLoader(), getServer(), unhookTask, detailedReporter); protocolManager = new PacketFilterManager(getClassLoader(), getServer(), unhookTask, detailedReporter);
detailedReporter.addGlobalParameter("manager", protocolManager); detailedReporter.addGlobalParameter("manager", protocolManager);
// Update injection hook
try {
protocolManager.setPlayerHook(config.getInjectionMethod());
} catch (IllegalArgumentException e) {
detailedReporter.reportWarning(config, "Cannot parse injection method. Using default.", e);
}
// Initialize command handlers // Initialize command handlers
commandProtocol = new CommandProtocol(detailedReporter, this, updater, config); commandProtocol = new CommandProtocol(detailedReporter, this, updater, config);
commandPacket = new CommandPacket(detailedReporter, this, logger, protocolManager); commandPacket = new CommandPacket(detailedReporter, this, logger, protocolManager);

Datei anzeigen

@ -16,3 +16,7 @@ global:
# Disable version checking for the given Minecraft version. Backup your world first! # Disable version checking for the given Minecraft version. Backup your world first!
ignore version check: ignore version check:
# Override the starting injecting method
injection method: