/
LiquidRequirement.java
47 lines (34 loc) · 1.42 KB
/
LiquidRequirement.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package net.aufdemrand.denizen.scripts.requirements.core;
import net.aufdemrand.denizen.exceptions.RequirementCheckException;
import net.aufdemrand.denizen.scripts.requirements.AbstractRequirement;
import net.aufdemrand.denizen.scripts.requirements.RequirementsContext;
import net.aufdemrand.denizen.objects.aH;
import net.aufdemrand.denizen.utilities.debugging.dB;
import org.bukkit.block.Block;
import java.util.List;
public class LiquidRequirement extends AbstractRequirement{
@Override
public void onEnable() {
// nothing to do here
}
@Override
public boolean check(RequirementsContext context, List<String> args) throws RequirementCheckException {
boolean outcome = false;
Block blockToCheck = null;
if(args.size() < 1)
throw new RequirementCheckException("Must provide a BOOKMARK:block of the block to be checked!");
/* Get arguments */
for (String thisArg : args) {
if (aH.matchesLocation(thisArg)) {
blockToCheck = aH.getLocationFrom(thisArg).getBlock();
if (blockToCheck != null)
dB.echoDebug("...block to check is type '%s'.", blockToCheck.getType().toString());
}
else dB.echoError("Could not match argument '%s'!", thisArg);
}
if (blockToCheck != null && blockToCheck.isLiquid()) outcome = true;
if (outcome == true) dB.echoDebug("...block is liquid!");
else dB.echoDebug("...block is not liquid!");
return outcome;
}
}