mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-03 01:00:20 +01:00
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:
parent
be9a728eda
commit
25ab6a6659
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 1.08a
|
||||
version: 1.08b
|
||||
|
||||
softdepend: [ Permissions, CraftIRC ]
|
||||
|
||||
|
@ -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);
|
||||
@ -74,7 +78,9 @@ public class NukeCheck extends Check {
|
||||
|
||||
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--;
|
||||
|
@ -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)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user