diff --git a/config.yml b/config.yml index 1186e07..1675f3c 100644 --- a/config.yml +++ b/config.yml @@ -101,6 +101,6 @@ gui: # Title for menu that shows when a player executes /sleeping sleeping: "Sleeping Players" -# Version identifier (do not change) +# Spooky controls (don't change) version: 1.5 debug: true diff --git a/src/main/java/mykyta/Harbor/Commands/Command.java b/src/main/java/mykyta/Harbor/Commands/Command.java index 5b9385b..b257430 100644 --- a/src/main/java/mykyta/Harbor/Commands/Command.java +++ b/src/main/java/mykyta/Harbor/Commands/Command.java @@ -1,7 +1,5 @@ package mykyta.Harbor.Commands; -import java.util.List; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandExecutor; diff --git a/src/main/java/mykyta/Harbor/Config.java b/src/main/java/mykyta/Harbor/Config.java index 78225aa..341f009 100644 --- a/src/main/java/mykyta/Harbor/Config.java +++ b/src/main/java/mykyta/Harbor/Config.java @@ -29,18 +29,22 @@ public class Config { if (Util.debug) e.printStackTrace(); } + /** + * Fetches a boolean from the configuration + * @param location Configuration location of the boolean + */ + public String getVersion() { + try {return this.getString("version");} + catch (Exception e) {error(e); return "";} + } + /** * Fetches a boolean from the configuration * @param location Configuration location of the boolean */ public boolean getBoolean(String location) { - try { - return harbor.getConfig().getBoolean(location); - } - catch (Exception e) { - error(e); - return false; - } + try {return harbor.getConfig().getBoolean(location);} + catch (Exception e) {error(e); return false;} } /** @@ -48,13 +52,8 @@ public class Config { * @param location Configuration location of the string */ public String getString(String location) { - try { - return harbor.getConfig().getString(location); - } - catch (Exception e) { - error(e); - return ""; - } + try {return harbor.getConfig().getString(location);} + catch (Exception e) {error(e); return "";} } /** @@ -62,13 +61,8 @@ public class Config { * @param location Configuration location of the integer */ public int getInteger(String location) { - try { - return harbor.getConfig().getInt(location); - } - catch (Exception e) { - error(e); - return 0; - } + try {return harbor.getConfig().getInt(location);} + catch (Exception e) {error(e); return 0;} } /** @@ -76,13 +70,8 @@ public class Config { * @param location Configuration location of the double */ public double getDouble(String location) { - try { - return Double.parseDouble(harbor.getConfig().getString(location)); - } - catch (Exception e) { - error(e); - return 0.0; - } + try {return Double.parseDouble(harbor.getConfig().getString(location));} + catch (Exception e) {error(e); return 0.0;} } /** @@ -90,12 +79,7 @@ public class Config { * @param location Configuration location of the double */ public List getList(String location) { - try { - return harbor.getConfig().getStringList(location); - } - catch (Exception e) { - error(e); - return new ArrayList(); - } + try {return harbor.getConfig().getStringList(location);} + catch (Exception e) {error(e); return new ArrayList();} } } \ No newline at end of file diff --git a/src/main/java/mykyta/Harbor/Events/BedEnter.java b/src/main/java/mykyta/Harbor/Events/BedEnter.java index 19cc565..430c640 100644 --- a/src/main/java/mykyta/Harbor/Events/BedEnter.java +++ b/src/main/java/mykyta/Harbor/Events/BedEnter.java @@ -54,6 +54,9 @@ public class BedEnter implements Listener { .replace("[player]", p.getName()) .replace("[needed]", String.valueOf(util.getNeeded(w)))); } + if (config.getBoolean("features.title")) { + util.sendTitle(p, config.getString("messages.title.sleeping.top"), config.getString("messages.title.sleeping.bottom")); + } // Skip night if possible util.skip(w); diff --git a/src/main/java/mykyta/Harbor/Events/PlayerJoin.java b/src/main/java/mykyta/Harbor/Events/PlayerJoin.java index 3d86ad5..12f3340 100644 --- a/src/main/java/mykyta/Harbor/Events/PlayerJoin.java +++ b/src/main/java/mykyta/Harbor/Events/PlayerJoin.java @@ -1,5 +1,6 @@ package mykyta.Harbor.Events; +import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; @@ -17,7 +18,7 @@ public class PlayerJoin implements Listener { String json = "[{\"text\":\"[prefix]§7Hey there, Harbor [version] was released! \"},{\"text\":\"§7§oClick §7§ome §7§oto §7§oupdate!\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/harbor update\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"§a§l↑ §7Update Harbor.\"}}]"; if (event.getPlayer().isOp() && updater.check() && config.getBoolean("features.notifier")) util.sendJSONMessage(event.getPlayer(), json.replace("[version]", updater.getLatest()).replace("[prefix]", config.getString("messages.miscellaneous.prefix")).replace("&", "§")); - + if (!config.getVersion().equals(util.version)) event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "&7The configuration is &nout of date!&7 This server is currently using configuration &oversion " + config.getVersion() + "&7, but the latest configuration is &oversion " + util.version + "&7. Make sure you update the configuration to ensure correct functionality of the plugin.")); Util.activity.put(event.getPlayer(), System.currentTimeMillis()); } } \ No newline at end of file diff --git a/src/main/java/mykyta/Harbor/Task.java b/src/main/java/mykyta/Harbor/Task.java index 5a06444..b0938f8 100644 --- a/src/main/java/mykyta/Harbor/Task.java +++ b/src/main/java/mykyta/Harbor/Task.java @@ -13,7 +13,7 @@ public class Task implements Runnable { @Override public void run() { Bukkit.getServer().getWorlds().forEach(w -> { - if (w.getTime() >= 12516 && w.getTime() <= 12547) w.getPlayers().forEach(p -> { + if (w.getTime() >= 12516 && w.getTime() <= 12537 && config.getBoolean("features.title")) w.getPlayers().forEach(p -> { util.sendTitle(p, config.getString("messages.title.evening.top"), config.getString("messages.title.evening.bottom")); }); if (util.getSleeping(w) > 0 && util.getNeeded(w) == 0) { diff --git a/src/main/java/mykyta/Harbor/Util.java b/src/main/java/mykyta/Harbor/Util.java index 1bee0b8..d510f47 100644 --- a/src/main/java/mykyta/Harbor/Util.java +++ b/src/main/java/mykyta/Harbor/Util.java @@ -28,7 +28,7 @@ public class Util { public static HashMap activity = new HashMap(); public static ArrayList afk = new ArrayList(); - public String version = "1.5"; + public final String version = "1.5"; public static boolean enabled = true; public static boolean debug = false; private static NMS nms;