Move multi protocol plugin activation to a utility.

This commit is contained in:
asofold 2017-05-28 21:03:21 +02:00
parent ddc0436e43
commit 049a925fb3
2 changed files with 38 additions and 8 deletions

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.activation;
import fr.neatmonster.nocheatplus.components.registry.activation.Activation;
/**
* Static auxiliary functionality.
*
* @author asofold
*
*/
public class ActivationUtil {
private static final String ERROR_NEED_CONDITION_OR = "Must use setConditionOR() with this method.";
/**
* Auxiliary method to activate with any of the typical protocol support
* plugins existing (currently: ViaVersion, ProtocolSupport).
*
* @param activation
* @return The given Activation instance.
* @throws IllegalArgumentException
* If getConditionOr does not return true.
*/
public static Activation addMultiProtocolSupportPlugins(Activation activation) {
// TODO: Typically there is more confinement necessary, more specific naming will be needed.
if (!activation.getConditionsOR()) {
throw new IllegalArgumentException(ERROR_NEED_CONDITION_OR);
}
// ViaVersion
activation.pluginExist("ViaVersion");
// ProtocolSupport
activation.pluginExist("ProtocolSupport");
return activation;
}
}

View File

@ -2,6 +2,7 @@ package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.special;
import org.bukkit.Material;
import fr.neatmonster.nocheatplus.compat.activation.ActivationUtil;
import fr.neatmonster.nocheatplus.compat.blocks.AbstractBlockPropertiesPatch;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.utilities.map.BlockFlags;
@ -23,14 +24,7 @@ public class MultiClientProtocolWaterLilyPatch extends AbstractBlockPropertiesPa
.setConditionsOR()
// TODO: Other/More ?
;
// ViaVersion
activation
.pluginExist("ViaVersion")
;
// ProtocolSupport
activation
.pluginExist("ProtocolSupport")
;
ActivationUtil.addMultiProtocolSupportPlugins(activation);
}
@Override