Added option to limit reach for block destruction + configuration file

will get default values for missing boolean options instead of always
false.
This commit is contained in:
Evenprime 2011-07-09 18:32:07 +02:00
parent be9a728eda
commit 25ab6a6659
5 changed files with 21 additions and 4 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 1.08a
version: 1.08b
softdepend: [ Permissions, CraftIRC ]

View File

@ -26,6 +26,8 @@ public class NukeCheck extends Check {
private String kickMessage;
private String logMessage;
private boolean limitReach;
public NukeCheck(NoCheat plugin, NoCheatConfiguration config) {
super(plugin, "nuke", PermissionData.PERMISSION_NUKE, config);
@ -42,6 +44,8 @@ public class NukeCheck extends Check {
logMessage = config.getStringValue("nuke.logmessage").
replace("[player]", "%1$s");
limitReach = config.getBooleanValue("nuke.limitreach");
setActive(config.getBooleanValue("active.nuke"));
} catch (ConfigurationException e) {
setActive(false);
@ -72,9 +76,11 @@ public class NukeCheck extends Check {
final double y2 = y1 + 2;
final double z2 = z1 + 2;
double factor = new Vector(x1 + 1, y1 + 1, z1 + 1).length();
double factor = new Vector(x1 + 1, y1 + 1, z1 + 1).length();
if(factor * direction.getX() >= x1 && factor * direction.getY() >= y1 && factor * direction.getZ() >= z1 &&
boolean tooFarAway = limitReach && factor > 4.85D;
if(!tooFarAway && factor * direction.getX() >= x1 && factor * direction.getY() >= y1 && factor * direction.getZ() >= z1 &&
factor * direction.getX() <= x2 && factor * direction.getY() <= y2 && factor * direction.getZ() <= z2) {
if(data.counter > 0) {
data.counter--;

View File

@ -244,6 +244,8 @@ public class NoCheatConfiguration {
SimpleYaml.getString("nuke.logmessage", "Nuke: [player] tried to nuke the world", yamlContent)));
nukeNode.add(new LongStringOption("kickmessage",
SimpleYaml.getString("nuke.kickmessage", "No nuking allowed", yamlContent)));
nukeNode.add(new BooleanOption("limitreach",
SimpleYaml.getBoolean("nuke.limitreach", true, yamlContent)));
}

View File

@ -182,6 +182,8 @@ public class Explainations {
set("nuke.kickmessage", "The message that is shown to players that get kicked for nuking");
set("nuke.checkops", "Also check players with OP-status, unless there is another reason\n" +
"to not check them, e.g. they got the relevant permission from a Permissions plugin.");
set("nuke.limitreach", "Deny blockbreaking over longer distances than the standard minecraft\n" +
"client allows.");
}
private static void set(String id, String text) {

View File

@ -121,7 +121,14 @@ public class SimpleYaml {
public static boolean getBoolean(String path, boolean defaultValue, Map<String, Object> node) {
try {
return Boolean.parseBoolean((String)getProperty(path, node));
if(((String)getProperty(path, node)).equals("true")) {
return true;
} else if(((String)getProperty(path, node)).equals("false")) {
return false;
}
else {
return defaultValue;
}
}
catch(Exception e) {
//e.printStackTrace();