Java 16 optimisations

This commit is contained in:
WiIIiam278 committed 2021-06-16 20:53:33 +01:00
1 parent 46dd32d5c2
commit e1113efeac
23 files changed
+116 -173

No files matched your search

@@ -96,19 +96,19 @@ public final class HuskHomes extends JavaPlugin {
private void initializeDatabase() {
String dataStorageType = HuskHomes.getSettings().getDatabaseType().toLowerCase();
switch (dataStorageType) {
case "mysql":
case "mysql" -> {
database = new MySQL(getInstance());
database.load();
break;
case "sqlite":
}
case "sqlite" -> {
database = new SQLite(getInstance());
database.load();
break;
default:
}
default -> {
getLogger().log(Level.WARNING, "An invalid data storage type was specified in config.yml; defaulting to SQLite");
database = new SQLite(getInstance());
database.load();
break;
}
}
}
@@ -21,8 +21,6 @@ import static org.bukkit.configuration.file.YamlConfiguration.loadConfiguration;
public class MessageManager {
private static final int languageFileVersion = 1;
private static final Map<String, String> messages = new HashMap<>();
private static final HuskHomes plugin = HuskHomes.getInstance();
@@ -57,14 +55,15 @@ public class MessageManager {
}
FileConfiguration config = loadConfiguration(f);
config.options().header(
" ------------------------------ \n" +
"| HuskHomes Messages |\n" +
"| Developed by William278 |\n" +
" ------------------------------ \n" +
"If you'd like to use a different language, you can change it in the config.yml \n" +
"Change the appearance/text of messages in the plugin using this config. \n" +
"This config makes use of MineDown formatting, with extensive support for custom colors & formats. \n" +
"For formatting help, see: https://github.com/Phoenix616/MineDown or check the HuskHomes Wiki.");
"""
------------------------------\s
| HuskHomes Messages |
| Developed by William278 |
------------------------------\s
If you'd like to use a different language, you can change it in the config.yml\s
Change the appearance/text of messages in the plugin using this config.\s
This config makes use of MineDown formatting, with extensive support for custom colors & formats.\s
For formatting help, see: https://github.com/Phoenix616/MineDown or check the HuskHomes Wiki.""");
InputStream defaultMessageFile = plugin.getResource("Languages/" + language + ".yml");
if (defaultMessageFile != null) {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultMessageFile, StandardCharsets.UTF_8));
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
* An event, fired when a player changes the description of a home.
*/
public class PlayerChangeHomeDescriptionEvent extends PlayerHomeUpdateEvent {
private final String oldDescription;
private final String newDescription;
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
* An event, fired when a player changes the description of a warp.
*/
public class PlayerChangeWarpDescriptionEvent extends PlayerWarpUpdateEvent {
private final String oldDescription;
private final String newDescription;
@@ -12,7 +12,6 @@ import org.bukkit.event.HandlerList;
* Also fires when it is deleted
*/
public class PlayerHomeUpdateEvent extends Event {
private final Player player;
private final Home home;
private static final HandlerList HANDLER_LIST = new HandlerList();
@@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
* An event, fired when a player edits a Warp to change it's location
*/
public class PlayerRelocateHomeEvent extends PlayerHomeUpdateEvent {
private final TeleportationPoint oldTeleportationPoint;
private final TeleportationPoint newTeleportationPoint;
@@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
* An event, fired when a player edits a Warp to change it's location
*/
public class PlayerRelocateWarpEvent extends PlayerWarpUpdateEvent {
private final TeleportationPoint oldTeleportationPoint;
private final TeleportationPoint newTeleportationPoint;
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
* An event, fired when a player renames a home
*/
public class PlayerRenameHomeEvent extends PlayerHomeUpdateEvent {
private final String oldName;
private final String newName;
@@ -1,10 +1,6 @@
package me.william278.huskhomes2.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import java.util.Collections;
@@ -57,7 +57,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
}
switch (args[1].toLowerCase(Locale.ENGLISH)) {
case "location":
case "location" -> {
Location newLocation = p.getLocation();
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID());
@@ -66,11 +66,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().removePublicHomeMarker(homeName, p.getName());
}
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(relocateHomeEvent));
DataManager.updateHomeLocation(p.getName(), homeName, newLocation, connection);
MessageManager.sendMessage(p, "edit_home_update_location", homeName);
@@ -79,8 +76,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().addPublicHomeMarker(locationMovedHome);
}
return;
case "description":
}
case "description" -> {
if (args.length >= 3) {
Home descriptionChangedHome = DataManager.getHome(p.getName(), homeName, connection);
@@ -122,8 +119,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
} else {
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> description <new description>");
}
return;
case "rename":
}
case "rename" -> {
if (args.length >= 3) {
String newName = args[2];
if (newName.length() > 16) {
@@ -160,8 +157,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
} else {
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
}
return;
case "public":
}
case "public" -> {
Home privateHome = DataManager.getHome(p.getName(), homeName, connection);
if (!privateHome.isPublic()) {
if (HuskHomes.getSettings().doEconomy()) {
@@ -190,8 +187,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
} else {
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
}
return;
case "private":
}
case "private" -> {
Home publicHome = DataManager.getHome(p.getName(), homeName, connection);
if (publicHome.isPublic()) {
PlayerMakeHomePrivateEvent makeHomePrivateEvent = new PlayerMakeHomePrivateEvent(p, publicHome);
@@ -206,9 +203,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
} else {
MessageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName);
}
return;
default:
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
}
default -> MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
}
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred editing a home.");
@@ -7,7 +7,6 @@ import me.william278.huskhomes2.api.events.PlayerChangeWarpDescriptionEvent;
import me.william278.huskhomes2.api.events.PlayerRelocateWarpEvent;
import me.william278.huskhomes2.api.events.PlayerRenameWarpEvent;
import me.william278.huskhomes2.data.DataManager;
import me.william278.huskhomes2.integrations.Map.DynMap;
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
import me.william278.huskhomes2.teleport.points.Warp;
import me.william278.huskhomes2.util.RegexUtil;
@@ -53,7 +52,7 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
}
switch (args[1]) {
case "location":
case "location" -> {
Location newLocation = p.getLocation();
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID());
@@ -62,10 +61,8 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().removeWarpMarker(warpName);
}
PlayerRelocateWarpEvent relocateWarpEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(relocateWarpEvent));
DataManager.updateWarpLocation(warpName, p.getLocation(), connection);
MessageManager.sendMessage(p, "edit_warp_update_location", warpName);
@@ -74,8 +71,8 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().addWarpMarker(locationMovedWarp);
}
return;
case "description":
}
case "description" -> {
if (args.length >= 3) {
Warp descriptionChangedWarp = DataManager.getWarp(warpName, connection);
@@ -117,8 +114,8 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
} else {
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> description <new description>");
}
return;
case "rename":
}
case "rename" -> {
if (args.length >= 3) {
Warp renamedWarp = DataManager.getWarp(warpName, connection);
String newName = args[2];
@@ -151,9 +148,8 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
} else {
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> rename <new warp>");
}
return;
default:
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
}
default -> MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
}
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occured editing a warp.", e);
@@ -71,10 +71,8 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
}
switch (args[0]) {
case "about":
case "info":
if (sender instanceof Player) {
Player p = (Player) sender;
case "about", "info" -> {
if (sender instanceof Player p) {
if (!p.hasPermission("huskhomes.about")) {
MessageManager.sendMessage(p, "error_no_permission");
return true;
@@ -82,9 +80,9 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
}
sender.spigot().sendMessage(new MineDown(PLUGIN_INFORMATION.toString()).toComponent());
return true;
case "update":
if (sender instanceof Player) {
Player p = (Player) sender;
}
case "update" -> {
if (sender instanceof Player p) {
if (p.hasPermission("huskhomes.version_checker")) {
if (!HuskHomes.getVersionCheckString().contains("HuskHomes is up to date!")) {
String updateMessage = "[Update:](dark_red) [" +
@@ -102,9 +100,9 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
plugin.getLogger().info(HuskHomes.getVersionCheckString());
}
return true;
case "reload":
if (sender instanceof Player) {
Player p = (Player) sender;
}
case "reload" -> {
if (sender instanceof Player p) {
if (p.hasPermission("huskhomes.reload")) {
HuskHomes.getSettings().reload();
MessageManager.loadMessages(HuskHomes.getSettings().getLanguage());
@@ -119,9 +117,9 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
plugin.getLogger().info("Reloaded config and message files.");
}
return true;
case "migrate":
if (sender instanceof Player) {
Player p = (Player) sender;
}
case "migrate" -> {
if (sender instanceof Player p) {
MessageManager.sendMessage(p, "error_console_only");
return true;
}
@@ -136,28 +134,30 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
sender.sendMessage(ChatColor.RED + "Invalid syntax! Usage: /huskhomes migrate essentialsX");
}
return true;
case "help":
if (sender instanceof Player) {
Player player = (Player) sender;
}
case "help" -> {
if (sender instanceof Player p) {
if (args.length == 2) {
try {
int pageNo = Integer.parseInt(args[1]);
showHelpMenu(player, pageNo);
showHelpMenu(p, pageNo);
} catch (NumberFormatException ex) {
MessageManager.sendMessage(player, "error_invalid_page_number");
MessageManager.sendMessage(p, "error_invalid_page_number");
}
} else {
showHelpMenu(player, 1);
showHelpMenu(p, 1);
}
}
return true;
default:
}
default -> {
if (sender instanceof Player) {
showHelpMenu((Player) sender, 1);
} else {
sender.spigot().sendMessage(new MineDown(PLUGIN_INFORMATION.toString()).toComponent());
}
return true;
}
}
}
@@ -48,11 +48,10 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
if (!(sender instanceof Player p)) {
handleConsolePublicHomeTeleport(sender, args);
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
PublicHomeListCommand.displayPublicHomeList(p, 1);
return true;
@@ -12,7 +12,7 @@ public class SetSpawnCommand extends CommandBase {
protected void onCommand(Player p, Command command, String label, String[] args) {
if (HuskHomes.getSettings().doSpawnCommand()) {
if (HuskHomes.getSettings().doCrossServerSpawn()) {
SettingHandler.updateCrossServerSpawnWarp(p.getLocation(), p);
SettingHandler.updateCrossServerSpawnWarp(p);
return;
}
SettingHandler.setSpawnLocation(p.getLocation());
@@ -2,7 +2,6 @@ package me.william278.huskhomes2.commands;
import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.MessageManager;
import me.william278.huskhomes2.integrations.VanishChecker;
import me.william278.huskhomes2.teleport.TeleportManager;
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
import org.bukkit.Bukkit;
@@ -27,11 +27,10 @@ public class WarpCommand extends CommandBase {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
if (!(sender instanceof Player p)) {
handleConsoleWarp(sender, args);
return true;
}
Player p = (Player) sender;
if (!HuskHomes.getSettings().doWarpCommand()) {
MessageManager.sendMessage(p, "error_command_disabled");
return true;
@@ -148,7 +148,7 @@ public class Settings {
if (mapPlugin != null) {
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
switch (mapPlugin.toLowerCase(Locale.ROOT)) {
case "dynmap":
case "dynmap" -> {
Plugin dynMap = pluginManager.getPlugin("dynmap");
if (dynMap == null) {
Bukkit.getLogger().warning("Dynmap integration was enabled in config, but the Dynmap plugin could not be found!");
@@ -157,8 +157,8 @@ public class Settings {
plugin.getConfig().set("map_integration.enabled", false);
plugin.saveConfig();
}
break;
case "bluemap":
}
case "bluemap" -> {
Plugin blueMap = pluginManager.getPlugin("BlueMap");
if (blueMap == null) {
Bukkit.getLogger().warning("BlueMap integration was enabled in config, but the BlueMap plugin could not be found!");
@@ -167,14 +167,14 @@ public class Settings {
plugin.getConfig().set("map_integration.enabled", false);
plugin.saveConfig();
}
break;
default:
}
default -> {
Bukkit.getLogger().warning("Map integration was enabled in config, but the map plugin type was invalid.");
Bukkit.getLogger().warning("The map integration setting has been disabled. Please ensure you specify a valid map plugin type.");
this.doMapIntegration = false;
plugin.getConfig().set("map_integration.enabled", false);
plugin.saveConfig();
break;
}
}
}
@@ -10,7 +10,6 @@ import java.util.logging.Level;
public abstract class Database {
protected HuskHomes plugin;
private Connection connection;
public Database(HuskHomes instance) {
plugin = instance;
@@ -21,7 +20,7 @@ public abstract class Database {
public abstract void load();
public void initialize() {
connection = getConnection();
Connection connection = getConnection();
// Test the retrieved connection; throw an error if it fails
try {
@@ -1,6 +1,5 @@
package me.william278.huskhomes2.integrations.Map;
import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.teleport.points.Home;
import me.william278.huskhomes2.teleport.points.Warp;
@@ -29,37 +29,35 @@ public class PluginMessageListener implements org.bukkit.plugin.messaging.Plugin
private void handlePluginMessage(PluginMessage pluginMessage, Player recipient) {
Connection connection = HuskHomes.getConnection();
switch (pluginMessage.getMessageType()) {
case SET_TP_DESTINATION:
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
DataManager.setPlayerDestinationLocation(pluginMessage.getMessageData(),
new TeleportationPoint(recipient.getLocation(), HuskHomes.getSettings().getServerID()), connection);
new PluginMessage(pluginMessage.getMessageData(), PluginMessageType.CONFIRM_DESTINATION_SET, "confirmed").send(recipient);
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred responding to a plugin message teleport destination update");
}
});
return;
case CONFIRM_DESTINATION_SET:
case SET_TP_DESTINATION -> Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
DataManager.setPlayerDestinationLocation(pluginMessage.getMessageData(),
new TeleportationPoint(recipient.getLocation(), HuskHomes.getSettings().getServerID()), connection);
new PluginMessage(pluginMessage.getMessageData(), PluginMessageType.CONFIRM_DESTINATION_SET, "confirmed").send(recipient);
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred responding to a plugin message teleport destination update");
}
});
case CONFIRM_DESTINATION_SET -> {
if (pluginMessage.getMessageData().equals("confirmed")) {
TeleportManager.teleportPlayer(recipient);
}
return;
case TPA_REQUEST:
}
case TPA_REQUEST -> {
if (!VanishChecker.isVanished(recipient)) {
TeleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(pluginMessage.getMessageData(), TeleportRequest.RequestType.TPA));
MessageManager.sendMessage(recipient, "tpa_request_ask", pluginMessage.getMessageData());
MessageManager.sendMessage(recipient, "teleport_request_options");
}
return;
case TPAHERE_REQUEST:
}
case TPAHERE_REQUEST -> {
if (!VanishChecker.isVanished(recipient)) {
TeleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(pluginMessage.getMessageData(), TeleportRequest.RequestType.TPAHERE));
MessageManager.sendMessage(recipient, "tpahere_request_ask", pluginMessage.getMessageData());
MessageManager.sendMessage(recipient, "teleport_request_options");
}
return;
case TPA_REQUEST_REPLY:
}
case TPA_REQUEST_REPLY -> {
final String tpaReplierName = pluginMessage.getMessageDataItems()[0];
final boolean tpaAccepted = Boolean.parseBoolean(pluginMessage.getMessageDataItems()[1]);
if (tpaAccepted) {
@@ -74,8 +72,8 @@ public class PluginMessageListener implements org.bukkit.plugin.messaging.Plugin
} else {
MessageManager.sendMessage(recipient, "tpa_has_declined", tpaReplierName);
}
return;
case TPAHERE_REQUEST_REPLY:
}
case TPAHERE_REQUEST_REPLY -> {
final String tpaHereReplierName = pluginMessage.getMessageDataItems()[0];
final boolean tpaHereAccepted = Boolean.parseBoolean(pluginMessage.getMessageDataItems()[1]);
if (tpaHereAccepted) {
@@ -83,17 +81,15 @@ public class PluginMessageListener implements org.bukkit.plugin.messaging.Plugin
} else {
MessageManager.sendMessage(recipient, "tpa_has_declined", tpaHereReplierName);
}
return;
case TELEPORT_TO_ME:
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
TeleportManager.teleportPlayer(recipient, pluginMessage.getMessageData(), connection);
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred responding to a plugin message teleport-to-me request");
}
});
return;
case GET_PLAYER_LIST:
}
case TELEPORT_TO_ME -> Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
TeleportManager.teleportPlayer(recipient, pluginMessage.getMessageData(), connection);
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred responding to a plugin message teleport-to-me request");
}
});
case GET_PLAYER_LIST -> {
final String requestingServer = pluginMessage.getMessageData();
StringBuilder playerList = new StringBuilder();
for (Player p : Bukkit.getOnlinePlayers()) {
@@ -103,14 +99,13 @@ public class PluginMessageListener implements org.bukkit.plugin.messaging.Plugin
if (playerList.toString().equals("")) {
return;
}
new PluginMessage(PluginMessageType.RETURN_PLAYER_LIST, playerList.substring(0, playerList.length()-1)).sendToServer(recipient, requestingServer);
return;
case RETURN_PLAYER_LIST:
new PluginMessage(PluginMessageType.RETURN_PLAYER_LIST, playerList.substring(0, playerList.length() - 1)).sendToServer(recipient, requestingServer);
}
case RETURN_PLAYER_LIST -> {
final String[] returningPlayers = pluginMessage.getMessageData().split("£");
HuskHomes.getPlayerList().addPlayers(returningPlayers);
return;
default:
HuskHomes.getInstance().getLogger().log(Level.WARNING, "Received a HuskHomes plugin message with an unrecognised type. Is your version of HuskHomes up to date?");
}
default -> HuskHomes.getInstance().getLogger().log(Level.WARNING, "Received a HuskHomes plugin message with an unrecognised type. Is your version of HuskHomes up to date?");
}
}
@@ -1,6 +1,5 @@
package me.william278.huskhomes2.teleport;
import de.themoep.minedown.MineDown;
import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.MessageManager;
import me.william278.huskhomes2.api.events.PlayerDeleteHomeEvent;
@@ -16,12 +15,6 @@ import me.william278.huskhomes2.teleport.points.Home;
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
import me.william278.huskhomes2.teleport.points.Warp;
import me.william278.huskhomes2.util.RegexUtil;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
@@ -53,14 +46,13 @@ public class SettingHandler {
HomeCommand.Tab.updatePlayerHomeCache(player);
} else {
switch (setHomeConditions.getConditionsNotMetReason()) {
case "error_set_home_maximum_homes":
case "error_set_home_maximum_homes" -> {
MessageManager.sendMessage(player, "error_set_home_maximum_homes", Integer.toString(HuskHomes.getSettings().getMaximumHomes()));
return;
case "error_insufficient_funds":
}
case "error_insufficient_funds" -> {
MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(HuskHomes.getSettings().getSetHomeCost()));
return;
default:
MessageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason());
}
default -> MessageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason());
}
}
} catch (SQLException e) {
@@ -69,7 +61,7 @@ public class SettingHandler {
});
}
public static void updateCrossServerSpawnWarp(Location location, Player p) {
public static void updateCrossServerSpawnWarp(Player p) {
Connection connection = HuskHomes.getConnection();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
@@ -138,20 +130,6 @@ public class SettingHandler {
});
}
private static BaseComponent[] deletionConfirmationButton(String commandType) {
BaseComponent[] buttonComponents = new MineDown(MessageManager.getRawMessage("delete_confirmation_button")).urlDetection(false).toComponent();
for (BaseComponent baseComponent : buttonComponents) {
baseComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, ("/huskhomes:" + commandType + " all confirm")));
baseComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder(MessageManager.getRawMessage("delete_confirmation_button_tooltip")).color(ChatColor.RED).italic(false).create())));
}
return buttonComponents;
}
private static void sendDeletionConfirmationWarning(Player player, String deletionType) {
// Send the delete-all confirmation warning
MessageManager.sendMessage(player, "delete_all_" + deletionType + "s_confirm");
}
// Delete all of a player's homes
public static void deleteAllHomes(Player player) {
Connection connection = HuskHomes.getConnection();
@@ -220,7 +198,7 @@ public class SettingHandler {
MessageManager.sendMessage(player, "error_no_homes_set");
return;
}
sendDeletionConfirmationWarning(player, "home");
MessageManager.sendMessage(player, "delete_all_homes_confirm");
return;
}
MessageManager.sendMessage(player, "error_home_invalid", homeName);
@@ -284,7 +262,7 @@ public class SettingHandler {
MessageManager.sendMessage(player, "error_no_warps_set");
return;
}
sendDeletionConfirmationWarning(player, "warp");
MessageManager.sendMessage(player, "delete_all_warps_confirm");
return;
}
MessageManager.sendMessage(player, "error_warp_invalid", warpName);
@@ -94,10 +94,8 @@ public class TimedTeleport {
try {
// Execute the teleport
switch (getTargetType()) {
case POINT:
TeleportManager.teleportPlayer(player, targetPoint, connection);
break;
case BACK:
case POINT -> TeleportManager.teleportPlayer(player, targetPoint, connection);
case BACK -> {
if (HuskHomes.getSettings().doEconomy()) {
double backCost = HuskHomes.getSettings().getBackCost();
if (backCost > 0) {
@@ -110,11 +108,9 @@ public class TimedTeleport {
}
}
TeleportManager.teleportPlayer(player, getTargetPoint(), connection);
break;
case PLAYER:
TeleportManager.teleportPlayer(player, getTargetPlayerName(), connection);
break;
case RANDOM:
}
case PLAYER -> TeleportManager.teleportPlayer(player, getTargetPlayerName(), connection);
case RANDOM -> {
RandomPoint randomPoint = new RandomPoint(player);
if (randomPoint.hasFailed()) {
return;
@@ -132,7 +128,7 @@ public class TimedTeleport {
}
TeleportManager.teleportPlayer(player, randomPoint, connection);
DataManager.updateRtpCooldown(player, connection);
break;
}
}
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred carrying out a timed teleport");
@@ -21,14 +21,12 @@ public class PlayerList {
}
public void initialize() {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
for (Player p : Bukkit.getOnlinePlayers()) {
updateList(p);
break;
}
}, 0, playerListUpdateTime);
});
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> Bukkit.getScheduler().runTaskTimer(plugin, () -> {
for (Player p : Bukkit.getOnlinePlayers()) {
updateList(p);
break;
}
}, 0, playerListUpdateTime));
}
public void updateList(Player updateRequester) {