mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
48 files changed
+808
-755
No files matched your search
@@ -61,7 +61,7 @@ public class EditingHandler {
|
|||||||
Integer.toString((int) home.getY()),
|
Integer.toString((int) home.getY()),
|
||||||
Integer.toString((int) home.getZ()));
|
Integer.toString((int) home.getZ()));
|
||||||
MessageManager.sendMessage(p, "edit_world", home.getWorldName());
|
MessageManager.sendMessage(p, "edit_world", home.getWorldName());
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
MessageManager.sendMessage(p, "edit_server", home.getServer());
|
MessageManager.sendMessage(p, "edit_server", home.getServer());
|
||||||
}
|
}
|
||||||
if (!home.isPublic()) {
|
if (!home.isPublic()) {
|
||||||
@@ -83,7 +83,7 @@ public class EditingHandler {
|
|||||||
Integer.toString((int) warp.getY()),
|
Integer.toString((int) warp.getY()),
|
||||||
Integer.toString((int) warp.getZ()));
|
Integer.toString((int) warp.getZ()));
|
||||||
MessageManager.sendMessage(p, "edit_world", warp.getWorldName());
|
MessageManager.sendMessage(p, "edit_world", warp.getWorldName());
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
MessageManager.sendMessage(p, "edit_server", warp.getServer());
|
MessageManager.sendMessage(p, "edit_server", warp.getServer());
|
||||||
}
|
}
|
||||||
p.sendMessage("");
|
p.sendMessage("");
|
||||||
|
|||||||
@@ -1,8 +1,30 @@
|
|||||||
package me.william278.huskhomes2;
|
package me.william278.huskhomes2;
|
||||||
|
|
||||||
import me.william278.huskhomes2.api.HuskHomesAPI;
|
import me.william278.huskhomes2.api.HuskHomesAPI;
|
||||||
import me.william278.huskhomes2.commands.*;
|
import me.william278.huskhomes2.commands.BackCommand;
|
||||||
import me.william278.huskhomes2.config.ConfigManager;
|
import me.william278.huskhomes2.commands.CommandBase;
|
||||||
|
import me.william278.huskhomes2.commands.DelhomeCommand;
|
||||||
|
import me.william278.huskhomes2.commands.DelwarpCommand;
|
||||||
|
import me.william278.huskhomes2.commands.EdithomeCommand;
|
||||||
|
import me.william278.huskhomes2.commands.EditwarpCommand;
|
||||||
|
import me.william278.huskhomes2.commands.HomeCommand;
|
||||||
|
import me.william278.huskhomes2.commands.HomelistCommand;
|
||||||
|
import me.william278.huskhomes2.commands.HuskhomesCommand;
|
||||||
|
import me.william278.huskhomes2.commands.PublichomeCommand;
|
||||||
|
import me.william278.huskhomes2.commands.PublichomelistCommand;
|
||||||
|
import me.william278.huskhomes2.commands.RtpCommand;
|
||||||
|
import me.william278.huskhomes2.commands.SethomeCommand;
|
||||||
|
import me.william278.huskhomes2.commands.SetspawnCommand;
|
||||||
|
import me.william278.huskhomes2.commands.SetwarpCommand;
|
||||||
|
import me.william278.huskhomes2.commands.SpawnCommand;
|
||||||
|
import me.william278.huskhomes2.commands.TpCommand;
|
||||||
|
import me.william278.huskhomes2.commands.TpaCommand;
|
||||||
|
import me.william278.huskhomes2.commands.TpacceptCommand;
|
||||||
|
import me.william278.huskhomes2.commands.TpahereCommand;
|
||||||
|
import me.william278.huskhomes2.commands.TpdenyCommand;
|
||||||
|
import me.william278.huskhomes2.commands.TphereCommand;
|
||||||
|
import me.william278.huskhomes2.commands.WarpCommand;
|
||||||
|
import me.william278.huskhomes2.commands.WarplistCommand;
|
||||||
import me.william278.huskhomes2.config.Settings;
|
import me.william278.huskhomes2.config.Settings;
|
||||||
import me.william278.huskhomes2.data.DataManager;
|
import me.william278.huskhomes2.data.DataManager;
|
||||||
import me.william278.huskhomes2.integrations.DynMapIntegration;
|
import me.william278.huskhomes2.integrations.DynMapIntegration;
|
||||||
@@ -24,13 +46,18 @@ import java.net.URLConnection;
|
|||||||
public final class HuskHomes extends JavaPlugin {
|
public final class HuskHomes extends JavaPlugin {
|
||||||
|
|
||||||
private static HuskHomes instance;
|
private static HuskHomes instance;
|
||||||
|
|
||||||
|
// TODO Remove
|
||||||
public static HuskHomes getInstance() {
|
public static HuskHomes getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
private void setInstance(HuskHomes instance) {
|
|
||||||
HuskHomes.instance = instance;
|
private static Settings settings;
|
||||||
|
|
||||||
|
// TODO Remove
|
||||||
|
public static Settings getSettings() {
|
||||||
|
return settings;
|
||||||
}
|
}
|
||||||
public static Settings settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HuskHomes API
|
* Returns the HuskHomes API
|
||||||
@@ -94,30 +121,36 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
plugin.getServer().getPluginManager().registerEvents(new PlayerListener(), plugin);
|
plugin.getServer().getPluginManager().registerEvents(new PlayerListener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
// Set instance for easy cross-class referencing
|
||||||
|
instance = this;
|
||||||
|
settings = new Settings(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
saveDefaultConfig();
|
||||||
|
|
||||||
// Plugin startup logic
|
// Plugin startup logic
|
||||||
getLogger().info("Enabling HuskHomes version " + this.getDescription().getVersion());
|
getLogger().info("Enabling HuskHomes version " + this.getDescription().getVersion());
|
||||||
|
|
||||||
// Set instance for easy cross-class referencing
|
|
||||||
setInstance(this);
|
|
||||||
|
|
||||||
// MIGRATION: Check if a migration needs to occur
|
// MIGRATION: Check if a migration needs to occur
|
||||||
LegacyMigrator.checkStartupMigration();
|
LegacyMigrator.checkStartupMigration();
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
ConfigManager.loadConfig();
|
settings.reload();
|
||||||
|
|
||||||
// MIGRATION: Migrate config files
|
// MIGRATION: Migrate config files
|
||||||
if (LegacyMigrator.startupMigrate) {
|
if (LegacyMigrator.isCanMigrate()) {
|
||||||
new LegacyMigrator().migrateConfig();
|
new LegacyMigrator().migrateConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the messages (in the right language)
|
// Load the messages (in the right language)
|
||||||
MessageManager.loadMessages(HuskHomes.settings.getLanguage());
|
MessageManager.loadMessages(HuskHomes.getSettings().getLanguage());
|
||||||
|
|
||||||
// Check for updates (if enabled)
|
// Check for updates (if enabled)
|
||||||
if (HuskHomes.settings.doUpdateChecks()) {
|
if (HuskHomes.getSettings().doUpdateChecks()) {
|
||||||
getLogger().info(getVersionCheckString());
|
getLogger().info(getVersionCheckString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,23 +161,23 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
DataManager.setupStorage();
|
DataManager.setupStorage();
|
||||||
|
|
||||||
// MIGRATION: Migrate SQL data
|
// MIGRATION: Migrate SQL data
|
||||||
if (LegacyMigrator.startupMigrate) {
|
if (LegacyMigrator.isCanMigrate()) {
|
||||||
new LegacyMigrator().migratePlayerData();
|
new LegacyMigrator().migratePlayerData();
|
||||||
new LegacyMigrator().migrateHomeData();
|
new LegacyMigrator().migrateHomeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the Dynmap integration if it is enabled
|
// Setup the Dynmap integration if it is enabled
|
||||||
if (HuskHomes.settings.doDynmap()) {
|
if (HuskHomes.getSettings().doDynmap()) {
|
||||||
DynMapIntegration.initializeDynmap();
|
DynMapIntegration.initializeDynmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup economy if it is enabled
|
// Setup economy if it is enabled
|
||||||
if (HuskHomes.settings.doEconomy()) {
|
if (HuskHomes.getSettings().doEconomy()) {
|
||||||
VaultIntegration.initializeEconomy();
|
VaultIntegration.initializeEconomy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up bungee channels if bungee mode is enabled
|
// Set up bungee channels if bungee mode is enabled
|
||||||
if (settings.doBungee()) {
|
if (getSettings().doBungee()) {
|
||||||
setupBungeeChannels();
|
setupBungeeChannels();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,5 +215,4 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
return "Error retrieving version information!";
|
return "Error retrieving version information!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ public class PluginMessageHandler implements PluginMessageListener {
|
|||||||
// Send a plugin message
|
// Send a plugin message
|
||||||
public static void sendPluginMessage(Player sender, String targetPlayerName, String messageType, String messageData) {
|
public static void sendPluginMessage(Player sender, String targetPlayerName, String messageType, String messageData) {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
int clusterID = HuskHomes.settings.getServerClusterID();
|
int clusterID = HuskHomes.getSettings().getServerClusterID();
|
||||||
|
|
||||||
// Send a plugin message to the specified player name
|
// Send a plugin message to the specified player name
|
||||||
out.writeUTF("ForwardToPlayer");
|
out.writeUTF("ForwardToPlayer");
|
||||||
@@ -89,7 +89,7 @@ public class PluginMessageHandler implements PluginMessageListener {
|
|||||||
"Please ensure you are running the latest version of HuskHomes on all your servers and that the cluster ID is set to a valid integer on all of them.");
|
"Please ensure you are running the latest version of HuskHomes on all your servers and that the cluster ID is set to a valid integer on all of them.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (HuskHomes.settings.getServerClusterID() != clusterID) {
|
if (HuskHomes.getSettings().getServerClusterID() != clusterID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +168,6 @@ public class PluginMessageHandler implements PluginMessageListener {
|
|||||||
// Set the requesters' teleport destination to a teleportation point of the recipient's current location
|
// Set the requesters' teleport destination to a teleportation point of the recipient's current location
|
||||||
public void setTeleportDestination(String requesterName, Player recipient) {
|
public void setTeleportDestination(String requesterName, Player recipient) {
|
||||||
DataManager.setPlayerDestinationLocation(requesterName,
|
DataManager.setPlayerDestinationLocation(requesterName,
|
||||||
new TeleportationPoint(recipient.getLocation(), HuskHomes.settings.getServerID()));
|
new TeleportationPoint(recipient.getLocation(), HuskHomes.getSettings().getServerID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,6 +120,6 @@ public class HuskHomesAPI {
|
|||||||
* @return the spawn position as a TeleportationPoint
|
* @return the spawn position as a TeleportationPoint
|
||||||
*/
|
*/
|
||||||
public TeleportationPoint getSpawnPosition() {
|
public TeleportationPoint getSpawnPosition() {
|
||||||
return TeleportManager.spawnLocation;
|
return TeleportManager.getSpawnLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,13 +10,12 @@ import org.bukkit.entity.Player;
|
|||||||
public class BackCommand extends CommandBase {
|
public class BackCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
TeleportationPoint lastPosition = DataManager.getPlayerLastPosition(p);
|
TeleportationPoint lastPosition = DataManager.getPlayerLastPosition(p);
|
||||||
if (lastPosition != null) {
|
if (lastPosition != null) {
|
||||||
TeleportManager.queueTimedTeleport(p, lastPosition);
|
TeleportManager.queueTimedTeleport(p, lastPosition);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_no_last_position");
|
MessageManager.sendMessage(p, "error_no_last_position");
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,12 +15,13 @@ public abstract class CommandBase implements CommandExecutor {
|
|||||||
@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) {
|
||||||
return onCommand((Player) sender, command, label, args);
|
onCommand((Player) sender, command, label, args);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean onCommand(Player player, Command command, String label, String[] args);
|
protected abstract void onCommand(Player player, Command command, String label, String[] args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register base for bukkit command
|
* Register base for bukkit command
|
||||||
|
|||||||
@@ -8,14 +8,13 @@ import org.bukkit.entity.Player;
|
|||||||
public class DelhomeCommand extends CommandBase {
|
public class DelhomeCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String homeName = args[0];
|
String homeName = args[0];
|
||||||
SettingHandler.deleteHome(p, homeName);
|
SettingHandler.deleteHome(p, homeName);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,14 +8,13 @@ import org.bukkit.entity.Player;
|
|||||||
public class DelwarpCommand extends CommandBase {
|
public class DelwarpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String warpName = args[0];
|
String warpName = args[0];
|
||||||
SettingHandler.deleteWarp(p, warpName);
|
SettingHandler.deleteWarp(p, warpName);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ import me.william278.huskhomes2.integrations.DynMapIntegration;
|
|||||||
import me.william278.huskhomes2.integrations.VaultIntegration;
|
import me.william278.huskhomes2.integrations.VaultIntegration;
|
||||||
import me.william278.huskhomes2.teleport.points.Home;
|
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.utils.RegexUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -24,203 +25,205 @@ import org.bukkit.util.StringUtil;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class EdithomeCommand extends CommandBase implements TabCompleter {
|
public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length >= 1) {
|
if (args.length == 0) {
|
||||||
String homeName = args[0];
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
if (DataManager.homeExists(p.getName(), homeName)) {
|
return;
|
||||||
if (args.length >= 2) {
|
}
|
||||||
switch (args[1]) {
|
|
||||||
case "location":
|
|
||||||
Location newLocation = p.getLocation();
|
|
||||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
|
||||||
|
|
||||||
// Remove old marker if on dynmap
|
String homeName = args[0];
|
||||||
Home locationMovedHome = DataManager.getHome(p.getName(), homeName);
|
if (!DataManager.homeExists(p.getName(), homeName)) {
|
||||||
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
|
if (args.length == 1) {
|
||||||
Bukkit.getPluginManager().callEvent(relocateHomeEvent);
|
Home home = DataManager.getHome(p.getName(), homeName);
|
||||||
if (relocateHomeEvent.isCancelled()) {
|
EditingHandler.showEditHomeOptions(p, home);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataManager.updateHomeLocation(p.getName(), homeName, newLocation);
|
switch (args[1].toLowerCase(Locale.ENGLISH)) {
|
||||||
MessageManager.sendMessage(p, "edit_home_update_location", homeName);
|
case "location":
|
||||||
|
Location newLocation = p.getLocation();
|
||||||
|
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID());
|
||||||
|
|
||||||
// Add new updated marker if using dynmap
|
// Remove old marker if on dynmap
|
||||||
locationMovedHome.setLocation(newLocation, HuskHomes.settings.getServerID());
|
Home locationMovedHome = DataManager.getHome(p.getName(), homeName);
|
||||||
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
DynMapIntegration.addDynamicMapMarker(locationMovedHome);
|
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
case "description":
|
|
||||||
if (args.length >= 3) {
|
|
||||||
Home descriptionChangedHome = DataManager.getHome(p.getName(), homeName);
|
|
||||||
|
|
||||||
// Get the new description
|
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
|
||||||
StringBuilder newDescription = new StringBuilder();
|
Bukkit.getPluginManager().callEvent(relocateHomeEvent);
|
||||||
for (int i = 2; i < args.length; i++) {
|
if (relocateHomeEvent.isCancelled()) {
|
||||||
if (i > 2) {
|
return;
|
||||||
newDescription.append(" ").append(args[i]);
|
}
|
||||||
} else {
|
|
||||||
newDescription = new StringBuilder(args[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String newDescriptionString = newDescription.toString();
|
|
||||||
PlayerChangeHomeDescriptionEvent changeHomeDescriptionEvent = new PlayerChangeHomeDescriptionEvent(p, descriptionChangedHome, newDescriptionString);
|
|
||||||
Bukkit.getPluginManager().callEvent(changeHomeDescriptionEvent);
|
|
||||||
if (changeHomeDescriptionEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Check the description is valid
|
|
||||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
|
||||||
MessageManager.sendMessage(p, "error_edit_home_invalid_description");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove old marker if on the Dynmap
|
DataManager.updateHomeLocation(p.getName(), homeName, newLocation);
|
||||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
MessageManager.sendMessage(p, "edit_home_update_location", homeName);
|
||||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update description
|
// Add new updated marker if using dynmap
|
||||||
DataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
locationMovedHome.setLocation(newLocation, HuskHomes.getSettings().getServerID());
|
||||||
|
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(locationMovedHome);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case "description":
|
||||||
|
if (args.length >= 3) {
|
||||||
|
Home descriptionChangedHome = DataManager.getHome(p.getName(), homeName);
|
||||||
|
|
||||||
// Add new marker if using Dynmap
|
// Get the new description
|
||||||
descriptionChangedHome.setDescription(newDescriptionString);
|
StringBuilder newDescription = new StringBuilder();
|
||||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
for (int i = 2; i < args.length; i++) {
|
||||||
DynMapIntegration.addDynamicMapMarker(descriptionChangedHome);
|
if (i > 2) {
|
||||||
}
|
newDescription.append(" ").append(args[i]);
|
||||||
|
} else {
|
||||||
|
newDescription = new StringBuilder(args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String newDescriptionString = newDescription.toString();
|
||||||
|
PlayerChangeHomeDescriptionEvent changeHomeDescriptionEvent = new PlayerChangeHomeDescriptionEvent(p, descriptionChangedHome, newDescriptionString);
|
||||||
|
Bukkit.getPluginManager().callEvent(changeHomeDescriptionEvent);
|
||||||
|
if (changeHomeDescriptionEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check the description is valid
|
||||||
|
if (newDescriptionString.length() > 255 || !RegexUtil.DESCRIPTION_PATTERN.matcher(newDescriptionString).matches()) {
|
||||||
|
MessageManager.sendMessage(p, "error_edit_home_invalid_description");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Confirmation message
|
// Remove old marker if on the Dynmap
|
||||||
MessageManager.sendMessage(p, "edit_home_update_description", homeName, newDescriptionString);
|
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update description
|
||||||
|
DataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
||||||
|
|
||||||
|
// Add new marker if using Dynmap
|
||||||
|
descriptionChangedHome.setDescription(newDescriptionString);
|
||||||
|
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(descriptionChangedHome);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirmation message
|
||||||
|
MessageManager.sendMessage(p, "edit_home_update_description", homeName, newDescriptionString);
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> description <new description>");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case "rename":
|
||||||
|
if (args.length >= 3) {
|
||||||
|
String newName = args[2];
|
||||||
|
if (newName.length() > 16) {
|
||||||
|
MessageManager.sendMessage(p, "error_set_home_invalid_length");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!RegexUtil.NAME_PATTERN.matcher(newName).matches()) {
|
||||||
|
MessageManager.sendMessage(p, "error_set_home_invalid_characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (DataManager.homeExists(p.getName(), newName)) {
|
||||||
|
MessageManager.sendMessage(p, "error_set_home_name_taken");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Home renamedHome = DataManager.getHome(p.getName(), homeName);
|
||||||
|
PlayerRenameHomeEvent renameHomeEvent = new PlayerRenameHomeEvent(p, renamedHome, newName);
|
||||||
|
Bukkit.getPluginManager().callEvent(renameHomeEvent);
|
||||||
|
if (renameHomeEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (renamedHome.isPublic()) {
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||||
|
}
|
||||||
|
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||||
|
PublichomeCommand.updatePublicHomeTabCache();
|
||||||
|
} else {
|
||||||
|
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||||
|
}
|
||||||
|
renamedHome.setName(newName);
|
||||||
|
if (renamedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(renamedHome);
|
||||||
|
}
|
||||||
|
HomeCommand.Tab.updatePlayerHomeCache(p);
|
||||||
|
MessageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case "public":
|
||||||
|
Home privateHome = DataManager.getHome(p.getName(), homeName);
|
||||||
|
if (!privateHome.isPublic()) {
|
||||||
|
if (HuskHomes.getSettings().doEconomy()) {
|
||||||
|
double publicHomeCost = HuskHomes.getSettings().getPublicHomeCost();
|
||||||
|
if (publicHomeCost > 0) {
|
||||||
|
if (!VaultIntegration.takeMoney(p, publicHomeCost)) {
|
||||||
|
MessageManager.sendMessage(p, "error_insufficient_funds", VaultIntegration.format(publicHomeCost));
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> description <new description>");
|
MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", homeName, VaultIntegration.format(publicHomeCost));
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
case "rename":
|
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||||
if (args.length >= 3) {
|
}
|
||||||
String newName = args[2];
|
} else {
|
||||||
if (newName.length() > 16) {
|
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||||
MessageManager.sendMessage(p, "error_set_home_invalid_length");
|
}
|
||||||
return true;
|
PlayerMakeHomePublicEvent makeHomePublicEvent = new PlayerMakeHomePublicEvent(p, privateHome);
|
||||||
}
|
Bukkit.getPluginManager().callEvent(makeHomePublicEvent);
|
||||||
if (!newName.matches("[A-Za-z0-9_\\-]+")) {
|
if (makeHomePublicEvent.isCancelled()) {
|
||||||
MessageManager.sendMessage(p, "error_set_home_invalid_characters");
|
return;
|
||||||
return true;
|
}
|
||||||
}
|
DataManager.updateHomePrivacy(p.getName(), homeName, true);
|
||||||
if (DataManager.homeExists(p.getName(), newName)) {
|
PublichomeCommand.updatePublicHomeTabCache();
|
||||||
MessageManager.sendMessage(p, "error_set_home_name_taken");
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
return true;
|
DynMapIntegration.addDynamicMapMarker(privateHome);
|
||||||
}
|
|
||||||
Home renamedHome = DataManager.getHome(p.getName(), homeName);
|
|
||||||
PlayerRenameHomeEvent renameHomeEvent = new PlayerRenameHomeEvent(p, renamedHome, newName);
|
|
||||||
Bukkit.getPluginManager().callEvent(renameHomeEvent);
|
|
||||||
if (renameHomeEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (renamedHome.isPublic()) {
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
|
||||||
}
|
|
||||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
|
||||||
PublichomeCommand.updatePublicHomeTabCache();
|
|
||||||
} else {
|
|
||||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
|
||||||
}
|
|
||||||
renamedHome.setName(newName);
|
|
||||||
if (renamedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(renamedHome);
|
|
||||||
}
|
|
||||||
HomeCommand.Tab.updatePlayerHomeCache(p);
|
|
||||||
MessageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "public":
|
|
||||||
Home privateHome = DataManager.getHome(p.getName(), homeName);
|
|
||||||
if (!privateHome.isPublic()) {
|
|
||||||
if (HuskHomes.settings.doEconomy()) {
|
|
||||||
double publicHomeCost = HuskHomes.settings.getPublicHomeCost();
|
|
||||||
if (publicHomeCost > 0) {
|
|
||||||
if (!VaultIntegration.takeMoney(p, publicHomeCost)) {
|
|
||||||
MessageManager.sendMessage(p, "error_insufficient_funds", VaultIntegration.format(publicHomeCost));
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", homeName, VaultIntegration.format(publicHomeCost));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
|
||||||
}
|
|
||||||
PlayerMakeHomePublicEvent makeHomePublicEvent = new PlayerMakeHomePublicEvent(p, privateHome);
|
|
||||||
Bukkit.getPluginManager().callEvent(makeHomePublicEvent);
|
|
||||||
if (makeHomePublicEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
DataManager.updateHomePrivacy(p.getName(), homeName, true);
|
|
||||||
PublichomeCommand.updatePublicHomeTabCache();
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(privateHome);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "private":
|
|
||||||
Home publicHome = DataManager.getHome(p.getName(), homeName);
|
|
||||||
if (publicHome.isPublic()) {
|
|
||||||
PlayerMakeHomePrivateEvent makeHomePrivateEvent = new PlayerMakeHomePrivateEvent(p, publicHome);
|
|
||||||
Bukkit.getPluginManager().callEvent(makeHomePrivateEvent);
|
|
||||||
if (makeHomePrivateEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
DataManager.updateHomePrivacy(p.getName(), homeName, false);
|
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
|
|
||||||
}
|
|
||||||
PublichomeCommand.updatePublicHomeTabCache();
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Home home = DataManager.getHome(p.getName(), homeName);
|
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
|
||||||
EditingHandler.showEditHomeOptions(p, home);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
} else {
|
return;
|
||||||
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
case "private":
|
||||||
}
|
Home publicHome = DataManager.getHome(p.getName(), homeName);
|
||||||
} else {
|
if (publicHome.isPublic()) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
PlayerMakeHomePrivateEvent makeHomePrivateEvent = new PlayerMakeHomePrivateEvent(p, publicHome);
|
||||||
|
Bukkit.getPluginManager().callEvent(makeHomePrivateEvent);
|
||||||
|
if (makeHomePrivateEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataManager.updateHomePrivacy(p.getName(), homeName, false);
|
||||||
|
MessageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
|
||||||
|
}
|
||||||
|
PublichomeCommand.updatePublicHomeTabCache();
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (!p.hasPermission("huskhomes.edithome")) {
|
if (!p.hasPermission("huskhomes.edithome")) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
final List<String> tabCompletions = new ArrayList<>();
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
StringUtil.copyPartialMatches(args[0], HomeCommand.Tab.homeTabCache.get(p.getUniqueId()), tabCompletions);
|
StringUtil.copyPartialMatches(args[0], HomeCommand.Tab.getHomeTabCache().get(p.getUniqueId()), tabCompletions);
|
||||||
Collections.sort(tabCompletions);
|
Collections.sort(tabCompletions);
|
||||||
return tabCompletions;
|
return tabCompletions;
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
@@ -234,7 +237,7 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
|||||||
}
|
}
|
||||||
return editHomeOptions;
|
return editHomeOptions;
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import me.william278.huskhomes2.data.DataManager;
|
|||||||
import me.william278.huskhomes2.integrations.DynMapIntegration;
|
import me.william278.huskhomes2.integrations.DynMapIntegration;
|
||||||
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.utils.RegexUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -25,142 +26,143 @@ import java.util.List;
|
|||||||
public class EditwarpCommand extends CommandBase implements TabCompleter {
|
public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length >= 1) {
|
if (args.length == 0) {
|
||||||
String warpName = args[0];
|
|
||||||
if (DataManager.warpExists(warpName)) {
|
|
||||||
if (args.length >= 2) {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "location":
|
|
||||||
Location newLocation = p.getLocation();
|
|
||||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
|
||||||
|
|
||||||
// Remove old marker if on the Dynmap
|
|
||||||
Warp locationMovedWarp = DataManager.getWarp(warpName);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerRelocateWarpEvent relocateWarpEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
|
|
||||||
Bukkit.getPluginManager().callEvent(relocateWarpEvent);
|
|
||||||
if (relocateWarpEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataManager.updateWarpLocation(warpName, p.getLocation());
|
|
||||||
MessageManager.sendMessage(p, "edit_warp_update_location", warpName);
|
|
||||||
|
|
||||||
// Add new updated marker if using Dynmap
|
|
||||||
locationMovedWarp.setLocation(newLocation, HuskHomes.settings.getServerID());
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(locationMovedWarp);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "description":
|
|
||||||
if (args.length >= 3) {
|
|
||||||
Warp descriptionChangedWarp = DataManager.getWarp(warpName);
|
|
||||||
|
|
||||||
// Get the new description
|
|
||||||
StringBuilder newDescription = new StringBuilder();
|
|
||||||
for (int i = 2; i < args.length; i++) {
|
|
||||||
if (i > 2) {
|
|
||||||
newDescription.append(" ").append(args[i]);
|
|
||||||
} else {
|
|
||||||
newDescription = new StringBuilder(args[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String newDescriptionString = newDescription.toString();
|
|
||||||
|
|
||||||
PlayerChangeWarpDescriptionEvent changeWarpDescriptionEvent = new PlayerChangeWarpDescriptionEvent(p, descriptionChangedWarp, newDescriptionString);
|
|
||||||
Bukkit.getPluginManager().callEvent(changeWarpDescriptionEvent);
|
|
||||||
if (changeWarpDescriptionEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the description is valid
|
|
||||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
|
||||||
MessageManager.sendMessage(p, "error_edit_warp_invalid_description");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update description
|
|
||||||
DataManager.updateWarpDescription(warpName, newDescriptionString);
|
|
||||||
|
|
||||||
descriptionChangedWarp.setDescription(newDescriptionString);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(descriptionChangedWarp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Confirmation message
|
|
||||||
MessageManager.sendMessage(p, "edit_warp_update_description", warpName, newDescriptionString);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> description <new description>");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "rename":
|
|
||||||
if (args.length >= 3) {
|
|
||||||
Warp renamedWarp = DataManager.getWarp(warpName);
|
|
||||||
String newName = args[2];
|
|
||||||
if (newName.length() > 16) {
|
|
||||||
MessageManager.sendMessage(p, "error_set_warp_invalid_length");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!newName.matches("[A-Za-z0-9_\\-]+")) {
|
|
||||||
MessageManager.sendMessage(p, "error_set_warp_invalid_characters");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (DataManager.warpExists(newName)) {
|
|
||||||
MessageManager.sendMessage(p, "error_set_warp_name_taken");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PlayerRenameWarpEvent renameWarpEvent = new PlayerRenameWarpEvent(p, renamedWarp, newName);
|
|
||||||
Bukkit.getPluginManager().callEvent(renameWarpEvent);
|
|
||||||
if (renameWarpEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
|
||||||
}
|
|
||||||
DataManager.updateWarpName(warpName, newName);
|
|
||||||
|
|
||||||
renamedWarp.setName(newName);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(renamedWarp);
|
|
||||||
}
|
|
||||||
WarpCommand.Tab.updateWarpsTabCache();
|
|
||||||
MessageManager.sendMessage(p, "edit_warp_update_name", warpName, newName);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> rename <new warp>");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Warp warp = DataManager.getWarp(warpName);
|
|
||||||
EditingHandler.showEditWarpOptions(p, warp);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String warpName = args[0];
|
||||||
|
if (!DataManager.warpExists(warpName)) {
|
||||||
|
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
Warp warp = DataManager.getWarp(warpName);
|
||||||
|
EditingHandler.showEditWarpOptions(p, warp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args[1]) {
|
||||||
|
case "location":
|
||||||
|
Location newLocation = p.getLocation();
|
||||||
|
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID());
|
||||||
|
|
||||||
|
// Remove old marker if on the Dynmap
|
||||||
|
Warp locationMovedWarp = DataManager.getWarp(warpName);
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerRelocateWarpEvent relocateWarpEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
|
||||||
|
Bukkit.getPluginManager().callEvent(relocateWarpEvent);
|
||||||
|
if (relocateWarpEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.updateWarpLocation(warpName, p.getLocation());
|
||||||
|
MessageManager.sendMessage(p, "edit_warp_update_location", warpName);
|
||||||
|
|
||||||
|
// Add new updated marker if using Dynmap
|
||||||
|
locationMovedWarp.setLocation(newLocation, HuskHomes.getSettings().getServerID());
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(locationMovedWarp);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case "description":
|
||||||
|
if (args.length >= 3) {
|
||||||
|
Warp descriptionChangedWarp = DataManager.getWarp(warpName);
|
||||||
|
|
||||||
|
// Get the new description
|
||||||
|
StringBuilder newDescription = new StringBuilder();
|
||||||
|
for (int i = 2; i < args.length; i++) {
|
||||||
|
if (i > 2) {
|
||||||
|
newDescription.append(" ").append(args[i]);
|
||||||
|
} else {
|
||||||
|
newDescription = new StringBuilder(args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String newDescriptionString = newDescription.toString();
|
||||||
|
|
||||||
|
PlayerChangeWarpDescriptionEvent changeWarpDescriptionEvent = new PlayerChangeWarpDescriptionEvent(p, descriptionChangedWarp, newDescriptionString);
|
||||||
|
Bukkit.getPluginManager().callEvent(changeWarpDescriptionEvent);
|
||||||
|
if (changeWarpDescriptionEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the description is valid
|
||||||
|
if (newDescriptionString.length() > 255 || !RegexUtil.DESCRIPTION_PATTERN.matcher(newDescriptionString).matches()) {
|
||||||
|
MessageManager.sendMessage(p, "error_edit_warp_invalid_description");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update description
|
||||||
|
DataManager.updateWarpDescription(warpName, newDescriptionString);
|
||||||
|
|
||||||
|
descriptionChangedWarp.setDescription(newDescriptionString);
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(descriptionChangedWarp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirmation message
|
||||||
|
MessageManager.sendMessage(p, "edit_warp_update_description", warpName, newDescriptionString);
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> description <new description>");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case "rename":
|
||||||
|
if (args.length >= 3) {
|
||||||
|
Warp renamedWarp = DataManager.getWarp(warpName);
|
||||||
|
String newName = args[2];
|
||||||
|
if (newName.length() > 16) {
|
||||||
|
MessageManager.sendMessage(p, "error_set_warp_invalid_length");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!RegexUtil.NAME_PATTERN.matcher(newName).matches()) {
|
||||||
|
MessageManager.sendMessage(p, "error_set_warp_invalid_characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (DataManager.warpExists(newName)) {
|
||||||
|
MessageManager.sendMessage(p, "error_set_warp_name_taken");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PlayerRenameWarpEvent renameWarpEvent = new PlayerRenameWarpEvent(p, renamedWarp, newName);
|
||||||
|
Bukkit.getPluginManager().callEvent(renameWarpEvent);
|
||||||
|
if (renameWarpEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||||
|
}
|
||||||
|
DataManager.updateWarpName(warpName, newName);
|
||||||
|
|
||||||
|
renamedWarp.setName(newName);
|
||||||
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(renamedWarp);
|
||||||
|
}
|
||||||
|
WarpCommand.Tab.updateWarpsTabCache();
|
||||||
|
MessageManager.sendMessage(p, "edit_warp_update_name", warpName, newName);
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> rename <new warp>");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (!p.hasPermission("huskhomes.editwarp")) {
|
if (!p.hasPermission("huskhomes.editwarp")) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
final List<String> tabCompletions = new ArrayList<>();
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
@@ -174,7 +176,7 @@ public class EditwarpCommand extends CommandBase implements TabCompleter {
|
|||||||
editWarpOptions.add("description");
|
editWarpOptions.add("description");
|
||||||
return editWarpOptions;
|
return editWarpOptions;
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ import java.util.UUID;
|
|||||||
public class HomeCommand extends CommandBase {
|
public class HomeCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String homeName = args[0];
|
String homeName = args[0];
|
||||||
if (DataManager.homeExists(p, homeName)) {
|
if (DataManager.homeExists(p, homeName)) {
|
||||||
@@ -36,12 +36,11 @@ public class HomeCommand extends CommandBase {
|
|||||||
if (homes.size() == 1) {
|
if (homes.size() == 1) {
|
||||||
// Teleport the player if they only have one home
|
// Teleport the player if they only have one home
|
||||||
TeleportManager.queueTimedTeleport(p, homes.get(0));
|
TeleportManager.queueTimedTeleport(p, homes.get(0));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListHandler.displayPlayerHomeList(p, 1);
|
ListHandler.displayPlayerHomeList(p, 1);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Tab implements TabCompleter {
|
public static class Tab implements TabCompleter {
|
||||||
@@ -49,7 +48,7 @@ public class HomeCommand extends CommandBase {
|
|||||||
// TODO Remove
|
// TODO Remove
|
||||||
// This HashMap stores a cache of a player's homes that is displayed when a user presses TAB.
|
// This HashMap stores a cache of a player's homes that is displayed when a user presses TAB.
|
||||||
// Owner UUID, Home Name
|
// Owner UUID, Home Name
|
||||||
public static Map<UUID, List<String>> homeTabCache = new HashMap<>();
|
private static Map<UUID, List<String>> homeTabCache = new HashMap<>();
|
||||||
|
|
||||||
// This method updates a player's home cache.
|
// This method updates a player's home cache.
|
||||||
public static void updatePlayerHomeCache(Player p) {
|
public static void updatePlayerHomeCache(Player p) {
|
||||||
@@ -66,7 +65,7 @@ public class HomeCommand extends CommandBase {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (!sender.hasPermission("huskhomes.home")) {
|
if (!sender.hasPermission("huskhomes.home")) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
final List<String> tabCompletions = new ArrayList<>();
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
@@ -74,7 +73,7 @@ public class HomeCommand extends CommandBase {
|
|||||||
List<String> homes = homeTabCache.get(p.getUniqueId());
|
List<String> homes = homeTabCache.get(p.getUniqueId());
|
||||||
if (homes == null) {
|
if (homes == null) {
|
||||||
updatePlayerHomeCache(p);
|
updatePlayerHomeCache(p);
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
StringUtil.copyPartialMatches(args[0], homes, tabCompletions);
|
StringUtil.copyPartialMatches(args[0], homes, tabCompletions);
|
||||||
|
|
||||||
@@ -82,8 +81,12 @@ public class HomeCommand extends CommandBase {
|
|||||||
|
|
||||||
return tabCompletions;
|
return tabCompletions;
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<UUID, List<String>> getHomeTabCache() {
|
||||||
|
return homeTabCache;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,18 +8,17 @@ import org.bukkit.entity.Player;
|
|||||||
public class HomelistCommand extends CommandBase {
|
public class HomelistCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
int pageNo = 1;
|
int pageNo = 1;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
try {
|
try {
|
||||||
pageNo = Integer.parseInt(args[0]);
|
pageNo = Integer.parseInt(args[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListHandler.displayPlayerHomeList(p, pageNo);
|
ListHandler.displayPlayerHomeList(p, pageNo);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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.config.ConfigManager;
|
|
||||||
import me.william278.huskhomes2.migrators.EssentialsMigrator;
|
import me.william278.huskhomes2.migrators.EssentialsMigrator;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@@ -36,81 +35,7 @@ public class HuskhomesCommand 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 (args.length >= 1) {
|
if (args.length == 0) {
|
||||||
switch (args[0]) {
|
|
||||||
case "update":
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (p.hasPermission("huskhomes.version_checker")) {
|
|
||||||
if (!HuskHomes.getVersionCheckString().contains("HuskHomes is up to date!")) {
|
|
||||||
p.sendMessage(org.bukkit.ChatColor.DARK_RED + "Update: " + org.bukkit.ChatColor.RED + HuskHomes.getVersionCheckString());
|
|
||||||
|
|
||||||
// Send a link to Spigot downloads page
|
|
||||||
ComponentBuilder componentBuilder = new ComponentBuilder();
|
|
||||||
TextComponent projectURL = new TextComponent("[Download]");
|
|
||||||
ClickEvent clickEvent = new ClickEvent(OPEN_URL, "https://www.spigotmc.org/resources/huskhomes.83767/updates");
|
|
||||||
projectURL.setClickEvent(clickEvent);
|
|
||||||
projectURL.setColor(net.md_5.bungee.api.ChatColor.AQUA);
|
|
||||||
componentBuilder = componentBuilder.append(TextComponent.fromLegacyText("§7Get the latest version: "));
|
|
||||||
componentBuilder = componentBuilder.append(projectURL);
|
|
||||||
p.spigot().sendMessage(componentBuilder.create());
|
|
||||||
} else {
|
|
||||||
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | HuskHomes is up-to-date! (Version " + plugin.getDescription().getVersion() + ")");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_no_permission");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
plugin.getLogger().info(HuskHomes.getVersionCheckString());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "reload":
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (p.hasPermission("huskhomes.reload")) {
|
|
||||||
plugin.reloadConfig();
|
|
||||||
ConfigManager.loadConfig();
|
|
||||||
MessageManager.loadMessages(HuskHomes.settings.getLanguage());
|
|
||||||
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | Reloaded config and message files.");
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_no_permission");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
ConfigManager.loadConfig();
|
|
||||||
MessageManager.loadMessages(HuskHomes.settings.getLanguage());
|
|
||||||
plugin.getLogger().info("Reloaded config and message files.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "migrate":
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
MessageManager.sendMessage(p, "error_console_only");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
if (args[1].equalsIgnoreCase("essentialsX")) {
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Attempting to migrate from EssentialsX...");
|
|
||||||
EssentialsMigrator.migrate();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Invalid argument! Usage: /huskhomes migrate essentialsX");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Invalid syntax! Usage: /huskhomes migrate essentialsX");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (!p.hasPermission("huskhomes.about")) {
|
|
||||||
MessageManager.sendMessage(p, "error_no_permission");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showAboutMenu(sender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (!p.hasPermission("huskhomes.about")) {
|
if (!p.hasPermission("huskhomes.about")) {
|
||||||
@@ -119,13 +44,86 @@ public class HuskhomesCommand extends CommandBase implements TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
showAboutMenu(sender);
|
showAboutMenu(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args[0]) {
|
||||||
|
case "update":
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (p.hasPermission("huskhomes.version_checker")) {
|
||||||
|
if (!HuskHomes.getVersionCheckString().contains("HuskHomes is up to date!")) {
|
||||||
|
p.sendMessage(org.bukkit.ChatColor.DARK_RED + "Update: " + org.bukkit.ChatColor.RED + HuskHomes.getVersionCheckString());
|
||||||
|
|
||||||
|
// Send a link to Spigot downloads page
|
||||||
|
ComponentBuilder componentBuilder = new ComponentBuilder();
|
||||||
|
TextComponent projectURL = new TextComponent("[Download]");
|
||||||
|
ClickEvent clickEvent = new ClickEvent(OPEN_URL, "https://www.spigotmc.org/resources/huskhomes.83767/updates");
|
||||||
|
projectURL.setClickEvent(clickEvent);
|
||||||
|
projectURL.setColor(net.md_5.bungee.api.ChatColor.AQUA);
|
||||||
|
componentBuilder = componentBuilder.append(TextComponent.fromLegacyText("§7Get the latest version: "));
|
||||||
|
componentBuilder = componentBuilder.append(projectURL);
|
||||||
|
p.spigot().sendMessage(componentBuilder.create());
|
||||||
|
} else {
|
||||||
|
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | HuskHomes is up-to-date! (Version " + plugin.getDescription().getVersion() + ")");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_no_permission");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.getLogger().info(HuskHomes.getVersionCheckString());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case "reload":
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (p.hasPermission("huskhomes.reload")) {
|
||||||
|
HuskHomes.getSettings().reload();
|
||||||
|
MessageManager.loadMessages(HuskHomes.getSettings().getLanguage());
|
||||||
|
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | Reloaded config and message files.");
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_no_permission");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
HuskHomes.getSettings().reload();
|
||||||
|
MessageManager.loadMessages(HuskHomes.getSettings().getLanguage());
|
||||||
|
plugin.getLogger().info("Reloaded config and message files.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case "migrate":
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
MessageManager.sendMessage(p, "error_console_only");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 2) {
|
||||||
|
if (args[1].equalsIgnoreCase("essentialsX")) {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Attempting to migrate from EssentialsX...");
|
||||||
|
EssentialsMigrator.migrate();
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Invalid argument! Usage: /huskhomes migrate essentialsX");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Invalid syntax! Usage: /huskhomes migrate essentialsX");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (!p.hasPermission("huskhomes.about")) {
|
||||||
|
MessageManager.sendMessage(p, "error_no_permission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showAboutMenu(sender);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player player, Command command, String label, String[] args) {
|
protected void onCommand(Player player, Command command, String label, String[] args) {
|
||||||
return true;
|
// Console is fine too
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,7 +141,7 @@ public class HuskhomesCommand extends CommandBase implements TabCompleter {
|
|||||||
|
|
||||||
return tabCompletions;
|
return tabCompletions;
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import me.william278.huskhomes2.data.DataManager;
|
|||||||
import me.william278.huskhomes2.teleport.ListHandler;
|
import me.william278.huskhomes2.teleport.ListHandler;
|
||||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||||
import me.william278.huskhomes2.teleport.points.Home;
|
import me.william278.huskhomes2.teleport.points.Home;
|
||||||
|
import me.william278.huskhomes2.utils.RegexUtil;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
@@ -33,35 +34,35 @@ public class PublichomeCommand extends CommandBase implements TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String publicHome = args[0];
|
ListHandler.displayPublicHomeList(p, 1);
|
||||||
if (publicHome.matches("[A-Za-z0-9_\\-]+\\.[A-Za-z0-9_\\-]+")) {
|
return;
|
||||||
String ownerName = publicHome.split("\\.")[0];
|
}
|
||||||
String homeName = publicHome.split("\\.")[1];
|
String publicHome = args[0];
|
||||||
if (DataManager.homeExists(ownerName, homeName)) {
|
if (RegexUtil.OWNER_NAME_PATTERN.matcher(publicHome).matches()) {
|
||||||
Home home = DataManager.getHome(ownerName, homeName);
|
String[] split = publicHome.split("\\.");
|
||||||
if (home.isPublic()) {
|
String ownerName = split[0];
|
||||||
TeleportManager.queueTimedTeleport(p, home);
|
String homeName = split[1];
|
||||||
} else {
|
if (DataManager.homeExists(ownerName, homeName)) {
|
||||||
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
Home home = DataManager.getHome(ownerName, homeName);
|
||||||
}
|
if (home.isPublic()) {
|
||||||
|
TeleportManager.queueTimedTeleport(p, home);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ListHandler.displayPublicHomeList(p, 1);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
if (!sender.hasPermission("huskhomes.publichome")) {
|
if (!sender.hasPermission("huskhomes.publichome")) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
final List<String> sortedHomeNames = new ArrayList<>();
|
final List<String> sortedHomeNames = new ArrayList<>();
|
||||||
@@ -75,7 +76,7 @@ public class PublichomeCommand extends CommandBase implements TabCompleter {
|
|||||||
return finalCompletions;
|
return finalCompletions;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,18 +8,17 @@ import org.bukkit.entity.Player;
|
|||||||
public class PublichomelistCommand extends CommandBase {
|
public class PublichomelistCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
int pageNo = 1;
|
int pageNo = 1;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
try {
|
try {
|
||||||
pageNo = Integer.parseInt(args[0]);
|
pageNo = Integer.parseInt(args[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListHandler.displayPublicHomeList(p, pageNo);
|
ListHandler.displayPublicHomeList(p, pageNo);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,8 @@ import org.bukkit.entity.Player;
|
|||||||
public class RtpCommand extends CommandBase {
|
public class RtpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (HuskHomes.settings.doRtpCommand()) {
|
if (HuskHomes.getSettings().doRtpCommand()) {
|
||||||
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
||||||
TeleportManager.queueRandomTeleport(p);
|
TeleportManager.queueRandomTeleport(p);
|
||||||
} else {
|
} else {
|
||||||
@@ -20,6 +20,5 @@ public class RtpCommand extends CommandBase {
|
|||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class SethomeCommand extends CommandBase {
|
public class SethomeCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String homeName = args[0];
|
String homeName = args[0];
|
||||||
SettingHandler.setHome(p.getLocation(), p, homeName);
|
SettingHandler.setHome(p.getLocation(), p, homeName);
|
||||||
@@ -21,7 +21,6 @@ public class SethomeCommand extends CommandBase {
|
|||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,14 +9,13 @@ import org.bukkit.entity.Player;
|
|||||||
public class SetspawnCommand extends CommandBase {
|
public class SetspawnCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (HuskHomes.settings.doSpawnCommand()) {
|
if (HuskHomes.getSettings().doSpawnCommand()) {
|
||||||
SettingHandler.setSpawnLocation(p.getLocation());
|
SettingHandler.setSpawnLocation(p.getLocation());
|
||||||
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
||||||
MessageManager.sendMessage(p, "set_spawn_success");
|
MessageManager.sendMessage(p, "set_spawn_success");
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,14 +8,13 @@ import org.bukkit.entity.Player;
|
|||||||
public class SetwarpCommand extends CommandBase {
|
public class SetwarpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String warpName = args[0];
|
String warpName = args[0];
|
||||||
SettingHandler.setWarp(p.getLocation(), p, warpName);
|
SettingHandler.setWarp(p.getLocation(), p, warpName);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,16 +9,15 @@ import org.bukkit.entity.Player;
|
|||||||
public class SpawnCommand extends CommandBase {
|
public class SpawnCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (HuskHomes.settings.doSpawnCommand()) {
|
if (HuskHomes.getSettings().doSpawnCommand()) {
|
||||||
if (TeleportManager.spawnLocation != null) {
|
if (TeleportManager.getSpawnLocation() != null) {
|
||||||
TeleportManager.queueTimedTeleport(p, TeleportManager.spawnLocation);
|
TeleportManager.queueTimedTeleport(p, TeleportManager.getSpawnLocation());
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,66 +19,64 @@ import java.util.List;
|
|||||||
public class TpCommand extends CommandBase {
|
public class TpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length >= 1) {
|
switch (args.length) {
|
||||||
switch (args.length) {
|
default: case 0:
|
||||||
case 1:
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
String targetPlayer = args[0];
|
return;
|
||||||
TeleportManager.teleportPlayer(p, targetPlayer);
|
case 1:
|
||||||
return true;
|
String targetPlayer = args[0];
|
||||||
case 3:
|
TeleportManager.teleportPlayer(p, targetPlayer);
|
||||||
try {
|
return;
|
||||||
double x = Double.parseDouble(args[0]);
|
case 3:
|
||||||
double y = Double.parseDouble(args[1]);
|
try {
|
||||||
double z = Double.parseDouble(args[2]);
|
double x = Double.parseDouble(args[0]);
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
double y = Double.parseDouble(args[1]);
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint);
|
double z = Double.parseDouble(args[2]);
|
||||||
} catch (Exception e) {
|
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.getSettings().getServerID());
|
||||||
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 4:
|
||||||
|
try {
|
||||||
|
double x = Double.parseDouble(args[0]);
|
||||||
|
double y = Double.parseDouble(args[1]);
|
||||||
|
double z = Double.parseDouble(args[2]);
|
||||||
|
String worldName = args[3];
|
||||||
|
if (Bukkit.getWorld(worldName) == null) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.getSettings().getServerID());
|
||||||
case 4:
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 5:
|
||||||
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
try {
|
try {
|
||||||
double x = Double.parseDouble(args[0]);
|
double x = Double.parseDouble(args[0]);
|
||||||
double y = Double.parseDouble(args[1]);
|
double y = Double.parseDouble(args[1]);
|
||||||
double z = Double.parseDouble(args[2]);
|
double z = Double.parseDouble(args[2]);
|
||||||
String worldName = args[3];
|
String worldName = args[3];
|
||||||
|
String serverName = args[4];
|
||||||
if (Bukkit.getWorld(worldName) == null) {
|
if (Bukkit.getWorld(worldName) == null) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, serverName);
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
case 5:
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
if (HuskHomes.settings.doBungee()) {
|
}
|
||||||
try {
|
return;
|
||||||
double x = Double.parseDouble(args[0]);
|
|
||||||
double y = Double.parseDouble(args[1]);
|
|
||||||
double z = Double.parseDouble(args[2]);
|
|
||||||
String worldName = args[3];
|
|
||||||
String serverName = args[4];
|
|
||||||
if (Bukkit.getWorld(worldName) == null) {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, serverName);
|
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint);
|
|
||||||
} catch (Exception e) {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Tab implements TabCompleter {
|
public static class Tab implements TabCompleter {
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ import org.bukkit.entity.Player;
|
|||||||
public class TpaCommand extends CommandBase {
|
public class TpaCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String targetPlayer = args[0];
|
String targetPlayer = args[0];
|
||||||
TeleportRequestHandler.sendTeleportToRequest(p, targetPlayer);
|
TeleportRequestHandler.sendTeleportToRequest(p, targetPlayer);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class TpacceptCommand extends CommandBase {
|
public class TpacceptCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
TeleportRequestHandler.replyTpRequest(p, true);
|
TeleportRequestHandler.replyTpRequest(p, true);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,13 +8,12 @@ import org.bukkit.entity.Player;
|
|||||||
public class TpahereCommand extends CommandBase {
|
public class TpahereCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String targetPlayer = args[0];
|
String targetPlayer = args[0];
|
||||||
TeleportRequestHandler.sendTeleportHereRequest(p, targetPlayer);
|
TeleportRequestHandler.sendTeleportHereRequest(p, targetPlayer);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class TpdenyCommand extends CommandBase {
|
public class TpdenyCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
TeleportRequestHandler.replyTpRequest(p, false);
|
TeleportRequestHandler.replyTpRequest(p, false);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,13 +8,12 @@ import org.bukkit.entity.Player;
|
|||||||
public class TphereCommand extends CommandBase {
|
public class TphereCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String targetPlayer = args[0];
|
String targetPlayer = args[0];
|
||||||
TeleportManager.teleportHere(p, targetPlayer);
|
TeleportManager.teleportHere(p, targetPlayer);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,34 +16,34 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class WarpCommand extends CommandBase {
|
public class WarpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (HuskHomes.settings.doWarpCommand()) {
|
if (!HuskHomes.getSettings().doWarpCommand()) {
|
||||||
if (args.length == 1) {
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
String warpName = args[0];
|
return;
|
||||||
if (DataManager.warpExists(warpName)) {
|
}
|
||||||
Warp warp = DataManager.getWarp(warpName);
|
if (args.length == 1) {
|
||||||
TeleportManager.queueTimedTeleport(p, warp);
|
String warpName = args[0];
|
||||||
} else {
|
if (DataManager.warpExists(warpName)) {
|
||||||
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
Warp warp = DataManager.getWarp(warpName);
|
||||||
}
|
TeleportManager.queueTimedTeleport(p, warp);
|
||||||
} else {
|
} else {
|
||||||
ListHandler.displayWarpList(p, 1);
|
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
ListHandler.displayWarpList(p, 1);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Tab implements TabCompleter {
|
public static class Tab implements TabCompleter {
|
||||||
|
|
||||||
// TODO Remove
|
// TODO Remove
|
||||||
// Cached HashMap of warps
|
// Cached HashMap of warps
|
||||||
public static final HashSet<String> warpsTabCache = new HashSet<>();
|
public static final Set<String> warpsTabCache = new HashSet<>();
|
||||||
|
|
||||||
// Updates the public home cache
|
// Updates the public home cache
|
||||||
public static void updateWarpsTabCache() {
|
public static void updateWarpsTabCache() {
|
||||||
@@ -57,7 +57,7 @@ public class WarpCommand extends CommandBase {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
if (!sender.hasPermission("huskhomes.warp")) {
|
if (!sender.hasPermission("huskhomes.warp")) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
final List<String> tabCompletions = new ArrayList<>();
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
@@ -69,7 +69,7 @@ public class WarpCommand extends CommandBase {
|
|||||||
return tabCompletions;
|
return tabCompletions;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,18 +8,17 @@ import org.bukkit.entity.Player;
|
|||||||
public class WarplistCommand extends CommandBase {
|
public class WarplistCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||||
int pageNo = 1;
|
int pageNo = 1;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
try {
|
try {
|
||||||
pageNo = Integer.parseInt(args[0]);
|
pageNo = Integer.parseInt(args[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListHandler.displayWarpList(p, pageNo);
|
ListHandler.displayWarpList(p, pageNo);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package me.william278.huskhomes2.config;
|
|
||||||
|
|
||||||
import me.william278.huskhomes2.HuskHomes;
|
|
||||||
import me.william278.huskhomes2.config.Settings;
|
|
||||||
|
|
||||||
public class ConfigManager {
|
|
||||||
|
|
||||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
|
||||||
|
|
||||||
// (Re-)Load the config file
|
|
||||||
public static void loadConfig() {
|
|
||||||
plugin.getConfig().options().header(
|
|
||||||
" ------------------------------ \n" +
|
|
||||||
"| HuskHomes Config |\n" +
|
|
||||||
"| Developed by William278 |\n" +
|
|
||||||
" ------------------------------ \n" +
|
|
||||||
"Configuration guide: https://github.com/WiIIiam278/HuskHomes2/wiki \n");
|
|
||||||
plugin.getConfig().options().copyHeader(true);
|
|
||||||
plugin.saveDefaultConfig();
|
|
||||||
HuskHomes.settings = new Settings(plugin.getConfig());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,8 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
// Message language setting
|
// Message language setting
|
||||||
private String language;
|
private String language;
|
||||||
|
|
||||||
@@ -77,21 +79,31 @@ public class Settings {
|
|||||||
private boolean doSpawnCommand;
|
private boolean doSpawnCommand;
|
||||||
private boolean doWarpCommand;
|
private boolean doWarpCommand;
|
||||||
|
|
||||||
private void setSettings(FileConfiguration configFile) {
|
public Settings(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// (Re-)Load the config file
|
||||||
|
public void reload() {
|
||||||
|
plugin.reloadConfig();
|
||||||
|
reloadFromFile(plugin.getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadFromFile(FileConfiguration config) {
|
||||||
try {
|
try {
|
||||||
this.language = configFile.getString("language");
|
this.language = config.getString("language");
|
||||||
|
|
||||||
this.updateReminders = configFile.getBoolean("check_for_updates");
|
this.updateReminders = config.getBoolean("check_for_updates");
|
||||||
|
|
||||||
this.doBungee = configFile.getBoolean("bungee_options.enable_bungee_mode");
|
this.doBungee = config.getBoolean("bungee_options.enable_bungee_mode");
|
||||||
this.server = configFile.getString("bungee_options.server_id");
|
this.server = config.getString("bungee_options.server_id");
|
||||||
this.clusterID = configFile.getInt("bungee_options.cluster_id");
|
this.clusterID = config.getInt("bungee_options.cluster_id");
|
||||||
|
|
||||||
this.storageType = configFile.getString("data_storage_options.storage_type");
|
this.storageType = config.getString("data_storage_options.storage_type");
|
||||||
this.playerDataTable = configFile.getString("data_storage_options.table_names.player_data");
|
this.playerDataTable = config.getString("data_storage_options.table_names.player_data");
|
||||||
this.locationsDataTable = configFile.getString("data_storage_options.table_names.locations_data");
|
this.locationsDataTable = config.getString("data_storage_options.table_names.locations_data");
|
||||||
this.homesDataTable = configFile.getString("data_storage_options.table_names.homes_data");
|
this.homesDataTable = config.getString("data_storage_options.table_names.homes_data");
|
||||||
this.warpsDataTable = configFile.getString("data_storage_options.table_names.warps_data");
|
this.warpsDataTable = config.getString("data_storage_options.table_names.warps_data");
|
||||||
|
|
||||||
// Resolve conflict between storage type and bungee mode
|
// Resolve conflict between storage type and bungee mode
|
||||||
if (storageType.equalsIgnoreCase("sqlite") && doBungee) {
|
if (storageType.equalsIgnoreCase("sqlite") && doBungee) {
|
||||||
@@ -101,13 +113,13 @@ public class Settings {
|
|||||||
this.doBungee = false;
|
this.doBungee = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mySQLhost = configFile.getString("data_storage_options.mysql_credentials.host");
|
this.mySQLhost = config.getString("data_storage_options.mysql_credentials.host");
|
||||||
this.mySQLdatabase = configFile.getString("data_storage_options.mysql_credentials.database");
|
this.mySQLdatabase = config.getString("data_storage_options.mysql_credentials.database");
|
||||||
this.mySQLusername = configFile.getString("data_storage_options.mysql_credentials.username");
|
this.mySQLusername = config.getString("data_storage_options.mysql_credentials.username");
|
||||||
this.mySQLpassword = configFile.getString("data_storage_options.mysql_credentials.password");
|
this.mySQLpassword = config.getString("data_storage_options.mysql_credentials.password");
|
||||||
this.mySQLport = configFile.getInt("data_storage_options.mysql_credentials.port");
|
this.mySQLport = config.getInt("data_storage_options.mysql_credentials.port");
|
||||||
|
|
||||||
this.doDynmap = configFile.getBoolean("dynmap_integration.enabled");
|
this.doDynmap = config.getBoolean("dynmap_integration.enabled");
|
||||||
|
|
||||||
if (this.doDynmap) {
|
if (this.doDynmap) {
|
||||||
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||||
@@ -119,14 +131,14 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dynmapPublicHomes = configFile.getBoolean("dynmap_integration.markers.public_homes.show");
|
this.dynmapPublicHomes = config.getBoolean("dynmap_integration.markers.public_homes.show");
|
||||||
this.dynmapWarps = configFile.getBoolean("dynmap_integration.markers.warps.show");
|
this.dynmapWarps = config.getBoolean("dynmap_integration.markers.warps.show");
|
||||||
this.dynmapPublicHomeMarkerIconID = configFile.getString("dynmap_integration.markers.public_homes.icon_id");
|
this.dynmapPublicHomeMarkerIconID = config.getString("dynmap_integration.markers.public_homes.icon_id");
|
||||||
this.dynmapWarpMarkerIconID = configFile.getString("dynmap_integration.markers.warps.icon_id");
|
this.dynmapWarpMarkerIconID = config.getString("dynmap_integration.markers.warps.icon_id");
|
||||||
this.dynmapPublicHomeMarkerSet = configFile.getString("dynmap_integration.markers.public_homes.set_name");
|
this.dynmapPublicHomeMarkerSet = config.getString("dynmap_integration.markers.public_homes.set_name");
|
||||||
this.dynmapWarpMarkerSet = configFile.getString("dynmap_integration.markers.warps.set_name");
|
this.dynmapWarpMarkerSet = config.getString("dynmap_integration.markers.warps.set_name");
|
||||||
|
|
||||||
this.doEconomy = configFile.getBoolean("economy_integration.enabled");
|
this.doEconomy = config.getBoolean("economy_integration.enabled");
|
||||||
|
|
||||||
if (this.doEconomy) {
|
if (this.doEconomy) {
|
||||||
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||||
@@ -138,16 +150,16 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.freeHomeSlots = configFile.getInt("economy_integration.free_home_slots");
|
this.freeHomeSlots = config.getInt("economy_integration.free_home_slots");
|
||||||
this.setHomeCost = configFile.getDouble("economy_integration.costs.additional_home_slot");
|
this.setHomeCost = config.getDouble("economy_integration.costs.additional_home_slot");
|
||||||
this.publicHomeCost = configFile.getDouble("economy_integration.costs.make_home_public");
|
this.publicHomeCost = config.getDouble("economy_integration.costs.make_home_public");
|
||||||
this.rtpCost = configFile.getDouble("economy_integration.costs.random_teleport");
|
this.rtpCost = config.getDouble("economy_integration.costs.random_teleport");
|
||||||
|
|
||||||
// Retrieve sounds used in plugin; if invalid, use defaults.
|
// Retrieve sounds used in plugin; if invalid, use defaults.
|
||||||
try {
|
try {
|
||||||
this.teleportationCompleteSound = Sound.valueOf(configFile.getString("general.sounds.teleportation_complete"));
|
this.teleportationCompleteSound = Sound.valueOf(config.getString("general.sounds.teleportation_complete"));
|
||||||
this.teleportWarmupSound = Sound.valueOf(configFile.getString("general.sounds.teleportation_warmup"));
|
this.teleportWarmupSound = Sound.valueOf(config.getString("general.sounds.teleportation_warmup"));
|
||||||
this.teleportCancelledSound = Sound.valueOf(configFile.getString("general.sounds.teleportation_cancelled"));
|
this.teleportCancelledSound = Sound.valueOf(config.getString("general.sounds.teleportation_cancelled"));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
Bukkit.getLogger().severe("Invalid sound specified in config.yml; using default sounds instead.");
|
Bukkit.getLogger().severe("Invalid sound specified in config.yml; using default sounds instead.");
|
||||||
this.teleportationCompleteSound = Sound.ENTITY_ENDERMAN_TELEPORT;
|
this.teleportationCompleteSound = Sound.ENTITY_ENDERMAN_TELEPORT;
|
||||||
@@ -156,22 +168,22 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.checkVanishedPlayers = configFile.getBoolean("handle_vanished_players");
|
this.checkVanishedPlayers = config.getBoolean("handle_vanished_players");
|
||||||
|
|
||||||
this.doSpawnCommand = configFile.getBoolean("spawn_command.enabled");
|
this.doSpawnCommand = config.getBoolean("spawn_command.enabled");
|
||||||
this.doWarpCommand = configFile.getBoolean("enable_warp_command");
|
this.doWarpCommand = config.getBoolean("enable_warp_command");
|
||||||
|
|
||||||
this.doRtpCommand = configFile.getBoolean("random_teleport_command.enabled");
|
this.doRtpCommand = config.getBoolean("random_teleport_command.enabled");
|
||||||
this.rtpRange = configFile.getInt("random_teleport_command.range");
|
this.rtpRange = config.getInt("random_teleport_command.range");
|
||||||
this.rtpCooldown = configFile.getInt("random_teleport_command.cooldown");
|
this.rtpCooldown = config.getInt("random_teleport_command.cooldown");
|
||||||
|
|
||||||
this.privateHomesPerPage = configFile.getInt("general.lists.private_homes_per_page");
|
this.privateHomesPerPage = config.getInt("general.lists.private_homes_per_page");
|
||||||
this.publicHomesPerPage = configFile.getInt("general.lists.public_homes_per_page");
|
this.publicHomesPerPage = config.getInt("general.lists.public_homes_per_page");
|
||||||
this.warpsPerPage = configFile.getInt("general.lists.warps_per_page");
|
this.warpsPerPage = config.getInt("general.lists.warps_per_page");
|
||||||
|
|
||||||
this.maximumHomes = configFile.getInt("general.max_sethomes");
|
this.maximumHomes = config.getInt("general.max_sethomes");
|
||||||
this.teleportRequestExpiryTime = configFile.getInt("general.teleport_request_expiry_time");
|
this.teleportRequestExpiryTime = config.getInt("general.teleport_request_expiry_time");
|
||||||
this.teleportWarmupTime = configFile.getInt("general.teleport_warmup_time");
|
this.teleportWarmupTime = config.getInt("general.teleport_warmup_time");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
HuskHomes.disablePlugin("An error occurred loading the HuskHomes config (" + e.getCause() + ")");
|
HuskHomes.disablePlugin("An error occurred loading the HuskHomes config (" + e.getCause() + ")");
|
||||||
@@ -179,14 +191,6 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadSettings(FileConfiguration configFile) {
|
|
||||||
setSettings(configFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Settings(FileConfiguration configFile) {
|
|
||||||
setSettings(configFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean showPublicHomesOnDynmap() {
|
public boolean showPublicHomesOnDynmap() {
|
||||||
return dynmapPublicHomes;
|
return dynmapPublicHomes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO Should not be an utility class for SQL class
|
||||||
|
Instead of doing everything here, all methods should be moved into corresponding classes
|
||||||
|
|
||||||
|
*/
|
||||||
// This class handles the saving of data; whether that be through SQLite or mySQL
|
// This class handles the saving of data; whether that be through SQLite or mySQL
|
||||||
public class DataManager {
|
public class DataManager {
|
||||||
|
|
||||||
@@ -26,23 +31,23 @@ public class DataManager {
|
|||||||
|
|
||||||
public static String createLocationsTable = "";
|
public static String createLocationsTable = "";
|
||||||
|
|
||||||
public static final String createHomesTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getHomesDataTable() + " (" +
|
public static final String createHomesTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getHomesDataTable() + " (" +
|
||||||
"`player_id` integer NOT NULL," +
|
"`player_id` integer NOT NULL," +
|
||||||
"`location_id` integer NOT NULL," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL," +
|
"`name` varchar(16) NOT NULL," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"`public` boolean NOT NULL," +
|
"`public` boolean NOT NULL," +
|
||||||
"PRIMARY KEY (`player_id`, `name`)," +
|
"PRIMARY KEY (`player_id`, `name`)," +
|
||||||
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.settings.getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
|
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.getSettings().getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
|
||||||
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
public static final String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getWarpsDataTable() + " (" +
|
public static final String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getWarpsDataTable() + " (" +
|
||||||
"`location_id` integer NOT NULL," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL UNIQUE," +
|
"`name` varchar(16) NOT NULL UNIQUE," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"PRIMARY KEY (`location_id`)," +
|
"PRIMARY KEY (`location_id`)," +
|
||||||
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
@@ -66,7 +71,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
||||||
ps.setString(1, playerUUID.toString());
|
ps.setString(1, playerUUID.toString());
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -92,7 +97,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `username`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `username`=?;");
|
||||||
ps.setString(1, playerUsername);
|
ps.setString(1, playerUsername);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -118,7 +123,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -155,7 +160,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -183,7 +188,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -251,7 +256,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getHomesDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -286,7 +291,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `public`;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getHomesDataTable() + " WHERE `public`;");
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
List<Home> publicHomes = new ArrayList<>();
|
List<Home> publicHomes = new ArrayList<>();
|
||||||
@@ -317,7 +322,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + ";");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getWarpsDataTable() + ";");
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
List<Warp> warps = new ArrayList<>();
|
List<Warp> warps = new ArrayList<>();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -348,7 +353,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, name);
|
ps.setString(1, name);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -382,7 +387,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
||||||
ps.setInt(1, ownerID);
|
ps.setInt(1, ownerID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
@@ -420,7 +425,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, warpName);
|
ps.setString(1, warpName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -467,7 +472,7 @@ public class DataManager {
|
|||||||
public static void updateHomeLocation(String ownerName, String homeName, Location newLocation) {
|
public static void updateHomeLocation(String ownerName, String homeName, Location newLocation) {
|
||||||
Integer playerID = getPlayerId(ownerName);
|
Integer playerID = getPlayerId(ownerName);
|
||||||
updateHomeTeleportLocation(playerID,homeName,
|
updateHomeTeleportLocation(playerID,homeName,
|
||||||
new TeleportationPoint(newLocation, HuskHomes.settings.getServerID()));
|
new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateWarpName(String warpName, String newName) {
|
public static void updateWarpName(String warpName, String newName) {
|
||||||
@@ -480,7 +485,7 @@ public class DataManager {
|
|||||||
|
|
||||||
public static void updateWarpLocation(String warpName, Location newLocation) {
|
public static void updateWarpLocation(String warpName, Location newLocation) {
|
||||||
updateWarpTeleportLocation(warpName,
|
updateWarpTeleportLocation(warpName,
|
||||||
new TeleportationPoint(newLocation, HuskHomes.settings.getServerID()));
|
new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a home with a given owner username and home name
|
// Return a home with a given owner username and home name
|
||||||
@@ -492,7 +497,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
@@ -529,7 +534,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, warpName);
|
ps.setString(1, warpName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -561,7 +566,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
@@ -589,7 +594,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
||||||
ps.setString(1, playerUUIDString);
|
ps.setString(1, playerUUIDString);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -611,7 +616,7 @@ public class DataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getLocationsDataTable() + " WHERE `location_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getLocationsDataTable() + " WHERE `location_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
@@ -622,7 +627,7 @@ public class DataManager {
|
|||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().severe("An SQL exception occurred in retrieving a teleportation location.");
|
Bukkit.getLogger().severe("An SQL exception occurred in retrieving a teleportation location.");
|
||||||
Bukkit.getLogger().severe("location ID: " + locationID.toString());
|
Bukkit.getLogger().severe("location ID: " + locationID.toString());
|
||||||
Bukkit.getLogger().severe("SELECT * FROM " + HuskHomes.settings.getLocationsDataTable() + " WHERE `location_id`=" + locationID.toString() + ";");
|
Bukkit.getLogger().severe("SELECT * FROM " + HuskHomes.getSettings().getLocationsDataTable() + " WHERE `location_id`=" + locationID.toString() + ";");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@@ -697,7 +702,7 @@ public class DataManager {
|
|||||||
Integer playerID = getPlayerId(p.getUniqueId());
|
Integer playerID = getPlayerId(p.getUniqueId());
|
||||||
if (playerID != null) {
|
if (playerID != null) {
|
||||||
long currentTime = Instant.now().getEpochSecond();
|
long currentTime = Instant.now().getEpochSecond();
|
||||||
int newCooldownTime = (int) currentTime + (60 * HuskHomes.settings.getRtpCooldown());
|
int newCooldownTime = (int) currentTime + (60 * HuskHomes.getSettings().getRtpCooldown());
|
||||||
database.setRtpCooldown(playerID, newCooldownTime);
|
database.setRtpCooldown(playerID, newCooldownTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -754,8 +759,8 @@ public class DataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setupStorage() {
|
public static void setupStorage() {
|
||||||
if (HuskHomes.settings.getStorageType().equalsIgnoreCase("mysql")) {
|
if (HuskHomes.getSettings().getStorageType().equalsIgnoreCase("mysql")) {
|
||||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getPlayerDataTable() + " (" +
|
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getPlayerDataTable() + " (" +
|
||||||
"`player_id` integer AUTO_INCREMENT," +
|
"`player_id` integer AUTO_INCREMENT," +
|
||||||
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
||||||
"`username` varchar(16) NOT NULL," +
|
"`username` varchar(16) NOT NULL," +
|
||||||
@@ -766,10 +771,10 @@ public class DataManager {
|
|||||||
"`last_location_id` integer NULL," +
|
"`last_location_id` integer NULL," +
|
||||||
|
|
||||||
"PRIMARY KEY (`player_id`)," +
|
"PRIMARY KEY (`player_id`)," +
|
||||||
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
||||||
"FOREIGN KEY (`last_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`last_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getLocationsDataTable() + " (" +
|
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getLocationsDataTable() + " (" +
|
||||||
"`location_id` integer AUTO_INCREMENT," +
|
"`location_id` integer AUTO_INCREMENT," +
|
||||||
"`server` text NOT NULL," +
|
"`server` text NOT NULL," +
|
||||||
"`world` text NOT NULL," +
|
"`world` text NOT NULL," +
|
||||||
@@ -782,7 +787,7 @@ public class DataManager {
|
|||||||
"PRIMARY KEY (`location_id`)" +
|
"PRIMARY KEY (`location_id`)" +
|
||||||
");";
|
");";
|
||||||
} else {
|
} else {
|
||||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getPlayerDataTable() + " (" +
|
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getPlayerDataTable() + " (" +
|
||||||
"`player_id` integer NOT NULL," +
|
"`player_id` integer NOT NULL," +
|
||||||
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
||||||
"`username` varchar(16) NOT NULL," +
|
"`username` varchar(16) NOT NULL," +
|
||||||
@@ -792,10 +797,10 @@ public class DataManager {
|
|||||||
"`dest_location_id` integer NULL," +
|
"`dest_location_id` integer NULL," +
|
||||||
"`last_location_id` integer NULL," +
|
"`last_location_id` integer NULL," +
|
||||||
"PRIMARY KEY (`player_id`)," +
|
"PRIMARY KEY (`player_id`)," +
|
||||||
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
||||||
"FOREIGN KEY (`last_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`last_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getLocationsDataTable() + " (" +
|
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getLocationsDataTable() + " (" +
|
||||||
"`location_id` integer PRIMARY KEY," +
|
"`location_id` integer PRIMARY KEY," +
|
||||||
"`server` text NOT NULL," +
|
"`server` text NOT NULL," +
|
||||||
"`world` text NOT NULL," +
|
"`world` text NOT NULL," +
|
||||||
|
|||||||
@@ -14,9 +14,14 @@ import java.sql.Statement;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO Should not relay on SQL
|
||||||
|
Instead should contain abstract getters and setters etc, so some alternative way of storing data may exist
|
||||||
|
Current method should possibly go into the SQL class
|
||||||
|
*/
|
||||||
public abstract class Database {
|
public abstract class Database {
|
||||||
HuskHomes plugin;
|
protected HuskHomes plugin;
|
||||||
Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
public Database(HuskHomes instance) {
|
public Database(HuskHomes instance) {
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
@@ -29,7 +34,7 @@ public abstract class Database {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
connection = getSQLConnection();
|
connection = getSQLConnection();
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + ";");
|
PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + ";");
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
close(ps, rs);
|
close(ps, rs);
|
||||||
|
|
||||||
@@ -41,7 +46,7 @@ public abstract class Database {
|
|||||||
// Insert a teleportation point, returns generated id
|
// Insert a teleportation point, returns generated id
|
||||||
public Integer addTeleportationPoint(TeleportationPoint point, Connection conn) {
|
public Integer addTeleportationPoint(TeleportationPoint point, Connection conn) {
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getLocationsDataTable() + " (world,server,x,y,z,yaw,pitch) VALUES(?,?,?,?,?,?,?);", Statement.RETURN_GENERATED_KEYS);
|
PreparedStatement ps = conn.prepareStatement("INSERT INTO " + HuskHomes.getSettings().getLocationsDataTable() + " (world,server,x,y,z,yaw,pitch) VALUES(?,?,?,?,?,?,?);", Statement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
ps.setString(1, point.getWorldName());
|
ps.setString(1, point.getWorldName());
|
||||||
ps.setString(2, point.getServer());
|
ps.setString(2, point.getServer());
|
||||||
@@ -72,7 +77,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
Integer locationID = addTeleportationPoint(home, conn);
|
Integer locationID = addTeleportationPoint(home, conn);
|
||||||
|
|
||||||
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getHomesDataTable() + " (player_id,location_id,name,description,public) VALUES(?,?,?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.getSettings().getHomesDataTable() + " (player_id,location_id,name,description,public) VALUES(?,?,?,?,?);");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.setInt(2, locationID);
|
ps.setInt(2, locationID);
|
||||||
ps.setString(3, home.getName());
|
ps.setString(3, home.getName());
|
||||||
@@ -96,7 +101,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(warp, conn);
|
Integer locationID = addTeleportationPoint(warp, conn);
|
||||||
|
|
||||||
// Insert the warp with the location_id of the last inserted teleport point
|
// Insert the warp with the location_id of the last inserted teleport point
|
||||||
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getWarpsDataTable() + " (location_id,name,description) VALUES(?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.getSettings().getWarpsDataTable() + " (location_id,name,description) VALUES(?,?,?);");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setString(2, warp.getName());
|
ps.setString(2, warp.getName());
|
||||||
ps.setString(3, warp.getDescription());
|
ps.setString(3, warp.getDescription());
|
||||||
@@ -115,7 +120,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Delete the warp with the given name
|
// Delete the warp with the given name
|
||||||
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.getSettings().getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, warpName);
|
ps.setString(1, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|
||||||
@@ -133,7 +138,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Delete the home with the given name and player ID
|
// Delete the home with the given name and player ID
|
||||||
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.getSettings().getHomesDataTable() + " WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setString(1, homeName);
|
ps.setString(1, homeName);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -151,7 +156,7 @@ public abstract class Database {
|
|||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.getSettings().getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
||||||
ps.setString(1, p.getUniqueId().toString());
|
ps.setString(1, p.getUniqueId().toString());
|
||||||
ps.setString(2, p.getName());
|
ps.setString(2, p.getName());
|
||||||
ps.setInt(3, Home.getFreeHomes(p));
|
ps.setInt(3, Home.getFreeHomes(p));
|
||||||
@@ -172,10 +177,10 @@ public abstract class Database {
|
|||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.getSettings().getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
||||||
ps.setString(1, playerUUID.toString());
|
ps.setString(1, playerUUID.toString());
|
||||||
ps.setString(2, playerName);
|
ps.setString(2, playerName);
|
||||||
ps.setInt(3, HuskHomes.settings.getFreeHomeSlots());
|
ps.setInt(3, HuskHomes.getSettings().getFreeHomeSlots());
|
||||||
ps.setInt(4, 0);
|
ps.setInt(4, 0);
|
||||||
ps.setBoolean(5, false);
|
ps.setBoolean(5, false);
|
||||||
|
|
||||||
@@ -193,7 +198,7 @@ public abstract class Database {
|
|||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.getSettings().getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
||||||
ps.setString(1, playerUUID.toString());
|
ps.setString(1, playerUUID.toString());
|
||||||
ps.setString(2, playerName);
|
ps.setString(2, playerName);
|
||||||
ps.setInt(3, homeSlots);
|
ps.setInt(3, homeSlots);
|
||||||
@@ -212,7 +217,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `username`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `username`=? WHERE `player_id`=?;");
|
||||||
ps.setString(1, newName);
|
ps.setString(1, newName);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -227,7 +232,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `is_teleporting`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `is_teleporting`=? WHERE `player_id`=?;");
|
||||||
ps.setBoolean(1, value);
|
ps.setBoolean(1, value);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -242,7 +247,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `home_slots`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `home_slots`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, newValue);
|
ps.setInt(1, newValue);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -257,7 +262,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `rtp_cooldown`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `rtp_cooldown`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, newTime);
|
ps.setInt(1, newTime);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -274,7 +279,7 @@ public abstract class Database {
|
|||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.settings.getLocationsDataTable() + " WHERE `location_id`=?;");
|
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.getSettings().getLocationsDataTable() + " WHERE `location_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -292,7 +297,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Set the home location ID to the new teleport point for the given home
|
// Set the home location ID to the new teleport point for the given home
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `public`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getHomesDataTable() + " SET `public`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setBoolean(1, isPublic);
|
ps.setBoolean(1, isPublic);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -314,7 +319,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the home location ID to the new teleport point for the given home
|
// Set the home location ID to the new teleport point for the given home
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `location_id`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getHomesDataTable() + " SET `location_id`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -336,7 +341,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the warp location ID to the new teleport point
|
// Set the warp location ID to the new teleport point
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getWarpsDataTable() + " SET `location_id`=? WHERE `name`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getWarpsDataTable() + " SET `location_id`=? WHERE `name`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setString(2, warpName);
|
ps.setString(2, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -353,7 +358,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the home description
|
// Update the home description
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `description`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getHomesDataTable() + " SET `description`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setString(1, newDescription);
|
ps.setString(1, newDescription);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -372,7 +377,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the warp description
|
// Update the warp description
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getWarpsDataTable() + " SET `description`=? WHERE `name`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getWarpsDataTable() + " SET `description`=? WHERE `name`=?;");
|
||||||
ps.setString(1, newDescription);
|
ps.setString(1, newDescription);
|
||||||
ps.setString(2, warpName);
|
ps.setString(2, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -390,7 +395,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the home name
|
// Update the home name
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `name`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getHomesDataTable() + " SET `name`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setString(1, newHomeName);
|
ps.setString(1, newHomeName);
|
||||||
ps.setString(2, oldHomeName);
|
ps.setString(2, oldHomeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -410,7 +415,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the warp name
|
// Update the warp name
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getWarpsDataTable() + " SET `name`=? WHERE `name`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getWarpsDataTable() + " SET `name`=? WHERE `name`=?;");
|
||||||
ps.setString(1, newWarpName);
|
ps.setString(1, newWarpName);
|
||||||
ps.setString(2, oldWarpName);
|
ps.setString(2, oldWarpName);
|
||||||
|
|
||||||
@@ -432,7 +437,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the destination location with the location_id of the last inserted teleport point
|
// Set the destination location with the location_id of the last inserted teleport point
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `last_location_id`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `last_location_id`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -453,7 +458,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the destination location with the location_id of the last inserted teleport point
|
// Set the destination location with the location_id of the last inserted teleport point
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `dest_location_id`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `dest_location_id`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -470,7 +475,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `dest_location_id`=NULL WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `dest_location_id`=NULL WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@@ -485,7 +490,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `last_location_id`=NULL WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.getSettings().getPlayerDataTable() + " SET `last_location_id`=NULL WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
|||||||
@@ -10,9 +10,14 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO Split into SQLite, MySQL and abstract SQL classes
|
||||||
|
Even tho both are using pretty much the same syntax and stuff, their initializations are too different and should
|
||||||
|
not co-exist in the same class.
|
||||||
|
*/
|
||||||
public class SQL extends Database {
|
public class SQL extends Database {
|
||||||
|
|
||||||
private final String SQLiteDatabaseName = "HuskHomesData";
|
private static final String SQLITE_DATABASE_NAME = "HuskHomesData";
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
@@ -26,11 +31,11 @@ public class SQL extends Database {
|
|||||||
|
|
||||||
// Initialise connection via mySQL
|
// Initialise connection via mySQL
|
||||||
private void getMySQLConnection() {
|
private void getMySQLConnection() {
|
||||||
String host = HuskHomes.settings.getMySQLhost();
|
String host = HuskHomes.getSettings().getMySQLhost();
|
||||||
int port = HuskHomes.settings.getMySQLport();
|
int port = HuskHomes.getSettings().getMySQLport();
|
||||||
String database = HuskHomes.settings.getMySQLdatabase();
|
String database = HuskHomes.getSettings().getMySQLdatabase();
|
||||||
String username = HuskHomes.settings.getMySQLusername();
|
String username = HuskHomes.getSettings().getMySQLusername();
|
||||||
String password = HuskHomes.settings.getMySQLpassword();
|
String password = HuskHomes.getSettings().getMySQLpassword();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
synchronized (HuskHomes.getInstance()) {
|
synchronized (HuskHomes.getInstance()) {
|
||||||
@@ -47,19 +52,19 @@ public class SQL extends Database {
|
|||||||
|
|
||||||
// Initialise connection via SQLite
|
// Initialise connection via SQLite
|
||||||
private void getSQLiteConnection() {
|
private void getSQLiteConnection() {
|
||||||
File dataFolder = new File(plugin.getDataFolder(), SQLiteDatabaseName + ".db");
|
File dataFolder = new File(plugin.getDataFolder(), SQLITE_DATABASE_NAME + ".db");
|
||||||
if (!dataFolder.exists()) {
|
if (!dataFolder.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!dataFolder.createNewFile()) {
|
if (!dataFolder.createNewFile()) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Failed to write new file: " + SQLiteDatabaseName + ".db (file already exists)");
|
plugin.getLogger().log(Level.SEVERE, "Failed to write new file: " + SQLITE_DATABASE_NAME + ".db (file already exists)");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "An error occurred writing a file: " + SQLiteDatabaseName + ".db (" + e.getCause() + ")");
|
plugin.getLogger().log(Level.SEVERE, "An error occurred writing a file: " + SQLITE_DATABASE_NAME + ".db (" + e.getCause() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
setConnection(DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().getAbsolutePath() + "/" + SQLiteDatabaseName + ".db"));
|
setConnection(DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().getAbsolutePath() + "/" + SQLITE_DATABASE_NAME + ".db"));
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "An exception occurred initialising the SQLite database", ex);
|
plugin.getLogger().log(Level.SEVERE, "An exception occurred initialising the SQLite database", ex);
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
@@ -70,7 +75,7 @@ public class SQL extends Database {
|
|||||||
public Connection getSQLConnection() {
|
public Connection getSQLConnection() {
|
||||||
try {
|
try {
|
||||||
if (connection == null || connection.isClosed()) {
|
if (connection == null || connection.isClosed()) {
|
||||||
String dataStorageType = HuskHomes.settings.getStorageType().toLowerCase();
|
String dataStorageType = HuskHomes.getSettings().getStorageType().toLowerCase();
|
||||||
switch (dataStorageType) {
|
switch (dataStorageType) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
getMySQLConnection();
|
getMySQLConnection();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class DynMapIntegration {
|
|||||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||||
|
|
||||||
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.warps");
|
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.warps");
|
||||||
Marker m = markerSet.createMarker(markerId, warp.getName(), warp.getWorldName(), warp.getX(), warp.getY(), warp.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(HuskHomes.settings.getDynmapWarpMarkerIconID()), false);
|
Marker m = markerSet.createMarker(markerId, warp.getName(), warp.getWorldName(), warp.getX(), warp.getY(), warp.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(HuskHomes.getSettings().getDynmapWarpMarkerIconID()), false);
|
||||||
String warpPopup = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/warp %WARP_NAME%</span><br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
String warpPopup = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/warp %WARP_NAME%</span><br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
||||||
warpPopup = warpPopup.replace("%WARP_NAME%", escapeHtml(warp.getName()));
|
warpPopup = warpPopup.replace("%WARP_NAME%", escapeHtml(warp.getName()));
|
||||||
warpPopup = warpPopup.replace("%DESCRIPTION%", escapeHtml(warp.getDescription()));
|
warpPopup = warpPopup.replace("%DESCRIPTION%", escapeHtml(warp.getDescription()));
|
||||||
@@ -63,7 +63,7 @@ public class DynMapIntegration {
|
|||||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||||
|
|
||||||
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.public_homes");
|
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.public_homes");
|
||||||
Marker m = markerSet.createMarker(markerId, home.getName(), home.getWorldName(), home.getX(), home.getY(), home.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(HuskHomes.settings.getDynmapPublicHomeMarkerIconID()), false);
|
Marker m = markerSet.createMarker(markerId, home.getName(), home.getWorldName(), home.getX(), home.getY(), home.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(HuskHomes.getSettings().getDynmapPublicHomeMarkerIconID()), false);
|
||||||
String publicHomePopup = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/phome %HOME_NAME%</span><br/><span style=\"font-weight:bold;\">Owner: </span>%OWNER%<br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
String publicHomePopup = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/phome %HOME_NAME%</span><br/><span style=\"font-weight:bold;\">Owner: </span>%OWNER%<br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
||||||
publicHomePopup = publicHomePopup.replace("%HOME_NAME%", escapeHtml(home.getName()));
|
publicHomePopup = publicHomePopup.replace("%HOME_NAME%", escapeHtml(home.getName()));
|
||||||
publicHomePopup = publicHomePopup.replace("%OWNER%", escapeHtml(home.getOwnerUsername()));
|
publicHomePopup = publicHomePopup.replace("%OWNER%", escapeHtml(home.getOwnerUsername()));
|
||||||
@@ -79,18 +79,18 @@ public class DynMapIntegration {
|
|||||||
dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
|
dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
|
||||||
|
|
||||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||||
if (HuskHomes.settings.showPublicHomesOnDynmap()) {
|
if (HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.public_homes", HuskHomes.settings.getDynmapPublicHomeMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.public_homes", HuskHomes.getSettings().getDynmapPublicHomeMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||||
for (Home home : DataManager.getPublicHomes()) {
|
for (Home home : DataManager.getPublicHomes()) {
|
||||||
if (!HuskHomes.settings.doBungee() || home.getServer().equals(HuskHomes.settings.getServerID())) {
|
if (!HuskHomes.getSettings().doBungee() || home.getServer().equals(HuskHomes.getSettings().getServerID())) {
|
||||||
addDynamicMapMarker(home);
|
addDynamicMapMarker(home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (HuskHomes.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.warps", HuskHomes.settings.getDynmapWarpMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.warps", HuskHomes.getSettings().getDynmapWarpMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||||
for (Warp warp : DataManager.getWarps()) {
|
for (Warp warp : DataManager.getWarps()) {
|
||||||
if (!HuskHomes.settings.doBungee() || warp.getServer().equals(HuskHomes.settings.getServerID())) {
|
if (!HuskHomes.getSettings().doBungee() || warp.getServer().equals(HuskHomes.getSettings().getServerID())) {
|
||||||
addDynamicMapMarker(warp);
|
addDynamicMapMarker(warp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.bukkit.metadata.MetadataValue;
|
|||||||
public class VanishChecker {
|
public class VanishChecker {
|
||||||
|
|
||||||
public static boolean isVanished(Player player) {
|
public static boolean isVanished(Player player) {
|
||||||
if (HuskHomes.settings.isCheckVanishedPlayers()) {
|
if (HuskHomes.getSettings().isCheckVanishedPlayers()) {
|
||||||
for (MetadataValue meta : player.getMetadata("vanished")) {
|
for (MetadataValue meta : player.getMetadata("vanished")) {
|
||||||
if (meta.asBoolean()) return true;
|
if (meta.asBoolean()) return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerDie(PlayerDeathEvent e) {
|
public void onPlayerDie(PlayerDeathEvent e) {
|
||||||
Player p = e.getEntity();
|
Player p = e.getEntity();
|
||||||
if (p.hasPermission("huskhomes.back.death")) {
|
if (p.hasPermission("huskhomes.back.death")) {
|
||||||
DataManager.setPlayerLastPosition(p, new TeleportationPoint(p.getLocation(), HuskHomes.settings.getServerID()));
|
DataManager.setPlayerLastPosition(p, new TeleportationPoint(p.getLocation(), HuskHomes.getSettings().getServerID()));
|
||||||
MessageManager.sendMessage(p, "return_by_death");
|
MessageManager.sendMessage(p, "return_by_death");
|
||||||
p.spigot().sendMessage(backButton().create());
|
p.spigot().sendMessage(backButton().create());
|
||||||
}
|
}
|
||||||
@@ -49,8 +49,8 @@ public class PlayerListener implements Listener {
|
|||||||
// Create player on SQL if they don't exist already
|
// Create player on SQL if they don't exist already
|
||||||
if (!DataManager.playerExists(p)) {
|
if (!DataManager.playerExists(p)) {
|
||||||
DataManager.createPlayer(p);
|
DataManager.createPlayer(p);
|
||||||
if (TeleportManager.spawnLocation != null) {
|
if (TeleportManager.getSpawnLocation() != null) {
|
||||||
p.teleport(TeleportManager.spawnLocation.getLocation());
|
p.teleport(TeleportManager.getSpawnLocation().getLocation());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check if they've changed their name and update if so
|
// Check if they've changed their name and update if so
|
||||||
@@ -61,7 +61,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If bungee mode, check if the player joined the server from a teleport and act accordingly
|
// If bungee mode, check if the player joined the server from a teleport and act accordingly
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
if (DataManager.getPlayerTeleporting(p)) {
|
if (DataManager.getPlayerTeleporting(p)) {
|
||||||
TeleportManager.teleportPlayer(p);
|
TeleportManager.teleportPlayer(p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class EssentialsMigrator {
|
|||||||
|
|
||||||
// Migrate data from EssentialsX
|
// Migrate data from EssentialsX
|
||||||
public static void migrate() {
|
public static void migrate() {
|
||||||
String serverID = HuskHomes.settings.getServerID();
|
String serverID = HuskHomes.getSettings().getServerID();
|
||||||
File essentialsDataFolder = new File(Bukkit.getWorldContainer() + File.separator + "plugins" + File.separator + "Essentials");
|
File essentialsDataFolder = new File(Bukkit.getWorldContainer() + File.separator + "plugins" + File.separator + "Essentials");
|
||||||
if (essentialsDataFolder.exists()) {
|
if (essentialsDataFolder.exists()) {
|
||||||
Bukkit.getLogger().info("Essentials plugin data found!");
|
Bukkit.getLogger().info("Essentials plugin data found!");
|
||||||
@@ -33,7 +33,7 @@ public class EssentialsMigrator {
|
|||||||
|
|
||||||
File[] playerFiles = essentialsPlayerDataFolder.listFiles();
|
File[] playerFiles = essentialsPlayerDataFolder.listFiles();
|
||||||
for (File playerFile : playerFiles) {
|
for (File playerFile : playerFiles) {
|
||||||
String uuidS = playerFile.getName().replaceFirst("[.][^.]+$", "");
|
String uuidS = playerFile.getName().split("\\.")[0];
|
||||||
UUID uuid = UUID.fromString(uuidS);
|
UUID uuid = UUID.fromString(uuidS);
|
||||||
FileConfiguration playerFileConfig = loadConfiguration(playerFile);
|
FileConfiguration playerFileConfig = loadConfiguration(playerFile);
|
||||||
String playerName = playerFileConfig.getString("lastAccountName");
|
String playerName = playerFileConfig.getString("lastAccountName");
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.william278.huskhomes2.migrators;
|
package me.william278.huskhomes2.migrators;
|
||||||
|
|
||||||
import me.william278.huskhomes2.HuskHomes;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.config.ConfigManager;
|
|
||||||
import me.william278.huskhomes2.data.DataManager;
|
import me.william278.huskhomes2.data.DataManager;
|
||||||
import me.william278.huskhomes2.teleport.points.Home;
|
import me.william278.huskhomes2.teleport.points.Home;
|
||||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||||
@@ -21,7 +20,7 @@ import static org.bukkit.configuration.file.YamlConfiguration.loadConfiguration;
|
|||||||
// This class migrates data from HuskHomes 1.5.x to HuskHomes 2.x
|
// This class migrates data from HuskHomes 1.5.x to HuskHomes 2.x
|
||||||
public class LegacyMigrator {
|
public class LegacyMigrator {
|
||||||
|
|
||||||
public static boolean startupMigrate;
|
private static boolean canMigrate;
|
||||||
private static String sourcePlayerTable;
|
private static String sourcePlayerTable;
|
||||||
private static String sourceHomeTable;
|
private static String sourceHomeTable;
|
||||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
@@ -42,7 +41,7 @@ public class LegacyMigrator {
|
|||||||
if (!config.contains("config_file_version") && config.contains("host")) {
|
if (!config.contains("config_file_version") && config.contains("host")) {
|
||||||
Bukkit.getLogger().info("Detected HuskHomes 1.0 data to migrate!");
|
Bukkit.getLogger().info("Detected HuskHomes 1.0 data to migrate!");
|
||||||
Bukkit.getLogger().info("- Preparing Migration -");
|
Bukkit.getLogger().info("- Preparing Migration -");
|
||||||
startupMigrate = true;
|
canMigrate = true;
|
||||||
createMigrationSubdirectory();
|
createMigrationSubdirectory();
|
||||||
if (!configFile.renameTo(new File(plugin.getDataFolder() + File.separator + "MigratedData" + File.separator + "OLD_config.yml"))) {
|
if (!configFile.renameTo(new File(plugin.getDataFolder() + File.separator + "MigratedData" + File.separator + "OLD_config.yml"))) {
|
||||||
Bukkit.getLogger().warning("Failed to move old config.yml!");
|
Bukkit.getLogger().warning("Failed to move old config.yml!");
|
||||||
@@ -117,11 +116,10 @@ public class LegacyMigrator {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
|
|
||||||
// Reload settings with new ones
|
// Reload settings with new ones
|
||||||
plugin.reloadConfig();
|
HuskHomes.getSettings().reload();
|
||||||
ConfigManager.loadConfig();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getLogger().warning("Failed to migrate data; " + e.getCause() + " when trying to migrate config data");
|
Bukkit.getLogger().warning("Failed to migrate data; " + e.getCause() + " when trying to migrate config data");
|
||||||
startupMigrate = false;
|
canMigrate = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getLogger().info("- Config migrations complete! -");
|
Bukkit.getLogger().info("- Config migrations complete! -");
|
||||||
@@ -131,8 +129,8 @@ public class LegacyMigrator {
|
|||||||
try {
|
try {
|
||||||
synchronized (HuskHomes.getInstance()) {
|
synchronized (HuskHomes.getInstance()) {
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
Class.forName("com.mysql.jdbc.Driver");
|
||||||
return DriverManager.getConnection("jdbc:mysql://" + HuskHomes.settings.getMySQLhost() + ":" + HuskHomes.settings.getMySQLport()
|
return DriverManager.getConnection("jdbc:mysql://" + HuskHomes.getSettings().getMySQLhost() + ":" + HuskHomes.getSettings().getMySQLport()
|
||||||
+ "/" + HuskHomes.settings.getMySQLdatabase() + "?autoReconnect=true&useSSL=false", HuskHomes.settings.getMySQLusername(), HuskHomes.settings.getMySQLpassword());
|
+ "/" + HuskHomes.getSettings().getMySQLdatabase() + "?autoReconnect=true&useSSL=false", HuskHomes.getSettings().getMySQLusername(), HuskHomes.getSettings().getMySQLpassword());
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return null;
|
return null;
|
||||||
@@ -208,4 +206,7 @@ public class LegacyMigrator {
|
|||||||
Bukkit.getLogger().info("-- Migration complete! --");
|
Bukkit.getLogger().info("-- Migration complete! --");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCanMigrate() {
|
||||||
|
return canMigrate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class ListHandler {
|
|||||||
MessageManager.sendMessage(player, "error_no_homes_set");
|
MessageManager.sendMessage(player, "error_no_homes_set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int itemsPerPage = HuskHomes.settings.getPrivateHomesPerPage();
|
int itemsPerPage = HuskHomes.getSettings().getPrivateHomesPerPage();
|
||||||
int homeLowerBound = (pageNumber - 1) * itemsPerPage;
|
int homeLowerBound = (pageNumber - 1) * itemsPerPage;
|
||||||
int homeUpperBound = pageNumber * itemsPerPage;
|
int homeUpperBound = pageNumber * itemsPerPage;
|
||||||
if (homeUpperBound > homes.size()) {
|
if (homeUpperBound > homes.size()) {
|
||||||
@@ -130,7 +130,7 @@ public class ListHandler {
|
|||||||
MessageManager.sendMessage(player, "error_no_public_homes_set");
|
MessageManager.sendMessage(player, "error_no_public_homes_set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int itemsPerPage = HuskHomes.settings.getPublicHomesPerPage();
|
int itemsPerPage = HuskHomes.getSettings().getPublicHomesPerPage();
|
||||||
int homeLowerBound = (pageNumber - 1) * itemsPerPage;
|
int homeLowerBound = (pageNumber - 1) * itemsPerPage;
|
||||||
int homeUpperBound = pageNumber * itemsPerPage;
|
int homeUpperBound = pageNumber * itemsPerPage;
|
||||||
if (homeUpperBound > homes.size()) {
|
if (homeUpperBound > homes.size()) {
|
||||||
@@ -174,7 +174,7 @@ public class ListHandler {
|
|||||||
MessageManager.sendMessage(player, "error_no_warps_set");
|
MessageManager.sendMessage(player, "error_no_warps_set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int itemsPerPage = HuskHomes.settings.getWarpsPerPage();
|
int itemsPerPage = HuskHomes.getSettings().getWarpsPerPage();
|
||||||
int warpsLowerBound = (pageNumber - 1) * itemsPerPage;
|
int warpsLowerBound = (pageNumber - 1) * itemsPerPage;
|
||||||
int warpsUpperBound = pageNumber * itemsPerPage;
|
int warpsUpperBound = pageNumber * itemsPerPage;
|
||||||
if (warpsUpperBound > warps.size()) {
|
if (warpsUpperBound > warps.size()) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import me.william278.huskhomes2.integrations.VaultIntegration;
|
|||||||
import me.william278.huskhomes2.teleport.points.Home;
|
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.utils.RegexUtil;
|
||||||
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;
|
||||||
@@ -29,7 +30,7 @@ public class SettingHandler {
|
|||||||
public static void setHome(Location location, Player player, String name) {
|
public static void setHome(Location location, Player player, String name) {
|
||||||
SetHomeConditions setHomeConditions = new SetHomeConditions(player, name);
|
SetHomeConditions setHomeConditions = new SetHomeConditions(player, name);
|
||||||
if (setHomeConditions.areConditionsMet()) {
|
if (setHomeConditions.areConditionsMet()) {
|
||||||
Home home = new Home(location, HuskHomes.settings.getServerID(), player, name, false);
|
Home home = new Home(location, HuskHomes.getSettings().getServerID(), player, name, false);
|
||||||
PlayerSetHomeEvent event = new PlayerSetHomeEvent(player, home);
|
PlayerSetHomeEvent event = new PlayerSetHomeEvent(player, home);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@@ -41,10 +42,10 @@ public class SettingHandler {
|
|||||||
} 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.settings.getMaximumHomes()));
|
MessageManager.sendMessage(player, "error_set_home_maximum_homes", Integer.toString(HuskHomes.getSettings().getMaximumHomes()));
|
||||||
return;
|
return;
|
||||||
case "error_insufficient_funds":
|
case "error_insufficient_funds":
|
||||||
MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(HuskHomes.settings.getSetHomeCost()));
|
MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(HuskHomes.getSettings().getSetHomeCost()));
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
MessageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason());
|
MessageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason());
|
||||||
@@ -56,7 +57,7 @@ public class SettingHandler {
|
|||||||
public static void setWarp(Location location, Player player, String name) {
|
public static void setWarp(Location location, Player player, String name) {
|
||||||
SetWarpConditions setWarpConditions = new SetWarpConditions(name);
|
SetWarpConditions setWarpConditions = new SetWarpConditions(name);
|
||||||
if (setWarpConditions.areConditionsMet()) {
|
if (setWarpConditions.areConditionsMet()) {
|
||||||
Warp warp = new Warp(location, HuskHomes.settings.getServerID(), name);
|
Warp warp = new Warp(location, HuskHomes.getSettings().getServerID(), name);
|
||||||
PlayerSetWarpEvent event = new PlayerSetWarpEvent(player, warp);
|
PlayerSetWarpEvent event = new PlayerSetWarpEvent(player, warp);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@@ -64,7 +65,7 @@ public class SettingHandler {
|
|||||||
}
|
}
|
||||||
DataManager.addWarp(warp);
|
DataManager.addWarp(warp);
|
||||||
MessageManager.sendMessage(player, "set_warp_success", name);
|
MessageManager.sendMessage(player, "set_warp_success", name);
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
DynMapIntegration.addDynamicMapMarker(warp);
|
DynMapIntegration.addDynamicMapMarker(warp);
|
||||||
}
|
}
|
||||||
WarpCommand.Tab.updateWarpsTabCache();
|
WarpCommand.Tab.updateWarpsTabCache();
|
||||||
@@ -80,7 +81,7 @@ public class SettingHandler {
|
|||||||
if (home != null) {
|
if (home != null) {
|
||||||
if (home.isPublic()) {
|
if (home.isPublic()) {
|
||||||
// Delete Dynmap marker if it exists & if the home is public
|
// Delete Dynmap marker if it exists & if the home is public
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||||
DynMapIntegration.removeDynamicMapMarker(homeName, player.getName());
|
DynMapIntegration.removeDynamicMapMarker(homeName, player.getName());
|
||||||
}
|
}
|
||||||
PlayerDeleteHomeEvent event = new PlayerDeleteHomeEvent(player, home);
|
PlayerDeleteHomeEvent event = new PlayerDeleteHomeEvent(player, home);
|
||||||
@@ -114,7 +115,7 @@ public class SettingHandler {
|
|||||||
}
|
}
|
||||||
DataManager.deleteWarp(warpName);
|
DataManager.deleteWarp(warpName);
|
||||||
MessageManager.sendMessage(player, "warp_deleted", warpName);
|
MessageManager.sendMessage(player, "warp_deleted", warpName);
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||||
}
|
}
|
||||||
WarpCommand.Tab.updateWarpsTabCache();
|
WarpCommand.Tab.updateWarpsTabCache();
|
||||||
@@ -136,17 +137,17 @@ public class SettingHandler {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
|
|
||||||
// Update the current spawn location
|
// Update the current spawn location
|
||||||
TeleportManager.spawnLocation = new TeleportationPoint(location, HuskHomes.settings.getServerID());
|
TeleportManager.setSpawnLocation(new TeleportationPoint(location, HuskHomes.getSettings().getServerID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update current spawn location from config
|
// Update current spawn location from config
|
||||||
public static void fetchSpawnLocation() {
|
public static void fetchSpawnLocation() {
|
||||||
TeleportManager.spawnLocation = getSpawnLocation();
|
TeleportManager.setSpawnLocation(getSpawnLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get spawn location from config
|
// Get spawn location from config
|
||||||
private static TeleportationPoint getSpawnLocation() {
|
private static TeleportationPoint getSpawnLocation() {
|
||||||
String server = HuskHomes.settings.getServerID();
|
String server = HuskHomes.getSettings().getServerID();
|
||||||
try {
|
try {
|
||||||
FileConfiguration config = plugin.getConfig();
|
FileConfiguration config = plugin.getConfig();
|
||||||
String worldName = (config.getString("spawn_command.position.world"));
|
String worldName = (config.getString("spawn_command.position.world"));
|
||||||
@@ -179,7 +180,7 @@ public class SettingHandler {
|
|||||||
conditionsNotMetReason = "error_set_warp_invalid_length";
|
conditionsNotMetReason = "error_set_warp_invalid_length";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!warpName.matches("[A-Za-z0-9_\\-]+")) {
|
if (!RegexUtil.NAME_PATTERN.matcher(warpName).matches()) {
|
||||||
conditionsNotMetReason = "error_set_warp_invalid_characters";
|
conditionsNotMetReason = "error_set_warp_invalid_characters";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -215,12 +216,12 @@ public class SettingHandler {
|
|||||||
conditionsNotMetReason = "error_set_home_invalid_length";
|
conditionsNotMetReason = "error_set_home_invalid_length";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!homeName.matches("[A-Za-z0-9_\\-]+")) {
|
if (!RegexUtil.NAME_PATTERN.matcher(homeName).matches()) {
|
||||||
conditionsNotMetReason = "error_set_home_invalid_characters";
|
conditionsNotMetReason = "error_set_home_invalid_characters";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (HuskHomes.settings.doEconomy()) {
|
if (HuskHomes.getSettings().doEconomy()) {
|
||||||
double setHomeCost = HuskHomes.settings.getSetHomeCost();
|
double setHomeCost = HuskHomes.getSettings().getSetHomeCost();
|
||||||
if (setHomeCost > 0) {
|
if (setHomeCost > 0) {
|
||||||
int currentPlayerHomeSlots = DataManager.getPlayerHomeSlots(player);
|
int currentPlayerHomeSlots = DataManager.getPlayerHomeSlots(player);
|
||||||
if (currentHomeCount > (currentPlayerHomeSlots - 1)) {
|
if (currentHomeCount > (currentPlayerHomeSlots - 1)) {
|
||||||
|
|||||||
@@ -12,20 +12,21 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class TeleportManager {
|
public class TeleportManager {
|
||||||
|
|
||||||
public static HashSet<TimedTeleport> queuedTeleports = new HashSet<>();
|
private static Set<TimedTeleport> queuedTeleports = new HashSet<>();
|
||||||
|
|
||||||
public static TeleportationPoint spawnLocation = null;
|
private static TeleportationPoint spawnLocation;
|
||||||
|
|
||||||
public static void teleportPlayer(Player player, String targetPlayer) {
|
public static void teleportPlayer(Player player, String targetPlayer) {
|
||||||
DataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), HuskHomes.settings.getServerID()));
|
DataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), HuskHomes.getSettings().getServerID()));
|
||||||
setPlayerDestinationFromTargetPlayer(player, targetPlayer);
|
setPlayerDestinationFromTargetPlayer(player, targetPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleportPlayer(Player player, TeleportationPoint point) {
|
public static void teleportPlayer(Player player, TeleportationPoint point) {
|
||||||
DataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), HuskHomes.settings.getServerID()));
|
DataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), HuskHomes.getSettings().getServerID()));
|
||||||
DataManager.setPlayerDestinationLocation(player, point);
|
DataManager.setPlayerDestinationLocation(player, point);
|
||||||
teleportPlayer(player);
|
teleportPlayer(player);
|
||||||
}
|
}
|
||||||
@@ -34,13 +35,13 @@ public class TeleportManager {
|
|||||||
TeleportationPoint teleportationPoint = DataManager.getPlayerDestination(p);
|
TeleportationPoint teleportationPoint = DataManager.getPlayerDestination(p);
|
||||||
if (teleportationPoint != null) {
|
if (teleportationPoint != null) {
|
||||||
String server = teleportationPoint.getServer();
|
String server = teleportationPoint.getServer();
|
||||||
if (!HuskHomes.settings.doBungee() || server.equals(HuskHomes.settings.getServerID())) {
|
if (!HuskHomes.getSettings().doBungee() || server.equals(HuskHomes.getSettings().getServerID())) {
|
||||||
p.teleport(teleportationPoint.getLocation());
|
p.teleport(teleportationPoint.getLocation());
|
||||||
p.playSound(p.getLocation(), HuskHomes.settings.getTeleportationCompleteSound(), 1, 1);
|
p.playSound(p.getLocation(), HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1);
|
||||||
MessageManager.sendMessage(p, "teleporting_complete");
|
MessageManager.sendMessage(p, "teleporting_complete");
|
||||||
DataManager.setPlayerTeleporting(p, false);
|
DataManager.setPlayerTeleporting(p, false);
|
||||||
DataManager.clearPlayerDestination(p.getName());
|
DataManager.clearPlayerDestination(p.getName());
|
||||||
} else if (HuskHomes.settings.doBungee()) {
|
} else if (HuskHomes.getSettings().doBungee()) {
|
||||||
DataManager.setPlayerDestinationLocation(p, teleportationPoint);
|
DataManager.setPlayerDestinationLocation(p, teleportationPoint);
|
||||||
DataManager.setPlayerTeleporting(p, true);
|
DataManager.setPlayerTeleporting(p, true);
|
||||||
PluginMessageHandler.sendPlayer(p, server);
|
PluginMessageHandler.sendPlayer(p, server);
|
||||||
@@ -54,7 +55,7 @@ public class TeleportManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
queuedTeleports.add(new TimedTeleport(player, targetPlayer));
|
getQueuedTeleports().add(new TimedTeleport(player, targetPlayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queueTimedTeleport(Player player, TeleportationPoint point) {
|
public static void queueTimedTeleport(Player player, TeleportationPoint point) {
|
||||||
@@ -63,7 +64,7 @@ public class TeleportManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
queuedTeleports.add(new TimedTeleport(player, point));
|
getQueuedTeleports().add(new TimedTeleport(player, point));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queueRandomTeleport(Player player) {
|
public static void queueRandomTeleport(Player player) {
|
||||||
@@ -77,8 +78,8 @@ public class TeleportManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (HuskHomes.settings.doEconomy()) {
|
if (HuskHomes.getSettings().doEconomy()) {
|
||||||
double rtpCost = HuskHomes.settings.getRtpCost();
|
double rtpCost = HuskHomes.getSettings().getRtpCost();
|
||||||
if (rtpCost > 0) {
|
if (rtpCost > 0) {
|
||||||
if (!VaultIntegration.hasMoney(player, rtpCost)) {
|
if (!VaultIntegration.hasMoney(player, rtpCost)) {
|
||||||
MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(rtpCost));
|
MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(rtpCost));
|
||||||
@@ -87,8 +88,8 @@ public class TeleportManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.hasPermission("huskhomes.bypass_timer")) {
|
if (player.hasPermission("huskhomes.bypass_timer")) {
|
||||||
if (HuskHomes.settings.doEconomy()) {
|
if (HuskHomes.getSettings().doEconomy()) {
|
||||||
double rtpCost = HuskHomes.settings.getRtpCost();
|
double rtpCost = HuskHomes.getSettings().getRtpCost();
|
||||||
if (rtpCost > 0) {
|
if (rtpCost > 0) {
|
||||||
VaultIntegration.takeMoney(player, rtpCost);
|
VaultIntegration.takeMoney(player, rtpCost);
|
||||||
MessageManager.sendMessage(player, "rtp_spent_money", VaultIntegration.format(rtpCost));
|
MessageManager.sendMessage(player, "rtp_spent_money", VaultIntegration.format(rtpCost));
|
||||||
@@ -99,7 +100,7 @@ public class TeleportManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
queuedTeleports.add(new TimedTeleport(player));
|
getQueuedTeleports().add(new TimedTeleport(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleportHere(Player requester, String targetPlayerName) {
|
public static void teleportHere(Player requester, String targetPlayerName) {
|
||||||
@@ -111,7 +112,7 @@ public class TeleportManager {
|
|||||||
MessageManager.sendMessage(requester, "error_tp_self");
|
MessageManager.sendMessage(requester, "error_tp_self");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
teleportHereCrossServer(requester, targetPlayerName);
|
teleportHereCrossServer(requester, targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
MessageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
||||||
@@ -132,13 +133,13 @@ public class TeleportManager {
|
|||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
if (requester.getUniqueId() != targetPlayer.getUniqueId()) {
|
if (requester.getUniqueId() != targetPlayer.getUniqueId()) {
|
||||||
DataManager.setPlayerDestinationLocation(requester,
|
DataManager.setPlayerDestinationLocation(requester,
|
||||||
new TeleportationPoint(targetPlayer.getLocation(), HuskHomes.settings.getServerID()));
|
new TeleportationPoint(targetPlayer.getLocation(), HuskHomes.getSettings().getServerID()));
|
||||||
teleportPlayer(requester);
|
teleportPlayer(requester);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(requester, "error_tp_self");
|
MessageManager.sendMessage(requester, "error_tp_self");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
setTeleportationDestinationCrossServer(requester, targetPlayerName);
|
setTeleportationDestinationCrossServer(requester, targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
MessageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
||||||
@@ -146,4 +147,15 @@ public class TeleportManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<TimedTeleport> getQueuedTeleports() {
|
||||||
|
return queuedTeleports;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TeleportationPoint getSpawnLocation() {
|
||||||
|
return spawnLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSpawnLocation(TeleportationPoint spawnLocation) {
|
||||||
|
TeleportManager.spawnLocation = spawnLocation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ public class TeleportRequest {
|
|||||||
this.requestType = requestType.toLowerCase();
|
this.requestType = requestType.toLowerCase();
|
||||||
}
|
}
|
||||||
long currentUnixTime = Instant.now().getEpochSecond();
|
long currentUnixTime = Instant.now().getEpochSecond();
|
||||||
requestExpiryTime = currentUnixTime + HuskHomes.settings.getTeleportRequestExpiryTime();
|
requestExpiryTime = currentUnixTime + HuskHomes.getSettings().getTeleportRequestExpiryTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSenderName() {
|
public String getSenderName() {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class TeleportRequestHandler {
|
|||||||
MessageManager.sendMessage(requester, "error_tp_self");
|
MessageManager.sendMessage(requester, "error_tp_self");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpa");
|
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpa");
|
||||||
MessageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
MessageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
@@ -103,7 +103,7 @@ public class TeleportRequestHandler {
|
|||||||
MessageManager.sendMessage(requester, "error_tp_self");
|
MessageManager.sendMessage(requester, "error_tp_self");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpahere");
|
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpahere");
|
||||||
MessageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
MessageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
@@ -137,7 +137,7 @@ public class TeleportRequestHandler {
|
|||||||
MessageManager.sendMessage(requester, "tpa_has_declined", p.getName());
|
MessageManager.sendMessage(requester, "tpa_has_declined", p.getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HuskHomes.settings.doBungee()) {
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
MessageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
MessageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
||||||
|
|
||||||
@@ -166,27 +166,27 @@ public class TeleportRequestHandler {
|
|||||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||||
|
|
||||||
// Update active timed teleports
|
// Update active timed teleports
|
||||||
if (!TeleportManager.queuedTeleports.isEmpty()) {
|
if (!TeleportManager.getQueuedTeleports().isEmpty()) {
|
||||||
for (TimedTeleport timedTeleport : TeleportManager.queuedTeleports) {
|
for (TimedTeleport timedTeleport : TeleportManager.getQueuedTeleports()) {
|
||||||
Player teleporter = Bukkit.getPlayer(timedTeleport.getTeleporter().getUniqueId());
|
Player teleporter = Bukkit.getPlayer(timedTeleport.getTeleporter().getUniqueId());
|
||||||
if (teleporter != null) {
|
if (teleporter != null) {
|
||||||
if (timedTeleport.getTimeRemaining() > 0) {
|
if (timedTeleport.getTimeRemaining() > 0) {
|
||||||
if (!timedTeleport.hasMoved(teleporter)) {
|
if (!timedTeleport.hasMoved(teleporter)) {
|
||||||
if (!timedTeleport.hasLostHealth(teleporter)) {
|
if (!timedTeleport.hasLostHealth(teleporter)) {
|
||||||
teleporter.playSound(teleporter.getLocation(), HuskHomes.settings.getTeleportWarmupSound(), 2, 1);
|
teleporter.playSound(teleporter.getLocation(), HuskHomes.getSettings().getTeleportWarmupSound(), 2, 1);
|
||||||
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_countdown",
|
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_countdown",
|
||||||
Integer.toString(timedTeleport.getTimeRemaining()));
|
Integer.toString(timedTeleport.getTimeRemaining()));
|
||||||
timedTeleport.decrementTimeRemaining();
|
timedTeleport.decrementTimeRemaining();
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_cancelled");
|
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_cancelled");
|
||||||
MessageManager.sendMessage(teleporter, "teleporting_cancelled_damage");
|
MessageManager.sendMessage(teleporter, "teleporting_cancelled_damage");
|
||||||
teleporter.playSound(teleporter.getLocation(), HuskHomes.settings.getTeleportCancelledSound(), 1, 1);
|
teleporter.playSound(teleporter.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||||
completedTeleports.add(timedTeleport);
|
completedTeleports.add(timedTeleport);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_cancelled");
|
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_cancelled");
|
||||||
MessageManager.sendMessage(teleporter, "teleporting_cancelled_movement");
|
MessageManager.sendMessage(teleporter, "teleporting_cancelled_movement");
|
||||||
teleporter.playSound(teleporter.getLocation(), HuskHomes.settings.getTeleportCancelledSound(), 1, 1);
|
teleporter.playSound(teleporter.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||||
completedTeleports.add(timedTeleport);
|
completedTeleports.add(timedTeleport);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -200,8 +200,8 @@ public class TeleportRequestHandler {
|
|||||||
TeleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPlayerName());
|
TeleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPlayerName());
|
||||||
break;
|
break;
|
||||||
case "random":
|
case "random":
|
||||||
if (HuskHomes.settings.doEconomy()) {
|
if (HuskHomes.getSettings().doEconomy()) {
|
||||||
double rtpCost = HuskHomes.settings.getRtpCost();
|
double rtpCost = HuskHomes.getSettings().getRtpCost();
|
||||||
if (rtpCost > 0) {
|
if (rtpCost > 0) {
|
||||||
if (!VaultIntegration.takeMoney(teleporter, rtpCost)) {
|
if (!VaultIntegration.takeMoney(teleporter, rtpCost)) {
|
||||||
MessageManager.sendMessage(teleporter, "error_insufficient_funds", VaultIntegration.format(rtpCost));
|
MessageManager.sendMessage(teleporter, "error_insufficient_funds", VaultIntegration.format(rtpCost));
|
||||||
@@ -226,7 +226,7 @@ public class TeleportRequestHandler {
|
|||||||
// Clear completed teleports
|
// Clear completed teleports
|
||||||
if (!completedTeleports.isEmpty()) {
|
if (!completedTeleports.isEmpty()) {
|
||||||
for (TimedTeleport timedTeleport : completedTeleports) {
|
for (TimedTeleport timedTeleport : completedTeleports) {
|
||||||
TeleportManager.queuedTeleports.remove(timedTeleport);
|
TeleportManager.getQueuedTeleports().remove(timedTeleport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
completedTeleports.clear();
|
completedTeleports.clear();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class TimedTeleport {
|
|||||||
private double initialTeleporterHealth;
|
private double initialTeleporterHealth;
|
||||||
|
|
||||||
private int timeRemaining;
|
private int timeRemaining;
|
||||||
private final int warmupTime = HuskHomes.settings.getTeleportWarmupTime();
|
private final int warmupTime = HuskHomes.getSettings().getTeleportWarmupTime();
|
||||||
|
|
||||||
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint) {
|
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint) {
|
||||||
this.teleporter = teleporter;
|
this.teleporter = teleporter;
|
||||||
|
|||||||
@@ -151,11 +151,11 @@ public class Home extends TeleportationPoint {
|
|||||||
try {
|
try {
|
||||||
return Integer.parseInt(permission.split("\\.")[2]);
|
return Integer.parseInt(permission.split("\\.")[2]);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
return HuskHomes.settings.getMaximumHomes();
|
return HuskHomes.getSettings().getMaximumHomes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HuskHomes.settings.getMaximumHomes();
|
return HuskHomes.getSettings().getMaximumHomes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of set homes a player can set for free
|
// Returns the number of set homes a player can set for free
|
||||||
@@ -166,10 +166,10 @@ public class Home extends TeleportationPoint {
|
|||||||
try {
|
try {
|
||||||
return Integer.parseInt(permission.split("\\.")[2]);
|
return Integer.parseInt(permission.split("\\.")[2]);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
return HuskHomes.settings.getFreeHomeSlots();
|
return HuskHomes.getSettings().getFreeHomeSlots();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HuskHomes.settings.getFreeHomeSlots();
|
return HuskHomes.getSettings().getFreeHomeSlots();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,10 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
private static final int MAX_RANDOM_ATTEMPTS = 8;
|
private static final int MAX_RANDOM_ATTEMPTS = 8;
|
||||||
|
|
||||||
public RandomPoint(Player player) {
|
public RandomPoint(Player player) {
|
||||||
super(player.getLocation(), HuskHomes.settings.getServerID());
|
super(player.getLocation(), HuskHomes.getSettings().getServerID());
|
||||||
Location randomLocation = getRandomLocation(player.getWorld());
|
Location randomLocation = getRandomLocation(player.getWorld());
|
||||||
if (randomLocation != null) {
|
if (randomLocation != null) {
|
||||||
setLocation(randomLocation, HuskHomes.settings.getServerID());
|
setLocation(randomLocation, HuskHomes.getSettings().getServerID());
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(player, "error_rtp_randomization_timeout");
|
MessageManager.sendMessage(player, "error_rtp_randomization_timeout");
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
double blockCenterZ = 0.5;
|
double blockCenterZ = 0.5;
|
||||||
|
|
||||||
// The furthest distance at which a player can be teleported to
|
// The furthest distance at which a player can be teleported to
|
||||||
int rtpRange = HuskHomes.settings.getRtpRange();
|
int rtpRange = HuskHomes.getSettings().getRtpRange();
|
||||||
|
|
||||||
// Calculate random X and Z coords
|
// Calculate random X and Z coords
|
||||||
x = random.nextInt(rtpRange);
|
x = random.nextInt(rtpRange);
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package me.william278.huskhomes2.utils;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public final class RegexUtil {
|
||||||
|
|
||||||
|
public static final Pattern DESCRIPTION_PATTERN = Pattern.compile("[a-zA-Z0-9\\d\\-_\\s]+");
|
||||||
|
public static final Pattern NAME_PATTERN = Pattern.compile("[A-Za-z0-9_\\-]+");
|
||||||
|
public static final Pattern OWNER_NAME_PATTERN = Pattern.compile("[A-Za-z0-9_]\\.[A-Za-z0-9_\\-]");
|
||||||
|
|
||||||
|
private RegexUtil() {
|
||||||
|
// No object for you
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
|
# ------------------------------
|
||||||
|
# | HuskHomes Config |
|
||||||
|
# | Developed by William278 |
|
||||||
|
# ------------------------------
|
||||||
|
# Configuration guide: https://github.com/WiIIiam278/HuskHomes2/wiki
|
||||||
|
|
||||||
language: 'en-gb'
|
language: 'en-gb'
|
||||||
check_for_updates: true
|
check_for_updates: true
|
||||||
data_storage_options:
|
data_storage_options:
|
||||||
|
|||||||
Reference in new issue
Block a user