mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
Port to adventure and MineDown-adventure
This commit is contained in:
1 parent
c56936d9d5
commit
98c2461c89
17 files changed
+60
-48
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.william278.annotaml.Annotaml;
|
||||
import net.william278.desertwell.Version;
|
||||
import net.william278.huskhomes.command.BukkitCommand;
|
||||
@@ -84,6 +85,9 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
@Nullable
|
||||
private Server server;
|
||||
|
||||
// Adventure audience
|
||||
private BukkitAudiences audiences;
|
||||
|
||||
// Instance of the plugin
|
||||
private static BukkitHuskHomes instance;
|
||||
|
||||
@@ -106,6 +110,9 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
this.logger = new BukkitLogger(getLogger());
|
||||
this.resourceReader = new BukkitResourceReader(this);
|
||||
|
||||
// Create adventure audience
|
||||
this.audiences = BukkitAudiences.create(this);
|
||||
|
||||
// Detect if an upgrade is needed
|
||||
final BukkitUpgradeUtil upgradeData = BukkitUpgradeUtil.detect(this);
|
||||
|
||||
@@ -134,7 +141,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
getLoggingAdapter().log(Level.INFO, "Successfully established a connection to the database");
|
||||
} else {
|
||||
throw new HuskHomesInitializationException("Failed to establish a connection to the database. " +
|
||||
"Please check the supplied database credentials in the config file");
|
||||
"Please check the supplied database credentials in the config file");
|
||||
}
|
||||
|
||||
// Initialize the network messenger if proxy mode is enabled
|
||||
@@ -196,8 +203,8 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
if (pluginHooks.size() > 0) {
|
||||
pluginHooks.forEach(PluginHook::initialize);
|
||||
getLoggingAdapter().log(Level.INFO, "Registered " + pluginHooks.size() + " plugin hooks: " +
|
||||
pluginHooks.stream().map(PluginHook::getHookName)
|
||||
.collect(Collectors.joining(", ")));
|
||||
pluginHooks.stream().map(PluginHook::getHookName)
|
||||
.collect(Collectors.joining(", ")));
|
||||
}
|
||||
|
||||
// Register events
|
||||
@@ -227,8 +234,8 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
if (settings.disabledCommands.stream().anyMatch(disabledCommand -> {
|
||||
final String command = (disabledCommand.startsWith("/") ? disabledCommand.substring(1) : disabledCommand);
|
||||
return command.equalsIgnoreCase(commandType.commandBase.command) ||
|
||||
Arrays.stream(commandType.commandBase.aliases)
|
||||
.anyMatch(alias -> alias.equalsIgnoreCase(command));
|
||||
Arrays.stream(commandType.commandBase.aliases)
|
||||
.anyMatch(alias -> alias.equalsIgnoreCase(command));
|
||||
})) {
|
||||
new BukkitCommand(new DisabledCommand(this), this).register(pluginCommand);
|
||||
return;
|
||||
@@ -255,7 +262,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
getLatestVersionIfOutdated().thenAccept(newestVersion ->
|
||||
newestVersion.ifPresent(newVersion -> getLoggingAdapter().log(Level.WARNING,
|
||||
"An update is available for HuskHomes, v" + newVersion
|
||||
+ " (Currently running v" + getPluginVersion() + ")")));
|
||||
+ " (Currently running v" + getPluginVersion() + ")")));
|
||||
}
|
||||
|
||||
// Perform automatic upgrade if detected
|
||||
@@ -297,6 +304,19 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
if (networkMessenger != null) {
|
||||
networkMessenger.terminate();
|
||||
}
|
||||
if (audiences != null) {
|
||||
audiences.close();
|
||||
audiences = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the adventure Bukkit audiences
|
||||
*
|
||||
* @return The adventure Bukkit audiences
|
||||
*/
|
||||
public BukkitAudiences getAudiences() {
|
||||
return audiences;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in new issue
Block a user