From 4fd71e0241b68c1ec135e93e640c5686236ee5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Thu, 25 Jun 2020 20:45:26 +0200 Subject: [PATCH] fixes and features - finished Maven implementation - removed Ant build version auto-increment because of Maven - added "send-tp-message-on-join" entry to config to enable/disable the "teleport-to-hub-on-join" message - renamed CommonValues to PluginCache --- HubThat-Reborn.iml | 18 +++++-- ant_build_increment.xml | 38 --------------- ant_buildversion_end.txt | 1 - ant_buildversion_init.txt | 1 - build.number | 5 -- buildNumber.properties | 3 ++ pom.xml | 48 +++++++++++++++++-- .../hubthat/commands/HubCommand.java | 22 +++++---- .../hubthat/commands/HubThatCommand.java | 7 +-- .../hubthat/commands/SpawnCommand.java | 10 ++-- .../hubthat/commands/WorldListCommand.java | 28 ++++++----- .../hubthat/commands/WorldTpCommand.java | 2 +- .../hubthat/listeners/PlayerJoinListener.java | 5 +- .../hubthat/listeners/PlayerMoveListener.java | 8 ++-- .../hubthat/utils/ConfigEntries.java | 2 + .../{CommonValues.java => PluginCache.java} | 6 ++- .../hubthat/utils/TeleportUtils.java | 48 ++++++++++++------- .../hubthat/utils/files/FileUtils.java | 7 +-- .../utils/statistics/UpdateChecker.java | 2 +- src/main/resources/config.yml | 1 + src/main/resources/plugin.yml | 2 +- 21 files changed, 152 insertions(+), 112 deletions(-) delete mode 100644 ant_build_increment.xml delete mode 100644 ant_buildversion_end.txt delete mode 100644 ant_buildversion_init.txt delete mode 100644 build.number create mode 100644 buildNumber.properties rename src/main/java/net/mindoverflow/hubthat/utils/{CommonValues.java => PluginCache.java} (74%) diff --git a/HubThat-Reborn.iml b/HubThat-Reborn.iml index 95f4596..42cad09 100644 --- a/HubThat-Reborn.iml +++ b/HubThat-Reborn.iml @@ -1,9 +1,12 @@ - - - + + + + - + + + @@ -27,5 +30,12 @@ + + + + + + + \ No newline at end of file diff --git a/ant_build_increment.xml b/ant_build_increment.xml deleted file mode 100644 index 63a38bf..0000000 --- a/ant_build_increment.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - simple example increment build variable - - - - - - - - - - Changing build version from BUILD_VERSION to ${version}.${build.number} in file plugin.yml... - - - Changed! - - - - - - Changing back build version ${version}.${build.number} in file plugin.yml to BUILD_VERSION... - - - - - Changed! - - - \ No newline at end of file diff --git a/ant_buildversion_end.txt b/ant_buildversion_end.txt deleted file mode 100644 index 0cdcdaf..0000000 --- a/ant_buildversion_end.txt +++ /dev/null @@ -1 +0,0 @@ -Changing back build version 10.0.166 in file plugin.yml to BUILD_VERSION... \ No newline at end of file diff --git a/ant_buildversion_init.txt b/ant_buildversion_init.txt deleted file mode 100644 index a290bc0..0000000 --- a/ant_buildversion_init.txt +++ /dev/null @@ -1 +0,0 @@ -Changed! \ No newline at end of file diff --git a/build.number b/build.number deleted file mode 100644 index d868690..0000000 --- a/build.number +++ /dev/null @@ -1,5 +0,0 @@ -#Build Number for ANT. Do not edit! -#Fri Jun 12 13:54:11 CEST 2020 -\#Build=Number for ANT. Do not edit\! -build.number=167 -\#Tue=Jul 30 16\:09\:09 CEST 2019 diff --git a/buildNumber.properties b/buildNumber.properties new file mode 100644 index 0000000..c80e2fe --- /dev/null +++ b/buildNumber.properties @@ -0,0 +1,3 @@ +#maven.buildNumber.plugin properties file +#Thu Jun 25 19:47:56 CEST 2020 +buildNumber=180 diff --git a/pom.xml b/pom.xml index 3461de7..42135f1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,13 @@ net.mindoverflow.hubthat HubThat - 1.0-SNAPSHOT + 10.1 + + scm:svn:http://127.0.0.1/dummy + scm:svn:https://127.0.0.1/dummy + HEAD + http://127.0.0.1/dummy + @@ -18,12 +24,46 @@ + + org.codehaus.mojo + buildnumber-maven-plugin + 1.1 + + + buildnumber + validate + + create + + + + + {0,number} + + buildNumber + + false + false + unknownbuild + + + + + + src/main/resources + true + + *.yml + + + - 1.9 - 1.9 + 1.8 + 1.8 UTF-8 + ${project.version} @@ -38,7 +78,7 @@ org.spigotmc spigot-api - 1.15.2-R0.1-SNAPSHOT + 1.16.1-R0.1-SNAPSHOT provided diff --git a/src/main/java/net/mindoverflow/hubthat/commands/HubCommand.java b/src/main/java/net/mindoverflow/hubthat/commands/HubCommand.java index 6d18ed0..584bcea 100644 --- a/src/main/java/net/mindoverflow/hubthat/commands/HubCommand.java +++ b/src/main/java/net/mindoverflow/hubthat/commands/HubCommand.java @@ -9,7 +9,6 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.Objects; import java.util.logging.Level; public class HubCommand implements CommandExecutor @@ -89,10 +88,10 @@ public class HubCommand implements CommandExecutor else { // Check if he's not already teleporting. - if(!CommonValues.teleporting.contains(username)) + if(!PluginCache.teleporting.contains(username)) { // Put the player in the ArrayList of players waiting to be teleported. - CommonValues.teleporting.add(username); + PluginCache.teleporting.add(username); // Load the teleportation delay. int delay = FileUtils.FileType.CONFIG_YAML.yaml.getInt(ConfigEntries.HUB_DELAY.path); @@ -108,11 +107,11 @@ public class HubCommand implements CommandExecutor @Override public void run() { - if(!CommonValues.cancelRunnable.contains(username) && CommonValues.teleporting.contains(username)) + if(!PluginCache.cancelRunnable.contains(username) && PluginCache.teleporting.contains(username)) { teleportToHub(commandSender, (Player)commandSender); } - CommonValues.cancelRunnable.remove(username); + PluginCache.cancelRunnable.remove(username); } }, delay * 20); // Convert seconds to ticks. @@ -136,15 +135,20 @@ public class HubCommand implements CommandExecutor } } - // Method to teleport the player to the hub. - public static void teleportToHub(CommandSender actor, Player player) + public static void teleportToHub(CommandSender actor, Player player, boolean sendMessage) { String username = player.getName(); // Teleport the player to the destination. - TeleportUtils.teleportPlayer(actor, player, FileUtils.FileType.HUB_YAML); + TeleportUtils.teleportPlayer(actor, player, FileUtils.FileType.HUB_YAML, sendMessage); // Remove it from the "teleporting" list - so it won't get teleported if it's waiting the spawn delay. - CommonValues.teleporting.remove(username); + PluginCache.teleporting.remove(username); + } + + // Method to teleport the player to the hub. + public static void teleportToHub(CommandSender actor, Player player) + { + teleportToHub(actor, player, true); } } diff --git a/src/main/java/net/mindoverflow/hubthat/commands/HubThatCommand.java b/src/main/java/net/mindoverflow/hubthat/commands/HubThatCommand.java index d080e68..12c6d45 100644 --- a/src/main/java/net/mindoverflow/hubthat/commands/HubThatCommand.java +++ b/src/main/java/net/mindoverflow/hubthat/commands/HubThatCommand.java @@ -5,6 +5,7 @@ import net.mindoverflow.hubthat.commands.hubthatcommands.HelpCommand; import net.mindoverflow.hubthat.commands.hubthatcommands.ReloadCommand; import net.mindoverflow.hubthat.utils.Debugger; import net.mindoverflow.hubthat.utils.MessageUtils; +import net.mindoverflow.hubthat.utils.PluginCache; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -46,10 +47,10 @@ public class HubThatCommand implements CommandExecutor // Check if there are any args. if(args.length == 0) { - MessageUtils.sendColorizedMessage(commandSender, "&7HubThat version &6" + plugin.getDescription().getVersion() + " for SpigotMC/CraftBukkit &61.7&7-&61.15&7."); - MessageUtils.sendColorizedMessage(commandSender, "&7Coded by &6mind_overflow&7, all rights reserved (&6Copyright © '20&7)."); + MessageUtils.sendColorizedMessage(commandSender, "&6" + plugin.getName() +"&7 version &6" + plugin.getDescription().getVersion() + "&7 for &6SpigotMC/CraftBukkit &6" + PluginCache.minSupportedVersion + "&7-&6" + PluginCache.maxSupportedVersion + "&7."); + MessageUtils.sendColorizedMessage(commandSender, "&7Coded by &6" + debugger.authorName + "&7, all rights reserved (&6Copyright © '20&7)."); commandSender.sendMessage(""); - MessageUtils.sendColorizedMessage(commandSender, "&7Write &6/hubthat help&7 to see plugin commands."); + MessageUtils.sendColorizedMessage(commandSender, "&7Write &6/"+ plugin.getName().toLowerCase() + " help&7 to see plugin commands."); } // Check if there is a single argument after the command itself. else if (args.length == 1) diff --git a/src/main/java/net/mindoverflow/hubthat/commands/SpawnCommand.java b/src/main/java/net/mindoverflow/hubthat/commands/SpawnCommand.java index 5fc2b9f..fa6de6c 100644 --- a/src/main/java/net/mindoverflow/hubthat/commands/SpawnCommand.java +++ b/src/main/java/net/mindoverflow/hubthat/commands/SpawnCommand.java @@ -96,7 +96,7 @@ public class SpawnCommand implements CommandExecutor else { // Check if he's not already teleporting. - if(!CommonValues.teleporting.contains(username)) + if(!PluginCache.teleporting.contains(username)) { if(args.length > 0) { @@ -126,18 +126,18 @@ public class SpawnCommand implements CommandExecutor MessageUtils.sendColorizedMessage(commandSender, delayMessage); // Put the player in the ArrayList of players waiting to be teleported. - CommonValues.teleporting.add(username); + PluginCache.teleporting.add(username); // Start a timer. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,() -> { - if(!CommonValues.cancelRunnable.contains(username) && CommonValues.teleporting.contains(username)) + if(!PluginCache.cancelRunnable.contains(username) && PluginCache.teleporting.contains(username)) { // Run method to check if there are any args and teleport the player accordingly. checkArgsAndTeleport(args, commandSender); } - CommonValues.cancelRunnable.remove(username); + PluginCache.cancelRunnable.remove(username); }, delay * 20); // Convert seconds to ticks. return true; @@ -201,6 +201,6 @@ public class SpawnCommand implements CommandExecutor TeleportUtils.teleportPlayer(sender, player, FileUtils.FileType.SPAWN_YAML, worldName); // Remove the player from the teleporting list, since it's not teleporting anymore. // Also remove it from the "teleporting" list - so it won't get teleported if it's waiting the hub delay. - CommonValues.teleporting.remove(username); + PluginCache.teleporting.remove(username); } } diff --git a/src/main/java/net/mindoverflow/hubthat/commands/WorldListCommand.java b/src/main/java/net/mindoverflow/hubthat/commands/WorldListCommand.java index d4babca..345ce46 100644 --- a/src/main/java/net/mindoverflow/hubthat/commands/WorldListCommand.java +++ b/src/main/java/net/mindoverflow/hubthat/commands/WorldListCommand.java @@ -2,6 +2,7 @@ package net.mindoverflow.hubthat.commands; import net.mindoverflow.hubthat.HubThat; import net.mindoverflow.hubthat.utils.*; +import org.bukkit.Difficulty; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -47,26 +48,29 @@ public class WorldListCommand implements CommandExecutor i++; // Store world type and difficulty. String worldType = currentWorld.getWorldType().getName().toLowerCase(); - String worldDifficulty = currentWorld.getDifficulty().name().toLowerCase(); + + Difficulty difficulty = currentWorld.getDifficulty(); + String worldDifficulty = difficulty.name().toLowerCase(); + if(difficulty == Difficulty.PEACEFUL) worldDifficulty = "&b" + worldDifficulty; + else if(difficulty == Difficulty.EASY) worldDifficulty = "&a" + worldDifficulty; + else if(difficulty == Difficulty.NORMAL) worldDifficulty = "&e" + worldDifficulty; + else if(difficulty == Difficulty.HARD) worldDifficulty = "&c" + worldDifficulty; + World.Environment environment = currentWorld.getEnvironment(); String worldEnvironment = environment.name().toLowerCase(); if(environment == World.Environment.NETHER) worldEnvironment = "&c" + worldEnvironment; - else if(environment == World.Environment.THE_END) worldEnvironment = "&d" + worldEnvironment; + else if(environment == World.Environment.THE_END) worldEnvironment = "&dend"; else if(environment == World.Environment.NORMAL) worldEnvironment = "&a" + worldEnvironment; - // Store player numbers. We have a list of all players, so we will need to iterate through all of them. - int playersNumber = 0; - for(Player p : currentWorld.getPlayers()) - { - playersNumber++; - } + // Store player numbers. + int playersNumber = currentWorld.getPlayers().size(); // Send the completed message. MessageUtils.sendColorizedMessage(commandSender, "&3" + i + "&7: &b" + currentWorld.getName() + - "&7, type: &e" + worldType + - "&7, players: &e" + playersNumber + - "&7, difficulty: &e" + worldDifficulty + - "&7, environment: &e" + worldEnvironment); + "&7, type: &e" + worldType + //type (flat, normal, large biomes) + "&7, pl: &e" + playersNumber + //players + "&7, diff: &e" + worldDifficulty +//difficulty (peaceful, easy, normal, hard) + "&7, env: &e" + worldEnvironment); //environment (normal, nether, the_end) } MessageUtils.sendColorizedMessage(commandSender, "&7---------"); diff --git a/src/main/java/net/mindoverflow/hubthat/commands/WorldTpCommand.java b/src/main/java/net/mindoverflow/hubthat/commands/WorldTpCommand.java index a7cbbff..672316e 100644 --- a/src/main/java/net/mindoverflow/hubthat/commands/WorldTpCommand.java +++ b/src/main/java/net/mindoverflow/hubthat/commands/WorldTpCommand.java @@ -73,7 +73,7 @@ public class WorldTpCommand implements CommandExecutor // Cast Player to commandSender so we can teleport it. Player player = (Player)commandSender; // Teleport the Player. - fixInvisibilityBefore(player, destinationLocation); + fixInvisibilityBefore(destinationLocation); plugin.getServer().getScheduler().runTaskLater(plugin, () -> player.teleport(destinationLocation), 1); fixInvisibilityAfter(player); // Tell the player he has been teleported. diff --git a/src/main/java/net/mindoverflow/hubthat/listeners/PlayerJoinListener.java b/src/main/java/net/mindoverflow/hubthat/listeners/PlayerJoinListener.java index 1eafcea..110b914 100644 --- a/src/main/java/net/mindoverflow/hubthat/listeners/PlayerJoinListener.java +++ b/src/main/java/net/mindoverflow/hubthat/listeners/PlayerJoinListener.java @@ -5,6 +5,7 @@ import net.mindoverflow.hubthat.commands.HubCommand; import net.mindoverflow.hubthat.utils.ConfigEntries; import net.mindoverflow.hubthat.utils.Debugger; import net.mindoverflow.hubthat.utils.MessageUtils; +import net.mindoverflow.hubthat.utils.PluginCache; import net.mindoverflow.hubthat.utils.files.FileUtils; import org.bukkit.GameMode; import org.bukkit.configuration.file.YamlConfiguration; @@ -87,11 +88,11 @@ public class PlayerJoinListener implements Listener if(configYaml.getBoolean(ConfigEntries.MULTIVERSE_BYPASS.path)) { - plugin.getServer().getScheduler().runTaskLater(plugin, ()-> HubCommand.teleportToHub(player, player), 10L); + plugin.getServer().getScheduler().runTaskLater(plugin, ()-> HubCommand.teleportToHub(player, player, PluginCache.sendJoinTpMessage), 10L); } else { - HubCommand.teleportToHub(player, player); + HubCommand.teleportToHub(player, player, PluginCache.sendJoinTpMessage); } } } diff --git a/src/main/java/net/mindoverflow/hubthat/listeners/PlayerMoveListener.java b/src/main/java/net/mindoverflow/hubthat/listeners/PlayerMoveListener.java index 9045d0c..fd6beb1 100644 --- a/src/main/java/net/mindoverflow/hubthat/listeners/PlayerMoveListener.java +++ b/src/main/java/net/mindoverflow/hubthat/listeners/PlayerMoveListener.java @@ -1,6 +1,6 @@ package net.mindoverflow.hubthat.listeners; -import net.mindoverflow.hubthat.utils.CommonValues; +import net.mindoverflow.hubthat.utils.PluginCache; import net.mindoverflow.hubthat.utils.ConfigEntries; import net.mindoverflow.hubthat.utils.LocalizedMessages; import net.mindoverflow.hubthat.utils.MessageUtils; @@ -23,7 +23,7 @@ public class PlayerMoveListener implements Listener String playerName = event.getPlayer().getName(); // Check if the player is waiting the teleport delay. - if (CommonValues.teleporting.contains(playerName)) + if (PluginCache.teleporting.contains(playerName)) { // Check if the player moved a whole block. if(event.getFrom().getBlockX() != event.getTo().getBlockX() || @@ -31,8 +31,8 @@ public class PlayerMoveListener implements Listener event.getFrom().getBlockZ() != event.getTo().getBlockZ()) { // Remove the player from the list and warn him. - CommonValues.teleporting.remove(playerName); - CommonValues.cancelRunnable.add(playerName); + PluginCache.teleporting.remove(playerName); + PluginCache.cancelRunnable.add(playerName); MessageUtils.sendLocalizedMessage(event.getPlayer(), LocalizedMessages.WARNING_TELEPORTATION_CANCELLED); } } diff --git a/src/main/java/net/mindoverflow/hubthat/utils/ConfigEntries.java b/src/main/java/net/mindoverflow/hubthat/utils/ConfigEntries.java index 304addd..ea27a6c 100644 --- a/src/main/java/net/mindoverflow/hubthat/utils/ConfigEntries.java +++ b/src/main/java/net/mindoverflow/hubthat/utils/ConfigEntries.java @@ -20,6 +20,8 @@ public enum ConfigEntries TELEPORTATION_TP_HUB_ON_JOIN("teleportation.teleport-to-hub-on-join"), + TELEPORTATION_TP_MESSAGE_ON_JOIN("teleportation.send-tp-message-on-join"), + TELEPORTATION_TP_HUB_ON_RESPAWN("teleportation.teleport-to-hub-on-respawn"), MULTIVERSE_BYPASS("settings.multiverse-bypass"), diff --git a/src/main/java/net/mindoverflow/hubthat/utils/CommonValues.java b/src/main/java/net/mindoverflow/hubthat/utils/PluginCache.java similarity index 74% rename from src/main/java/net/mindoverflow/hubthat/utils/CommonValues.java rename to src/main/java/net/mindoverflow/hubthat/utils/PluginCache.java index d8e7e82..da87b52 100644 --- a/src/main/java/net/mindoverflow/hubthat/utils/CommonValues.java +++ b/src/main/java/net/mindoverflow/hubthat/utils/PluginCache.java @@ -5,7 +5,7 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; -public class CommonValues +public class PluginCache { @@ -14,5 +14,9 @@ public class CommonValues public static Boolean updateChecker = true; public static boolean invisibilityFix = false; // sometimes, in buggy versions of Spigot, players become invisible after getting teleported. this fixes the problem. + public static boolean sendJoinTpMessage = true; public static final ItemStack AIR = new ItemStack(Material.AIR, 1); + + public static final double minSupportedVersion = 1.7; + public static final double maxSupportedVersion = 1.16; } diff --git a/src/main/java/net/mindoverflow/hubthat/utils/TeleportUtils.java b/src/main/java/net/mindoverflow/hubthat/utils/TeleportUtils.java index fd677b4..da0351b 100644 --- a/src/main/java/net/mindoverflow/hubthat/utils/TeleportUtils.java +++ b/src/main/java/net/mindoverflow/hubthat/utils/TeleportUtils.java @@ -26,7 +26,7 @@ public class TeleportUtils Player player = plugin.getServer().getPlayer(playerName); if(player == null) return; - fixInvisibilityBefore(player, location); + fixInvisibilityBefore(location); plugin.getServer().getScheduler().runTaskLater(plugin, () -> { player.teleport(location); @@ -35,7 +35,7 @@ public class TeleportUtils } // Method to teleport a player, given its username and defined if it's a hub or a spawn. - public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, String currentWorldName) + public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, String currentWorldName, boolean sendMessage) { // Get the Player object from his playername. //Player player = plugin.getServer().getPlayer(playerName); @@ -88,16 +88,16 @@ public class TeleportUtils if(type == FileUtils.FileType.HUB_YAML) { // send a message about the hub being not set - MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET); + if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET); } else if(type == FileUtils.FileType.SPAWN_YAML) { // send a message about the spawn being not set. - MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_SPAWN_NOT_SET); + if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_SPAWN_NOT_SET); } else { - MessageUtils.sendColorizedMessage(sender, "&cError in code. Contact the developer!"); + if(sendMessage) MessageUtils.sendColorizedMessage(sender, "&cError in code. Contact the developer!"); } // Stop. return; @@ -109,7 +109,7 @@ public class TeleportUtils if(worldName.equals("__UNSET__") && type == FileUtils.FileType.HUB_YAML) { // Warn the player about the hub not being set. - MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET); + if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET); // Stop. return; } @@ -120,15 +120,18 @@ public class TeleportUtils if(destinationWorld == null) { // Tell the player that the world does not exist. - String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, false); - errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldName); - MessageUtils.sendColorizedMessage(player, errorWorldNotExistingMessage); + if(sendMessage) + { + String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, false); + errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldName); + MessageUtils.sendColorizedMessage(player, errorWorldNotExistingMessage); + } return; } // Store the location in a variable and teleport the player to it. final Location finalLocation = new Location(destinationWorld, x, y, z, (float)yaw, (float)pitch); - fixInvisibilityBefore(player, finalLocation); + fixInvisibilityBefore(finalLocation); plugin.getServer().getScheduler().runTaskLater(plugin, () -> { player.teleport(finalLocation); @@ -140,9 +143,9 @@ public class TeleportUtils if(type == FileUtils.FileType.HUB_YAML) { // Send a message to the player about him being successfully teleported. - MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_HUB_TELEPORTED); + if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_HUB_TELEPORTED); - if(sender != player) + if((sender != player) && (sendMessage)) { String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_HUB_TELEPORTED_OTHER, true).replace("%player%", player.getName()); sender.sendMessage(message); @@ -150,15 +153,26 @@ public class TeleportUtils } else //if(type == FileUtils.FileType.SPAWN_YAML) // left here but commented, for easy understanding { - MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_SPAWN_TELEPORTED); + if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_SPAWN_TELEPORTED); - if(sender != player) + if((sender != player) && (sendMessage)) { String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_SPAWN_TELEPORTED_OTHER, true).replace("%player%", player.getName()).replace("%world%", worldName); sender.sendMessage(message); } } } + + public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, String currentWorldName) + { + teleportPlayer(sender, player, type, currentWorldName, true); + } + + public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, boolean sendMessage) + { + teleportPlayer(sender, player, type, null, sendMessage); + } + public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type) { teleportPlayer(sender, player, type, null); @@ -166,14 +180,14 @@ public class TeleportUtils public static void fixInvisibilityAfter(Player player) { - if(CommonValues.invisibilityFix) + if(PluginCache.invisibilityFix) { debugger.sendDebugMessage(Level.INFO, "Invisibility fix enabled!"); - player.getInventory().addItem(CommonValues.AIR); + player.getInventory().addItem(PluginCache.AIR); } } - public static void fixInvisibilityBefore(Player player, Location destination) + public static void fixInvisibilityBefore(Location destination) { destination.getChunk().load(); } diff --git a/src/main/java/net/mindoverflow/hubthat/utils/files/FileUtils.java b/src/main/java/net/mindoverflow/hubthat/utils/files/FileUtils.java index 8d011da..b35160e 100644 --- a/src/main/java/net/mindoverflow/hubthat/utils/files/FileUtils.java +++ b/src/main/java/net/mindoverflow/hubthat/utils/files/FileUtils.java @@ -1,7 +1,7 @@ package net.mindoverflow.hubthat.utils.files; import net.mindoverflow.hubthat.HubThat; -import net.mindoverflow.hubthat.utils.CommonValues; +import net.mindoverflow.hubthat.utils.PluginCache; import net.mindoverflow.hubthat.utils.ConfigEntries; import net.mindoverflow.hubthat.utils.Debugger; import net.mindoverflow.hubthat.utils.statistics.UpdateChecker; @@ -61,7 +61,7 @@ public class FileUtils if(config.getBoolean(ConfigEntries.UPDATE_CHECKER_ENABLED.path)) { - CommonValues.updateChecker = true; + PluginCache.updateChecker = true; if(UpdateChecker.task != null) { plugin.getServer().getScheduler().cancelTask(UpdateChecker.task.getTaskId()); @@ -70,7 +70,8 @@ public class FileUtils UpdateChecker.task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, plugin.updateChecker, 1, 20 * 60 * 60 * 12); } - CommonValues.invisibilityFix = config.getBoolean(ConfigEntries.INVISIBILITY_FIX.path); + PluginCache.invisibilityFix = config.getBoolean(ConfigEntries.INVISIBILITY_FIX.path); + PluginCache.sendJoinTpMessage = config.getBoolean(ConfigEntries.TELEPORTATION_TP_MESSAGE_ON_JOIN.path); } // Only reload the needed File. diff --git a/src/main/java/net/mindoverflow/hubthat/utils/statistics/UpdateChecker.java b/src/main/java/net/mindoverflow/hubthat/utils/statistics/UpdateChecker.java index e83328c..cbf54e1 100644 --- a/src/main/java/net/mindoverflow/hubthat/utils/statistics/UpdateChecker.java +++ b/src/main/java/net/mindoverflow/hubthat/utils/statistics/UpdateChecker.java @@ -233,7 +233,7 @@ public class UpdateChecker implements Runnable if(!(player instanceof Player)) return; // Check if the updater is enabled. - if(CommonValues.updateChecker) + if(PluginCache.updateChecker) { debugger.sendDebugMessage(Level.INFO, "Update Checker is enabled!"); // Check if the player has permissions to get notifications about updates. diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d6cb469..237c8bf 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -13,6 +13,7 @@ gamemode: mode: 0 teleportation: teleport-to-hub-on-join: true + send-tp-message-on-join: true teleport-to-hub-on-respawn: false respawn-handler: true settings: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 28d3656..91b4ce8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: HubThat -version: 10.0.167 +version: ${versionName}.${buildNumber} author: mind_overflow main: net.mindoverflow.hubthat.HubThat api-version: 1.13