mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
More command refactoring work
This commit is contained in:
1 parent
4ad77a53c1
commit
9ca141a58f
10 files changed
+116
-395
No files matched your search
@@ -7,9 +7,9 @@ import net.william278.desertwell.Version;
|
||||
import net.william278.huskhomes.command.BukkitCommand;
|
||||
import net.william278.huskhomes.command.Command;
|
||||
import net.william278.huskhomes.command.DisabledCommand;
|
||||
import net.william278.huskhomes.config.Spawn;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.config.Spawn;
|
||||
import net.william278.huskhomes.database.Database;
|
||||
import net.william278.huskhomes.database.MySqlDatabase;
|
||||
import net.william278.huskhomes.database.SqLiteDatabase;
|
||||
@@ -22,21 +22,20 @@ import net.william278.huskhomes.manager.Manager;
|
||||
import net.william278.huskhomes.network.Broker;
|
||||
import net.william278.huskhomes.network.PluginMessageBroker;
|
||||
import net.william278.huskhomes.network.RedisBroker;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.user.ConsoleUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Server;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.random.NormalDistributionEngine;
|
||||
import net.william278.huskhomes.random.RandomTeleportEngine;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.user.ConsoleUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.util.*;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -203,24 +202,19 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, PluginMess
|
||||
// Register commands
|
||||
this.registeredCommands = new ArrayList<>();
|
||||
Arrays.stream(BukkitCommand.Type.values()).forEach(commandType -> {
|
||||
final PluginCommand pluginCommand = getCommand(commandType.getCommand().getName());
|
||||
if (pluginCommand == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the command is disabled, use the disabled CommandBase
|
||||
if (settings.getDisabledCommands().stream().anyMatch(disabledCommand -> {
|
||||
final String command = (disabledCommand.startsWith("/") ? disabledCommand.substring(1) : disabledCommand);
|
||||
return command.equalsIgnoreCase(commandType.getCommand().command) || Arrays.stream(commandType.getCommand().aliases).anyMatch(alias -> alias.equalsIgnoreCase(command));
|
||||
return command.equalsIgnoreCase(commandType.getCommand().getName()) || commandType.getCommand().getAliases().stream().anyMatch(alias -> alias.equalsIgnoreCase(command));
|
||||
})) {
|
||||
new BukkitCommand(new DisabledCommand(this), this).register(pluginCommand);
|
||||
new BukkitCommand(new DisabledCommand(this), this).register();
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, register the command
|
||||
final Command command = commandType.getCommand();
|
||||
this.registeredCommands.add(command);
|
||||
new BukkitCommand(command, this).register(pluginCommand);
|
||||
new BukkitCommand(command, this).register();
|
||||
});
|
||||
log(Level.INFO, "Successfully registered permissions & commands.");
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
* Commands available on the Bukkit HuskHomes implementation
|
||||
*/
|
||||
public enum Type {
|
||||
HOME_COMMAND(new HomeCommand(BukkitHuskHomes.getInstance())),
|
||||
HOME_COMMAND(new PrivateHomeCommand(BukkitHuskHomes.getInstance())),
|
||||
SET_HOME_COMMAND(new SetHomeCommand(BukkitHuskHomes.getInstance())),
|
||||
HOME_LIST_COMMAND(new HomeListCommand(BukkitHuskHomes.getInstance())),
|
||||
DEL_HOME_COMMAND(new DelHomeCommand(BukkitHuskHomes.getInstance())),
|
||||
|
||||
@@ -74,8 +74,8 @@ public class DynMapHook extends MapHook {
|
||||
.setDescription(MarkerInformationPopup.create(home.getMeta().getName())
|
||||
.setThumbnailMarker(PUBLIC_HOME_MARKER_IMAGE_NAME)
|
||||
.addField("Owner", home.getOwner().getUsername())
|
||||
.addField("Description", plugin.getLocales().wrapText(home.getMeta().getDescription()))
|
||||
.addField("Command", "/" + BukkitCommand.Type.PUBLIC_HOME_COMMAND.getCommand().command + " " + home.getMeta().getName())
|
||||
.addField("Description", plugin.getLocales().wrapText(home.getMeta().getDescription(), 60))
|
||||
.addField("Command", "/" + BukkitCommand.Type.PUBLIC_HOME_COMMAND.getCommand().getName() + " " + home.getMeta().getName())
|
||||
.toHtml());
|
||||
updatedFuture.complete(null);
|
||||
}));
|
||||
@@ -120,8 +120,8 @@ public class DynMapHook extends MapHook {
|
||||
warp.getX(), warp.getY(), warp.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(WARP_MARKER_IMAGE_NAME), false)
|
||||
.setDescription(MarkerInformationPopup.create(warp.getMeta().getName())
|
||||
.setThumbnailMarker(WARP_MARKER_IMAGE_NAME)
|
||||
.addField("Description", plugin.getLocales().wrapText(warp.getMeta().getDescription()))
|
||||
.addField("Command", "/" + BukkitCommand.Type.WARP_COMMAND.getCommand().command + " " + warp.getMeta().getName())
|
||||
.addField("Description", plugin.getLocales().wrapText(warp.getMeta().getDescription(), 60))
|
||||
.addField("Command", "/" + BukkitCommand.Type.WARP_COMMAND.getCommand().getName() + " " + warp.getMeta().getName())
|
||||
.toHtml());
|
||||
updatedFuture.complete(null);
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user