mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Encapsulate some more variables
Refactor Settings class a bit and move header straight to the file
This commit is contained in:
30 files changed
+248
-255
No files matched your search
@@ -61,7 +61,7 @@ public class EditingHandler {
|
||||
Integer.toString((int) home.getY()),
|
||||
Integer.toString((int) home.getZ()));
|
||||
MessageManager.sendMessage(p, "edit_world", home.getWorldName());
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
MessageManager.sendMessage(p, "edit_server", home.getServer());
|
||||
}
|
||||
if (!home.isPublic()) {
|
||||
@@ -83,7 +83,7 @@ public class EditingHandler {
|
||||
Integer.toString((int) warp.getY()),
|
||||
Integer.toString((int) warp.getZ()));
|
||||
MessageManager.sendMessage(p, "edit_world", warp.getWorldName());
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
MessageManager.sendMessage(p, "edit_server", warp.getServer());
|
||||
}
|
||||
p.sendMessage("");
|
||||
|
||||
@@ -25,7 +25,6 @@ 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.ConfigManager;
|
||||
import me.william278.huskhomes2.config.Settings;
|
||||
import me.william278.huskhomes2.data.DataManager;
|
||||
import me.william278.huskhomes2.integrations.DynMapIntegration;
|
||||
@@ -48,11 +47,17 @@ public final class HuskHomes extends JavaPlugin {
|
||||
|
||||
private static HuskHomes instance;
|
||||
|
||||
// TODO Remove
|
||||
public static HuskHomes getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static Settings settings;
|
||||
private static Settings settings;
|
||||
|
||||
// TODO Remove
|
||||
public static Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HuskHomes API
|
||||
@@ -118,13 +123,15 @@ public final class HuskHomes extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// TODO Remove
|
||||
// Set instance for easy cross-class referencing
|
||||
instance = this;
|
||||
settings = new Settings(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
public void onEnable() { //nb=
|
||||
saveDefaultConfig();
|
||||
|
||||
// Plugin startup logic
|
||||
getLogger().info("Enabling HuskHomes version " + this.getDescription().getVersion());
|
||||
|
||||
@@ -132,18 +139,18 @@ public final class HuskHomes extends JavaPlugin {
|
||||
LegacyMigrator.checkStartupMigration();
|
||||
|
||||
// Load the config
|
||||
ConfigManager.loadConfig();
|
||||
settings.reload();
|
||||
|
||||
// MIGRATION: Migrate config files
|
||||
if (LegacyMigrator.startupMigrate) {
|
||||
if (LegacyMigrator.isCanMigrate()) {
|
||||
new LegacyMigrator().migrateConfig();
|
||||
}
|
||||
|
||||
// Load the messages (in the right language)
|
||||
MessageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||
MessageManager.loadMessages(HuskHomes.getSettings().getLanguage());
|
||||
|
||||
// Check for updates (if enabled)
|
||||
if (HuskHomes.settings.doUpdateChecks()) {
|
||||
if (HuskHomes.getSettings().doUpdateChecks()) {
|
||||
getLogger().info(getVersionCheckString());
|
||||
}
|
||||
|
||||
@@ -154,23 +161,23 @@ public final class HuskHomes extends JavaPlugin {
|
||||
DataManager.setupStorage();
|
||||
|
||||
// MIGRATION: Migrate SQL data
|
||||
if (LegacyMigrator.startupMigrate) {
|
||||
if (LegacyMigrator.isCanMigrate()) {
|
||||
new LegacyMigrator().migratePlayerData();
|
||||
new LegacyMigrator().migrateHomeData();
|
||||
}
|
||||
|
||||
// Setup the Dynmap integration if it is enabled
|
||||
if (HuskHomes.settings.doDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap()) {
|
||||
DynMapIntegration.initializeDynmap();
|
||||
}
|
||||
|
||||
// Setup economy if it is enabled
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
VaultIntegration.initializeEconomy();
|
||||
}
|
||||
|
||||
// Set up bungee channels if bungee mode is enabled
|
||||
if (settings.doBungee()) {
|
||||
if (getSettings().doBungee()) {
|
||||
setupBungeeChannels();
|
||||
}
|
||||
|
||||
@@ -208,5 +215,4 @@ public final class HuskHomes extends JavaPlugin {
|
||||
return "Error retrieving version information!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class PluginMessageHandler implements PluginMessageListener {
|
||||
// Send a plugin message
|
||||
public static void sendPluginMessage(Player sender, String targetPlayerName, String messageType, String messageData) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
int clusterID = HuskHomes.settings.getServerClusterID();
|
||||
int clusterID = HuskHomes.getSettings().getServerClusterID();
|
||||
|
||||
// Send a plugin message to the specified player name
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
if (HuskHomes.settings.getServerClusterID() != clusterID) {
|
||||
if (HuskHomes.getSettings().getServerClusterID() != clusterID) {
|
||||
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
|
||||
public void setTeleportDestination(String requesterName, Player recipient) {
|
||||
DataManager.setPlayerDestinationLocation(requesterName,
|
||||
new TeleportationPoint(recipient.getLocation(), HuskHomes.settings.getServerID()));
|
||||
new TeleportationPoint(recipient.getLocation(), HuskHomes.getSettings().getServerID()));
|
||||
}
|
||||
}
|
||||
@@ -36,11 +36,11 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
switch (args[1]) {
|
||||
case "location":
|
||||
Location newLocation = p.getLocation();
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID());
|
||||
|
||||
// Remove old marker if on dynmap
|
||||
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.removeDynamicMapMarker(homeName, p.getName());
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
MessageManager.sendMessage(p, "edit_home_update_location", homeName);
|
||||
|
||||
// Add new updated marker if using dynmap
|
||||
locationMovedHome.setLocation(newLocation, HuskHomes.settings.getServerID());
|
||||
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
locationMovedHome.setLocation(newLocation, HuskHomes.getSettings().getServerID());
|
||||
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(locationMovedHome);
|
||||
}
|
||||
return true;
|
||||
@@ -85,7 +85,7 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
}
|
||||
|
||||
// Remove old marker if on the Dynmap
|
||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
|
||||
// Add new marker if using Dynmap
|
||||
descriptionChangedHome.setDescription(newDescriptionString);
|
||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(descriptionChangedHome);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
return true;
|
||||
}
|
||||
if (renamedHome.isPublic()) {
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||
}
|
||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||
@@ -135,7 +135,7 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||
}
|
||||
renamedHome.setName(newName);
|
||||
if (renamedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
if (renamedHome.isPublic() && HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(renamedHome);
|
||||
}
|
||||
HomeCommand.Tab.updatePlayerHomeCache(p);
|
||||
@@ -147,8 +147,8 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
case "public":
|
||||
Home privateHome = DataManager.getHome(p.getName(), homeName);
|
||||
if (!privateHome.isPublic()) {
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double publicHomeCost = HuskHomes.settings.getPublicHomeCost();
|
||||
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));
|
||||
@@ -169,7 +169,7 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
}
|
||||
DataManager.updateHomePrivacy(p.getName(), homeName, true);
|
||||
PublichomeCommand.updatePublicHomeTabCache();
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(privateHome);
|
||||
}
|
||||
} else {
|
||||
@@ -186,7 +186,7 @@ public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
}
|
||||
DataManager.updateHomePrivacy(p.getName(), homeName, false);
|
||||
MessageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
|
||||
}
|
||||
PublichomeCommand.updatePublicHomeTabCache();
|
||||
|
||||
@@ -33,11 +33,11 @@ public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||
switch (args[1]) {
|
||||
case "location":
|
||||
Location newLocation = p.getLocation();
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID());
|
||||
|
||||
// Remove old marker if on the Dynmap
|
||||
Warp locationMovedWarp = DataManager.getWarp(warpName);
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||
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()) {
|
||||
locationMovedWarp.setLocation(newLocation, HuskHomes.getSettings().getServerID());
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(locationMovedWarp);
|
||||
}
|
||||
return true;
|
||||
@@ -83,7 +83,7 @@ public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||
DataManager.updateWarpDescription(warpName, newDescriptionString);
|
||||
|
||||
descriptionChangedWarp.setDescription(newDescriptionString);
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(descriptionChangedWarp);
|
||||
}
|
||||
|
||||
@@ -123,13 +123,13 @@ public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||
}
|
||||
DataManager.updateWarpName(warpName, newName);
|
||||
|
||||
renamedWarp.setName(newName);
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(renamedWarp);
|
||||
}
|
||||
WarpCommand.Tab.updateWarpsTabCache();
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.william278.huskhomes2.commands;
|
||||
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.config.ConfigManager;
|
||||
import me.william278.huskhomes2.migrators.EssentialsMigrator;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@@ -68,17 +67,16 @@ public class HuskhomesCommand extends CommandBase implements TabCompleter {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission("huskhomes.reload")) {
|
||||
plugin.reloadConfig();
|
||||
ConfigManager.loadConfig();
|
||||
MessageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||
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 {
|
||||
ConfigManager.loadConfig();
|
||||
MessageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||
HuskHomes.getSettings().reload();
|
||||
MessageManager.loadMessages(HuskHomes.getSettings().getLanguage());
|
||||
plugin.getLogger().info("Reloaded config and message files.");
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class RtpCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doRtpCommand()) {
|
||||
if (HuskHomes.getSettings().doRtpCommand()) {
|
||||
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
||||
TeleportManager.queueRandomTeleport(p);
|
||||
} else {
|
||||
|
||||
@@ -10,7 +10,7 @@ public class SetspawnCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doSpawnCommand()) {
|
||||
if (HuskHomes.getSettings().doSpawnCommand()) {
|
||||
SettingHandler.setSpawnLocation(p.getLocation());
|
||||
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
||||
MessageManager.sendMessage(p, "set_spawn_success");
|
||||
|
||||
@@ -10,7 +10,7 @@ public class SpawnCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doSpawnCommand()) {
|
||||
if (HuskHomes.getSettings().doSpawnCommand()) {
|
||||
if (TeleportManager.spawnLocation != null) {
|
||||
TeleportManager.queueTimedTeleport(p, TeleportManager.spawnLocation);
|
||||
} else {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TpCommand extends CommandBase {
|
||||
double x = Double.parseDouble(args[0]);
|
||||
double y = Double.parseDouble(args[1]);
|
||||
double z = Double.parseDouble(args[2]);
|
||||
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
||||
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]");
|
||||
@@ -47,14 +47,14 @@ public class TpCommand extends CommandBase {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||
return true;
|
||||
}
|
||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, 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 true;
|
||||
case 5:
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
try {
|
||||
double x = Double.parseDouble(args[0]);
|
||||
double y = Double.parseDouble(args[1]);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class WarpCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doWarpCommand()) {
|
||||
if (HuskHomes.getSettings().doWarpCommand()) {
|
||||
if (args.length == 1) {
|
||||
String warpName = args[0];
|
||||
if (DataManager.warpExists(warpName)) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
// Message language setting
|
||||
private String language;
|
||||
|
||||
@@ -77,21 +79,31 @@ public class Settings {
|
||||
private boolean doSpawnCommand;
|
||||
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 {
|
||||
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.server = configFile.getString("bungee_options.server_id");
|
||||
this.clusterID = configFile.getInt("bungee_options.cluster_id");
|
||||
this.doBungee = config.getBoolean("bungee_options.enable_bungee_mode");
|
||||
this.server = config.getString("bungee_options.server_id");
|
||||
this.clusterID = config.getInt("bungee_options.cluster_id");
|
||||
|
||||
this.storageType = configFile.getString("data_storage_options.storage_type");
|
||||
this.playerDataTable = configFile.getString("data_storage_options.table_names.player_data");
|
||||
this.locationsDataTable = configFile.getString("data_storage_options.table_names.locations_data");
|
||||
this.homesDataTable = configFile.getString("data_storage_options.table_names.homes_data");
|
||||
this.warpsDataTable = configFile.getString("data_storage_options.table_names.warps_data");
|
||||
this.storageType = config.getString("data_storage_options.storage_type");
|
||||
this.playerDataTable = config.getString("data_storage_options.table_names.player_data");
|
||||
this.locationsDataTable = config.getString("data_storage_options.table_names.locations_data");
|
||||
this.homesDataTable = config.getString("data_storage_options.table_names.homes_data");
|
||||
this.warpsDataTable = config.getString("data_storage_options.table_names.warps_data");
|
||||
|
||||
// Resolve conflict between storage type and bungee mode
|
||||
if (storageType.equalsIgnoreCase("sqlite") && doBungee) {
|
||||
@@ -101,13 +113,13 @@ public class Settings {
|
||||
this.doBungee = false;
|
||||
}
|
||||
|
||||
this.mySQLhost = configFile.getString("data_storage_options.mysql_credentials.host");
|
||||
this.mySQLdatabase = configFile.getString("data_storage_options.mysql_credentials.database");
|
||||
this.mySQLusername = configFile.getString("data_storage_options.mysql_credentials.username");
|
||||
this.mySQLpassword = configFile.getString("data_storage_options.mysql_credentials.password");
|
||||
this.mySQLport = configFile.getInt("data_storage_options.mysql_credentials.port");
|
||||
this.mySQLhost = config.getString("data_storage_options.mysql_credentials.host");
|
||||
this.mySQLdatabase = config.getString("data_storage_options.mysql_credentials.database");
|
||||
this.mySQLusername = config.getString("data_storage_options.mysql_credentials.username");
|
||||
this.mySQLpassword = config.getString("data_storage_options.mysql_credentials.password");
|
||||
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) {
|
||||
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||
@@ -119,14 +131,14 @@ public class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
this.dynmapPublicHomes = configFile.getBoolean("dynmap_integration.markers.public_homes.show");
|
||||
this.dynmapWarps = configFile.getBoolean("dynmap_integration.markers.warps.show");
|
||||
this.dynmapPublicHomeMarkerIconID = configFile.getString("dynmap_integration.markers.public_homes.icon_id");
|
||||
this.dynmapWarpMarkerIconID = configFile.getString("dynmap_integration.markers.warps.icon_id");
|
||||
this.dynmapPublicHomeMarkerSet = configFile.getString("dynmap_integration.markers.public_homes.set_name");
|
||||
this.dynmapWarpMarkerSet = configFile.getString("dynmap_integration.markers.warps.set_name");
|
||||
this.dynmapPublicHomes = config.getBoolean("dynmap_integration.markers.public_homes.show");
|
||||
this.dynmapWarps = config.getBoolean("dynmap_integration.markers.warps.show");
|
||||
this.dynmapPublicHomeMarkerIconID = config.getString("dynmap_integration.markers.public_homes.icon_id");
|
||||
this.dynmapWarpMarkerIconID = config.getString("dynmap_integration.markers.warps.icon_id");
|
||||
this.dynmapPublicHomeMarkerSet = config.getString("dynmap_integration.markers.public_homes.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) {
|
||||
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||
@@ -138,16 +150,16 @@ public class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
this.freeHomeSlots = configFile.getInt("economy_integration.free_home_slots");
|
||||
this.setHomeCost = configFile.getDouble("economy_integration.costs.additional_home_slot");
|
||||
this.publicHomeCost = configFile.getDouble("economy_integration.costs.make_home_public");
|
||||
this.rtpCost = configFile.getDouble("economy_integration.costs.random_teleport");
|
||||
this.freeHomeSlots = config.getInt("economy_integration.free_home_slots");
|
||||
this.setHomeCost = config.getDouble("economy_integration.costs.additional_home_slot");
|
||||
this.publicHomeCost = config.getDouble("economy_integration.costs.make_home_public");
|
||||
this.rtpCost = config.getDouble("economy_integration.costs.random_teleport");
|
||||
|
||||
// Retrieve sounds used in plugin; if invalid, use defaults.
|
||||
try {
|
||||
this.teleportationCompleteSound = Sound.valueOf(configFile.getString("general.sounds.teleportation_complete"));
|
||||
this.teleportWarmupSound = Sound.valueOf(configFile.getString("general.sounds.teleportation_warmup"));
|
||||
this.teleportCancelledSound = Sound.valueOf(configFile.getString("general.sounds.teleportation_cancelled"));
|
||||
this.teleportationCompleteSound = Sound.valueOf(config.getString("general.sounds.teleportation_complete"));
|
||||
this.teleportWarmupSound = Sound.valueOf(config.getString("general.sounds.teleportation_warmup"));
|
||||
this.teleportCancelledSound = Sound.valueOf(config.getString("general.sounds.teleportation_cancelled"));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
Bukkit.getLogger().severe("Invalid sound specified in config.yml; using default sounds instead.");
|
||||
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.doWarpCommand = configFile.getBoolean("enable_warp_command");
|
||||
this.doSpawnCommand = config.getBoolean("spawn_command.enabled");
|
||||
this.doWarpCommand = config.getBoolean("enable_warp_command");
|
||||
|
||||
this.doRtpCommand = configFile.getBoolean("random_teleport_command.enabled");
|
||||
this.rtpRange = configFile.getInt("random_teleport_command.range");
|
||||
this.rtpCooldown = configFile.getInt("random_teleport_command.cooldown");
|
||||
this.doRtpCommand = config.getBoolean("random_teleport_command.enabled");
|
||||
this.rtpRange = config.getInt("random_teleport_command.range");
|
||||
this.rtpCooldown = config.getInt("random_teleport_command.cooldown");
|
||||
|
||||
this.privateHomesPerPage = configFile.getInt("general.lists.private_homes_per_page");
|
||||
this.publicHomesPerPage = configFile.getInt("general.lists.public_homes_per_page");
|
||||
this.warpsPerPage = configFile.getInt("general.lists.warps_per_page");
|
||||
this.privateHomesPerPage = config.getInt("general.lists.private_homes_per_page");
|
||||
this.publicHomesPerPage = config.getInt("general.lists.public_homes_per_page");
|
||||
this.warpsPerPage = config.getInt("general.lists.warps_per_page");
|
||||
|
||||
this.maximumHomes = configFile.getInt("general.max_sethomes");
|
||||
this.teleportRequestExpiryTime = configFile.getInt("general.teleport_request_expiry_time");
|
||||
this.teleportWarmupTime = configFile.getInt("general.teleport_warmup_time");
|
||||
this.maximumHomes = config.getInt("general.max_sethomes");
|
||||
this.teleportRequestExpiryTime = config.getInt("general.teleport_request_expiry_time");
|
||||
this.teleportWarmupTime = config.getInt("general.teleport_warmup_time");
|
||||
|
||||
} catch (Exception e) {
|
||||
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() {
|
||||
return dynmapPublicHomes;
|
||||
}
|
||||
|
||||
@@ -26,23 +26,23 @@ public class DataManager {
|
||||
|
||||
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," +
|
||||
"`location_id` integer NOT NULL," +
|
||||
"`name` varchar(16) NOT NULL," +
|
||||
"`description` varchar(255) NOT NULL," +
|
||||
"`public` boolean NOT NULL," +
|
||||
"PRIMARY KEY (`player_id`, `name`)," +
|
||||
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.settings.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 (`player_id`) REFERENCES " + HuskHomes.getSettings().getPlayerDataTable() + " (`player_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," +
|
||||
"`name` varchar(16) NOT NULL UNIQUE," +
|
||||
"`description` varchar(255) NOT NULL," +
|
||||
"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();
|
||||
@@ -66,7 +66,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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());
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -92,7 +92,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -118,7 +118,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -155,7 +155,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -183,7 +183,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -251,7 +251,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -286,7 +286,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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();
|
||||
if (rs != null) {
|
||||
List<Home> publicHomes = new ArrayList<>();
|
||||
@@ -317,7 +317,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + ";");
|
||||
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getWarpsDataTable() + ";");
|
||||
rs = ps.executeQuery();
|
||||
List<Warp> warps = new ArrayList<>();
|
||||
if (rs != null) {
|
||||
@@ -348,7 +348,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -382,7 +382,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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.setString(2, homeName);
|
||||
rs = ps.executeQuery();
|
||||
@@ -420,7 +420,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -467,7 +467,7 @@ public class DataManager {
|
||||
public static void updateHomeLocation(String ownerName, String homeName, Location newLocation) {
|
||||
Integer playerID = getPlayerId(ownerName);
|
||||
updateHomeTeleportLocation(playerID,homeName,
|
||||
new TeleportationPoint(newLocation, HuskHomes.settings.getServerID()));
|
||||
new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID()));
|
||||
}
|
||||
|
||||
public static void updateWarpName(String warpName, String newName) {
|
||||
@@ -480,7 +480,7 @@ public class DataManager {
|
||||
|
||||
public static void updateWarpLocation(String warpName, Location newLocation) {
|
||||
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
|
||||
@@ -492,7 +492,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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.setString(2, homeName);
|
||||
rs = ps.executeQuery();
|
||||
@@ -529,7 +529,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -561,7 +561,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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.setString(2, homeName);
|
||||
rs = ps.executeQuery();
|
||||
@@ -589,7 +589,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs != null) {
|
||||
@@ -611,7 +611,7 @@ public class DataManager {
|
||||
|
||||
try {
|
||||
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);
|
||||
rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
@@ -622,7 +622,7 @@ public class DataManager {
|
||||
} else {
|
||||
Bukkit.getLogger().severe("An SQL exception occurred in retrieving a teleportation location.");
|
||||
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;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
@@ -697,7 +697,7 @@ public class DataManager {
|
||||
Integer playerID = getPlayerId(p.getUniqueId());
|
||||
if (playerID != null) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -754,8 +754,8 @@ public class DataManager {
|
||||
}
|
||||
|
||||
public static void setupStorage() {
|
||||
if (HuskHomes.settings.getStorageType().equalsIgnoreCase("mysql")) {
|
||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getPlayerDataTable() + " (" +
|
||||
if (HuskHomes.getSettings().getStorageType().equalsIgnoreCase("mysql")) {
|
||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getPlayerDataTable() + " (" +
|
||||
"`player_id` integer AUTO_INCREMENT," +
|
||||
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
||||
"`username` varchar(16) NOT NULL," +
|
||||
@@ -766,10 +766,10 @@ public class DataManager {
|
||||
"`last_location_id` integer NULL," +
|
||||
|
||||
"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 (`last_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.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," +
|
||||
"`server` text NOT NULL," +
|
||||
"`world` text NOT NULL," +
|
||||
@@ -782,7 +782,7 @@ public class DataManager {
|
||||
"PRIMARY KEY (`location_id`)" +
|
||||
");";
|
||||
} else {
|
||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getPlayerDataTable() + " (" +
|
||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.getSettings().getPlayerDataTable() + " (" +
|
||||
"`player_id` integer NOT NULL," +
|
||||
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
||||
"`username` varchar(16) NOT NULL," +
|
||||
@@ -792,10 +792,10 @@ public class DataManager {
|
||||
"`dest_location_id` integer NULL," +
|
||||
"`last_location_id` integer NULL," +
|
||||
"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 (`last_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.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," +
|
||||
"`server` text NOT NULL," +
|
||||
"`world` text NOT NULL," +
|
||||
|
||||
@@ -15,8 +15,8 @@ import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class Database {
|
||||
HuskHomes plugin;
|
||||
Connection connection;
|
||||
protected HuskHomes plugin;
|
||||
private Connection connection;
|
||||
|
||||
public Database(HuskHomes instance) {
|
||||
plugin = instance;
|
||||
@@ -29,7 +29,7 @@ public abstract class Database {
|
||||
public void initialize() {
|
||||
connection = getSQLConnection();
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + ";");
|
||||
PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + ";");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
close(ps, rs);
|
||||
|
||||
@@ -41,7 +41,7 @@ public abstract class Database {
|
||||
// Insert a teleportation point, returns generated id
|
||||
public Integer addTeleportationPoint(TeleportationPoint point, Connection conn) {
|
||||
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(2, point.getServer());
|
||||
@@ -72,7 +72,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
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(2, locationID);
|
||||
ps.setString(3, home.getName());
|
||||
@@ -96,7 +96,7 @@ public abstract class Database {
|
||||
Integer locationID = addTeleportationPoint(warp, conn);
|
||||
|
||||
// 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.setString(2, warp.getName());
|
||||
ps.setString(3, warp.getDescription());
|
||||
@@ -115,7 +115,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
|
||||
// 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.executeUpdate();
|
||||
|
||||
@@ -133,7 +133,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
|
||||
// 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.setInt(2, playerID);
|
||||
ps.executeUpdate();
|
||||
@@ -151,7 +151,7 @@ public abstract class Database {
|
||||
try {
|
||||
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(2, p.getName());
|
||||
ps.setInt(3, Home.getFreeHomes(p));
|
||||
@@ -172,10 +172,10 @@ public abstract class Database {
|
||||
try {
|
||||
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(2, playerName);
|
||||
ps.setInt(3, HuskHomes.settings.getFreeHomeSlots());
|
||||
ps.setInt(3, HuskHomes.getSettings().getFreeHomeSlots());
|
||||
ps.setInt(4, 0);
|
||||
ps.setBoolean(5, false);
|
||||
|
||||
@@ -193,7 +193,7 @@ public abstract class Database {
|
||||
try {
|
||||
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(2, playerName);
|
||||
ps.setInt(3, homeSlots);
|
||||
@@ -212,7 +212,7 @@ public abstract class Database {
|
||||
|
||||
try {
|
||||
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.setInt(2, playerID);
|
||||
ps.executeUpdate();
|
||||
@@ -227,7 +227,7 @@ public abstract class Database {
|
||||
|
||||
try {
|
||||
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.setInt(2, playerID);
|
||||
ps.executeUpdate();
|
||||
@@ -242,7 +242,7 @@ public abstract class Database {
|
||||
|
||||
try {
|
||||
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(2, playerID);
|
||||
ps.executeUpdate();
|
||||
@@ -257,7 +257,7 @@ public abstract class Database {
|
||||
|
||||
try {
|
||||
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(2, playerID);
|
||||
ps.executeUpdate();
|
||||
@@ -274,7 +274,7 @@ public abstract class Database {
|
||||
try {
|
||||
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.executeUpdate();
|
||||
@@ -292,7 +292,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
|
||||
// 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.setString(2, homeName);
|
||||
ps.setInt(3, ownerID);
|
||||
@@ -314,7 +314,7 @@ public abstract class Database {
|
||||
Integer locationID = addTeleportationPoint(point, conn);
|
||||
|
||||
// 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.setString(2, homeName);
|
||||
ps.setInt(3, ownerID);
|
||||
@@ -336,7 +336,7 @@ public abstract class Database {
|
||||
Integer locationID = addTeleportationPoint(point, conn);
|
||||
|
||||
// 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.setString(2, warpName);
|
||||
ps.executeUpdate();
|
||||
@@ -353,7 +353,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
|
||||
// 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(2, homeName);
|
||||
ps.setInt(3, ownerID);
|
||||
@@ -372,7 +372,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
|
||||
// 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(2, warpName);
|
||||
ps.executeUpdate();
|
||||
@@ -390,7 +390,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
|
||||
// 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(2, oldHomeName);
|
||||
ps.setInt(3, ownerID);
|
||||
@@ -410,7 +410,7 @@ public abstract class Database {
|
||||
conn = getSQLConnection();
|
||||
|
||||
// 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(2, oldWarpName);
|
||||
|
||||
@@ -432,7 +432,7 @@ public abstract class Database {
|
||||
Integer locationID = addTeleportationPoint(point, conn);
|
||||
|
||||
// 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(2, playerID);
|
||||
ps.executeUpdate();
|
||||
@@ -453,7 +453,7 @@ public abstract class Database {
|
||||
Integer locationID = addTeleportationPoint(point, conn);
|
||||
|
||||
// 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(2, playerID);
|
||||
ps.executeUpdate();
|
||||
@@ -470,7 +470,7 @@ public abstract class Database {
|
||||
|
||||
try {
|
||||
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.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
@@ -485,7 +485,7 @@ public abstract class Database {
|
||||
|
||||
try {
|
||||
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.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
|
||||
@@ -26,11 +26,11 @@ public class SQL extends Database {
|
||||
|
||||
// Initialise connection via mySQL
|
||||
private void getMySQLConnection() {
|
||||
String host = HuskHomes.settings.getMySQLhost();
|
||||
int port = HuskHomes.settings.getMySQLport();
|
||||
String database = HuskHomes.settings.getMySQLdatabase();
|
||||
String username = HuskHomes.settings.getMySQLusername();
|
||||
String password = HuskHomes.settings.getMySQLpassword();
|
||||
String host = HuskHomes.getSettings().getMySQLhost();
|
||||
int port = HuskHomes.getSettings().getMySQLport();
|
||||
String database = HuskHomes.getSettings().getMySQLdatabase();
|
||||
String username = HuskHomes.getSettings().getMySQLusername();
|
||||
String password = HuskHomes.getSettings().getMySQLpassword();
|
||||
|
||||
try {
|
||||
synchronized (HuskHomes.getInstance()) {
|
||||
@@ -70,7 +70,7 @@ public class SQL extends Database {
|
||||
public Connection getSQLConnection() {
|
||||
try {
|
||||
if (connection == null || connection.isClosed()) {
|
||||
String dataStorageType = HuskHomes.settings.getStorageType().toLowerCase();
|
||||
String dataStorageType = HuskHomes.getSettings().getStorageType().toLowerCase();
|
||||
switch (dataStorageType) {
|
||||
case "mysql":
|
||||
getMySQLConnection();
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DynMapIntegration {
|
||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||
|
||||
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>";
|
||||
warpPopup = warpPopup.replace("%WARP_NAME%", escapeHtml(warp.getName()));
|
||||
warpPopup = warpPopup.replace("%DESCRIPTION%", escapeHtml(warp.getDescription()));
|
||||
@@ -63,7 +63,7 @@ public class DynMapIntegration {
|
||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||
|
||||
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>";
|
||||
publicHomePopup = publicHomePopup.replace("%HOME_NAME%", escapeHtml(home.getName()));
|
||||
publicHomePopup = publicHomePopup.replace("%OWNER%", escapeHtml(home.getOwnerUsername()));
|
||||
@@ -79,18 +79,18 @@ public class DynMapIntegration {
|
||||
dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
|
||||
|
||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||
if (HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.public_homes", HuskHomes.settings.getDynmapPublicHomeMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||
if (HuskHomes.getSettings().showPublicHomesOnDynmap()) {
|
||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.public_homes", HuskHomes.getSettings().getDynmapPublicHomeMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.warps", HuskHomes.settings.getDynmapWarpMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||
if (HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.warps", HuskHomes.getSettings().getDynmapWarpMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.metadata.MetadataValue;
|
||||
public class VanishChecker {
|
||||
|
||||
public static boolean isVanished(Player player) {
|
||||
if (HuskHomes.settings.isCheckVanishedPlayers()) {
|
||||
if (HuskHomes.getSettings().isCheckVanishedPlayers()) {
|
||||
for (MetadataValue meta : player.getMetadata("vanished")) {
|
||||
if (meta.asBoolean()) return true;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerDie(PlayerDeathEvent e) {
|
||||
Player p = e.getEntity();
|
||||
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");
|
||||
p.spigot().sendMessage(backButton().create());
|
||||
}
|
||||
@@ -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 (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
if (DataManager.getPlayerTeleporting(p)) {
|
||||
TeleportManager.teleportPlayer(p);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class EssentialsMigrator {
|
||||
|
||||
// Migrate data from EssentialsX
|
||||
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");
|
||||
if (essentialsDataFolder.exists()) {
|
||||
Bukkit.getLogger().info("Essentials plugin data found!");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package me.william278.huskhomes2.migrators;
|
||||
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.config.ConfigManager;
|
||||
import me.william278.huskhomes2.data.DataManager;
|
||||
import me.william278.huskhomes2.teleport.points.Home;
|
||||
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
|
||||
public class LegacyMigrator {
|
||||
|
||||
public static boolean startupMigrate;
|
||||
private static boolean canMigrate;
|
||||
private static String sourcePlayerTable;
|
||||
private static String sourceHomeTable;
|
||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||
@@ -42,7 +41,7 @@ public class LegacyMigrator {
|
||||
if (!config.contains("config_file_version") && config.contains("host")) {
|
||||
Bukkit.getLogger().info("Detected HuskHomes 1.0 data to migrate!");
|
||||
Bukkit.getLogger().info("- Preparing Migration -");
|
||||
startupMigrate = true;
|
||||
canMigrate = true;
|
||||
createMigrationSubdirectory();
|
||||
if (!configFile.renameTo(new File(plugin.getDataFolder() + File.separator + "MigratedData" + File.separator + "OLD_config.yml"))) {
|
||||
Bukkit.getLogger().warning("Failed to move old config.yml!");
|
||||
@@ -117,11 +116,10 @@ public class LegacyMigrator {
|
||||
plugin.saveConfig();
|
||||
|
||||
// Reload settings with new ones
|
||||
plugin.reloadConfig();
|
||||
ConfigManager.loadConfig();
|
||||
HuskHomes.getSettings().reload();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().warning("Failed to migrate data; " + e.getCause() + " when trying to migrate config data");
|
||||
startupMigrate = false;
|
||||
canMigrate = false;
|
||||
return;
|
||||
}
|
||||
Bukkit.getLogger().info("- Config migrations complete! -");
|
||||
@@ -131,8 +129,8 @@ public class LegacyMigrator {
|
||||
try {
|
||||
synchronized (HuskHomes.getInstance()) {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
return DriverManager.getConnection("jdbc:mysql://" + HuskHomes.settings.getMySQLhost() + ":" + HuskHomes.settings.getMySQLport()
|
||||
+ "/" + HuskHomes.settings.getMySQLdatabase() + "?autoReconnect=true&useSSL=false", HuskHomes.settings.getMySQLusername(), HuskHomes.settings.getMySQLpassword());
|
||||
return DriverManager.getConnection("jdbc:mysql://" + HuskHomes.getSettings().getMySQLhost() + ":" + HuskHomes.getSettings().getMySQLport()
|
||||
+ "/" + HuskHomes.getSettings().getMySQLdatabase() + "?autoReconnect=true&useSSL=false", HuskHomes.getSettings().getMySQLusername(), HuskHomes.getSettings().getMySQLpassword());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
return null;
|
||||
@@ -208,4 +206,7 @@ public class LegacyMigrator {
|
||||
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");
|
||||
return;
|
||||
}
|
||||
int itemsPerPage = HuskHomes.settings.getPrivateHomesPerPage();
|
||||
int itemsPerPage = HuskHomes.getSettings().getPrivateHomesPerPage();
|
||||
int homeLowerBound = (pageNumber - 1) * itemsPerPage;
|
||||
int homeUpperBound = pageNumber * itemsPerPage;
|
||||
if (homeUpperBound > homes.size()) {
|
||||
@@ -130,7 +130,7 @@ public class ListHandler {
|
||||
MessageManager.sendMessage(player, "error_no_public_homes_set");
|
||||
return;
|
||||
}
|
||||
int itemsPerPage = HuskHomes.settings.getPublicHomesPerPage();
|
||||
int itemsPerPage = HuskHomes.getSettings().getPublicHomesPerPage();
|
||||
int homeLowerBound = (pageNumber - 1) * itemsPerPage;
|
||||
int homeUpperBound = pageNumber * itemsPerPage;
|
||||
if (homeUpperBound > homes.size()) {
|
||||
@@ -174,7 +174,7 @@ public class ListHandler {
|
||||
MessageManager.sendMessage(player, "error_no_warps_set");
|
||||
return;
|
||||
}
|
||||
int itemsPerPage = HuskHomes.settings.getWarpsPerPage();
|
||||
int itemsPerPage = HuskHomes.getSettings().getWarpsPerPage();
|
||||
int warpsLowerBound = (pageNumber - 1) * itemsPerPage;
|
||||
int warpsUpperBound = pageNumber * itemsPerPage;
|
||||
if (warpsUpperBound > warps.size()) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SettingHandler {
|
||||
public static void setHome(Location location, Player player, String name) {
|
||||
SetHomeConditions setHomeConditions = new SetHomeConditions(player, name);
|
||||
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);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
@@ -41,10 +41,10 @@ public class SettingHandler {
|
||||
} else {
|
||||
switch (setHomeConditions.getConditionsNotMetReason()) {
|
||||
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;
|
||||
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;
|
||||
default:
|
||||
MessageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason());
|
||||
@@ -56,7 +56,7 @@ public class SettingHandler {
|
||||
public static void setWarp(Location location, Player player, String name) {
|
||||
SetWarpConditions setWarpConditions = new SetWarpConditions(name);
|
||||
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);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
@@ -64,7 +64,7 @@ public class SettingHandler {
|
||||
}
|
||||
DataManager.addWarp(warp);
|
||||
MessageManager.sendMessage(player, "set_warp_success", name);
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(warp);
|
||||
}
|
||||
WarpCommand.Tab.updateWarpsTabCache();
|
||||
@@ -80,7 +80,7 @@ public class SettingHandler {
|
||||
if (home != null) {
|
||||
if (home.isPublic()) {
|
||||
// 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());
|
||||
}
|
||||
PlayerDeleteHomeEvent event = new PlayerDeleteHomeEvent(player, home);
|
||||
@@ -114,7 +114,7 @@ public class SettingHandler {
|
||||
}
|
||||
DataManager.deleteWarp(warpName);
|
||||
MessageManager.sendMessage(player, "warp_deleted", warpName);
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
if (HuskHomes.getSettings().doDynmap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||
}
|
||||
WarpCommand.Tab.updateWarpsTabCache();
|
||||
@@ -136,7 +136,7 @@ public class SettingHandler {
|
||||
plugin.saveConfig();
|
||||
|
||||
// Update the current spawn location
|
||||
TeleportManager.spawnLocation = new TeleportationPoint(location, HuskHomes.settings.getServerID());
|
||||
TeleportManager.spawnLocation = new TeleportationPoint(location, HuskHomes.getSettings().getServerID());
|
||||
}
|
||||
|
||||
// Update current spawn location from config
|
||||
@@ -146,7 +146,7 @@ public class SettingHandler {
|
||||
|
||||
// Get spawn location from config
|
||||
private static TeleportationPoint getSpawnLocation() {
|
||||
String server = HuskHomes.settings.getServerID();
|
||||
String server = HuskHomes.getSettings().getServerID();
|
||||
try {
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
String worldName = (config.getString("spawn_command.position.world"));
|
||||
@@ -219,8 +219,8 @@ public class SettingHandler {
|
||||
conditionsNotMetReason = "error_set_home_invalid_characters";
|
||||
return;
|
||||
}
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double setHomeCost = HuskHomes.settings.getSetHomeCost();
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
double setHomeCost = HuskHomes.getSettings().getSetHomeCost();
|
||||
if (setHomeCost > 0) {
|
||||
int currentPlayerHomeSlots = DataManager.getPlayerHomeSlots(player);
|
||||
if (currentHomeCount > (currentPlayerHomeSlots - 1)) {
|
||||
|
||||
@@ -20,12 +20,12 @@ public class TeleportManager {
|
||||
public static TeleportationPoint spawnLocation = null;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
teleportPlayer(player);
|
||||
}
|
||||
@@ -34,13 +34,13 @@ public class TeleportManager {
|
||||
TeleportationPoint teleportationPoint = DataManager.getPlayerDestination(p);
|
||||
if (teleportationPoint != null) {
|
||||
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.playSound(p.getLocation(), HuskHomes.settings.getTeleportationCompleteSound(), 1, 1);
|
||||
p.playSound(p.getLocation(), HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1);
|
||||
MessageManager.sendMessage(p, "teleporting_complete");
|
||||
DataManager.setPlayerTeleporting(p, false);
|
||||
DataManager.clearPlayerDestination(p.getName());
|
||||
} else if (HuskHomes.settings.doBungee()) {
|
||||
} else if (HuskHomes.getSettings().doBungee()) {
|
||||
DataManager.setPlayerDestinationLocation(p, teleportationPoint);
|
||||
DataManager.setPlayerTeleporting(p, true);
|
||||
PluginMessageHandler.sendPlayer(p, server);
|
||||
@@ -77,8 +77,8 @@ public class TeleportManager {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double rtpCost = HuskHomes.settings.getRtpCost();
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
double rtpCost = HuskHomes.getSettings().getRtpCost();
|
||||
if (rtpCost > 0) {
|
||||
if (!VaultIntegration.hasMoney(player, rtpCost)) {
|
||||
MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(rtpCost));
|
||||
@@ -87,8 +87,8 @@ public class TeleportManager {
|
||||
}
|
||||
}
|
||||
if (player.hasPermission("huskhomes.bypass_timer")) {
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double rtpCost = HuskHomes.settings.getRtpCost();
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
double rtpCost = HuskHomes.getSettings().getRtpCost();
|
||||
if (rtpCost > 0) {
|
||||
VaultIntegration.takeMoney(player, rtpCost);
|
||||
MessageManager.sendMessage(player, "rtp_spent_money", VaultIntegration.format(rtpCost));
|
||||
@@ -111,7 +111,7 @@ public class TeleportManager {
|
||||
MessageManager.sendMessage(requester, "error_tp_self");
|
||||
}
|
||||
} else {
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
teleportHereCrossServer(requester, targetPlayerName);
|
||||
} else {
|
||||
MessageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
||||
@@ -132,13 +132,13 @@ public class TeleportManager {
|
||||
if (targetPlayer != null) {
|
||||
if (requester.getUniqueId() != targetPlayer.getUniqueId()) {
|
||||
DataManager.setPlayerDestinationLocation(requester,
|
||||
new TeleportationPoint(targetPlayer.getLocation(), HuskHomes.settings.getServerID()));
|
||||
new TeleportationPoint(targetPlayer.getLocation(), HuskHomes.getSettings().getServerID()));
|
||||
teleportPlayer(requester);
|
||||
} else {
|
||||
MessageManager.sendMessage(requester, "error_tp_self");
|
||||
}
|
||||
} else {
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
setTeleportationDestinationCrossServer(requester, targetPlayerName);
|
||||
} else {
|
||||
MessageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TeleportRequest {
|
||||
this.requestType = requestType.toLowerCase();
|
||||
}
|
||||
long currentUnixTime = Instant.now().getEpochSecond();
|
||||
requestExpiryTime = currentUnixTime + HuskHomes.settings.getTeleportRequestExpiryTime();
|
||||
requestExpiryTime = currentUnixTime + HuskHomes.getSettings().getTeleportRequestExpiryTime();
|
||||
}
|
||||
|
||||
public String getSenderName() {
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TeleportRequestHandler {
|
||||
MessageManager.sendMessage(requester, "error_tp_self");
|
||||
}
|
||||
} else {
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpa");
|
||||
MessageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
||||
} else {
|
||||
@@ -103,7 +103,7 @@ public class TeleportRequestHandler {
|
||||
MessageManager.sendMessage(requester, "error_tp_self");
|
||||
}
|
||||
} else {
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpahere");
|
||||
MessageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
||||
} else {
|
||||
@@ -137,7 +137,7 @@ public class TeleportRequestHandler {
|
||||
MessageManager.sendMessage(requester, "tpa_has_declined", p.getName());
|
||||
}
|
||||
} else {
|
||||
if (HuskHomes.settings.doBungee()) {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
if (accepted) {
|
||||
MessageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
||||
|
||||
@@ -173,20 +173,20 @@ public class TeleportRequestHandler {
|
||||
if (timedTeleport.getTimeRemaining() > 0) {
|
||||
if (!timedTeleport.hasMoved(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",
|
||||
Integer.toString(timedTeleport.getTimeRemaining()));
|
||||
timedTeleport.decrementTimeRemaining();
|
||||
} else {
|
||||
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_cancelled");
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
MessageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_cancelled");
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
@@ -200,8 +200,8 @@ public class TeleportRequestHandler {
|
||||
TeleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPlayerName());
|
||||
break;
|
||||
case "random":
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double rtpCost = HuskHomes.settings.getRtpCost();
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
double rtpCost = HuskHomes.getSettings().getRtpCost();
|
||||
if (rtpCost > 0) {
|
||||
if (!VaultIntegration.takeMoney(teleporter, rtpCost)) {
|
||||
MessageManager.sendMessage(teleporter, "error_insufficient_funds", VaultIntegration.format(rtpCost));
|
||||
|
||||
@@ -18,7 +18,7 @@ public class TimedTeleport {
|
||||
private double initialTeleporterHealth;
|
||||
|
||||
private int timeRemaining;
|
||||
private final int warmupTime = HuskHomes.settings.getTeleportWarmupTime();
|
||||
private final int warmupTime = HuskHomes.getSettings().getTeleportWarmupTime();
|
||||
|
||||
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint) {
|
||||
this.teleporter = teleporter;
|
||||
|
||||
@@ -151,11 +151,11 @@ public class Home extends TeleportationPoint {
|
||||
try {
|
||||
return Integer.parseInt(permission.split("\\.")[2]);
|
||||
} 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
|
||||
@@ -166,10 +166,10 @@ public class Home extends TeleportationPoint {
|
||||
try {
|
||||
return Integer.parseInt(permission.split("\\.")[2]);
|
||||
} 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;
|
||||
|
||||
public RandomPoint(Player player) {
|
||||
super(player.getLocation(), HuskHomes.settings.getServerID());
|
||||
super(player.getLocation(), HuskHomes.getSettings().getServerID());
|
||||
Location randomLocation = getRandomLocation(player.getWorld());
|
||||
if (randomLocation != null) {
|
||||
setLocation(randomLocation, HuskHomes.settings.getServerID());
|
||||
setLocation(randomLocation, HuskHomes.getSettings().getServerID());
|
||||
} else {
|
||||
MessageManager.sendMessage(player, "error_rtp_randomization_timeout");
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class RandomPoint extends TeleportationPoint {
|
||||
double blockCenterZ = 0.5;
|
||||
|
||||
// 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
|
||||
x = random.nextInt(rtpRange);
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
# ------------------------------
|
||||
# | HuskHomes Config |
|
||||
# | Developed by William278 |
|
||||
# ------------------------------
|
||||
# Configuration guide: https://github.com/WiIIiam278/HuskHomes2/wiki
|
||||
|
||||
language: 'en-gb'
|
||||
check_for_updates: true
|
||||
data_storage_options:
|
||||
|
||||
Reference in new issue
Block a user