mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-27 09:42:37 +01:00
Fix null check in age
This commit is contained in:
parent
2e2a83779e
commit
138aaacbcf
@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.api.gui.CitizensInventoryClickEvent;
|
||||
import net.citizensnpcs.api.gui.InputMenu;
|
||||
import net.citizensnpcs.api.gui.InputMenus;
|
||||
import net.citizensnpcs.api.gui.InventoryMenuPage;
|
||||
import net.citizensnpcs.api.gui.InventoryMenuSlot;
|
||||
import net.citizensnpcs.api.gui.Menu;
|
||||
@ -72,8 +72,8 @@ public class NPCConfigurator extends InventoryMenuPage {
|
||||
SLOT_MAP.put(0, new ConfiguratorInfo(Util.getFallbackMaterial("OAK_SIGN", "SIGN"), (evt) -> {
|
||||
evt.slot.setDescription("Edit NPC name\n" + evt.npc.getName());
|
||||
if (evt.event != null) {
|
||||
evt.ctx.getMenu()
|
||||
.transition(InputMenu.setter(() -> evt.npc.getName(), (input) -> evt.npc.setName(input)));
|
||||
evt.ctx.getMenu().transition(
|
||||
InputMenus.stringSetter(() -> evt.npc.getName(), (input) -> evt.npc.setName(input)));
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class Age extends Trait implements Toggleable {
|
||||
} else if (npc.getEntity() instanceof Zombie) {
|
||||
((Zombie) npc.getEntity()).setBaby(age < 0);
|
||||
ageable = null;
|
||||
} else if (npc.getEntity().getType().name().equals("TADPOLE")) {
|
||||
} else if (npc.isSpawned() && npc.getEntity().getType().name().equals("TADPOLE")) {
|
||||
((Tadpole) npc.getEntity()).setAge(age);
|
||||
ageable = null;
|
||||
} else {
|
||||
|
@ -13,7 +13,8 @@ import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.api.gui.CitizensInventoryClickEvent;
|
||||
import net.citizensnpcs.api.gui.ClickHandler;
|
||||
import net.citizensnpcs.api.gui.InputMenu;
|
||||
import net.citizensnpcs.api.gui.InputMenus;
|
||||
import net.citizensnpcs.api.gui.InputMenus.Choice;
|
||||
import net.citizensnpcs.api.gui.InventoryMenu;
|
||||
import net.citizensnpcs.api.gui.InventoryMenuPage;
|
||||
import net.citizensnpcs.api.gui.InventoryMenuSlot;
|
||||
@ -49,7 +50,7 @@ public class ShopTrait extends Trait {
|
||||
@Persist
|
||||
private String requiredPermission;
|
||||
@Persist
|
||||
private final ShopType type = ShopType.VIEW;
|
||||
private ShopType type = ShopType.VIEW;
|
||||
|
||||
private NPCShop(String name) {
|
||||
this.name = name;
|
||||
@ -99,13 +100,19 @@ public class ShopTrait extends Trait {
|
||||
@ClickHandler(slot = { 0, 2 })
|
||||
public void onPermissionChange(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
|
||||
event.setCancelled(true);
|
||||
ctx.getMenu()
|
||||
.transition(InputMenu.setter(() -> shop.getRequiredPermission(), (p) -> shop.setPermission(p)));
|
||||
ctx.getMenu().transition(
|
||||
InputMenus.stringSetter(() -> shop.getRequiredPermission(), (p) -> shop.setPermission(p)));
|
||||
}
|
||||
|
||||
@ClickHandler(slot = { 0, 0 })
|
||||
public void onShopTypeChange(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
|
||||
event.setCancelled(true);
|
||||
ctx.getMenu().transition(InputMenus.<ShopType> picker("Edit shop type", (chosen) -> {
|
||||
shop.type = chosen.getValue();
|
||||
}, Choice.of(ShopType.BUY, Material.DIAMOND, "Players buy items", shop.type == ShopType.BUY),
|
||||
Choice.of(ShopType.SELL, Material.EMERALD, "Players sell items", shop.type == ShopType.SELL),
|
||||
Choice.of(ShopType.VIEW, Material.ENDER_EYE, "Players view items only",
|
||||
shop.type == ShopType.VIEW)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user