into develop
This commit is contained in:
tastybento 2019-06-15 22:10:25 -07:00
commit acb7c1fc76
7 changed files with 27 additions and 29 deletions

View File

@ -37,9 +37,7 @@ public class AdminBlueprintSaveCommand extends ConfirmableCommand {
// Check if file exists // Check if file exists
File newFile = new File(parent.getBlueprintsFolder(), fileName + BlueprintsManager.BLUEPRINT_SUFFIX); File newFile = new File(parent.getBlueprintsFolder(), fileName + BlueprintsManager.BLUEPRINT_SUFFIX);
if (newFile.exists()) { if (newFile.exists()) {
this.askConfirmation(user, user.getTranslation("commands.admin.blueprint.file-exists"), () -> { this.askConfirmation(user, user.getTranslation("commands.admin.blueprint.file-exists"), () -> hideAndSave(user, parent, clipboard, fileName));
hideAndSave(user, parent, clipboard, fileName);
});
return false; return false;
} }
return hideAndSave(user, parent, clipboard, fileName); return hideAndSave(user, parent, clipboard, fileName);

View File

@ -33,7 +33,7 @@ public class BlockInteractionListener extends FlagListener {
* 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
*/ */
Map<String, String> STRING_FLAGS = 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")
@ -285,8 +285,8 @@ public class BlockInteractionListener extends FlagListener {
checkIsland(e, player, loc, Flags.ITEM_FRAME); checkIsland(e, player, loc, Flags.ITEM_FRAME);
break; break;
default: default:
if (STRING_FLAGS.containsKey(type.name())) { if (stringFlags.containsKey(type.name())) {
Optional<Flag> f = BentoBox.getInstance().getFlagsManager().getFlag(STRING_FLAGS.get(type.name())); Optional<Flag> f = BentoBox.getInstance().getFlagsManager().getFlag(stringFlags.get(type.name()));
if (f.isPresent()) checkIsland(e, player, loc, f.get()); if (f.isPresent()) checkIsland(e, player, loc, f.get());
} }
} }

View File

@ -27,7 +27,7 @@ public class CreeperListener extends FlagListener {
*/ */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onExplosion(final EntityExplodeEvent e) { public void onExplosion(final EntityExplodeEvent e) {
if (e.getEntity() == null || !e.getEntityType().equals(EntityType.CREEPER) || !getIWM().inWorld(e.getLocation())) { if (!e.getEntityType().equals(EntityType.CREEPER) || !getIWM().inWorld(e.getLocation())) {
return; return;
} }
// If creeper damage is not allowed in world, remove it // If creeper damage is not allowed in world, remove it

View File

@ -41,11 +41,11 @@ import world.bentobox.bentobox.util.Util;
public class BlueprintManagementPanel { public class BlueprintManagementPanel {
private final BentoBox plugin; private final BentoBox plugin;
private final Blueprint NORMAL_BP; private final Blueprint normalBlueprint;
private final Blueprint NETHER_BP; private final Blueprint netherBlueprint;
private final Blueprint END_BP; private final Blueprint endBlueprint;
private final Map<Integer, World.Environment> SLOT_TO_ENV; private final Map<Integer, World.Environment> slotToEnvironment;
private final Map<World.Environment, Blueprint> ENV_TO_BP; private final Map<World.Environment, Blueprint> environmentToBlueprint;
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;
@ -58,11 +58,11 @@ public class BlueprintManagementPanel {
this.plugin = plugin; this.plugin = plugin;
this.user = user; this.user = user;
this.addon = addon; this.addon = addon;
NORMAL_BP = 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"));
NETHER_BP = 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"));
END_BP = 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"));
SLOT_TO_ENV = 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);
ENV_TO_BP = ImmutableMap.of(World.Environment.NORMAL, NORMAL_BP, World.Environment.NETHER, NETHER_BP, World.Environment.THE_END, END_BP); environmentToBlueprint = ImmutableMap.of(World.Environment.NORMAL, normalBlueprint, World.Environment.NETHER, netherBlueprint, World.Environment.THE_END, endBlueprint);
} }
private String t(String t) { private String t(String t) {
@ -82,7 +82,7 @@ public class BlueprintManagementPanel {
// Create the panel // Create the panel
PanelBuilder pb = new PanelBuilder().name(t("title")).user(user).size(45); PanelBuilder pb = new PanelBuilder().name(t("title")).user(user).size(45);
// Panel has New Blueprint Bundle button - clicking in creates a new bundle // Panel has New Blueprint Bundle button - clicking in creates a new bundle
pb.item(36, getNewBundle(user, addon)); pb.item(36, getNewBundle(addon));
// Get the bundles // Get the bundles
Comparator<BlueprintBundle> sortByDisplayName = (p, o) -> p.getDisplayName().compareToIgnoreCase(o.getDisplayName()); Comparator<BlueprintBundle> sortByDisplayName = (p, o) -> p.getDisplayName().compareToIgnoreCase(o.getDisplayName());
plugin.getBlueprintsManager().getBlueprintBundles(addon).values().stream().limit(36) plugin.getBlueprintsManager().getBlueprintBundles(addon).values().stream().limit(36)
@ -153,10 +153,10 @@ public class BlueprintManagementPanel {
PanelBuilder pb = new PanelBuilder().name(bb.getDisplayName()).user(user).size(45).listener(new IconChanger(plugin, addon, this, bb)); PanelBuilder pb = new PanelBuilder().name(bb.getDisplayName()).user(user).size(45).listener(new IconChanger(plugin, addon, this, bb));
// Display bundle icon // Display bundle icon
pb.item(0, getBundleIcon(bb)); pb.item(0, getBundleIcon(bb));
SLOT_TO_ENV.forEach((k,v) -> { slotToEnvironment.forEach((k, v) -> {
String bpName = bb.getBlueprint(v); String bpName = bb.getBlueprint(v);
pb.item(k-1, getWorldInstrTile(v)); pb.item(k-1, getWorldInstrTile(v));
pb.item(k, getBlueprintItem(addon, k, bb, plugin.getBlueprintsManager().getBlueprints(addon).getOrDefault(bpName, ENV_TO_BP.get(v)))); pb.item(k, getBlueprintItem(addon, k, bb, plugin.getBlueprintsManager().getBlueprints(addon).getOrDefault(bpName, environmentToBlueprint.get(v))));
}); });
for (int i = 9; i < 18; i++) { for (int i = 9; i < 18; i++) {
@ -284,7 +284,7 @@ public class BlueprintManagementPanel {
protected PanelItem getBlueprintItem(GameModeAddon addon, int pos, BlueprintBundle bb, Blueprint blueprint) { protected PanelItem getBlueprintItem(GameModeAddon addon, int pos, BlueprintBundle bb, Blueprint blueprint) {
// Create description // Create description
List<String> desc = blueprint.getDescription() == null ? new ArrayList<>() : blueprint.getDescription(); List<String> desc = blueprint.getDescription() == null ? new ArrayList<>() : blueprint.getDescription();
if ((!blueprint.equals(END_BP) && !blueprint.equals(NORMAL_BP) && !blueprint.equals(NETHER_BP))) { if ((!blueprint.equals(endBlueprint) && !blueprint.equals(normalBlueprint) && !blueprint.equals(netherBlueprint))) {
if ((pos > MIN_WORLD_SLOT && pos < MAX_WORLD_SLOT)) { if ((pos > MIN_WORLD_SLOT && pos < MAX_WORLD_SLOT)) {
desc.add(t("remove")); desc.add(t("remove"));
} else { } else {
@ -302,7 +302,7 @@ public class BlueprintManagementPanel {
if (clickType.equals(ClickType.RIGHT)) { if (clickType.equals(ClickType.RIGHT)) {
u.getPlayer().playSound(u.getLocation(), Sound.BLOCK_GLASS_BREAK, 1F, 1F); u.getPlayer().playSound(u.getLocation(), Sound.BLOCK_GLASS_BREAK, 1F, 1F);
// Remove the item and replace with the blank // Remove the item and replace with the blank
bb.clearBlueprint(SLOT_TO_ENV.get(slot)); bb.clearBlueprint(slotToEnvironment.get(slot));
// Save // Save
plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb); plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb);
openBB(bb); openBB(bb);
@ -314,7 +314,7 @@ public class BlueprintManagementPanel {
u.getPlayer().playSound(u.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F); u.getPlayer().playSound(u.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F);
Blueprint bp = selected.getValue(); Blueprint bp = selected.getValue();
// make slot the chosen one // make slot the chosen one
bb.setBlueprint(SLOT_TO_ENV.get(slot), bp); bb.setBlueprint(slotToEnvironment.get(slot), bp);
// Save // Save
plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb); plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb);
openBB(bb); openBB(bb);
@ -344,7 +344,7 @@ public class BlueprintManagementPanel {
.build(); .build();
} }
private PanelItem getNewBundle(@NonNull User user, @NonNull GameModeAddon addon) { private PanelItem getNewBundle(@NonNull GameModeAddon addon) {
return new PanelItemBuilder() return new PanelItemBuilder()
.name(t("new-bundle")) .name(t("new-bundle"))
.description(t("new-bundle-instructions")) .description(t("new-bundle-instructions"))

View File

@ -43,7 +43,7 @@ public class IconChanger implements PanelListener {
@Override @Override
public void onInventoryClick(User user, InventoryClickEvent event) { public void onInventoryClick(User user, InventoryClickEvent event) {
// Handle icon changing // Handle icon changing
if (event.getCurrentItem().getType() != null && !event.getCurrentItem().getType().equals(Material.AIR) && event.getRawSlot() > 44) { if (event.getCurrentItem() != null && !event.getCurrentItem().getType().equals(Material.AIR) && event.getRawSlot() > 44) {
Material icon = event.getCurrentItem().getType(); Material icon = event.getCurrentItem().getType();
Entry<Integer, Blueprint> selected = blueprintManagementPanel.getSelected(); Entry<Integer, Blueprint> selected = blueprintManagementPanel.getSelected();
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F); user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F);

View File

@ -205,9 +205,9 @@ public class Converter {
private Vector getVector(String name) { private Vector getVector(String name) {
String[] pos = name.split(","); String[] pos = name.split(",");
int x = Integer.valueOf(pos[0]); int x = Integer.parseInt(pos[0]);
int y = Integer.valueOf(pos[1]); int y = Integer.parseInt(pos[1]);
int z = Integer.valueOf(pos[2]); int z = Integer.parseInt(pos[2]);
return new Vector(x,y,z); return new Vector(x,y,z);
} }

View File

@ -52,7 +52,7 @@ public class SchemLoader {
* @throws IOException - if there's a load error with unziping or name * @throws IOException - if there's a load error with unziping or name
* @throws InvalidConfigurationException - the YAML of the schem is at fault * @throws InvalidConfigurationException - the YAML of the schem is at fault
*/ */
public void load(String fileName) throws FileNotFoundException, IOException, InvalidConfigurationException { public void load(String fileName) throws IOException, InvalidConfigurationException {
File zipFile = new File(schemFolder, fileName + ".schem"); File zipFile = new File(schemFolder, fileName + ".schem");
if (!zipFile.exists()) { if (!zipFile.exists()) {
plugin.logError(LOAD_ERROR + zipFile.getName()); plugin.logError(LOAD_ERROR + zipFile.getName());