Commit 4f26918a authored by Amosar's avatar Amosar

small optimisation/remove debuguer

parent a82203b2
......@@ -28,8 +28,8 @@ public class Main extends JavaPlugin{
private String line3;
private String line4;
private static ArrayList<String> ignoreWorld = new ArrayList<String>();
private static ArrayList<String> ignoreRegion = new ArrayList<String>();
private static final ArrayList<String> ignoreWorld = new ArrayList<>();
private static final ArrayList<String> ignoreRegion = new ArrayList<>();
public void onEnable(){
long startTime = System.currentTimeMillis();
......@@ -118,7 +118,7 @@ public class Main extends JavaPlugin{
private static void checkTimer(int delay){
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, new Runnable() {
@Override
public void run() {
for(RedstoneClock brdc : RedstoneClockController.getAll()){
......@@ -205,7 +205,7 @@ public class Main extends JavaPlugin{
}
}else if(args[0].equalsIgnoreCase("notifyAdmin")){
if(args.length == 1){
if(getConfig().getBoolean("NotifyAdmins") == true){
if(getConfig().getBoolean("NotifyAdmins")){
getConfig().set("NotifyAdmins", false);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"NotifyAdmins\"").replace("$value", "false"));
......@@ -215,11 +215,11 @@ public class Main extends JavaPlugin{
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"NotifyAdmins\"").replace("$value", "true"));
}
}else{
if(Boolean.parseBoolean(args[1])== true){
if(Boolean.parseBoolean(args[1])){
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){
}else if(!Boolean.parseBoolean(args[1])){
getConfig().set("NotifyAdmins", false);
saveConfig();
sender.sendMessage(CustomConfig.Prefix+CustomConfig.newValueInConfig.toString().replace("$setting", "\"NotifyAdmins\"").replace("$value", args[1]));
......
......@@ -66,13 +66,12 @@ public class PlayerListener implements Listener {
}
RedstoneClockController.removeRedstoneByLocation(e.getBlock().getLocation());
}else{
System.out.println(RedstoneClockController.getRedstoneClock(e.getBlock().getLocation()).getBoucle());
RedstoneClockController.getRedstoneClock(e.getBlock().getLocation()).addBoucle();
}
}
}
}
}else if(e.getBlock().getType() == Material.DIODE_BLOCK_ON
|| e.getBlock().getType() == Material.REDSTONE_COMPARATOR_ON){
......@@ -93,7 +92,7 @@ public class PlayerListener implements Listener {
e.getBlock().setType(Material.AIR);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {
@Override
public void run() {
b.setType(Material.SIGN_POST);
......@@ -121,10 +120,10 @@ public class PlayerListener implements Listener {
}
}
}
}
/* @EventHandler (priority = EventPriority.LOWEST)
public void onRedstoneClock2(BlockPhysicsEvent e){
System.out.println(e.getBlock().getType());
......
......@@ -6,14 +6,14 @@ import com.trafalcraft.antiRedstoneClock.Main;
public class RedstoneClock {
private long endTime;
private final long endTime;
private int boucle;
private Location loc;
private final Location loc;
//only for comparator
private boolean lastStatus;
public RedstoneClock(Location loc){
endTime = (long) System.currentTimeMillis()/1000+Main.getDelay();
endTime = System.currentTimeMillis() /1000+Main.getDelay();
boucle = 0;
this.loc = loc;
//only for comparator
......@@ -38,11 +38,7 @@ public class RedstoneClock {
//only for comparator
public void updateStatus(){
if(lastStatus){
lastStatus = false;
}else{
lastStatus = true;
}
lastStatus = !lastStatus;
}
//only for comparator
public boolean getlastStatus(){
......@@ -50,6 +46,6 @@ public class RedstoneClock {
}
public boolean isEnd(){
return ((long) System.currentTimeMillis()/1000)>=endTime;
return (System.currentTimeMillis() /1000)>=endTime;
}
}
......@@ -11,22 +11,18 @@ import com.trafalcraft.antiRedstoneClock.util.CustomConfig;
public class RedstoneClockController {
//private static Map<Location, RedstoneClock> activeMap = Maps.newHashMap();
private static ConcurrentMap<Location, RedstoneClock> activeMap = Maps.newConcurrentMap();
private static final ConcurrentMap<Location, RedstoneClock> activeMap = Maps.newConcurrentMap();
public static void addRedstone(Location location) throws Exception{
if(contains(location)){
throw new Exception(CustomConfig.ERREUR+CustomConfig.duplicate_object.toString());
}else{
activeMap.put(location, new RedstoneClock(location));
return;
}
}
public static boolean contains(Location location){
if(activeMap.containsKey(location)){
return true;
}
return false;
return activeMap.containsKey(location);
}
public static void removeRedstoneByLocation(Location location){
......
......@@ -23,15 +23,15 @@ public enum CustomConfig {
//Exception
duplicate_object("This list already contains this redstone");
static JavaPlugin plugin = Main.getInstance();
static final JavaPlugin plugin = Main.getInstance();
public static void getHelp(Player sender){
sender.sendMessage("");
sender.sendMessage("§3§l-------------AntiRedstoneClock-------------");
sender.sendMessage("§3/arc checkList <nom de l'arene> §b- display the active redstoneclock.");
sender.sendMessage("§3/arc setMaxImpulsion <numero> §b- Change the 0\"MaxImpulsion\" setting.");
sender.sendMessage("§3/arc setDelay <numero> §b- Change the \"Delay\" setting.");
sender.sendMessage("§3/arc notifyAdmin <numero> §b- change the \"notifyAdmin\" setting.");
sender.sendMessage("§3/arc reload <numero> §b- To reload the config file.");
sender.sendMessage("§3/arc checkList <Page number> §b- display the active redstoneclock.");
sender.sendMessage("§3/arc setMaxImpulsion <number> §b- Change the 0\"MaxImpulsion\" setting.");
sender.sendMessage("§3/arc setDelay <number> §b- Change the \"Delay\" setting.");
sender.sendMessage("§3/arc notifyAdmin <number> §b- change the \"notifyAdmin\" setting.");
sender.sendMessage("§3/arc reload <number> §b- To reload the config file.");
sender.sendMessage(" §3Version: §6" + plugin.getDescription().getVersion());
sender.sendMessage("§3------------------------------------------------");
sender.sendMessage("");
......@@ -40,14 +40,14 @@ public enum CustomConfig {
private String value;
private CustomConfig(String value) {
CustomConfig(String value) {
this.value = value;
}
public String toString(){
return value;
}
public void replaceby(String value){
private void replaceby(String value){
this.value = value;
}
......
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