mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-28 03:17:53 +01:00
Show warning about disfunctional Permissions plugin (at most) every 60
seconds instead of just once. Shutdown ALL async tasks properly (missed one) Added new keyword "[distance]" for moving violation messages
This commit is contained in:
parent
bfae43effc
commit
2fa4beb656
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 1.04b
|
||||
version: 1.04c
|
||||
|
||||
softdepend: [ Permissions, CraftIRC ]
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
|
||||
private NoCheatConfiguration config;
|
||||
|
||||
private boolean exceptionWithPermissions = false;
|
||||
private long exceptionWithPermissions = 0;
|
||||
|
||||
private int cleanUpTaskId = -1;
|
||||
private int serverLagMeasureTaskSetup = -1;
|
||||
@ -188,7 +188,7 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
|
||||
if(serverLagMeasureTaskSetup != -1) return;
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
|
||||
serverLagMeasureTaskSetup = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -201,7 +201,7 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
}
|
||||
|
||||
private void teardownServerLagMeasureTask() {
|
||||
if(serverLagMeasureTaskSetup == -1)
|
||||
if(serverLagMeasureTaskSetup != -1)
|
||||
Bukkit.getServer().getScheduler().cancelTask(serverLagMeasureTaskSetup);
|
||||
}
|
||||
|
||||
@ -298,11 +298,11 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
}
|
||||
}
|
||||
catch(Throwable e) {
|
||||
if(!this.exceptionWithPermissions) {
|
||||
if(this.exceptionWithPermissions + 60000 < System.currentTimeMillis()) {
|
||||
// Prevent spam and recursion by definitely doing this only once
|
||||
this.exceptionWithPermissions = true;
|
||||
this.exceptionWithPermissions = System.currentTimeMillis();
|
||||
|
||||
String logtext = "Asking Permissions-Plugin if "+player.getName()+" has permission "+PermissionData.permissionNames[permission]+" caused an Exception "+ e.getMessage() + ". Please review your permissions config file. This message is only displayed once, the player is considered to not have that permission from now on. The full stack trace is written into the nocheat logfile.";
|
||||
String logtext = "Asking Permissions-Plugin if "+player.getName()+" has permission "+PermissionData.permissionNames[permission]+" caused an Exception "+ e.getMessage() + ". Please review your permissions config file. This message is displayed at most once every 60 seconds.";
|
||||
log(Level.SEVERE, logtext);
|
||||
for(StackTraceElement s : e.getStackTrace()) {
|
||||
config.logger.log(Level.SEVERE, s.toString());
|
||||
|
@ -84,8 +84,9 @@ public class NoCheatData {
|
||||
int id;
|
||||
id = pairs.getValue().airbuild != null ? pairs.getValue().airbuild.summaryTask : -1;
|
||||
|
||||
if(id != -1)
|
||||
if(id != -1) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(id);
|
||||
}
|
||||
|
||||
id = pairs.getValue().moving != null ? pairs.getValue().moving.summaryTask : -1;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -507,7 +508,7 @@ public class MovingCheck extends Check {
|
||||
if(a.firstAfter == violations || a.repeat) {
|
||||
if(a instanceof LogAction) {
|
||||
// prepare log message if necessary
|
||||
String log = String.format(logMessage, player.getName(), from.getWorld().getName(), to.getWorld().getName(), from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ());
|
||||
String log = String.format(Locale.US, logMessage, player.getName(), from.getWorld().getName(), to.getWorld().getName(), from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ(), Math.abs(from.getX()-to.getX()),to.getY()-from.getY(), Math.abs(from.getZ()-to.getZ()));
|
||||
|
||||
plugin.log(((LogAction)a).level, log);
|
||||
|
||||
|
@ -149,11 +149,16 @@ public class NoCheatConfiguration {
|
||||
root.add(movingNode);
|
||||
|
||||
movingNode.add(new LongStringOption("logmessage",
|
||||
SimpleYaml.getString("moving.logmessage", "Moving violation: [player] from [world] [from] to [to]", yamlContent).
|
||||
replace("[player]", "%1$s").replace("[world]", "%2$s").replace("[from]", "(%4$.1f, %5$.1f, %6$.1f)").replace("[to]", "(%7$.1f, %8$.1f, %9$.1f)")));
|
||||
SimpleYaml.getString("moving.logmessage", "Moving violation: [player] from [world] [from] to [to] distance [distance]", yamlContent).
|
||||
replace("[player]", "%1$s").replace("[world]", "%2$s").
|
||||
replace("[from]", "(%4$.1f, %5$.1f, %6$.1f)").
|
||||
replace("[to]", "(%7$.1f, %8$.1f, %9$.1f)").
|
||||
replace("[distance]", "(%10$.1f, %11$.1f, %12$.1f)")));
|
||||
|
||||
movingNode.add(new LongStringOption("summarymessage",
|
||||
SimpleYaml.getString("moving.summarymessage", "Moving summary of last ~[timeframe] seconds: [player] total Violations: [violations]", yamlContent).
|
||||
replace("[timeframe]", "%2$d").replace("[player]", "%1$s").replace("[violations]", "(%3$d,%4$d,%5$d)")));
|
||||
replace("[timeframe]", "%2$d").replace("[player]", "%1$s").
|
||||
replace("[violations]", "(%3$d,%4$d,%5$d)")));
|
||||
movingNode.add(new BooleanOption("allowflying",
|
||||
SimpleYaml.getBoolean("moving.allowflying", false, yamlContent)));
|
||||
movingNode.add(new BooleanOption("allowfakesneak",
|
||||
|
Loading…
Reference in New Issue
Block a user