mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 13:45:14 +01:00
Fixed some code smells
This commit is contained in:
parent
fc066a04a3
commit
539d2a0516
@ -125,8 +125,6 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
|||||||
// Register command if it is not already registered
|
// Register command if it is not already registered
|
||||||
if (plugin.getCommand(label) == null) {
|
if (plugin.getCommand(label) == null) {
|
||||||
plugin.getCommandsManager().registerCommand(this);
|
plugin.getCommandsManager().registerCommand(this);
|
||||||
// register your completions.
|
|
||||||
//registerCompletions(plugin.getCommodore(), this);
|
|
||||||
}
|
}
|
||||||
// Default references to description and parameters
|
// Default references to description and parameters
|
||||||
setDescription("commands." + label + ".description");
|
setDescription("commands." + label + ".description");
|
||||||
|
@ -47,7 +47,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
|||||||
}
|
}
|
||||||
// Confirm
|
// Confirm
|
||||||
askConfirmation(user, () -> deletePlayer(user, targetUUID));
|
askConfirmation(user, () -> deletePlayer(user, targetUUID));
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deletePlayer(User user, UUID targetUUID) {
|
private void deletePlayer(User user, UUID targetUUID) {
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package world.bentobox.bentobox.api.commands.island;
|
package world.bentobox.bentobox.api.commands.island;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -154,20 +154,10 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
*/
|
*/
|
||||||
// Check if there is a ConfigEntry annotation on the field
|
// Check if there is a ConfigEntry annotation on the field
|
||||||
ConfigEntry configEntry = field.getAnnotation(ConfigEntry.class);
|
ConfigEntry configEntry = field.getAnnotation(ConfigEntry.class);
|
||||||
boolean overrideOnChange = false;
|
|
||||||
boolean experimental = false;
|
|
||||||
boolean needsReset = false;
|
|
||||||
|
|
||||||
// If there is a config annotation then do something
|
// If there is a config annotation then do something
|
||||||
if (configEntry != null && !configEntry.path().isEmpty()) {
|
if (configEntry != null && !configEntry.path().isEmpty()) {
|
||||||
storageLocation = configEntry.path();
|
storageLocation = configEntry.path();
|
||||||
// TODO: Not sure what to do with this one
|
|
||||||
overrideOnChange = configEntry.overrideOnChange();
|
|
||||||
// TODO: Not sure what to do with this one
|
|
||||||
experimental = configEntry.experimental();
|
|
||||||
// If this value has changed, then the addon will need a full reset
|
|
||||||
// TODO: Inform addon if this value is different to a value stored in the database?
|
|
||||||
needsReset = configEntry.needsReset();
|
|
||||||
}
|
}
|
||||||
// Some fields need custom handling to serialize or deserialize and the programmer will need to
|
// Some fields need custom handling to serialize or deserialize and the programmer will need to
|
||||||
// define them herself. She can add an annotation to do that.
|
// define them herself. She can add an annotation to do that.
|
||||||
|
@ -54,10 +54,6 @@ public class Flags {
|
|||||||
// Disabled setting 'rank'
|
// Disabled setting 'rank'
|
||||||
private static final int DISABLED = -1;
|
private static final int DISABLED = -1;
|
||||||
|
|
||||||
// TODO: add ELYTRA
|
|
||||||
// TODO: add FISHING
|
|
||||||
// TODO: add KEEP_INVENTORY - is it needed?
|
|
||||||
|
|
||||||
public static final Flag BREAK_BLOCKS = new FlagBuilder().id("BREAK_BLOCKS").icon(Material.STONE).listener(new BreakBlocksListener()).build();
|
public static final Flag BREAK_BLOCKS = new FlagBuilder().id("BREAK_BLOCKS").icon(Material.STONE).listener(new BreakBlocksListener()).build();
|
||||||
public static final Flag PLACE_BLOCKS = new FlagBuilder().id("PLACE_BLOCKS").icon(Material.GRASS).listener(new PlaceBlocksListener()).build();
|
public static final Flag PLACE_BLOCKS = new FlagBuilder().id("PLACE_BLOCKS").icon(Material.GRASS).listener(new PlaceBlocksListener()).build();
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package world.bentobox.bentobox.managers;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -11,7 +12,7 @@ import world.bentobox.bentobox.api.commands.CompositeCommand;
|
|||||||
|
|
||||||
public class CommandsManager {
|
public class CommandsManager {
|
||||||
|
|
||||||
private HashMap<String, CompositeCommand> commands = new HashMap<>();
|
private Map<String, CompositeCommand> commands = new HashMap<>();
|
||||||
|
|
||||||
public void registerCommand(CompositeCommand command) {
|
public void registerCommand(CompositeCommand command) {
|
||||||
commands.put(command.getLabel(), command);
|
commands.put(command.getLabel(), command);
|
||||||
@ -36,6 +37,13 @@ public class CommandsManager {
|
|||||||
return commands.get(command);
|
return commands.get(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the commands
|
||||||
|
*/
|
||||||
|
public Map<String, CompositeCommand> getCommands() {
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all commands registered so far
|
* List all commands registered so far
|
||||||
* @return set of commands
|
* @return set of commands
|
||||||
@ -44,11 +52,4 @@ public class CommandsManager {
|
|||||||
return commands.keySet();
|
return commands.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the commands
|
|
||||||
*/
|
|
||||||
public HashMap<String, CompositeCommand> getCommands() {
|
|
||||||
return commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ public class LocalesManager {
|
|||||||
|
|
||||||
public LocalesManager(BentoBox plugin) {
|
public LocalesManager(BentoBox plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
copyLocalesFromJar("BentoBox");
|
copyLocalesFromJar(plugin.getName());
|
||||||
loadLocalesFromFile("BentoBox"); // Default
|
loadLocalesFromFile(plugin.getName()); // Default
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,7 +157,7 @@ public class LocalesManager {
|
|||||||
*/
|
*/
|
||||||
public void reloadLanguages() {
|
public void reloadLanguages() {
|
||||||
languages.clear();
|
languages.clear();
|
||||||
loadLocalesFromFile("BentoBox");
|
loadLocalesFromFile(plugin.getName());
|
||||||
plugin.getAddonsManager().getAddons().forEach(addon -> loadLocalesFromFile(addon.getDescription().getName()));
|
plugin.getAddonsManager().getAddons().forEach(addon -> loadLocalesFromFile(addon.getDescription().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package world.bentobox.bentobox.api.commands.admin;
|
package world.bentobox.bentobox.api.commands.admin;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ -188,7 +189,7 @@ public class AdminDeleteCommandTest {
|
|||||||
|
|
||||||
AdminDeleteCommand itl = new AdminDeleteCommand(ac);
|
AdminDeleteCommand itl = new AdminDeleteCommand(ac);
|
||||||
// First requires confirmation
|
// First requires confirmation
|
||||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.confirmation.confirm", "[seconds]", "0");
|
Mockito.verify(user).sendMessage("commands.confirmation.confirm", "[seconds]", "0");
|
||||||
// Confirm
|
// Confirm
|
||||||
itl.execute(user, itl.getLabel(), Arrays.asList(name));
|
itl.execute(user, itl.getLabel(), Arrays.asList(name));
|
||||||
|
Loading…
Reference in New Issue
Block a user