1
0
mirror of https://github.com/nkomarn/harbor.git synced 2024-12-19 14:57:38 +01:00

Timer fixes (actionbar fixed as a result)

This commit is contained in:
Mykyta 2019-07-17 11:08:23 -07:00
parent 4598c47b15
commit d67b003457
No known key found for this signature in database
GPG Key ID: C147E30C19EA3570
6 changed files with 31 additions and 25 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.nkomarn</groupId>
<artifactId>Harbor</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -21,7 +21,7 @@ import java.util.stream.Stream;
public class Harbor extends JavaPlugin {
public static Harbor instance;
public static String version = "1.5.1";
public static String version = "1.5.2";
public static boolean debug = false;
public static boolean enabled = false;
public static boolean prerelease = false;
@ -50,7 +50,9 @@ public class Harbor extends JavaPlugin {
});
});
if (enabled) Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Timer(), 0L, config.getInteger("values.clock") * 20);
int interval = config.getInteger("values.clock");
if (enabled) Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,
new Timer(), 0L, interval * 20);
if (getConfig().getBoolean("debug")) debug = true;
if (enabled && this.getConfig().getBoolean("features.notifier")) {
if (debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
@ -65,6 +67,6 @@ public class Harbor extends JavaPlugin {
}
public void onDisable() {
// Nothing lol
}
}

View File

@ -25,17 +25,17 @@ public class NMSUtils {
Harbor.enabled = false;
}
if (Harbor.debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + c.getString("messages.miscellaneous.running").replace("[version]", v)));
if (v.equals("v1_8_R1")) {nms = new NMS_1_8_R1();}
else if (v.equals("v1_8_R2")) {nms = new NMS_1_8_R2();}
else if (v.equals("v1_8_R3")) {nms = new NMS_1_8_R3();}
else if (v.equals("v1_9_R1")) {nms = new NMS_1_9_R1();}
else if (v.equals("v1_9_R2")) {nms = new NMS_1_9_R2();}
else if (v.equals("v1_10_R1")) {nms = new NMS_1_10_R1();}
else if (v.equals("v1_11_R1")) {nms = new NMS_1_11_R1();}
else if (v.equals("v1_12_R1")) {nms = new NMS_1_12_R1();}
else if (v.equals("v1_13_R1")) {nms = new NMS_1_13_R1();}
else if (v.equals("v1_13_R2")) {nms = new NMS_1_13_R2();}
else if (v.equals("v1_14_R1")) {nms = new NMS_1_14_R1();}
if (v.equals("v1_8_R1")) {nms = new NMS_1_8_R1(); Harbor.enabled = true;}
else if (v.equals("v1_8_R2")) {nms = new NMS_1_8_R2(); Harbor.enabled = true;}
else if (v.equals("v1_8_R3")) {nms = new NMS_1_8_R3(); Harbor.enabled = true;}
else if (v.equals("v1_9_R1")) {nms = new NMS_1_9_R1(); Harbor.enabled = true;}
else if (v.equals("v1_9_R2")) {nms = new NMS_1_9_R2(); Harbor.enabled = true;}
else if (v.equals("v1_10_R1")) {nms = new NMS_1_10_R1(); Harbor.enabled = true;}
else if (v.equals("v1_11_R1")) {nms = new NMS_1_11_R1(); Harbor.enabled = true;}
else if (v.equals("v1_12_R1")) {nms = new NMS_1_12_R1(); Harbor.enabled = true;}
else if (v.equals("v1_13_R1")) {nms = new NMS_1_13_R1(); Harbor.enabled = true;}
else if (v.equals("v1_13_R2")) {nms = new NMS_1_13_R2(); Harbor.enabled = true;}
else if (v.equals("v1_14_R1")) {nms = new NMS_1_14_R1(); Harbor.enabled = true;}
else {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "This version of Harbor is incompatible with your server version. As such, Harbor will be disabled."));
Bukkit.getPluginManager().disablePlugin(Harbor.instance);

View File

@ -18,15 +18,17 @@ public class Timer implements Runnable {
public void run() {
try {
Bukkit.getServer().getWorlds().forEach(w -> {
if (n.getSleeping(w) > 0 && n.getNeeded(w) != 0) {
w.getPlayers().forEach(p -> nms.sendActionbar(p, c.getString("messages.actionbar.sleeping"), w));
}
else if (n.getSleeping(w) > 0 && n.getNeeded(w) == 0) {
w.getPlayers().forEach(p -> nms.sendActionbar(p, c.getString("messages.actionbar.everyone"), w));
}
if (w.getTime() >= 12516 && w.getTime() <= 12535 && c.getBoolean("messages.title.title"))
w.getPlayers().forEach(p -> nms.sendTitle(p, c.getString("messages.title.evening.top"), c.getString("messages.title.evening.bottom")));
if (n.getSleeping(w) > 0 && n.getNeeded(w) == 0) n.skip(w);
if (n.getSleeping(w) > 0 && n.getSleeping(w) < n.getNeeded(w))
w.getPlayers().forEach(p -> nms.sendActionbar(p, c.getString("messages.actionbar.sleeping"), w));
else if (n.getSleeping(w) == n.getNeeded(w) && n.getSleeping(w) > 0)
w.getPlayers().forEach(p -> nms.sendActionbar(p, c.getString("messages.actionbar.everyone"), w));
if (c.getBoolean("features.afk")) w.getPlayers().forEach(p -> {
if (TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - Counters.activity.get(p)) >= c.getInteger("values.timeout")) {
if (Counters.sleeping.get(w).contains(p)) {

View File

@ -61,7 +61,7 @@ public class Counters {
return a;
}
public boolean isExcluded(Player p) {
private boolean isExcluded(Player p) {
boolean s = false;
if (c.getBoolean("features.ignore")) if (p.getGameMode() == GameMode.SURVIVAL) s = false; else s = true;
if (c.getBoolean("features.bypass")) if (p.hasPermission("harbor.bypass")) s = true; else s = false;
@ -73,10 +73,12 @@ public class Counters {
if (c.getBoolean("features.skip") && Math.max(0, this.getNeeded(w) - this.getExcluded(w).size()) == 0) {
w.setTime(1000L);
// Set weather to clear TODO ASYNC NO BAD DON'T ASYNC CAUSE 1.14 API CHANGE BAD
// Synchronously set weather to clear
if (c.getBoolean("features.weather")) {
w.setStorm(false);
w.setThundering(false);
Bukkit.getScheduler().runTask(Harbor.instance, () -> {
w.setStorm(false);
w.setThundering(false);
});
}
// Display messages

View File

@ -104,5 +104,5 @@ gui:
sleeping: "Sleeping Players | Page [page]"
# Spooky controls (don't change)
version: 1.5.1
version: 1.5.2
debug: false