diff --git a/pom.xml b/pom.xml
index 58be95a..24bc332 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
dk.fido2603
semihardcore
- 0.0.7
+ 0.0.8
Semi-Hardcore
diff --git a/src/main/java/dk/fido2603/semihardcore/PlayerManager.java b/src/main/java/dk/fido2603/semihardcore/PlayerManager.java
index efec6ae..7bbc30a 100644
--- a/src/main/java/dk/fido2603/semihardcore/PlayerManager.java
+++ b/src/main/java/dk/fido2603/semihardcore/PlayerManager.java
@@ -78,7 +78,8 @@ public void newPlayerCheck(PlayerJoinEvent event)
// Delay the kick, to make sure the player is gone...
SemiHardcore.server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
- player.kickPlayer("You still have time left on your death cooldown: " + TimeConverter.parseMillisToUFString(plugin.timeToBan-timeDiff(playerId)) + "!");
+ String kickMessage = plugin.messageKickPlayerTimeLeft.replace("{timeLeft}", TimeConverter.parseMillisToUFString(plugin.timeToBan-timeDiff(playerId)));
+ player.kickPlayer(ChatColor.translateAlternateColorCodes('&', kickMessage));
}
}, 20L);
plugin.logDebug("Tried to keep player, " + player.getName() +", away from joining, as they are banned!");
@@ -200,13 +201,15 @@ public boolean banPlayer(Player player, UUID playerId)
// Delay the kick, to not have the console make a "Removing entity while ticking!" Exception
SemiHardcore.server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
- player.kickPlayer("You have been set on a cooldown for: " + plugin.timeToBanStringUF + "!");
+ String kickMessage = plugin.messageKickPlayerOnBan.replace("{banTime}",plugin.timeToBanStringUF);
+ player.kickPlayer(ChatColor.translateAlternateColorCodes('&', kickMessage));
}
}, 1L);
this.semihardcoreConfig.set(playerId.toString() + ".Name", player.getName());
- plugin.sendInfoAll("&c" + player.getName() + " has been banned for &4" + plugin.timeToBanStringUF + "&c!");
+ String banMessage = plugin.messageBanPlayer.replace("{playerName}", player.getName()).replace("{timeBanned}", plugin.timeToBanStringUF);
+ plugin.sendInfoAll(banMessage);
saveTimed();
diff --git a/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java b/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java
index b002370..1d5483e 100644
--- a/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java
+++ b/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java
@@ -18,9 +18,22 @@ public class SemiHardcore extends JavaPlugin
{
public static boolean pluginEnabled = false;
public boolean vaultEnabled = false;
- public boolean uhcDayEnabled = true;
+
+ public boolean uhcDayEnabled = false;
public Integer uhcDay = 2;
public boolean isUHCDay = false;
+
+ public boolean playSoundEnabled = true;
+ private String uhcStartSound = "entity.wither.spawn";
+ private String uhcEndSound = "entity.ender_dragon.growl";
+
+ public String messageLoginUHCDay = "&4-> &6It is currently UHC day! Take care, there is no natural regen!&4 <-";
+ public String messageBanPlayer = "&c{playerName} has been banned for &4{timeBanned}&c!";
+ public String messageKickPlayerOnBan = "&4You have been set on a cooldown for: &c{banTime}&4!";
+ public String messageKickPlayerTimeLeft = "&cYou still have time left on your death cooldown: &4{timeLeft}&c!";
+ private String messageStartUHCDay = "&4-> &6It is now UHC day! Take care, no more natural regen! &4<-";
+ private String messageEndUHCDay = "&4-> &6It is no longer UHC day! &4<-";
+
public static Server server = null;
public boolean debug = false;
private String timeToBanString = "24h";
@@ -61,13 +74,21 @@ public void sendInfoAll(String message) {
public void sendInfo(Player player, String message)
{
+ String translatedMessage = ChatColor.translateAlternateColorCodes('&', message);
if (player == null)
{
- log(message);
+ log(translatedMessage);
}
else
{
- player.sendMessage(message);
+ player.sendMessage(translatedMessage);
+ }
+ }
+
+ public void playSoundAll(String sound) {
+ for (Player player : plugin.getServer().getOnlinePlayers())
+ {
+ player.playSound(player.getLocation(), sound, 1.0F, 1.0F);
}
}
@@ -150,14 +171,20 @@ public void run()
logDebug("Day: " + TimeConverter.getDayOfWeek() + " - UHCDay: " + plugin.uhcDay.toString());
getServer().dispatchCommand(console, "gamerule naturalRegeneration false");
isUHCDay = true;
- sendInfoAll("&6It is now UHC day! Take care, no more natural regen!");
+ sendInfoAll(plugin.messageStartUHCDay);
+ if (plugin.playSoundEnabled) {
+ plugin.playSoundAll(plugin.uhcStartSound);
+ }
}
else if (!(TimeConverter.getDayOfWeek() == uhcDay) && isUHCDay) {
log("It's not UHC day anymore, switching the gamerule...");
logDebug("Day: " + TimeConverter.getDayOfWeek() + " - UHCDay: " + plugin.uhcDay.toString());
getServer().dispatchCommand(console, "gamerule naturalRegeneration true");
isUHCDay = false;
- sendInfoAll("&6It is no longer UHC day!");
+ sendInfoAll(plugin.messageEndUHCDay);
+ if (plugin.playSoundEnabled) {
+ plugin.playSoundAll(plugin.uhcEndSound);
+ }
}
}
}, 20L, 600L); // 1200 is the ideal number of ticks for a minute, so we'll check each half minute - waiting about a second for the first check though, to get the things started
@@ -194,8 +221,19 @@ public void loadSettings()
this.debug = config.getBoolean("Settings.Debug", false);
this.timeToBanString = config.getString("Settings.TimeToBan", "24h");
- this.uhcDayEnabled = config.getBoolean("Settings.UHCDayEnabled", true);
- this.uhcDay = config.getInt("Settings.UHCDay", 2);
+
+ this.uhcDayEnabled = config.getBoolean("Misc.UHCDayEnabled", false);
+ this.uhcDay = config.getInt("Misc.UHCDay", 2);
+ this.uhcDayEnabled = config.getBoolean("Misc.PlaySounds", true);
+ this.uhcStartSound = config.getString("Misc.Sound_UHCStart", "entity.ender_dragon.growl");
+ this.uhcEndSound = config.getString("Misc.Sound_UHCEnd", "entity.wither.spawn");
+
+ this.messageLoginUHCDay = config.getString("Messages.LoginUHCDay", "&4-> &6It is currently UHC day! Take care, there is no natural regen!&4 <-");
+ this.messageBanPlayer = config.getString("Messages.BanPlayer", "&c{playerName} has been banned for &4{timeBanned}&c!");
+ this.messageKickPlayerOnBan = config.getString("Messages.KickPlayerOnBan", "&4You have been set on a cooldown for: &c{banTime}&4!");
+ this.messageKickPlayerTimeLeft = config.getString("Messages.PlayerTimeLeft", "&cYou still have time left on your death cooldown: &4{timeLeft}&c!");
+ this.messageStartUHCDay = config.getString("Messages.StartUHCDay", "&4-> &6It is now UHC day! Take care, no more natural regen! &4<-");
+ this.messageEndUHCDay = config.getString("Messages.EndUHCDay", "&4-> &6It is no longer UHC day! &4<-");
this.timeToBan = TimeConverter.parseStringToMillis(timeToBanString);
@@ -207,8 +245,19 @@ public void saveSettings()
{
config.set("Settings.Debug", Boolean.valueOf(this.debug));
config.set("Settings.TimeToBan", this.timeToBanString);
- config.set("Settings.UHCDayEnabled", Boolean.valueOf(this.uhcDayEnabled));
- config.set("Settings.UHCDay", this.uhcDay);
+
+ config.set("Misc.UHCDayEnabled", Boolean.valueOf(this.uhcDayEnabled));
+ config.set("Misc.UHCDay", this.uhcDay);
+ config.set("Misc.PlaySounds", this.playSoundEnabled);
+ config.set("Misc.Sound_UHCStart", this.uhcStartSound);
+ config.set("Misc.Sound_UHCEnd", this.uhcEndSound);
+
+ config.set("Messages.LoginUHCDay", this.messageLoginUHCDay);
+ config.set("Messages.BanPlayer", this.messageBanPlayer);
+ config.set("Messages.KickPlayerOnBan", this.messageKickPlayerOnBan);
+ config.set("Messages.PlayerTimeLeft", this.messageKickPlayerTimeLeft);
+ config.set("Messages.StartUHCDay", this.messageStartUHCDay);
+ config.set("Messages.EndUHCDay", this.messageEndUHCDay);
saveConfig();
}
diff --git a/src/main/java/dk/fido2603/semihardcore/listeners/PlayerListener.java b/src/main/java/dk/fido2603/semihardcore/listeners/PlayerListener.java
index 985c5b4..4d720d4 100644
--- a/src/main/java/dk/fido2603/semihardcore/listeners/PlayerListener.java
+++ b/src/main/java/dk/fido2603/semihardcore/listeners/PlayerListener.java
@@ -25,6 +25,10 @@ public void onPlayerJoin(PlayerJoinEvent event)
{
return;
}
+ if (plugin.uhcDayEnabled && plugin.isUHCDay) {
+ plugin.logDebug("Trying to send player the It is UHC day message!");
+ plugin.sendInfo(event.getPlayer(), plugin.messageLoginUHCDay);
+ }
if (!event.getPlayer().isOp() && (!SemiHardcore.getPermissionsManager().hasPermission(event.getPlayer(), "semihardcore.exempt"))) {
plugin.logDebug("No op or exempt, checking player");
SemiHardcore.getPlayerManager().newPlayerCheck(event);