mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-03-01 18:51:08 +01:00
Fixes code smells.
This commit is contained in:
parent
9798edebd5
commit
d6248a3577
@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||||
@ -14,6 +15,7 @@ import world.bentobox.bentobox.database.objects.Island;
|
|||||||
public class AdminSwitchtoCommand extends ConfirmableCommand {
|
public class AdminSwitchtoCommand extends ConfirmableCommand {
|
||||||
|
|
||||||
private UUID targetUUID;
|
private UUID targetUUID;
|
||||||
|
private @NonNull List<Island> islands;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch player's island to the numbered one in trash
|
* Switch player's island to the numbered one in trash
|
||||||
@ -45,18 +47,17 @@ public class AdminSwitchtoCommand extends ConfirmableCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Check island number
|
||||||
|
islands = getIslands().getQuarantinedIslandByUser(getWorld(), targetUUID);
|
||||||
|
if (islands.isEmpty()) {
|
||||||
|
user.sendMessage("commands.admin.trash.no-islands-in-trash");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, String label, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// Check island number
|
|
||||||
List<Island> islands = getIslands().getQuarantinedIslandByUser(getWorld(), targetUUID);
|
|
||||||
if (islands.isEmpty()) {
|
|
||||||
user.sendMessage("commands.admin.trash.no-islands-in-trash");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
// Check number
|
|
||||||
if (NumberUtils.isDigits(args.get(1))) {
|
if (NumberUtils.isDigits(args.get(1))) {
|
||||||
try {
|
try {
|
||||||
Integer n = Integer.valueOf(args.get(1));
|
Integer n = Integer.valueOf(args.get(1));
|
||||||
@ -77,7 +78,6 @@ public class AdminSwitchtoCommand extends ConfirmableCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,19 +29,22 @@ import world.bentobox.bentobox.lists.Flags;
|
|||||||
*/
|
*/
|
||||||
public class BlockInteractionListener extends FlagListener {
|
public class BlockInteractionListener extends FlagListener {
|
||||||
|
|
||||||
|
private static final String FURNACE = "FURNACE";
|
||||||
|
private static final String CRAFTING = "CRAFTING";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These cover materials in another server version.
|
* These cover materials in another server version.
|
||||||
* This avoids run time errors due to unknown enum values, at the expense of a string comparison
|
* This avoids run time errors due to unknown enum values, at the expense of a string comparison
|
||||||
*/
|
*/
|
||||||
private final Map<String, String> stringFlags = ImmutableMap.<String, String>builder()
|
private final Map<String, String> stringFlags = ImmutableMap.<String, String>builder()
|
||||||
.put("CAMPFIRE", "FURNACE")
|
.put("CAMPFIRE", FURNACE)
|
||||||
.put("CARTOGRAPHY_TABLE", "CRAFTING")
|
.put("CARTOGRAPHY_TABLE", CRAFTING)
|
||||||
.put("GRINDSTONE", "CRAFTING")
|
.put("GRINDSTONE", CRAFTING)
|
||||||
.put("LECTERN", "BREAK_BLOCKS")
|
.put("LECTERN", "BREAK_BLOCKS")
|
||||||
.put("LOOM", "CRAFTING")
|
.put("LOOM", CRAFTING)
|
||||||
.put("STONECUTTER", "CRAFTING")
|
.put("STONECUTTER", CRAFTING)
|
||||||
.put("SMOKER", "FURNACE")
|
.put("SMOKER", FURNACE)
|
||||||
.put("BLAST_FURNACE", "FURNACE")
|
.put("BLAST_FURNACE", FURNACE)
|
||||||
.put("COMPOSTER", "CONTAINER")
|
.put("COMPOSTER", "CONTAINER")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ public class BlueprintsManager {
|
|||||||
public static final String DEFAULT_BUNDLE_NAME = "default";
|
public static final String DEFAULT_BUNDLE_NAME = "default";
|
||||||
|
|
||||||
public static final @NonNull String FOLDER_NAME = "blueprints";
|
public static final @NonNull String FOLDER_NAME = "blueprints";
|
||||||
|
private static final String FOR = "' for ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of blueprint bundles to game mode addon.
|
* Map of blueprint bundles to game mode addon.
|
||||||
@ -179,7 +180,7 @@ public class BlueprintsManager {
|
|||||||
try {
|
try {
|
||||||
BlueprintBundle bb = gson.fromJson(new FileReader(file), BlueprintBundle.class);
|
BlueprintBundle bb = gson.fromJson(new FileReader(file), BlueprintBundle.class);
|
||||||
blueprintBundles.get(addon).add(bb);
|
blueprintBundles.get(addon).add(bb);
|
||||||
plugin.log("Loaded Blueprint Bundle '" + bb.getUniqueId() + "' for " + addon.getDescription().getName());
|
plugin.log("Loaded Blueprint Bundle '" + bb.getUniqueId() + FOR + addon.getDescription().getName());
|
||||||
loaded = true;
|
loaded = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.logError("Could not load blueprint bundle " + file.getName() + " " + e.getMessage());
|
plugin.logError("Could not load blueprint bundle " + file.getName() + " " + e.getMessage());
|
||||||
@ -253,7 +254,7 @@ public class BlueprintsManager {
|
|||||||
bp.setName(fileName);
|
bp.setName(fileName);
|
||||||
}
|
}
|
||||||
blueprints.get(addon).add(bp);
|
blueprints.get(addon).add(bp);
|
||||||
plugin.log("Loaded blueprint '" + bp.getName() + "' for " + addon.getDescription().getName());
|
plugin.log("Loaded blueprint '" + bp.getName() + FOR + addon.getDescription().getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.logError("Could not load blueprint " + fileName + " " + e.getMessage());
|
plugin.logError("Could not load blueprint " + fileName + " " + e.getMessage());
|
||||||
plugin.logStacktrace(e);
|
plugin.logStacktrace(e);
|
||||||
@ -271,7 +272,7 @@ public class BlueprintsManager {
|
|||||||
blueprints.putIfAbsent(addon, new ArrayList<>());
|
blueprints.putIfAbsent(addon, new ArrayList<>());
|
||||||
blueprints.get(addon).removeIf(b -> b.getName().equals(bp.getName()));
|
blueprints.get(addon).removeIf(b -> b.getName().equals(bp.getName()));
|
||||||
blueprints.get(addon).add(bp);
|
blueprints.get(addon).add(bp);
|
||||||
plugin.log("Added blueprint '" + bp.getName() + "' for " + addon.getDescription().getName());
|
plugin.log("Added blueprint '" + bp.getName() + FOR + addon.getDescription().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,6 +49,7 @@ public class BlueprintManagementPanel {
|
|||||||
private static final int MAX_WORLD_SLOT = 9;
|
private static final int MAX_WORLD_SLOT = 9;
|
||||||
private static final int MIN_WORLD_SLOT = 0;
|
private static final int MIN_WORLD_SLOT = 0;
|
||||||
public static final int MAX_BP_SLOT = 35;
|
public static final int MAX_BP_SLOT = 35;
|
||||||
|
private static final String INSTRUCTION = "instruction";
|
||||||
private Entry<Integer, Blueprint> selected;
|
private Entry<Integer, Blueprint> selected;
|
||||||
private Map<Integer, Blueprint> blueprints = new HashMap<>();
|
private Map<Integer, Blueprint> blueprints = new HashMap<>();
|
||||||
private final User user;
|
private final User user;
|
||||||
@ -58,9 +59,9 @@ public class BlueprintManagementPanel {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.addon = addon;
|
this.addon = addon;
|
||||||
normalBlueprint = new Blueprint().setIcon(Material.GREEN_STAINED_GLASS_PANE).setName(t("normal")).setDescription(t("instruction"));
|
normalBlueprint = new Blueprint().setIcon(Material.GREEN_STAINED_GLASS_PANE).setName(t("normal")).setDescription(t(INSTRUCTION));
|
||||||
netherBlueprint = new Blueprint().setIcon(Material.RED_STAINED_GLASS_PANE).setName(t("nether")).setDescription(t("instruction"));
|
netherBlueprint = new Blueprint().setIcon(Material.RED_STAINED_GLASS_PANE).setName(t("nether")).setDescription(t(INSTRUCTION));
|
||||||
endBlueprint = new Blueprint().setIcon(Material.YELLOW_STAINED_GLASS_PANE).setName(t("end")).setDescription(t("instruction"));
|
endBlueprint = new Blueprint().setIcon(Material.YELLOW_STAINED_GLASS_PANE).setName(t("end")).setDescription(t(INSTRUCTION));
|
||||||
slotToEnvironment = ImmutableMap.of(3, World.Environment.NORMAL, 5, World.Environment.NETHER, 7, World.Environment.THE_END);
|
slotToEnvironment = ImmutableMap.of(3, World.Environment.NORMAL, 5, World.Environment.NETHER, 7, World.Environment.THE_END);
|
||||||
environmentToBlueprint = ImmutableMap.of(World.Environment.NORMAL, normalBlueprint, World.Environment.NETHER, netherBlueprint, World.Environment.THE_END, endBlueprint);
|
environmentToBlueprint = ImmutableMap.of(World.Environment.NORMAL, normalBlueprint, World.Environment.NETHER, netherBlueprint, World.Environment.THE_END, endBlueprint);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user