Browse Source

30 minute mine windows

lakebane-master
FatBoy-DOTC 10 months ago
parent
commit
9107540212
  1. 31
      src/engine/objects/Mine.java
  2. 4
      src/engine/server/world/WorldServer.java
  3. 35
      src/engine/workthreads/HourlyJobThread.java

31
src/engine/objects/Mine.java

@ -60,7 +60,7 @@ public class Mine extends AbstractGameObject {
public boolean hasProduced = false; public boolean hasProduced = false;
public int liveTime; public int liveTime;
public Boolean fullHour = true; public Boolean firstThirty = true;
public static ArrayList<Mine> ChinaMines = new ArrayList<>(); public static ArrayList<Mine> ChinaMines = new ArrayList<>();
public static ArrayList<Mine> EuroMines = new ArrayList<>(); public static ArrayList<Mine> EuroMines = new ArrayList<>();
@ -123,17 +123,9 @@ public class Mine extends AbstractGameObject {
public static void SetTimes(){ public static void SetTimes(){
EuroMines.get(0).liveTime = 12; EuroMines.get(0).liveTime = 12;
EuroMines.get(0).fullHour = true;
EuroMines.get(1).liveTime = 12; EuroMines.get(1).liveTime = 12;
EuroMines.get(1).fullHour = false;
EuroMines.get(2).liveTime = 12; EuroMines.get(2).liveTime = 12;
EuroMines.get(2).fullHour = false;
EuroMines.get(3).liveTime = 12; EuroMines.get(3).liveTime = 12;
EuroMines.get(3).fullHour = true;
EuroMines.get(4).liveTime = 13; EuroMines.get(4).liveTime = 13;
EuroMines.get(5).liveTime = 13; EuroMines.get(5).liveTime = 13;
EuroMines.get(6).liveTime = 13; EuroMines.get(6).liveTime = 13;
@ -256,6 +248,27 @@ public class Mine extends AbstractGameObject {
ChinaMines.add(serverMines.get(33)); ChinaMines.add(serverMines.get(33));
AmericaMines.add(serverMines.get(34)); AmericaMines.add(serverMines.get(34));
SetTimes(); SetTimes();
for(Mine mine : EuroMines){
if(EuroMines.indexOf(mine) %2 == 0 ){
mine.firstThirty = true;
} else{
mine.firstThirty = false;
}
}
for(Mine mine : AmericaMines){
if(AmericaMines.indexOf(mine) %2 == 0 ){
mine.firstThirty = true;
} else{
mine.firstThirty = false;
}
}
for(Mine mine : ChinaMines){
if(ChinaMines.indexOf(mine) %2 == 0 ){
mine.firstThirty = true;
} else{
mine.firstThirty = false;
}
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

4
src/engine/server/world/WorldServer.java

@ -231,9 +231,9 @@ public class WorldServer {
hourlyJobThread.setName("hourlyJob"); hourlyJobThread.setName("hourlyJob");
hourlyJobThread.start(); hourlyJobThread.start();
if(LocalDateTime.now().isAfter(LocalDateTime.now().withMinute(30).withSecond(0))) { if(LocalDateTime.now().isAfter(LocalDateTime.now().withMinute(30).withSecond(0))) {
nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1); nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(1).plusHours(1);
}else{ }else{
nextHourlyJobTime = LocalDateTime.now().withMinute(30).withSecond(0); nextHourlyJobTime = LocalDateTime.now().withMinute(30).withSecond(1);
} }
} }

35
src/engine/workthreads/HourlyJobThread.java

@ -21,6 +21,7 @@ import engine.objects.*;
import engine.server.world.WorldServer; import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -93,18 +94,32 @@ public class HourlyJobThread implements Runnable {
continue; continue;
} }
if (mine.liveTime == LocalDateTime.now().getHour() && mine.wasClaimed == false) {
if(mine.firstThirty == true && LocalDateTime.now().isAfter(LocalDateTime.now().withHour(mine.liveTime).withMinute(0).withSecond(0)) && LocalDateTime.now().isBefore(LocalDateTime.now().withHour(mine.liveTime).withMinute(30).withSecond(0))){
mineWindowOpen(mine);
continue;
}
if(mine.firstThirty == false && LocalDateTime.now().isAfter(LocalDateTime.now().withHour(mine.liveTime).withMinute(30).withSecond(0)) && LocalDateTime.now().isBefore(LocalDateTime.now().withHour(mine.liveTime).withMinute(0).withSecond(0).plusHours(1))){
mineWindowOpen(mine);
continue;
}
}
// Open Mines owned by nations having their WOO // Open Mines owned by nations having their WOO
// set to the current mine window. // set to the current mine window.
if (mine.liveTime == LocalDateTime.now().getHour() && mine.wasClaimed == false) { //if (mine.liveTime == LocalDateTime.now().getHour() && mine.wasClaimed == false) {
if (mine.fullHour == true) { /// if (mine.fullHour == true) {
HourlyJobThread.mineWindowOpen(mine); // HourlyJobThread.mineWindowOpen(mine);
continue; // continue;
} // }
else if(LocalDateTime.now().isBefore(LocalDateTime.now().withMinute(29).withSecond(59))) { // else if(LocalDateTime.now().isBefore(LocalDateTime.now().withMinute(29).withSecond(59))) {
mineWindowOpen(mine); // mineWindowOpen(mine);
continue; // continue;
} // }
} //}
// Close the mine if it reaches this far // Close the mine if it reaches this far
mineWindowClose(mine); mineWindowClose(mine);

Loading…
Cancel
Save