mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
Start refactor work
This commit is contained in:
1 parent
6a8851a446
commit
3e1ec09487
51 files changed
+2397
-2474
No files matched your search
@@ -39,11 +39,11 @@ public class BlueMapHook extends MapHook {
|
||||
// Create marker sets
|
||||
plugin.getWorlds().forEach(world -> blueMapAPI.getWorld(world.uuid)
|
||||
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(map -> {
|
||||
if (plugin.getSettings().publicHomesOnMap) {
|
||||
if (plugin.getSettings().isPublicHomesOnMap()) {
|
||||
map.getMarkerSets().put(blueMapWorld.getId() + ":" + PUBLIC_HOMES_MARKER_SET_ID,
|
||||
MarkerSet.builder().label("Public Homes").build());
|
||||
}
|
||||
if (plugin.getSettings().warpsOnMap) {
|
||||
if (plugin.getSettings().isWarpsOnMap()) {
|
||||
map.getMarkerSets().put(blueMapWorld.getId() + ":" + WARPS_MARKER_SET_ID,
|
||||
MarkerSet.builder().label("Warps").build());
|
||||
}
|
||||
|
||||
@@ -26,13 +26,15 @@ public abstract class MapHook extends PluginHook {
|
||||
@Override
|
||||
public final boolean initialize() {
|
||||
initializeMap().thenRun(() -> {
|
||||
if (plugin.getSettings().publicHomesOnMap) {
|
||||
plugin.getDatabase().getLocalPublicHomes(plugin)
|
||||
.thenAcceptAsync(homes -> homes.forEach(this::updateHome));
|
||||
if (plugin.getSettings().isPublicHomesOnMap()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalPublicHomes(plugin)
|
||||
.forEach(this::updateHome);
|
||||
}
|
||||
if (plugin.getSettings().warpsOnMap) {
|
||||
plugin.getDatabase().getLocalWarps(plugin)
|
||||
.thenAcceptAsync(warps -> warps.forEach(this::updateWarp));
|
||||
if (plugin.getSettings().isWarpsOnMap()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalWarps(plugin)
|
||||
.forEach(this::updateWarp);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
@@ -98,8 +100,8 @@ public abstract class MapHook extends PluginHook {
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
protected final boolean isValidPosition(@NotNull SavedPosition position) {
|
||||
if (position instanceof Warp && !plugin.getSettings().warpsOnMap) return false;
|
||||
if (position instanceof Home && !plugin.getSettings().publicHomesOnMap) return false;
|
||||
if (position instanceof Warp && !plugin.getSettings().isWarpsOnMap()) return false;
|
||||
if (position instanceof Home && !plugin.getSettings().isPublicHomesOnMap()) return false;
|
||||
|
||||
try {
|
||||
return position.server.equals(plugin.getServerName());
|
||||
|
||||
@@ -50,7 +50,7 @@ public class PlanDataExtension implements DataExtension {
|
||||
hidden = true
|
||||
)
|
||||
public boolean getHasUserData(@NotNull UUID uuid) {
|
||||
return database.getUserData(uuid).join().isPresent();
|
||||
return database.getUserData(uuid).isPresent();
|
||||
}
|
||||
|
||||
@NumberProvider(
|
||||
@@ -62,8 +62,8 @@ public class PlanDataExtension implements DataExtension {
|
||||
)
|
||||
@Conditional("hasData")
|
||||
public long getHomeCount(@NotNull UUID uuid) {
|
||||
return database.getUserData(uuid).join()
|
||||
.map(userData -> (long) database.getHomes(userData.user()).join().size())
|
||||
return database.getUserData(uuid)
|
||||
.map(userData -> (long) database.getHomes(userData.user()).size())
|
||||
.orElse(0L);
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ public class PlanDataExtension implements DataExtension {
|
||||
)
|
||||
@Conditional("hasData")
|
||||
public long getPublicHomeCount(@NotNull UUID uuid) {
|
||||
return database.getUserData(uuid).join()
|
||||
.map(userData -> database.getHomes(userData.user()).join()
|
||||
return database.getUserData(uuid)
|
||||
.map(userData -> database.getHomes(userData.user())
|
||||
.stream().filter(home -> home.isPublic).count())
|
||||
.orElse(0L);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class PlanDataExtension implements DataExtension {
|
||||
)
|
||||
@Conditional("hasData")
|
||||
public long getPurchasedHomeSlots(@NotNull UUID uuid) {
|
||||
return database.getUserData(uuid).join()
|
||||
return database.getUserData(uuid)
|
||||
.map(userData -> (long) userData.homeSlots())
|
||||
.orElse(0L);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class PlanDataExtension implements DataExtension {
|
||||
)
|
||||
@Conditional("hasData")
|
||||
public boolean isIgnoringTeleportRequests(@NotNull UUID uuid) {
|
||||
return database.getUserData(uuid).join()
|
||||
return database.getUserData(uuid)
|
||||
.map(UserData::ignoringTeleports)
|
||||
.orElse(false);
|
||||
}
|
||||
@@ -119,11 +119,11 @@ public class PlanDataExtension implements DataExtension {
|
||||
)
|
||||
@Conditional("hasData")
|
||||
public String getOfflinePosition(@NotNull UUID uuid) {
|
||||
return database.getUserData(uuid).join()
|
||||
.map(userData -> database.getOfflinePosition(userData.user()).join()
|
||||
return database.getUserData(uuid)
|
||||
.map(userData -> database.getOfflinePosition(userData.user())
|
||||
.map(position -> "x: " + (int) position.x + ", y: " + (int) position.y + ", z: " + (int) position.z
|
||||
+ " (" + position.world.name +
|
||||
((crossServer) ? "/" + position.server.name + ")" : ")"))
|
||||
+ " (" + position.world.name +
|
||||
((crossServer) ? "/" + position.server.name + ")" : ")"))
|
||||
.orElse(UNKNOWN_STRING))
|
||||
.orElse(UNKNOWN_STRING);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PlanHook extends PluginHook {
|
||||
|
||||
private void registerDataExtension() {
|
||||
try {
|
||||
ExtensionService.getInstance().register(new PlanDataExtension(database, plugin.getSettings().crossServer));
|
||||
ExtensionService.getInstance().register(new PlanDataExtension(database, plugin.getSettings().isCrossServer()));
|
||||
} catch (IllegalStateException planIsNotEnabled) {
|
||||
logger.log(Level.SEVERE, "Plan extension hook failed to register. Plan is not enabled.", planIsNotEnabled);
|
||||
// Plan is not enabled, handle exception
|
||||
|
||||
Reference in new issue
Block a user