Move multi protocol plugin activation to a utility.
This commit is contained in:
parent
ddc0436e43
commit
049a925fb3
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue