mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-30 20:37:52 +01:00
Creat a "DummyAction", if actions.txt does not contain a definition of
a custom action. Fixed newlines in "explainations" section of config file.
This commit is contained in:
parent
1f9a2643e8
commit
5ce7bc04cd
@ -0,0 +1,13 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
||||
|
||||
/**
|
||||
* This is only used to not lose config entries in case an action isn't defined correctly
|
||||
*
|
||||
*/
|
||||
public class DummyAction extends Action {
|
||||
|
||||
public DummyAction(String name, int delay, int repeat) {
|
||||
super(name, delay, repeat);
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,7 @@ import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ConsolecommandAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.DummyAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.LogAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.SpecialAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
@ -51,6 +52,8 @@ public abstract class Check {
|
||||
special = true;
|
||||
} else if(ac instanceof ConsolecommandAction) {
|
||||
executeConsoleCommand((ConsolecommandAction) ac, this, player, cc);
|
||||
} else if(ac instanceof DummyAction) {
|
||||
// nothing - it's a "DummyAction" after all
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,11 @@ import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.DummyAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
|
||||
@ -100,8 +103,20 @@ public class FlatFileConfiguration extends Configuration {
|
||||
al = new ActionList();
|
||||
}
|
||||
int th = Integer.parseInt(treshold);
|
||||
al.setActions(th, action.getActions(value.split("\\s+")));
|
||||
|
||||
List<Action> actions = new LinkedList<Action>();
|
||||
|
||||
for(String name : value.split("\\s+")) {
|
||||
Action a2 = action.getAction(name);
|
||||
if(a2 == null) {
|
||||
System.out.println("Nocheat: Action with name " + name + " isn't defined. You need to define it in your actions.txt file to make it work.");
|
||||
actions.add(new DummyAction(name, 0, 0));
|
||||
} else {
|
||||
actions.add(action.getAction(name));
|
||||
}
|
||||
}
|
||||
|
||||
al.setActions(th, actions.toArray(new Action[actions.size()]));
|
||||
return al;
|
||||
}
|
||||
|
||||
@ -184,6 +199,7 @@ public class FlatFileConfiguration extends Configuration {
|
||||
|
||||
for(String line : explainationLines) {
|
||||
w.write("# " + line);
|
||||
w.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,4 +30,9 @@ public class ActionMapper {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Action getAction(String actionName) {
|
||||
|
||||
return this.actions.get(actionName.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user