mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 14:38:53 +00:00
Add Pl3xMap support, Close #58
This commit is contained in:
1 parent
e28ceb20ff
commit
c89d263505
10 files changed
+237
-76
No files matched your search
@@ -124,6 +124,10 @@
|
|||||||
<id>minebench-repo</id>
|
<id>minebench-repo</id>
|
||||||
<url>https://repo.minebench.de/</url>
|
<url>https://repo.minebench.de/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>pl3x-repo</id>
|
||||||
|
<url>https://repo.pl3x.net/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -145,6 +149,12 @@
|
|||||||
<version>v1.6.0</version>
|
<version>v1.6.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.pl3x.map</groupId>
|
||||||
|
<artifactId>pl3xmap-api</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.MilkBowl</groupId>
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import me.william278.huskhomes2.integrations.map.BlueMap;
|
|||||||
import me.william278.huskhomes2.integrations.map.DynMap;
|
import me.william278.huskhomes2.integrations.map.DynMap;
|
||||||
import me.william278.huskhomes2.integrations.map.Map;
|
import me.william278.huskhomes2.integrations.map.Map;
|
||||||
import me.william278.huskhomes2.integrations.VaultIntegration;
|
import me.william278.huskhomes2.integrations.VaultIntegration;
|
||||||
|
import me.william278.huskhomes2.integrations.map.Pl3xMap;
|
||||||
import me.william278.huskhomes2.listeners.PlayerListener;
|
import me.william278.huskhomes2.listeners.PlayerListener;
|
||||||
import me.william278.huskhomes2.listeners.PluginMessageListener;
|
import me.william278.huskhomes2.listeners.PluginMessageListener;
|
||||||
import me.william278.huskhomes2.migrators.UpgradeDatabase;
|
import me.william278.huskhomes2.migrators.UpgradeDatabase;
|
||||||
@@ -191,16 +192,19 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
// Initialize the database
|
// Initialize the database
|
||||||
initializeDatabase();
|
initializeDatabase();
|
||||||
|
|
||||||
|
// Upgrade Database if needed
|
||||||
|
UpgradeDatabase.upgradeDatabase();
|
||||||
|
|
||||||
// Fetch spawn location if set
|
// Fetch spawn location if set
|
||||||
SettingHandler.fetchSpawnLocation();
|
SettingHandler.fetchSpawnLocation();
|
||||||
|
|
||||||
// Setup the map integration with the correct plugin
|
// Setup the map integration with the correct plugin
|
||||||
if (HuskHomes.getSettings().doMapIntegration()) {
|
if (HuskHomes.getSettings().doMapIntegration()) {
|
||||||
String mapPlugin = HuskHomes.getSettings().getMapPlugin();
|
String mapPlugin = HuskHomes.getSettings().getMapPlugin();
|
||||||
if (mapPlugin.equalsIgnoreCase("dynmap")) {
|
switch (mapPlugin) {
|
||||||
map = new DynMap();
|
case "dynmap" -> map = new DynMap();
|
||||||
} else if (mapPlugin.equalsIgnoreCase("bluemap")) {
|
case "bluemap" -> map = new BlueMap();
|
||||||
map = new BlueMap();
|
case "pl3xmap" -> map = new Pl3xMap();
|
||||||
}
|
}
|
||||||
map.initialize();
|
map.initialize();
|
||||||
}
|
}
|
||||||
@@ -221,9 +225,6 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
// Register events
|
// Register events
|
||||||
registerEvents(this);
|
registerEvents(this);
|
||||||
|
|
||||||
// Upgrade Database if needed
|
|
||||||
UpgradeDatabase.upgradeDatabase();
|
|
||||||
|
|
||||||
// bStats initialisation
|
// bStats initialisation
|
||||||
try {
|
try {
|
||||||
Metrics metrics = new Metrics(this, METRICS_PLUGIN_ID);
|
Metrics metrics = new Metrics(this, METRICS_PLUGIN_ID);
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class TpCommand extends CommandBase {
|
|||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try {
|
try {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
default: case 0:
|
default:
|
||||||
|
case 0:
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -78,6 +79,38 @@ public class TpCommand extends CommandBase {
|
|||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
case 6:
|
||||||
|
try {
|
||||||
|
double x = Double.parseDouble(args[0]);
|
||||||
|
double y = Double.parseDouble(args[1]);
|
||||||
|
double z = Double.parseDouble(args[2]);
|
||||||
|
String worldName = args[3];
|
||||||
|
float yaw = Float.parseFloat(args[4]);
|
||||||
|
float pitch = Float.parseFloat(args[5]);
|
||||||
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, yaw, pitch, HuskHomes.getSettings().getServerID());
|
||||||
|
TeleportManager.teleportPlayer(p, teleportationPoint, connection);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <yaw> <pitch>");
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
if (HuskHomes.getSettings().doBungee()) {
|
||||||
|
try {
|
||||||
|
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];
|
||||||
|
float yaw = Float.parseFloat(args[5]);
|
||||||
|
float pitch = Float.parseFloat(args[6]);
|
||||||
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, yaw, pitch, serverName);
|
||||||
|
TeleportManager.teleportPlayer(p, teleportationPoint, connection);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server> <yaw> <pitch>");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred while using /tp", e);
|
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred while using /tp", e);
|
||||||
|
|||||||
@@ -149,22 +149,12 @@ public class Settings {
|
|||||||
|
|
||||||
if (this.doMapIntegration) {
|
if (this.doMapIntegration) {
|
||||||
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||||
switch (mapPlugin.toLowerCase(Locale.ROOT)) {
|
switch (mapPlugin.toLowerCase()) {
|
||||||
case "dynmap" -> {
|
case "dynmap", "bluemap", "pl3xmap" -> {
|
||||||
Plugin dynMap = pluginManager.getPlugin("dynmap");
|
Plugin mapSpigotPlugin = pluginManager.getPlugin(mapPlugin.toLowerCase());
|
||||||
if (dynMap == null) {
|
if (mapSpigotPlugin == null) {
|
||||||
Bukkit.getLogger().warning("Dynmap integration was enabled in config, but the Dynmap plugin could not be found!");
|
Bukkit.getLogger().warning(mapPlugin + " integration was enabled in config, but the " + mapPlugin + " plugin could not be found!");
|
||||||
Bukkit.getLogger().warning("The map integration setting has been disabled. Please ensure BlueMap is installed and restart the server.");
|
Bukkit.getLogger().warning("The map integration setting has been disabled. Please ensure " + mapPlugin + " is installed and restart the server.");
|
||||||
this.doMapIntegration = false;
|
|
||||||
plugin.getConfig().set("map_integration.enabled", false);
|
|
||||||
plugin.saveConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "bluemap" -> {
|
|
||||||
Plugin blueMap = pluginManager.getPlugin("BlueMap");
|
|
||||||
if (blueMap == null) {
|
|
||||||
Bukkit.getLogger().warning("BlueMap integration was enabled in config, but the BlueMap plugin could not be found!");
|
|
||||||
Bukkit.getLogger().warning("The map integration setting has been disabled. Please ensure BlueMap is installed and restart the server.");
|
|
||||||
this.doMapIntegration = false;
|
this.doMapIntegration = false;
|
||||||
plugin.getConfig().set("map_integration.enabled", false);
|
plugin.getConfig().set("map_integration.enabled", false);
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
@@ -178,7 +168,6 @@ public class Settings {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mapPublicHomes = config.getBoolean("map_integration.markers.public_homes.show", true);
|
this.mapPublicHomes = config.getBoolean("map_integration.markers.public_homes.show", true);
|
||||||
@@ -305,7 +294,9 @@ public class Settings {
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getClusterID() { return clusterID; }
|
public int getClusterID() {
|
||||||
|
return clusterID;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean doBungee() {
|
public boolean doBungee() {
|
||||||
return doBungee;
|
return doBungee;
|
||||||
@@ -383,7 +374,9 @@ public class Settings {
|
|||||||
return crossServerSpawnWarpName;
|
return crossServerSpawnWarpName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doForceSpawnOnLogin() { return forceSpawnOnLogin; }
|
public boolean doForceSpawnOnLogin() {
|
||||||
|
return forceSpawnOnLogin;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean doEconomy() {
|
public boolean doEconomy() {
|
||||||
return doEconomy;
|
return doEconomy;
|
||||||
|
|||||||
@@ -777,7 +777,7 @@ public class DataManager {
|
|||||||
statement.setInt(1, addTeleportationPoint(warp, connection));
|
statement.setInt(1, addTeleportationPoint(warp, connection));
|
||||||
statement.setString(2, warp.getName());
|
statement.setString(2, warp.getName());
|
||||||
statement.setString(3, warp.getDescription());
|
statement.setString(3, warp.getDescription());
|
||||||
statement.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
|
statement.setTimestamp(4, new Timestamp(warp.getCreationTime()));
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -792,7 +792,7 @@ public class DataManager {
|
|||||||
statement.setString(3, home.getName());
|
statement.setString(3, home.getName());
|
||||||
statement.setString(4, home.getDescription());
|
statement.setString(4, home.getDescription());
|
||||||
statement.setBoolean(5, home.isPublic());
|
statement.setBoolean(5, home.isPublic());
|
||||||
statement.setTimestamp(6, new Timestamp(System.currentTimeMillis()));
|
statement.setTimestamp(6, new Timestamp(home.getCreationTime()));
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class BlueMap extends Map {
|
|||||||
try {
|
try {
|
||||||
MarkerAPI markerAPI = api.getMarkerAPI();
|
MarkerAPI markerAPI = api.getMarkerAPI();
|
||||||
markerAPI.getMarkerSet(PUBLIC_HOMES_MARKER_SET_ID).ifPresent(markerSet -> api.getWorld(world.getUID()).ifPresent(blueMapWorld -> {
|
markerAPI.getMarkerSet(PUBLIC_HOMES_MARKER_SET_ID).ifPresent(markerSet -> api.getWorld(world.getUID()).ifPresent(blueMapWorld -> {
|
||||||
String markerId = PUBLIC_HOMES_MARKER_SET_ID + "." + home.getName();
|
String markerId = PUBLIC_HOMES_MARKER_SET_ID + "." + home.getOwnerUsername() + "." + home.getName();
|
||||||
for (BlueMapMap map : blueMapWorld.getMaps()) {
|
for (BlueMapMap map : blueMapWorld.getMaps()) {
|
||||||
POIMarker marker = markerSet.createPOIMarker(markerId, map, home.getX(), home.getY(), home.getZ());
|
POIMarker marker = markerSet.createPOIMarker(markerId, map, home.getX(), home.getY(), home.getZ());
|
||||||
marker.setLabel(getPublicHomeInfoMenu(home));
|
marker.setLabel(getPublicHomeInfoMenu(home));
|
||||||
@@ -130,8 +130,8 @@ public class BlueMap extends Map {
|
|||||||
BlueMapAPI.getInstance().ifPresentOrElse(api -> {
|
BlueMapAPI.getInstance().ifPresentOrElse(api -> {
|
||||||
try {
|
try {
|
||||||
MarkerAPI markerAPI = api.getMarkerAPI();
|
MarkerAPI markerAPI = api.getMarkerAPI();
|
||||||
markerAPI.getMarkerSet(WARPS_MARKER_SET_ID).ifPresent(markerSet -> {
|
markerAPI.getMarkerSet(PUBLIC_HOMES_MARKER_SET_ID).ifPresent(markerSet -> {
|
||||||
String markerId = WARPS_MARKER_SET_ID + "." + homeName;
|
String markerId = PUBLIC_HOMES_MARKER_SET_ID + "." + ownerName + "." + homeName;
|
||||||
markerSet.removeMarker(markerId);
|
markerSet.removeMarker(markerId);
|
||||||
try {
|
try {
|
||||||
markerAPI.save();
|
markerAPI.save();
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package me.william278.huskhomes2.integrations.map;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
|
import me.william278.huskhomes2.teleport.points.Home;
|
||||||
|
import me.william278.huskhomes2.teleport.points.Warp;
|
||||||
|
import net.pl3x.map.api.Key;
|
||||||
|
import net.pl3x.map.api.Pl3xMapProvider;
|
||||||
|
import net.pl3x.map.api.Point;
|
||||||
|
import net.pl3x.map.api.SimpleLayerProvider;
|
||||||
|
import net.pl3x.map.api.marker.Icon;
|
||||||
|
import net.pl3x.map.api.marker.Marker;
|
||||||
|
import net.pl3x.map.api.marker.MarkerOptions;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class Pl3xMap extends Map {
|
||||||
|
|
||||||
|
private final HashMap<String,SimpleLayerProvider> publicHomeProviders = new HashMap<>();
|
||||||
|
private final HashMap<String,SimpleLayerProvider> warpProviders = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addWarpMarker(Warp warp) {
|
||||||
|
World world = Bukkit.getWorld(warp.getWorldName());
|
||||||
|
if (world != null) {
|
||||||
|
if (warpProviders.containsKey(world.getName())) {
|
||||||
|
Icon marker = Marker.icon(
|
||||||
|
Point.of(warp.getX(), warp.getZ()),
|
||||||
|
Key.of(HuskHomes.getSettings().getMapWarpMarkerIconID()),
|
||||||
|
10);
|
||||||
|
marker.markerOptions(MarkerOptions.builder()
|
||||||
|
.hoverTooltip(warp.getName())
|
||||||
|
.clickTooltip(getWarpInfoMenu(warp))
|
||||||
|
.build());
|
||||||
|
warpProviders.get(world.getName()).addMarker(Key.of(WARPS_MARKER_SET_ID + "." + warp.getName()), marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeWarpMarker(String warpName) {
|
||||||
|
String warpMarkerWorld = null;
|
||||||
|
final Key warpMarkerKey = Key.of(WARPS_MARKER_SET_ID + "." + warpName);
|
||||||
|
for (String worldName : warpProviders.keySet()) {
|
||||||
|
SimpleLayerProvider warpProvider = warpProviders.get(worldName);
|
||||||
|
if (warpProvider.hasMarker(warpMarkerKey)) {
|
||||||
|
warpMarkerWorld = worldName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (warpMarkerWorld != null) {
|
||||||
|
warpProviders.get(warpMarkerWorld).removeMarker(warpMarkerKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPublicHomeMarker(Home home) {
|
||||||
|
World world = Bukkit.getWorld(home.getWorldName());
|
||||||
|
if (world != null) {
|
||||||
|
if (publicHomeProviders.containsKey(world.getName())) {
|
||||||
|
Icon marker = Marker.icon(
|
||||||
|
Point.of(home.getX(), home.getZ()),
|
||||||
|
Key.of(HuskHomes.getSettings().getMapPublicHomeMarkerIconID()),
|
||||||
|
10);
|
||||||
|
marker.markerOptions(MarkerOptions.builder()
|
||||||
|
.hoverTooltip(home.getName())
|
||||||
|
.clickTooltip(getPublicHomeInfoMenu(home))
|
||||||
|
.build());
|
||||||
|
publicHomeProviders.get(world.getName()).addMarker(
|
||||||
|
Key.of(PUBLIC_HOMES_MARKER_SET_ID + "." + home.getOwnerUsername() + "." + home.getName()), marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePublicHomeMarker(String homeName, String ownerName) {
|
||||||
|
String publicHomeMarkerWorld = null;
|
||||||
|
final Key publicHomeMarkerKey = Key.of(PUBLIC_HOMES_MARKER_SET_ID + "." + ownerName + "." + homeName);
|
||||||
|
for (String worldName : publicHomeProviders.keySet()) {
|
||||||
|
SimpleLayerProvider warpProvider = publicHomeProviders.get(worldName);
|
||||||
|
if (warpProvider.hasMarker(publicHomeMarkerKey)) {
|
||||||
|
publicHomeMarkerWorld = worldName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (publicHomeMarkerWorld != null) {
|
||||||
|
publicHomeProviders.get(publicHomeMarkerWorld).removeMarker(publicHomeMarkerKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
net.pl3x.map.api.Pl3xMap mapAPI = Pl3xMapProvider.get();
|
||||||
|
for (net.pl3x.map.api.MapWorld world : mapAPI.mapWorlds()) {
|
||||||
|
// Register public home map layer
|
||||||
|
SimpleLayerProvider publicHomeProvider =
|
||||||
|
SimpleLayerProvider.builder(HuskHomes.getSettings().getMapPublicHomeMarkerSet())
|
||||||
|
.showControls(true)
|
||||||
|
.defaultHidden(false)
|
||||||
|
.layerPriority(6)
|
||||||
|
.zIndex(250)
|
||||||
|
.build();
|
||||||
|
world.layerRegistry().register(Key.of(PUBLIC_HOMES_MARKER_SET_ID), publicHomeProvider);
|
||||||
|
publicHomeProviders.put(world.name(), publicHomeProvider);
|
||||||
|
|
||||||
|
// Register warps map layer
|
||||||
|
SimpleLayerProvider warpProvider =
|
||||||
|
SimpleLayerProvider.builder(HuskHomes.getSettings().getMapPublicHomeMarkerSet())
|
||||||
|
.showControls(true)
|
||||||
|
.defaultHidden(false)
|
||||||
|
.layerPriority(7)
|
||||||
|
.zIndex(250)
|
||||||
|
.build();
|
||||||
|
world.layerRegistry().register(Key.of(WARPS_MARKER_SET_ID), warpProvider);
|
||||||
|
warpProviders.put(world.name(), warpProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,59 +12,63 @@ public class UpgradeDatabase {
|
|||||||
|
|
||||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
|
//todo this stuff doesn't work. TEST BEFORE LAUNCH
|
||||||
|
|
||||||
// Upgrade the database system if the config file version is not high enough
|
// Upgrade the database system if the config file version is not high enough
|
||||||
public static void upgradeDatabase() {
|
public static void upgradeDatabase() {
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
if (plugin.getConfig().getInt("config_file_version", 1) <= 6) {
|
if (plugin.getConfig().getInt("config_file_version", 1) <= 6) {
|
||||||
plugin.getLogger().info("Detected that the database might need updating. Running database upgrade...");
|
plugin.getLogger().info("Detected that the database might need updating. Running database upgrade...");
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
||||||
|
"ALTER TABLE " + HuskHomes.getSettings().getPlayerDataTable()
|
||||||
|
+ " ADD `is_ignoring_requests` boolean NOT NULL DEFAULT 0, "
|
||||||
|
+ "ADD `offline_location_id` integer NULL DEFAULT NULL, "
|
||||||
|
+ "ADD FOREIGN KEY (`offline_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION;")) {
|
||||||
|
tableUpdateStatement.executeUpdate();
|
||||||
|
plugin.getLogger().info("Database update complete!");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// Update the config file version
|
||||||
|
plugin.getConfig().set("config_file_version", 7);
|
||||||
|
plugin.saveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plugin.getConfig().getInt("config_file_version", 1) <= 7) {
|
||||||
|
plugin.getLogger().info("Detected that the database might need updating. Running database upgrade...");
|
||||||
|
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
||||||
|
"ALTER TABLE " + HuskHomes.getSettings().getHomesDataTable()
|
||||||
|
+ " ADD `creation_time` timestamp NOT NULL DEFAULT 0;")) {
|
||||||
|
tableUpdateStatement.execute();
|
||||||
|
try (PreparedStatement timeSettingStatement = HuskHomes.getConnection().prepareStatement(
|
||||||
|
"UPDATE " + HuskHomes.getSettings().getHomesDataTable() + " SET `creation_time`=CURRENT_TIMESTAMP;")) {
|
||||||
|
timeSettingStatement.executeUpdate();
|
||||||
|
}
|
||||||
|
plugin.getLogger().info("Database update complete!");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
||||||
"ALTER TABLE " + HuskHomes.getSettings().getPlayerDataTable()
|
"ALTER TABLE " + HuskHomes.getSettings().getWarpsDataTable()
|
||||||
+ " ADD `is_ignoring_requests` boolean NOT NULL DEFAULT 0, "
|
+ " ADD `creation_time` timestamp NOT NULL DEFAULT 0;")) {
|
||||||
+ "ADD `offline_location_id` integer NULL DEFAULT NULL, "
|
tableUpdateStatement.execute();
|
||||||
+ "ADD FOREIGN KEY (`offline_location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION;")) {
|
try (PreparedStatement timeSettingStatement = HuskHomes.getConnection().prepareStatement(
|
||||||
tableUpdateStatement.executeUpdate();
|
"UPDATE " + HuskHomes.getSettings().getWarpsDataTable() + " SET `creation_time`=CURRENT_TIMESTAMP;")) {
|
||||||
|
timeSettingStatement.executeUpdate();
|
||||||
|
}
|
||||||
plugin.getLogger().info("Database update complete!");
|
plugin.getLogger().info("Database update complete!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");
|
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
// Update the config file version
|
// Update the config file version
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
plugin.getConfig().set("config_file_version", 8);
|
||||||
plugin.getConfig().set("config_file_version", 7);
|
plugin.saveConfig();
|
||||||
plugin.saveConfig();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
|
||||||
if (plugin.getConfig().getInt("config_file_version", 1) <= 6) {
|
|
||||||
plugin.getLogger().info("Detected that the database might need updating. Running database upgrade...");
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
|
||||||
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
|
||||||
"ALTER TABLE " + HuskHomes.getSettings().getHomesDataTable()
|
|
||||||
+ " ADD `creation_time` timestamp NOT NULL DEFAULT ?;")) {
|
|
||||||
tableUpdateStatement.setTimestamp(1, new Timestamp(Instant.now().getEpochSecond()));
|
|
||||||
tableUpdateStatement.executeUpdate();
|
|
||||||
plugin.getLogger().info("Database update complete!");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");
|
|
||||||
} finally {
|
|
||||||
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
|
||||||
"ALTER TABLE " + HuskHomes.getSettings().getWarpsDataTable()
|
|
||||||
+ " ADD `creation_time` timestamp NOT NULL DEFAULT ?;")) {
|
|
||||||
tableUpdateStatement.setTimestamp(1, new Timestamp(Instant.now().getEpochSecond()));
|
|
||||||
tableUpdateStatement.executeUpdate();
|
|
||||||
plugin.getLogger().info("Database update complete!");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");
|
|
||||||
} finally {
|
|
||||||
// Update the config file version
|
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
|
||||||
plugin.getConfig().set("config_file_version", 8);
|
|
||||||
plugin.saveConfig();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ teleporting_complete: '[Teleportation complete!](#00fb9a)'
|
|||||||
teleporting_action_bar_countdown: '[Teleporting in](#00fb9a) [%1%](#00fb9a bold)[...](#00fb9a)'
|
teleporting_action_bar_countdown: '[Teleporting in](#00fb9a) [%1%](#00fb9a bold)[...](#00fb9a)'
|
||||||
teleporting_action_bar_cancelled: '[Teleportation cancelled!](#ff7e5e)'
|
teleporting_action_bar_cancelled: '[Teleportation cancelled!](#ff7e5e)'
|
||||||
teleporting_please_stand_still: '[Teleportation will be cancelled if you move or take damage.](gray)'
|
teleporting_please_stand_still: '[Teleportation will be cancelled if you move or take damage.](gray)'
|
||||||
home_deleted: '[Successfully deleted the home,](#00fb9a) [%1%](#00fb9a bold)'
|
home_deleted: '[Successfully deleted the home called](#00fb9a) [%1%](#00fb9a bold)'
|
||||||
warp_deleted: '[Successfully deleted the warp,](#00fb9a) [%1%](#00fb9a bold)'
|
warp_deleted: '[Successfully deleted the warp called](#00fb9a) [%1%](#00fb9a bold)'
|
||||||
error_home_invalid: '[Error:](#ff3300) [You do not have a home named "%1%"](#ff7e5e)'
|
error_home_invalid: '[Error:](#ff3300) [You do not have a home named "%1%"](#ff7e5e)'
|
||||||
error_warp_invalid: '[Error:](#ff3300) [There is no warp set named "%1%"](#ff7e5e)'
|
error_warp_invalid: '[Error:](#ff3300) [There is no warp set named "%1%"](#ff7e5e)'
|
||||||
error_invalid_syntax: '[Error:](#ff3300) [Incorrect syntax. Usage: %1%](#ff7e5e)'
|
error_invalid_syntax: '[Error:](#ff3300) [Incorrect syntax. Usage: %1%](#ff7e5e)'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ version: ${project.version}
|
|||||||
main: me.william278.huskhomes2.HuskHomes
|
main: me.william278.huskhomes2.HuskHomes
|
||||||
api-version: 1.16
|
api-version: 1.16
|
||||||
authors: [William278]
|
authors: [William278]
|
||||||
softdepend: [dynmap, Vault, BlueMap]
|
softdepend: [dynmap, Vault, BlueMap, Pl3xMap]
|
||||||
description: A powerful, intuitive and flexible teleportation suite
|
description: A powerful, intuitive and flexible teleportation suite
|
||||||
libraries: [mysql:mysql-connector-java:8.0.25]
|
libraries: [mysql:mysql-connector-java:8.0.25]
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user