Refactor map integration system to use abstract methods, start work on BlueMap support

Fix failed RTP still taking money (Closes #45)
This commit is contained in:
WiIIiam278 committed 2021-06-07 01:11:46 +01:00
1 parent 884d61d938
commit 30cf917969
14 files changed
+229 -116

No files matched your search

@@ -9,7 +9,7 @@ import me.william278.huskhomes2.api.events.PlayerMakeHomePublicEvent;
import me.william278.huskhomes2.api.events.PlayerRelocateHomeEvent;
import me.william278.huskhomes2.api.events.PlayerRenameHomeEvent;
import me.william278.huskhomes2.data.DataManager;
import me.william278.huskhomes2.integrations.DynMapIntegration;
import me.william278.huskhomes2.integrations.Map.DynMap;
import me.william278.huskhomes2.integrations.VaultIntegration;
import me.william278.huskhomes2.teleport.points.Home;
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
@@ -63,8 +63,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
// Remove old marker if on dynmap
Home locationMovedHome = DataManager.getHome(p.getName(), homeName, connection);
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().removePublicHomeMarker(homeName, p.getName());
}
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
@@ -76,8 +76,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
// Add new updated marker if using dynmap
locationMovedHome.setLocation(newLocation, HuskHomes.getSettings().getServerID());
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.addDynamicMapMarker(locationMovedHome);
if (locationMovedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().addPublicHomeMarker(locationMovedHome);
}
return;
case "description":
@@ -104,8 +104,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
}
// Remove old marker if on the Dynmap
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().removePublicHomeMarker(homeName, p.getName());
}
// Update description
@@ -113,8 +113,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
// Add new marker if using Dynmap
descriptionChangedHome.setDescription(newDescriptionString);
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.addDynamicMapMarker(descriptionChangedHome);
if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().addPublicHomeMarker(descriptionChangedHome);
}
// Confirmation message
@@ -143,8 +143,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(renameHomeEvent));
if (renamedHome.isPublic()) {
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().removePublicHomeMarker(homeName, p.getName());
}
DataManager.updateHomeName(p.getName(), homeName, newName, connection);
PublicHomeCommand.updatePublicHomeTabCache();
@@ -152,8 +152,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
DataManager.updateHomeName(p.getName(), homeName, newName, connection);
}
renamedHome.setName(newName);
if (renamedHome.isPublic() && HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.addDynamicMapMarker(renamedHome);
if (renamedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().addPublicHomeMarker(renamedHome);
}
HomeCommand.Tab.updatePlayerHomeCache(p);
MessageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
@@ -184,8 +184,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
DataManager.updateHomePrivacy(p.getName(), homeName, true, connection);
PublicHomeCommand.updatePublicHomeTabCache();
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.addDynamicMapMarker(privateHome);
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().addPublicHomeMarker(privateHome);
}
} else {
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
@@ -199,8 +199,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
DataManager.updateHomePrivacy(p.getName(), homeName, false, connection);
MessageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showPublicHomesOnDynmap()) {
DynMapIntegration.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) {
HuskHomes.getMap().removePublicHomeMarker(publicHome.getName(), publicHome.getOwnerUsername());
}
PublicHomeCommand.updatePublicHomeTabCache();
} else {
@@ -7,7 +7,7 @@ import me.william278.huskhomes2.api.events.PlayerChangeWarpDescriptionEvent;
import me.william278.huskhomes2.api.events.PlayerRelocateWarpEvent;
import me.william278.huskhomes2.api.events.PlayerRenameWarpEvent;
import me.william278.huskhomes2.data.DataManager;
import me.william278.huskhomes2.integrations.DynMapIntegration;
import me.william278.huskhomes2.integrations.Map.DynMap;
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
import me.william278.huskhomes2.teleport.points.Warp;
import me.william278.huskhomes2.util.RegexUtil;
@@ -59,8 +59,8 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
// Remove old marker if on the Dynmap
Warp locationMovedWarp = DataManager.getWarp(warpName, connection);
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
DynMapIntegration.removeDynamicMapMarker(warpName);
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().removeWarpMarker(warpName);
}
PlayerRelocateWarpEvent relocateWarpEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
@@ -71,8 +71,8 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
// Add new updated marker if using Dynmap
locationMovedWarp.setLocation(newLocation, HuskHomes.getSettings().getServerID());
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
DynMapIntegration.addDynamicMapMarker(locationMovedWarp);
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().addWarpMarker(locationMovedWarp);
}
return;
case "description":
@@ -100,16 +100,16 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
return;
}
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
DynMapIntegration.removeDynamicMapMarker(warpName);
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().removeWarpMarker(warpName);
}
// Update description
DataManager.updateWarpDescription(warpName, newDescriptionString, connection);
descriptionChangedWarp.setDescription(newDescriptionString);
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
DynMapIntegration.addDynamicMapMarker(descriptionChangedWarp);
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().addWarpMarker(descriptionChangedWarp);
}
// Confirmation message
@@ -137,14 +137,14 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
PlayerRenameWarpEvent renameWarpEvent = new PlayerRenameWarpEvent(p, renamedWarp, newName);
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(renameWarpEvent));
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
DynMapIntegration.removeDynamicMapMarker(warpName);
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().removeWarpMarker(warpName);
}
DataManager.updateWarpName(warpName, newName, connection);
renamedWarp.setName(newName);
if (HuskHomes.getSettings().doDynMap() && HuskHomes.getSettings().showWarpsOnDynmap()) {
DynMapIntegration.addDynamicMapMarker(renamedWarp);
if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showWarpsOnMap()) {
HuskHomes.getMap().addWarpMarker(renamedWarp);
}
WarpCommand.Tab.updateWarpsTabCache();
MessageManager.sendMessage(p, "edit_warp_update_name", warpName, newName);