mirror of
https://github.com/nkomarn/harbor.git
synced 2024-12-20 07:17:39 +01:00
Added randomized night skipped messages.
This commit is contained in:
parent
7712e8072b
commit
722d15134d
@ -101,6 +101,6 @@ gui:
|
|||||||
# Title for menu that shows when a player executes /sleeping
|
# Title for menu that shows when a player executes /sleeping
|
||||||
sleeping: "Sleeping Players"
|
sleeping: "Sleeping Players"
|
||||||
|
|
||||||
# Version identifier (do not change)
|
# Spooky controls (don't change)
|
||||||
version: 1.5
|
version: 1.5
|
||||||
debug: true
|
debug: true
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package mykyta.Harbor.Commands;
|
package mykyta.Harbor.Commands;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -29,18 +29,22 @@ public class Config {
|
|||||||
if (Util.debug) e.printStackTrace();
|
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
|
* Fetches a boolean from the configuration
|
||||||
* @param location Configuration location of the boolean
|
* @param location Configuration location of the boolean
|
||||||
*/
|
*/
|
||||||
public boolean getBoolean(String location) {
|
public boolean getBoolean(String location) {
|
||||||
try {
|
try {return harbor.getConfig().getBoolean(location);}
|
||||||
return harbor.getConfig().getBoolean(location);
|
catch (Exception e) {error(e); return false;}
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
error(e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,13 +52,8 @@ public class Config {
|
|||||||
* @param location Configuration location of the string
|
* @param location Configuration location of the string
|
||||||
*/
|
*/
|
||||||
public String getString(String location) {
|
public String getString(String location) {
|
||||||
try {
|
try {return harbor.getConfig().getString(location);}
|
||||||
return harbor.getConfig().getString(location);
|
catch (Exception e) {error(e); return "";}
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
error(e);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,13 +61,8 @@ public class Config {
|
|||||||
* @param location Configuration location of the integer
|
* @param location Configuration location of the integer
|
||||||
*/
|
*/
|
||||||
public int getInteger(String location) {
|
public int getInteger(String location) {
|
||||||
try {
|
try {return harbor.getConfig().getInt(location);}
|
||||||
return harbor.getConfig().getInt(location);
|
catch (Exception e) {error(e); return 0;}
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
error(e);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,13 +70,8 @@ public class Config {
|
|||||||
* @param location Configuration location of the double
|
* @param location Configuration location of the double
|
||||||
*/
|
*/
|
||||||
public double getDouble(String location) {
|
public double getDouble(String location) {
|
||||||
try {
|
try {return Double.parseDouble(harbor.getConfig().getString(location));}
|
||||||
return Double.parseDouble(harbor.getConfig().getString(location));
|
catch (Exception e) {error(e); return 0.0;}
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
error(e);
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,12 +79,7 @@ public class Config {
|
|||||||
* @param location Configuration location of the double
|
* @param location Configuration location of the double
|
||||||
*/
|
*/
|
||||||
public List<String> getList(String location) {
|
public List<String> getList(String location) {
|
||||||
try {
|
try {return harbor.getConfig().getStringList(location);}
|
||||||
return harbor.getConfig().getStringList(location);
|
catch (Exception e) {error(e); return new ArrayList<String>();}
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
error(e);
|
|
||||||
return new ArrayList<String>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,6 +54,9 @@ public class BedEnter implements Listener {
|
|||||||
.replace("[player]", p.getName())
|
.replace("[player]", p.getName())
|
||||||
.replace("[needed]", String.valueOf(util.getNeeded(w))));
|
.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
|
// Skip night if possible
|
||||||
util.skip(w);
|
util.skip(w);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package mykyta.Harbor.Events;
|
package mykyta.Harbor.Events;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
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.\"}}]";
|
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 (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());
|
Util.activity.put(event.getPlayer(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ public class Task implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Bukkit.getServer().getWorlds().forEach(w -> {
|
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"));
|
util.sendTitle(p, config.getString("messages.title.evening.top"), config.getString("messages.title.evening.bottom"));
|
||||||
});
|
});
|
||||||
if (util.getSleeping(w) > 0 && util.getNeeded(w) == 0) {
|
if (util.getSleeping(w) > 0 && util.getNeeded(w) == 0) {
|
||||||
|
@ -28,7 +28,7 @@ public class Util {
|
|||||||
public static HashMap<Player, Long> activity = new HashMap<Player, Long>();
|
public static HashMap<Player, Long> activity = new HashMap<Player, Long>();
|
||||||
public static ArrayList<Player> afk = new ArrayList<Player>();
|
public static ArrayList<Player> afk = new ArrayList<Player>();
|
||||||
|
|
||||||
public String version = "1.5";
|
public final String version = "1.5";
|
||||||
public static boolean enabled = true;
|
public static boolean enabled = true;
|
||||||
public static boolean debug = false;
|
public static boolean debug = false;
|
||||||
private static NMS nms;
|
private static NMS nms;
|
||||||
|
Loading…
Reference in New Issue
Block a user