mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
refactor: Move to ConfigLib, use lombok (#563)
* refactor: move to configlib, adjust config structure * fix: huskclaims typos * fix: don't generate `server.yml` in local mode * fix: NPE with server name
This commit is contained in:
1 parent
c55631a30d
commit
1723aa44fc
84 files changed
+4334
-4832
No files matched your search
@@ -20,6 +20,7 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.user.User;
|
||||
@@ -57,12 +58,13 @@ public class DynmapHook extends MapHook {
|
||||
public void apiEnabled(@NotNull DynmapCommonAPI dynmapCommonAPI) {
|
||||
dynmapApi = dynmapCommonAPI;
|
||||
|
||||
if (plugin.getSettings().doPublicHomesOnMap()) {
|
||||
final Settings.MapHookSettings settings = plugin.getSettings().getMapHook();
|
||||
if (settings.isShowPublicHomes()) {
|
||||
getMarkerIcon(PUBLIC_HOME_MARKER_IMAGE_NAME).orElseThrow();
|
||||
dynmapApi.getMarkerAPI().createMarkerSet(getPublicHomesKey(),
|
||||
getPublicHomesMarkerSetName(), dynmapApi.getMarkerAPI().getMarkerIcons(), false);
|
||||
}
|
||||
if (plugin.getSettings().doWarpsOnMap()) {
|
||||
if (settings.isShowWarps()) {
|
||||
getMarkerIcon(WARP_MARKER_IMAGE_NAME).orElseThrow();
|
||||
dynmapApi.getMarkerAPI().createMarkerSet(getWarpsKey(),
|
||||
getWarpsMarkerSetName(), dynmapApi.getMarkerAPI().getMarkerIcons(), false);
|
||||
@@ -89,7 +91,7 @@ public class DynmapHook extends MapHook {
|
||||
home.getX(), home.getY(), home.getZ(),
|
||||
getMarkerIcon(PUBLIC_HOME_MARKER_IMAGE_NAME).orElseThrow(), false)
|
||||
.setDescription(MarkerInformationPopup.publicHome(
|
||||
home, ICON_PATH + PUBLIC_HOME_MARKER_IMAGE_NAME, plugin
|
||||
home, ICON_PATH + PUBLIC_HOME_MARKER_IMAGE_NAME
|
||||
).toHtml());
|
||||
});
|
||||
});
|
||||
@@ -135,7 +137,7 @@ public class DynmapHook extends MapHook {
|
||||
warp.getX(), warp.getY(), warp.getZ(),
|
||||
getMarkerIcon(WARP_MARKER_IMAGE_NAME).orElseThrow(), false)
|
||||
.setDescription(MarkerInformationPopup.warp(
|
||||
warp, ICON_PATH + WARP_MARKER_IMAGE_NAME, plugin
|
||||
warp, ICON_PATH + WARP_MARKER_IMAGE_NAME
|
||||
).toHtml());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class EconomyHook extends Hook {
|
||||
*/
|
||||
public final void notifyDeducted(@NotNull OnlineUser user, @NotNull HuskHomes plugin,
|
||||
@NotNull TransactionResolver.Action action) {
|
||||
plugin.getSettings().getEconomyCost(action)
|
||||
plugin.getSettings().getEconomy().getCost(action)
|
||||
.flatMap(cost -> plugin.getLocales().getLocale(
|
||||
"economy_transaction_complete",
|
||||
formatCurrency(cost),
|
||||
@@ -125,7 +125,7 @@ public abstract class EconomyHook extends Hook {
|
||||
* Create an action with a default cost.
|
||||
*
|
||||
* @return the default cost
|
||||
* @deprecated Use the new {@link TransactionResolver.Action#getDefaultCost()} instead
|
||||
* @deprecated Use the new {@code TransactionResolver.Action#getDefaultCost()} instead
|
||||
*/
|
||||
@Deprecated(since = "4.4", forRemoval = true)
|
||||
public double getDefaultCost() {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.SavedPosition;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
@@ -47,12 +48,13 @@ public abstract class MapHook extends Hook {
|
||||
* Populate the map with public homes and warps.
|
||||
*/
|
||||
protected void populateMap() {
|
||||
if (plugin.getSettings().doPublicHomesOnMap()) {
|
||||
final Settings.MapHookSettings settings = plugin.getSettings().getMapHook();
|
||||
if (settings.isShowPublicHomes()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalPublicHomes(plugin)
|
||||
.forEach(this::updateHome);
|
||||
}
|
||||
if (plugin.getSettings().doWarpsOnMap()) {
|
||||
if (settings.isShowWarps()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalWarps(plugin)
|
||||
.forEach(this::updateWarp);
|
||||
@@ -121,14 +123,16 @@ public abstract class MapHook extends Hook {
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
protected final boolean isValidPosition(@NotNull SavedPosition position) {
|
||||
if (position instanceof Warp && !plugin.getSettings().doWarpsOnMap()) {
|
||||
final Settings.MapHookSettings settings = plugin.getSettings().getMapHook();
|
||||
if (position instanceof Warp && !settings.isShowWarps()) {
|
||||
return false;
|
||||
}
|
||||
if (position instanceof Home && !plugin.getSettings().doPublicHomesOnMap()) {
|
||||
if (position instanceof Home && !settings.isShowPublicHomes()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !plugin.getSettings().doCrossServer() || position.getServer().equals(plugin.getServerName());
|
||||
return !plugin.getSettings().getCrossServer().isEnabled()
|
||||
|| position.getServer().equals(plugin.getServerName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -172,22 +176,20 @@ public abstract class MapHook extends Hook {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static DynmapHook.MarkerInformationPopup warp(@NotNull Warp warp, @NotNull String thumbnail,
|
||||
@NotNull HuskHomes plugin) {
|
||||
protected static DynmapHook.MarkerInformationPopup warp(@NotNull Warp warp, @NotNull String thumbnail) {
|
||||
return MarkerInformationPopup.create(warp.getName())
|
||||
.thumbnail(thumbnail)
|
||||
.field("Description", plugin.getLocales().wrapText(warp.getMeta().getDescription(), 60))
|
||||
.field("Description", warp.getMeta().getDescription())
|
||||
.field("Location", warp.toString())
|
||||
.field("Command", "/warp " + warp.getSafeIdentifier());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static DynmapHook.MarkerInformationPopup publicHome(@NotNull Home home, @NotNull String thumbnail,
|
||||
@NotNull HuskHomes plugin) {
|
||||
protected static DynmapHook.MarkerInformationPopup publicHome(@NotNull Home home, @NotNull String thumbnail) {
|
||||
return MarkerInformationPopup.create(home.getName())
|
||||
.thumbnail(thumbnail)
|
||||
.field("Owner", home.getOwner().getUsername())
|
||||
.field("Description", plugin.getLocales().wrapText(home.getMeta().getDescription(), 60))
|
||||
.field("Description", home.getMeta().getDescription())
|
||||
.field("Location", home.toString())
|
||||
.field("Command", "/phome " + home.getSafeIdentifier());
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.pl3x.map.core.markers.option.Popup;
|
||||
import net.pl3x.map.core.markers.option.Tooltip;
|
||||
import net.pl3x.map.core.world.World;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.SavedPosition;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
@@ -126,11 +127,12 @@ public class Pl3xMapHook extends MapHook implements EventListener {
|
||||
}
|
||||
|
||||
private void registerLayers(@NotNull World world) {
|
||||
if (plugin.getSettings().doWarpsOnMap()) {
|
||||
final Settings.MapHookSettings settings = plugin.getSettings().getMapHook();
|
||||
if (settings.isShowWarps()) {
|
||||
WarpsLayer layer = new WarpsLayer(this, world);
|
||||
world.getLayerRegistry().register(layer);
|
||||
}
|
||||
if (plugin.getSettings().doPublicHomesOnMap()) {
|
||||
if (settings.isShowPublicHomes()) {
|
||||
PublicHomesLayer layer = new PublicHomesLayer(this, world);
|
||||
world.getLayerRegistry().register(layer);
|
||||
}
|
||||
@@ -139,10 +141,11 @@ public class Pl3xMapHook extends MapHook implements EventListener {
|
||||
@EventHandler
|
||||
public void onPl3xMapEnabled(@NotNull Pl3xMapEnabledEvent event) {
|
||||
// Register icons
|
||||
if (plugin.getSettings().doWarpsOnMap()) {
|
||||
final Settings.MapHookSettings settings = plugin.getSettings().getMapHook();
|
||||
if (settings.isShowWarps()) {
|
||||
this.registerIcon(WARPS_LAYER, "markers/16x/warp.png");
|
||||
}
|
||||
if (plugin.getSettings().doPublicHomesOnMap()) {
|
||||
if (settings.isShowPublicHomes()) {
|
||||
this.registerIcon(PUBLIC_HOMES_LAYER, "markers/16x/public-home.png");
|
||||
}
|
||||
|
||||
@@ -172,9 +175,9 @@ public class Pl3xMapHook extends MapHook implements EventListener {
|
||||
return Options.builder()
|
||||
.tooltip(new Tooltip(position.getIdentifier()))
|
||||
.popup(new Popup(position instanceof Home home ? MarkerInformationPopup.publicHome(
|
||||
home, ICON_PATH + WARPS_LAYER, plugin
|
||||
home, ICON_PATH + WARPS_LAYER
|
||||
).toHtml() : position instanceof Warp warp ? MarkerInformationPopup.warp(
|
||||
warp, ICON_PATH + PUBLIC_HOMES_LAYER, plugin
|
||||
warp, ICON_PATH + PUBLIC_HOMES_LAYER
|
||||
).toHtml() : ""))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ import com.djrapitops.plan.extension.ExtensionService;
|
||||
import com.djrapitops.plan.extension.annotation.*;
|
||||
import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.icon.Family;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.database.Database;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
@@ -87,18 +90,13 @@ public class PlanHook extends Hook {
|
||||
color = Color.LIGHT_BLUE
|
||||
)
|
||||
@SuppressWarnings("unused")
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
protected static class PlanDataExtension implements DataExtension {
|
||||
|
||||
private static final String UNKNOWN_STRING = "N/A";
|
||||
private Database database;
|
||||
|
||||
protected PlanDataExtension(@NotNull Database database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
protected PlanDataExtension() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallEvents[] callExtensionMethodsOn() {
|
||||
return new CallEvents[]{
|
||||
|
||||
Reference in new issue
Block a user