Commit c6860248 authored by Amosar's avatar Amosar

add cmds

parent c660b9c9
#En:Don't touch this value
#Fr: Ne pas modifier cette valeur
version: 0.2
version: 0.3
#En:Maximal number Redstone blink authorized during the "Delay" period
#Fr:Nombre maximal de clignotement de redstone autorise pendant la periode "Delay"
MaxImpulsion: 150
......@@ -36,5 +36,8 @@ Msg:
MsgToAdmin: 'Redstone clock disable in x:$X y:$Y Z:$Z. In the world $World'
unknownCmd: 'Unknown command. Type "/help" for help.'
reloadSuccess: 'Reload Success!'
newValueInConfig: 'The new value of $setting is $value'
RedStoneClockListHeader: 'RedstoneClockList: $page'
RedStoneClockListFooter: ''
Exception:
duplicate_object: 'This list already contains this redstone'
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
......@@ -49,12 +50,18 @@ public class Main extends JavaPlugin{
getConfig().set("version", "0.2");
getConfig().set("IgnoreWorlds", "redstoneWorld/survival");
getConfig().set("IgnoreRegions", "redstone/admins");
getConfig().set("Msg.message.newValueInConfig", "The new value of $setting is $value");
getConfig().set("Msg.message.RedStoneClockListHeader", "RedstoneClockList: $page");
getConfig().set("Msg.message.RedStoneClockListFooter", "");
plugin.saveConfig();
plugin.reloadConfig();
}if(getConfig().getString("version").equals("0.2")){
System.out.println("update config file to 0.3");
getConfig().set("version", "0.3");
getConfig().set("IgnoreRegions", "redstone/admins");
getConfig().set("Msg.message.newValueInConfig", "The new value of $setting is $value");
getConfig().set("Msg.message.RedStoneClockListHeader", "RedstoneClockList: $page");
getConfig().set("Msg.message.RedStoneClockListFooter", "");
plugin.saveConfig();
plugin.reloadConfig();
}
......@@ -141,7 +148,72 @@ public class Main extends JavaPlugin{
instance.getLogger().warning("An error as occured in the config.yml please fix it!");
e.printStackTrace();
}
}/*else if(args[0].equalsIgnoreCase("help")){
} else if(args[0].equalsIgnoreCase("checkList")){
try{
int test = Integer.parseInt(args[1]) * 5;
int indice = 0;
sender.sendMessage(CustomConfig.RedStoneClockListHeader.toString().replace("$page", "("+args[1]+"/"+getRDC().getAllLoc().size()/5+")"));
for(Location loc : getRDC().getAllLoc()){
if(!(indice > test) && !(indice < test-4)){
if(getRDC().getRedstoneClock(loc).getBoucle() > Main.getMaxImpulsions()*0.750){
sender.sendMessage("§4RedStoneClock> §fWorld:"+loc.getWorld().getName()+",X:"+loc.getX()+",Y:"+loc.getY()+",Z:"+loc.getZ()+" b:"+getRDC().getRedstoneClock(loc).getBoucle()+"/"+getMaxImpulsions());
}else if (getRDC().getRedstoneClock(loc).getBoucle() > Main.getMaxImpulsions()*0.5){
sender.sendMessage("§eRedStoneClock> §fWorld:"+loc.getWorld().getName()+",X:"+loc.getX()+",Y:"+loc.getY()+",Z:"+loc.getZ()+" b:"+getRDC().getRedstoneClock(loc).getBoucle()+"/"+getMaxImpulsions());
}else if (getRDC().getRedstoneClock(loc).getBoucle() > Main.getMaxImpulsions()*0.250){
sender.sendMessage("§aRedStoneClock> §fWorld:"+loc.getWorld().getName()+",X:"+loc.getX()+",Y:"+loc.getY()+",Z:"+loc.getZ()+" b:"+getRDC().getRedstoneClock(loc).getBoucle()+"/"+getMaxImpulsions());
}else{
sender.sendMessage("§2RedStoneClock> §fWorld:"+loc.getWorld().getName()+",X:"+loc.getX()+",Y:"+loc.getY()+",Z:"+loc.getZ()+" b:"+getRDC().getRedstoneClock(loc).getBoucle()+"/"+getMaxImpulsions());
}
}
indice++;
}
sender.sendMessage(CustomConfig.RedStoneClockListFooter.toString());
}catch(NumberFormatException e){
sender.sendMessage(CustomConfig.Command_Use.toString().replace("$commande", "checkList <number>"));
}
}else if(args[0].equalsIgnoreCase("setMaxImpulsion")){
try{
Integer.parseInt(args[1]);
getConfig().set("MaxImpulsion", args[1]);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"MaxImpulsion\"").replace("$value", args[1]));
}catch(NumberFormatException e){
sender.sendMessage(CustomConfig.Command_Use.toString().replace("$commande", "setMaxImpulsion <number>"));
}
}else if(args[0].equalsIgnoreCase("setDelay")){
try{
Integer.parseInt(args[1]);
getConfig().set("Delay", args[1]);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"Delay\"").replace("$value", args[1]));
}catch(NumberFormatException e){
sender.sendMessage(CustomConfig.Command_Use.toString().replace("$commande", "setDelay <number>"));
}
}else if(args[0].equalsIgnoreCase("notifyAdmin")){
if(args.length == 1){
if(getConfig().getBoolean("NotifyAdmins") == true){
getConfig().set("NotifyAdmins", false);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"NotifyAdmins\"").replace("$value", "false"));
}else{
getConfig().set("NotifyAdmins", true);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"NotifyAdmins\"").replace("$value", "true"));
}
}else{
if(Boolean.parseBoolean(args[1])== true){
getConfig().set("NotifyAdmins", true);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"NotifyAdmins\"").replace("$value", args[1]));
}else if(Boolean.parseBoolean(args[1])== false){
getConfig().set("NotifyAdmins", false);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"NotifyAdmins\"").replace("$value", args[1]));
}
}
}
/*else if(args[0].equalsIgnoreCase("help")){
}
if(sender instanceof Player){
CustomConfig.getHelp((Player) sender);
}
......
......@@ -47,7 +47,16 @@ public class RedstoneClockController {
return activeMap.size();
}
public Map<Location, RedstoneClock> getHashMap(){
return activeMap;
}
public Collection<RedstoneClock> getAll() {
return activeMap.values();
}
public Collection<Location> getAllLoc() {
return activeMap.keySet();
}
}
......@@ -14,7 +14,9 @@ public enum CustomConfig {
MsgToAdmin("Redstone clock disable in x:$X y:$Y Z:$Z. In the world $World"),
reloadSuccess("Reload Success!"),
unknownCmd("Unknown command. Type \"/help\" for help."),
newValueInConfig("The new value of $setting is $value"),
RedStoneClockListHeader("RedstoneClockList: $page"),
RedStoneClockListFooter(""),
//Exception
duplicate_object("This list already contains this redstone");
......@@ -53,6 +55,9 @@ public enum CustomConfig {
MsgToAdmin.replaceby(Main.getPlugin().getConfig().getString("Msg.message.MsgToAdmin").replace("&", "§"));
reloadSuccess.replaceby(Main.getPlugin().getConfig().getString("Msg.message.reloadSuccess").replace("&", "§"));
unknownCmd.replaceby(Main.getPlugin().getConfig().getString("Msg.message.unknownCmd").replace("&", "§"));
newValueInConfig.replaceby(Main.getPlugin().getConfig().getString("Msg.message.newValueInConfig").replace("&", "§"));
RedStoneClockListHeader.replaceby(Main.getPlugin().getConfig().getString("Msg.message.RedStoneClockListHeader").replace("&", "§"));
RedStoneClockListFooter.replaceby(Main.getPlugin().getConfig().getString("Msg.message.RedStoneClockListFooter").replace("&", "§"));
duplicate_object.replaceby(Main.getPlugin().getConfig().getString("Msg.Exception.duplicate_object").replace("&", "§"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment