diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Join.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Join.java index 6a1d934..082ee5a 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Join.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Join.java @@ -5,6 +5,7 @@ import me.SuperRonanCraft.BetterRTP.references.PermissionNode; import me.SuperRonanCraft.BetterRTP.references.file.FileOther; import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP; +import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore; import me.SuperRonanCraft.BetterRTP.references.web.Updater; import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP; import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler; @@ -12,6 +13,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerJoinEvent; +import java.util.Arrays; + public class Join { static void event(PlayerJoinEvent e) { @@ -25,12 +28,17 @@ static void event(PlayerJoinEvent e) { //Updater private static void updater(Player p) { - if (!getPl().getFiles().getType(FileOther.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && PermissionNode.UPDATER.check(p)) - if (!getPl().getDescription().getVersion().equals(Updater.updatedVersion)) - Message_RTP.sms(p, "&7There is currently an update for &6BetterRTP &7version &e#" + - Updater.updatedVersion + " &7you have version &e#" + getPl().getDescription().getVersion()); + if (!getPl().getFiles().getType(FileOther.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && PermissionNode.UPDATER.check(p)) { + if (!getPl().getDescription().getVersion().equals(Updater.updatedVersion)) { + String currentVersion = getPl().getDescription().getVersion(); + String newVersion = Updater.updatedVersion; + + MessagesCore.UPDATE.send(p, Arrays.asList(currentVersion, newVersion)); + } + } } + //RTP on first join private static void rtpOnFirstJoin(Player p) { if (getPl().getSettings().isRtpOnFirstJoin_Enabled() && !p.hasPlayedBefore()) diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/MessagesCore.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/MessagesCore.java index 05f059d..e0720ab 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/MessagesCore.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/MessagesCore.java @@ -19,6 +19,7 @@ public enum MessagesCore { OTHER_BIOME("Other.Biome"), NOTEXIST("NotExist"), RELOAD("Reload"), + UPDATE("Update"), NOPERMISSION("NoPermission.Basic"), NOPERMISSION_WORLD("NoPermission.World"), DISABLED_WORLD("DisabledWorld"), diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/PlaceholderAnalyzer.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/PlaceholderAnalyzer.java index e64e457..0d376f4 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/PlaceholderAnalyzer.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/PlaceholderAnalyzer.java @@ -64,9 +64,13 @@ private static String string(String str, String info) { str = str.replaceAll(Placeholders.WORLD.name, info); if (str.contains(Placeholders.COOLDOWN.name)) str = str.replaceAll(Placeholders.COOLDOWN.name, info); + if (str.contains(Placeholders.CURRENTDVERSION.name)) + str = str.replaceAll(Placeholders.CURRENTDVERSION.name, info); + + if (str.contains(Placeholders.NEWVERSION.name)) + str = str.replaceAll(Placeholders.NEWVERSION.name, info); return str; } - private static String location(String str, Location loc) { if (str.contains(Placeholders.LOCATION_X.name)) str = str.replace(Placeholders.LOCATION_X.name, String.valueOf(loc.getBlockX())); diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/Placeholders.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/Placeholders.java index e5e2aa6..c437ed7 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/Placeholders.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/messages/placeholder/Placeholders.java @@ -17,6 +17,9 @@ public enum Placeholders { PRICE("price"), DELAY("delay"), TIME("time"), + // Updater + NEWVERSION("newVersion"), + CURRENTDVERSION("currentVersion"), //Other BIOME("biome") ; diff --git a/src/main/resources/lang/en.yml b/src/main/resources/lang/en.yml index ac18b82..965673d 100644 --- a/src/main/resources/lang/en.yml +++ b/src/main/resources/lang/en.yml @@ -15,6 +15,7 @@ Messages: NotSafe: '&cCould not find safe spot within %attempts% attempts! &7%player% was not rtp''d!' Biome: '&cSeems like the biome&7 %biome%&c does not exist! &7Try using the tab list!' Reload: '&eConfig reloaded successfully!' + Update: '&7There is currently an update for &6BetterRTP &7version &e#%newVersion% &7you have version &e#%currentVersion%' NoPermission: Basic: '&cSorry! &7You don''t have permission to use this command! &8Permission: %permission%' World: '&cSorry! &7You are not allowed rtp in the %world% world! &8Permission: %permission%' @@ -61,4 +62,4 @@ Usage: Location: '&cUsage&7: /%command% edit location ' Worldtype: '&cUsage&7: /%command% edit world_type ' Override: '&cUsage&7: /%command% edit override ' - BlacklistedBlocks: '&cUsage&7: /%command% edit blacklistedblocks ' \ No newline at end of file + BlacklistedBlocks: '&cUsage&7: /%command% edit blacklistedblocks '