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