mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
Add fabric builds for older MC versions & add checkstyle (#449)
* Remove instance getters, improve command logic, register APi * Publish multiple fabric builds, enforce checkstyle * Bump guava * Bump to 4.4.2
This commit is contained in:
1 parent
51baf196b3
commit
c9f5262292
219 files changed
+8032
-1392
No files matched your search
@@ -44,7 +44,7 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Hook to display warps and public homes on <a href="https://github.com/BlueMap-Minecraft/BlueMap">BlueMap</a> maps
|
||||
* Hook to display warps and public homes on <a href="https://github.com/BlueMap-Minecraft/BlueMap">BlueMap</a> maps.
|
||||
*/
|
||||
public class BlueMapHook extends MapHook {
|
||||
|
||||
@@ -63,15 +63,15 @@ public class BlueMapHook extends MapHook {
|
||||
|
||||
for (World world : plugin.getWorlds()) {
|
||||
this.editMapWorld(world, (mapWorld -> {
|
||||
final MarkerSet publicHomeMarkers = MarkerSet.builder().label(getPublicHomesMarkerSetName()).build();
|
||||
final MarkerSet homeMarkers = MarkerSet.builder().label(getPublicHomesMarkerSetName()).build();
|
||||
final MarkerSet warpsMarkers = MarkerSet.builder().label(getWarpsMarkerSetName()).build();
|
||||
|
||||
for (BlueMapMap map : mapWorld.getMaps()) {
|
||||
map.getMarkerSets().put(getPublicHomesKey(), publicHomeMarkers);
|
||||
map.getMarkerSets().put(getPublicHomesKey(), homeMarkers);
|
||||
map.getMarkerSets().put(getWarpsKey(), warpsMarkers);
|
||||
}
|
||||
|
||||
publicHomesMarkerSets.put(world.getName(), publicHomeMarkers);
|
||||
publicHomesMarkerSets.put(world.getName(), homeMarkers);
|
||||
warpsMarkerSets.put(world.getName(), warpsMarkers);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Hook to display warps and public homes on Dynmap
|
||||
* Hook to display warps and public homes on Dynmap.
|
||||
*/
|
||||
public class DynmapHook extends MapHook {
|
||||
|
||||
@@ -171,8 +171,12 @@ public class DynmapHook extends MapHook {
|
||||
return getDynmap().map(api -> {
|
||||
publicHomesMarkers = api.getMarkerAPI().getMarkerSet(getPublicHomesKey());
|
||||
if (publicHomesMarkers == null) {
|
||||
publicHomesMarkers = api.getMarkerAPI().createMarkerSet(getPublicHomesKey(), getPublicHomesMarkerSetName(),
|
||||
api.getMarkerAPI().getMarkerIcons(), false);
|
||||
publicHomesMarkers = api.getMarkerAPI().createMarkerSet(
|
||||
getPublicHomesKey(),
|
||||
getPublicHomesMarkerSetName(),
|
||||
api.getMarkerAPI().getMarkerIcons(),
|
||||
false
|
||||
);
|
||||
} else {
|
||||
publicHomesMarkers.setMarkerSetLabel(getPublicHomesMarkerSetName());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A hook that provides economy features
|
||||
* A hook that provides economy features.
|
||||
*/
|
||||
public abstract class EconomyHook extends Hook {
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class EconomyHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the balance of a player
|
||||
* Get the balance of a player.
|
||||
*
|
||||
* @param player the player to get the balance of
|
||||
* @return the balance of the player
|
||||
@@ -45,7 +45,7 @@ public abstract class EconomyHook extends Hook {
|
||||
public abstract double getPlayerBalance(@NotNull OnlineUser player);
|
||||
|
||||
/**
|
||||
* Set the balance of a player
|
||||
* Set the balance of a player.
|
||||
*
|
||||
* @param player the player to set the balance of
|
||||
* @param amount the amount to set the balance to
|
||||
@@ -53,7 +53,7 @@ public abstract class EconomyHook extends Hook {
|
||||
public abstract void changePlayerBalance(@NotNull OnlineUser player, final double amount);
|
||||
|
||||
/**
|
||||
* Format a balance to a string
|
||||
* Format a balance to a string.
|
||||
*
|
||||
* @param amount the amount to format
|
||||
* @return the formatted string
|
||||
@@ -61,14 +61,14 @@ public abstract class EconomyHook extends Hook {
|
||||
public abstract String formatCurrency(final double amount);
|
||||
|
||||
/**
|
||||
* Send the player a message notifying them that they have been charged
|
||||
* for performing an action
|
||||
* Send the player a message notifying them that they have been charged for performing an action.
|
||||
*
|
||||
* @param user the user to notify
|
||||
* @param plugin the plugin instance
|
||||
* @param action the action that was performed
|
||||
*/
|
||||
public final void notifyDeducted(@NotNull OnlineUser user, @NotNull HuskHomes plugin, @NotNull TransactionResolver.Action action) {
|
||||
public final void notifyDeducted(@NotNull OnlineUser user, @NotNull HuskHomes plugin,
|
||||
@NotNull TransactionResolver.Action action) {
|
||||
plugin.getSettings().getEconomyCost(action)
|
||||
.flatMap(cost -> plugin.getLocales().getLocale(
|
||||
"economy_transaction_complete",
|
||||
@@ -81,14 +81,12 @@ public abstract class EconomyHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the player a message notifying them that they have been charged
|
||||
* for performing an action
|
||||
* Send the player a message notifying them that they have been charged for performing an action.
|
||||
*
|
||||
* @param user the user to notify
|
||||
* @param plugin the plugin instance
|
||||
* @param action the action that was performed
|
||||
* @deprecated See {@link #notifyDeducted(OnlineUser, HuskHomes, TransactionResolver.Action)} instead,
|
||||
* using the new {@link TransactionResolver.Action} enum
|
||||
* @deprecated See {@link #notifyDeducted(OnlineUser, HuskHomes, TransactionResolver.Action)} instead
|
||||
*/
|
||||
@Deprecated(since = "4.4", forRemoval = true)
|
||||
public final void notifyDeducted(@NotNull OnlineUser user, @NotNull HuskHomes plugin, @NotNull Action action) {
|
||||
@@ -96,7 +94,7 @@ public abstract class EconomyHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Economy actions for which a player can be charged
|
||||
* Economy actions for which a player can be charged.
|
||||
*
|
||||
* @deprecated Use the new {@link TransactionResolver.Action} enum instead
|
||||
*/
|
||||
@@ -124,7 +122,7 @@ public abstract class EconomyHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an action with a default cost
|
||||
* Create an action with a default cost.
|
||||
*
|
||||
* @return the default cost
|
||||
* @deprecated Use the new {@link TransactionResolver.Action#getDefaultCost()} instead
|
||||
@@ -135,7 +133,7 @@ public abstract class EconomyHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate this legacy Action to the new {@link TransactionResolver.Action}
|
||||
* Translate this legacy Action to the new {@link TransactionResolver.Action}.
|
||||
*
|
||||
* @return the equivalent {@link TransactionResolver.Action}
|
||||
*/
|
||||
|
||||
@@ -23,22 +23,22 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A plugin hook, where HuskHomes hooks into another plugin
|
||||
* A plugin hook, where HuskHomes hooks into another plugin.
|
||||
*/
|
||||
public abstract class Hook {
|
||||
|
||||
/**
|
||||
* The plugin that this hook is for
|
||||
* The plugin that this hook is for.
|
||||
*/
|
||||
protected final HuskHomes plugin;
|
||||
|
||||
/**
|
||||
* The name of the hook
|
||||
* The name of the hook.
|
||||
*/
|
||||
protected final String name;
|
||||
|
||||
/**
|
||||
* Construct a new {@link Hook}
|
||||
* Construct a new {@link Hook}.
|
||||
*
|
||||
* @param plugin the {@link HuskHomes} instance
|
||||
*/
|
||||
@@ -48,14 +48,18 @@ public abstract class Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the hook and return {@code true} if it could be enabled
|
||||
* Initialize the hook and return {@code true} if it could be enabled.
|
||||
*/
|
||||
public abstract void initialize() ;
|
||||
public abstract void initialize();
|
||||
|
||||
/**
|
||||
* Get the name of the hook.
|
||||
*
|
||||
* @return the name of the hook
|
||||
*/
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A hook for a mapping plugin, such as Dynmap
|
||||
* A hook for a mapping plugin, such as Dynmap.
|
||||
*/
|
||||
public abstract class MapHook extends Hook {
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class MapHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the map with public homes and warps
|
||||
* Populate the map with public homes and warps.
|
||||
*/
|
||||
protected void populateMap() {
|
||||
if (plugin.getSettings().doPublicHomesOnMap()) {
|
||||
@@ -60,47 +60,47 @@ public abstract class MapHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a home, adding it to the map if it exists, or updating it on the map if it doesn't
|
||||
* Update a home, adding it to the map if it exists, or updating it on the map if it doesn't.
|
||||
*
|
||||
* @param home the home to update
|
||||
*/
|
||||
public abstract void updateHome(@NotNull Home home);
|
||||
|
||||
/**
|
||||
* Removes a home from the map
|
||||
* Removes a home from the map.
|
||||
*
|
||||
* @param home the home to remove
|
||||
*/
|
||||
public abstract void removeHome(@NotNull Home home);
|
||||
|
||||
/**
|
||||
* Clears homes owned by a player from the map
|
||||
* Clears homes owned by a player from the map.
|
||||
*
|
||||
* @param user the player whose homes to clear
|
||||
*/
|
||||
public abstract void clearHomes(@NotNull User user);
|
||||
|
||||
/**
|
||||
* Update a warp, adding it to the map if it exists, or updating it on the map if it doesn't
|
||||
* Update a warp, adding it to the map if it exists, or updating it on the map if it doesn't.
|
||||
*
|
||||
* @param warp the warp to update
|
||||
*/
|
||||
public abstract void updateWarp(@NotNull Warp warp);
|
||||
|
||||
/**
|
||||
* Removes a warp from the map
|
||||
* Removes a warp from the map.
|
||||
*
|
||||
* @param warp the warp to remove
|
||||
*/
|
||||
public abstract void removeWarp(@NotNull Warp warp);
|
||||
|
||||
/**
|
||||
* Clears all warps from the map
|
||||
* Clears all warps from the map.
|
||||
*/
|
||||
public abstract void clearWarps();
|
||||
|
||||
/**
|
||||
* Returns if the position is valid to be set on this server
|
||||
* Returns if the position is valid to be set on this server.
|
||||
*
|
||||
* @param position the position to check
|
||||
* @return if the position is valid
|
||||
@@ -140,7 +140,7 @@ public abstract class MapHook extends Hook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML Dynmap marker information popup widget
|
||||
* Creates an HTML Dynmap marker information popup widget.
|
||||
*/
|
||||
protected static class MarkerInformationPopup {
|
||||
@NotNull
|
||||
@@ -158,7 +158,8 @@ 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,
|
||||
@NotNull HuskHomes plugin) {
|
||||
return MarkerInformationPopup.create(warp.getName())
|
||||
.thumbnail(thumbnail)
|
||||
.field("Description", plugin.getLocales().wrapText(warp.getMeta().getDescription(), 60))
|
||||
@@ -167,7 +168,8 @@ public abstract class MapHook extends Hook {
|
||||
}
|
||||
|
||||
@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,
|
||||
@NotNull HuskHomes plugin) {
|
||||
return MarkerInformationPopup.create(home.getName())
|
||||
.thumbnail(thumbnail)
|
||||
.field("Owner", home.getOwner().getUsername())
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Hooks into Plan to provide the {@link PlanDataExtension} with stats on the web panel
|
||||
* Hooks into Plan to provide the {@link PlanDataExtension} with stats on the web panel.
|
||||
*/
|
||||
public class PlanHook extends Hook {
|
||||
|
||||
@@ -66,12 +66,8 @@ public class PlanHook extends Hook {
|
||||
private void registerDataExtension() {
|
||||
try {
|
||||
ExtensionService.getInstance().register(new PlanDataExtension(plugin.getDatabase()));
|
||||
} catch (IllegalStateException planIsNotEnabled) {
|
||||
plugin.log(Level.SEVERE, "Plan extension hook failed to register. Plan is not enabled.", planIsNotEnabled);
|
||||
// Plan is not enabled, handle exception
|
||||
} catch (IllegalArgumentException dataExtensionImplementationIsInvalid) {
|
||||
plugin.log(Level.SEVERE, "Plan extension hook failed to register. Data hook implementation is invalid.", dataExtensionImplementationIsInvalid);
|
||||
// The DataExtension implementation has an implementation error, handle exception
|
||||
} catch (IllegalStateException | IllegalArgumentException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to register HuskHomes Plan extension", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user