mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-18 18:01:17 +02: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
|
author: Evenprime
|
||||||
|
|
||||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||||
version: 1.08a
|
version: 1.08b
|
||||||
|
|
||||||
softdepend: [ Permissions, CraftIRC ]
|
softdepend: [ Permissions, CraftIRC ]
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ public class NukeCheck extends Check {
|
|||||||
private String kickMessage;
|
private String kickMessage;
|
||||||
private String logMessage;
|
private String logMessage;
|
||||||
|
|
||||||
|
private boolean limitReach;
|
||||||
|
|
||||||
public NukeCheck(NoCheat plugin, NoCheatConfiguration config) {
|
public NukeCheck(NoCheat plugin, NoCheatConfiguration config) {
|
||||||
|
|
||||||
super(plugin, "nuke", PermissionData.PERMISSION_NUKE, config);
|
super(plugin, "nuke", PermissionData.PERMISSION_NUKE, config);
|
||||||
@ -42,6 +44,8 @@ public class NukeCheck extends Check {
|
|||||||
logMessage = config.getStringValue("nuke.logmessage").
|
logMessage = config.getStringValue("nuke.logmessage").
|
||||||
replace("[player]", "%1$s");
|
replace("[player]", "%1$s");
|
||||||
|
|
||||||
|
limitReach = config.getBooleanValue("nuke.limitreach");
|
||||||
|
|
||||||
setActive(config.getBooleanValue("active.nuke"));
|
setActive(config.getBooleanValue("active.nuke"));
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
setActive(false);
|
setActive(false);
|
||||||
@ -74,7 +78,9 @@ public class NukeCheck extends Check {
|
|||||||
|
|
||||||
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) {
|
factor * direction.getX() <= x2 && factor * direction.getY() <= y2 && factor * direction.getZ() <= z2) {
|
||||||
if(data.counter > 0) {
|
if(data.counter > 0) {
|
||||||
data.counter--;
|
data.counter--;
|
||||||
|
@ -244,6 +244,8 @@ public class NoCheatConfiguration {
|
|||||||
SimpleYaml.getString("nuke.logmessage", "Nuke: [player] tried to nuke the world", yamlContent)));
|
SimpleYaml.getString("nuke.logmessage", "Nuke: [player] tried to nuke the world", yamlContent)));
|
||||||
nukeNode.add(new LongStringOption("kickmessage",
|
nukeNode.add(new LongStringOption("kickmessage",
|
||||||
SimpleYaml.getString("nuke.kickmessage", "No nuking allowed", yamlContent)));
|
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.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" +
|
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.");
|
"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) {
|
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) {
|
public static boolean getBoolean(String path, boolean defaultValue, Map<String, Object> node) {
|
||||||
try {
|
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) {
|
catch(Exception e) {
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user