Fixed right click not clearing blueprints in management panel

Fixed NPE if a bundle does not have an end or nether bp.
This commit is contained in:
tastybento 2019-06-15 22:09:17 -07:00
parent 3ae98741c6
commit f50e59eef1
2 changed files with 12 additions and 8 deletions

View File

@ -368,7 +368,9 @@ public class BlueprintsManager {
&& addon.getWorldSettings().isNetherIslands()
&& addon.getNetherWorld() != null) {
bp = getBlueprints(addon).get(bb.getBlueprint(World.Environment.NETHER));
new BlueprintPaster(plugin, bp, addon.getNetherWorld(), island, null);
if (bp != null) {
new BlueprintPaster(plugin, bp, addon.getNetherWorld(), island, null);
}
}
// Make end island
if (bb.getBlueprint(World.Environment.THE_END) != null
@ -376,7 +378,9 @@ public class BlueprintsManager {
&& addon.getWorldSettings().isEndIslands()
&& addon.getEndWorld() != null) {
bp = getBlueprints(addon).get(bb.getBlueprint(World.Environment.THE_END));
new BlueprintPaster(plugin, bp, addon.getEndWorld(), island, null);
if (bp != null) {
new BlueprintPaster(plugin, bp, addon.getEndWorld(), island, null);
}
}
return true;

View File

@ -297,12 +297,6 @@ public class BlueprintManagementPanel {
.icon(blueprint.getIcon() == null ? Material.PAPER : blueprint.getIcon())
.glow(selected != null && pos == selected.getKey())
.clickHandler((panel, u, clickType, slot) -> {
// Renaming blueprint
if (clickType.equals(ClickType.RIGHT)) {
u.closeInventory();
this.askForBlueprintName(u.getPlayer(), addon, blueprint, bb);
return true;
}
// Handle the world squares
if (slot > MIN_WORLD_SLOT && slot < MAX_WORLD_SLOT) {
if (clickType.equals(ClickType.RIGHT)) {
@ -328,6 +322,12 @@ public class BlueprintManagementPanel {
} else {
// Select blueprint
if (blueprints.containsKey(slot)) {
// Renaming blueprint
if (clickType.equals(ClickType.RIGHT)) {
u.closeInventory();
this.askForBlueprintName(u.getPlayer(), addon, blueprint, bb);
return true;
}
if (selected != null && slot == selected.getKey()){
// Clicked on same item - deselect
selected = null;