mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-19 22:02:37 +01:00
Fixed some code smells
This commit is contained in:
parent
4b9d0edd97
commit
faba022a7b
@ -1,6 +1,5 @@
|
|||||||
package world.bentobox.bentobox.api.commands.admin;
|
package world.bentobox.bentobox.api.commands.admin;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
@ -17,36 +16,31 @@ import world.bentobox.bentobox.api.commands.admin.team.AdminTeamSetownerCommand;
|
|||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is default Admin command for console and op. It contains all necessary parts that
|
* This is default Admin command for console and op. It contains all necessary parts that
|
||||||
* for main command.
|
* for main command.
|
||||||
* @since 1.13.0
|
* @since 1.13.0
|
||||||
* @author BONNe
|
* @author BONNe
|
||||||
*/
|
*/
|
||||||
public abstract class DefaultAdminCommand extends CompositeCommand
|
public abstract class DefaultAdminCommand extends CompositeCommand {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* This is the top-level command constructor for commands that have no parent.
|
* This is the top-level command constructor for commands that have no parent.
|
||||||
*
|
*
|
||||||
* @param addon - GameMode addon
|
* @param addon - GameMode addon
|
||||||
*/
|
*/
|
||||||
public DefaultAdminCommand(GameModeAddon addon)
|
public DefaultAdminCommand(GameModeAddon addon) {
|
||||||
{
|
|
||||||
// Register command with alias from config.
|
// Register command with alias from config.
|
||||||
super(addon,
|
super(addon,
|
||||||
addon.getWorldSettings().getAdminCommandAliases().split(" ")[0],
|
addon.getWorldSettings().getAdminCommandAliases().split(" ")[0],
|
||||||
addon.getWorldSettings().getAdminCommandAliases().split(" "));
|
addon.getWorldSettings().getAdminCommandAliases().split(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setups anything that is necessary for default main admin command.
|
* Setups anything that is necessary for default main admin command.
|
||||||
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#setup()
|
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#setup()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setup()
|
public void setup() {
|
||||||
{
|
|
||||||
this.setPermission("admin.*");
|
this.setPermission("admin.*");
|
||||||
this.setOnlyPlayer(false);
|
this.setOnlyPlayer(false);
|
||||||
|
|
||||||
@ -88,10 +82,6 @@ public abstract class DefaultAdminCommand extends CompositeCommand
|
|||||||
new AdminSetSpawnPointCommand(this);
|
new AdminSetSpawnPointCommand(this);
|
||||||
// Reset flags
|
// Reset flags
|
||||||
new AdminResetFlagsCommand(this);
|
new AdminResetFlagsCommand(this);
|
||||||
// Trash
|
|
||||||
//new AdminTrashCommand(this);
|
|
||||||
//new AdminEmptyTrashCommand(this);
|
|
||||||
//new AdminSwitchtoCommand(this);
|
|
||||||
// Switch
|
// Switch
|
||||||
new AdminSwitchCommand(this);
|
new AdminSwitchCommand(this);
|
||||||
// Purge
|
// Purge
|
||||||
@ -100,16 +90,13 @@ public abstract class DefaultAdminCommand extends CompositeCommand
|
|||||||
new AdminSettingsCommand(this);
|
new AdminSettingsCommand(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines what will be executed when this command is run.
|
* Defines what will be executed when this command is run.
|
||||||
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#execute(User, String, List<String>)
|
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#execute(User, String, List<String>)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, String label, List<String> args)
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
{
|
if (user != null && !args.isEmpty()) {
|
||||||
if (user != null && !args.isEmpty())
|
|
||||||
{
|
|
||||||
user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getTopLabel());
|
user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getTopLabel());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class JSONDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> saveObject(T instance) throws IntrospectionException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public CompletableFuture<Boolean> saveObject(T instance) throws IntrospectionException, IllegalAccessException, InvocationTargetException {
|
||||||
CompletableFuture<Boolean> completableFuture = new CompletableFuture<>();
|
CompletableFuture<Boolean> completableFuture = new CompletableFuture<>();
|
||||||
// Null check
|
// Null check
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
|
@ -194,7 +194,7 @@ public class AddonsManager {
|
|||||||
String desc = perms.getString(perm + ".description");
|
String desc = perms.getString(perm + ".description");
|
||||||
// Replace placeholders for Game Mode Addon names
|
// Replace placeholders for Game Mode Addon names
|
||||||
if (perm.contains(GAMEMODE)) {
|
if (perm.contains(GAMEMODE)) {
|
||||||
getGameModeAddons().stream().map(g -> g.getPermissionPrefix())
|
getGameModeAddons().stream().map(Addon::getPermissionPrefix)
|
||||||
.forEach(p -> DefaultPermissions.registerPermission(perm.replace(GAMEMODE, p), desc, pd));
|
.forEach(p -> DefaultPermissions.registerPermission(perm.replace(GAMEMODE, p), desc, pd));
|
||||||
} else {
|
} else {
|
||||||
// Single perm
|
// Single perm
|
||||||
|
Loading…
Reference in New Issue
Block a user