Copy public class ConditionExample extends Condition {
public ConditionExample ( String identifier) {
super(identifier , "isExample" , 1 , false );
}
@ Override
public boolean parseCondition ( String [] args , LivingEntity player , @ Nullable LivingEntity target) {
return player . isGliding ();
}
}
Copy public class ConditionBlock extends Condition {
public ConditionBlock () {
super( "isBlock" , "isBlock [BLOCK-TYPE]" , 2 , true );
}
@ Override
public boolean parseCondition ( String [] args , LivingEntity player , @ Nullable LivingEntity target , Event event) {
if ( ! (event instanceof BlockBreakEvent)) return false ;
BlockBreakEvent blockBreakEvent = (BlockBreakEvent) event;
String block = args[ 1 ] . trim ();
return blockBreakEvent . getBlock () . getType () . toString () . equalsIgnoreCase (block);
}
}
Registering the condition
You will then need to add the following to your onEnable (Preferably with a delay)
You can register multiple conditions by separating them with a comma as shown below
Copy @ Override
public void onEnable() {
if ( getServer() . getPluginManager () . isPluginEnabled ( "EliteEnchantments" )) {
EliteEnchantmentsAPI . getAPI () . registerConditions (
new ConditionExample() ,
new ConditionBlock()
);
}
}