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:
William authored and GitHub committed 2023-07-02 13:26:12 +01:00
1 parent 51baf196b3
commit c9f5262292
219 files changed
+8032 -1392

No files matched your search

@@ -61,17 +61,25 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Represents a cross-platform instance of the plugin
* Represents a cross-platform instance of the plugin.
*/
public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolver, TransactionResolver {
/**
* The spigot resource ID, used for update checking.
*/
int SPIGOT_RESOURCE_ID = 83767;
/**
* Get the user representing the server console.
*
* @return the {@link ConsoleUser}
*/
@NotNull
ConsoleUser getConsole();
/**
* The {@link Set} of online {@link OnlineUser}s on this server
* The {@link Set} of online {@link OnlineUser}s on this server.
*
* @return a {@link Set} of currently online {@link OnlineUser}s
*/
@@ -121,7 +129,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
}
/**
* Initialize a faucet of the plugin
* Initialize a faucet of the plugin.
*
* @param name the name of the faucet
* @param runner a runnable for initializing the faucet
@@ -137,7 +145,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
}
/**
* The plugin {@link Settings} loaded from file
* The plugin {@link Settings} loaded from file.
*
* @return the plugin {@link Settings}
*/
@@ -147,7 +155,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
void setSettings(@NotNull Settings settings);
/**
* The plugin messages loaded from file
* The plugin messages loaded from file.
*
* @return The plugin {@link Locales}
*/
@@ -157,17 +165,29 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
void setLocales(@NotNull Locales locales);
/**
* The local {@link Spawn} location of this server, as cached to disk
* The local {@link Spawn} location of this server, as cached to disk.
*
* @return the {@link Spawn} location data
* @see #getSpawn() for the canonical spawn point to use
*/
Optional<Spawn> getServerSpawn();
/**
* Update the local {@link Spawn} config file.
*
* @param spawn the new {@link Spawn} data
*/
void setServerSpawn(@NotNull Spawn spawn);
/**
* The canonical spawn {@link Position} of this server, if it has been set
* Update the {@link Spawn} position to a location on the server.
*
* @param location the new {@link Spawn} location
*/
void setServerSpawn(@NotNull Location location);
/**
* The canonical spawn {@link Position} of this server, if it has been set.
*
* @return the {@link Position} of the spawn, or an empty {@link Optional} if it has not been set
*/
@@ -178,7 +198,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
}
/**
* Returns the {@link Server} the plugin is on
* Returns the {@link Server} the plugin is on.
*
* @return The {@link Server} object
*/
@@ -193,7 +213,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
UnsafeBlocks getUnsafeBlocks();
/**
* The {@link Database} that store persistent plugin data
* The {@link Database} that store persistent plugin data.
*
* @return the {@link Database} implementation for accessing data
*/
@@ -201,7 +221,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
Database getDatabase();
/**
* The {@link Validator} for validating home names and descriptions
* The {@link Validator} for validating home names and descriptions.
*
* @return the {@link Validator} instance
*/
@@ -209,7 +229,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
Validator getValidator();
/**
* The {@link Manager} that manages home, warp and user data
* The {@link Manager} that manages home, warp and user data.
*
* @return the {@link Manager} implementation
*/
@@ -217,7 +237,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
Manager getManager();
/**
* The {@link Broker} that sends cross-network messages
* The {@link Broker} that sends cross-network messages.
*
* @return the {@link Broker} implementation
*/
@@ -225,7 +245,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
Broker getMessenger();
/**
* The {@link RandomTeleportEngine} that manages random teleports
* The {@link RandomTeleportEngine} that manages random teleports.
*
* @return the {@link RandomTeleportEngine} implementation
*/
@@ -233,22 +253,14 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
RandomTeleportEngine getRandomTeleportEngine();
/**
* Sets the {@link RandomTeleportEngine} to be used for processing random teleports
* Sets the {@link RandomTeleportEngine} to be used for processing random teleports.
*
* @param randomTeleportEngine the {@link RandomTeleportEngine} to use
*/
void setRandomTeleportEngine(@NotNull RandomTeleportEngine randomTeleportEngine);
/**
* Update the {@link Spawn} position to a location on the server
*
* @param location the new {@link Spawn} location
*/
void setServerSpawn(@NotNull Location location);
/**
* Set of active {@link Hook}s running on the server
* Set of active {@link Hook}s running on the server.
*
* @return the {@link Set} of active {@link Hook}s
*/
@@ -277,7 +289,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
}
/**
* Returns a resource read from the plugin resources folder
* Returns a resource read from the plugin resources folder.
*
* @param name the name of the resource
* @return the resource read as an {@link InputStream}
@@ -286,7 +298,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
InputStream getResource(@NotNull String name);
/**
* Returns the plugin data folder containing the plugin config, etc
* Returns the plugin data folder containing the plugin config, etc.
*
* @return the plugin data folder
*/
@@ -294,7 +306,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
File getDataFolder();
/**
* Returns a list of worlds on the server
* Returns a list of worlds on the server.
*
* @return a list of worlds on the server
*/
@@ -302,7 +314,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
List<World> getWorlds();
/**
* Returns the plugin version
* Returns the plugin version.
*
* @return the plugin {@link Version}
*/
@@ -310,7 +322,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
Version getVersion();
/**
* Returns a list of enabled commands
* Returns a list of enabled commands.
*
* @return A list of registered and enabled {@link Command}s
*/
@@ -396,7 +408,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
}
/**
* Reloads the {@link Settings} and {@link Locales} from their respective config files
* Reloads the {@link Settings} and {@link Locales} from their respective config files.
*
* @return {@code true} if the reload was successful, {@code false} otherwise
*/
@@ -407,8 +419,14 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
setSettings(Annotaml.create(new File(getDataFolder(), "config.yml"), Settings.class).get());
// Load locales from language preset default
final Locales languagePresets = Annotaml.create(Locales.class, Objects.requireNonNull(getResource("locales/" + getSettings().getLanguage() + ".yml"))).get();
setLocales(Annotaml.create(new File(getDataFolder(), "messages_" + getSettings().getLanguage() + ".yml"), languagePresets).get());
final Locales languagePresets = Annotaml.create(
Locales.class,
Objects.requireNonNull(getResource("locales/" + getSettings().getLanguage() + ".yml"))
).get();
setLocales(Annotaml.create(new File(
getDataFolder(),
"messages_" + getSettings().getLanguage() + ".yml"
), languagePresets).get());
// Load server from file
if (getSettings().doCrossServer()) {
@@ -448,26 +466,26 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
getUpdateChecker().check().thenAccept(checked -> {
if (!checked.isUpToDate()) {
log(Level.WARNING, "A new version of HuskHomes is available: v"
+ checked.getLatestVersion() + " (running v" + getVersion() + ")");
+ checked.getLatestVersion() + " (running v" + getVersion() + ")");
}
});
}
}
/**
* Registers the plugin with bStats metrics
* Registers the plugin with bStats metrics.
*
* @param metricsId the bStats id for the plugin
*/
void registerMetrics(int metricsId);
/**
* Initialize plugin messaging channels
* Initialize plugin messaging channels.
*/
void initializePluginChannels();
/**
* Log a message to the console
* Log a message to the console.
*
* @param level the level to log at
* @param message the message to log
@@ -476,7 +494,7 @@ public interface HuskHomes extends Task.Supplier, EventDispatcher, SafetyResolve
void log(@NotNull Level level, @NotNull String message, Throwable... exceptions);
/**
* Create a resource key namespaced with the plugin id
* Create a resource key namespaced with the plugin id.
*
* @param data the string ID elements to join
* @return the key