-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
LiquidRequirement.java
58 lines (45 loc) · 1.85 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
48
49
50
51
52
53
54
55
56
57
58
package net.aufdemrand.denizen.scripts.requirements.core;
import net.aufdemrand.denizen.exceptions.RequirementCheckException;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.scripts.requirements.AbstractRequirement;
import net.aufdemrand.denizen.scripts.requirements.RequirementsContext;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.aH;
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 = dLocation.valueOf(thisArg).getBlock();
if (blockToCheck != null) {
dB.echoDebug(context.getScriptContainer(), "...block to check is type '" + blockToCheck.getType().toString() + "'");
}
}
else {
dB.echoError("Could not match argument '" + thisArg + "'");
}
}
if (blockToCheck != null && blockToCheck.isLiquid()) {
outcome = true;
}
if (outcome) {
dB.echoDebug(context.getScriptContainer(), "...block is liquid!");
}
else {
dB.echoDebug(context.getScriptContainer(), "...block is not liquid!");
}
return outcome;
}
}