Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private abstract class MenuEditChances extends Menu implements MenuQuantitable {
- @Getter
- protected final EditMode mode;
- @Setter
- @Getter
- private MenuQuantity quantity = MenuQuantity.ONE;
- private final Button modeButton;
- private final Button quantityButton;
- private MenuEditChances(final EditMode mode, final int size) {
- this(MenuBossIndividual.this, mode, size);
- }
- private MenuEditChances(final Menu parent, final EditMode mode, final int size) {
- super(parent);
- this.mode = mode;
- setSize(size);
- modeButton = new Button() {
- @Override
- public final void onClickedInMenu(final Player pl, final Menu menu, final ClickType click) {
- pl.closeInventory();
- getNextMenu().displayTo(pl);
- }
- @Override
- public ItemStack getItem() {
- return ItemCreator
- .of(mode == EditMode.ITEMS ? CompMaterial.CHEST : CompMaterial.GOLD_NUGGET,
- "Editing " + ItemUtil.bountify(mode),
- "",
- "&7Click to edit " + ItemUtil.bountify(mode.next()))
- .build().make();
- }
- };
- quantityButton = mode == EditMode.DROP_CHANCES ? getEditQuantityButton(this) : Button.makeEmpty();
- }
- @Override
- public ItemStack getItemAt(final int slot) {
- if (slot == getSize() - 5)
- return modeButton.getItem();
- if (slot == getSize() - 7 && !quantityButton.equals(Button.makeEmpty()))
- return quantityButton.getItem();
- if (slot > getSize() - 10)
- return getFillerItem();
- return null;
- }
- protected final ItemStack paintChanceItem(final BossDrop drop) {
- return drop != null && drop.getItem() != null ? mode == EditMode.DROP_CHANCES ? ItemCreator
- .of(drop.getItem())
- .lores(Arrays.asList(
- "",
- "&7Drop chance: &6" + Math.round(100 * Double.valueOf(drop.getDropChance())) + "%",
- "",
- " &8(Mouse click)",
- " &7&l< &4-{q}% &2+{q}% &7&l>".replace("{q}", quantity.getAmount() + "")))
- .hideTags(true)
- .build().make()
- : drop.getItem() : null;
- }
- @Override
- protected final String[] getInfo() {
- return mode == EditMode.ITEMS ? new String[] {
- "Here you edit the items",
- "for this Boss.",
- "",
- "Simply &2drag and drop &7items",
- "from your inventory here."
- }
- : new String[] {
- "Here you edit how likely it",
- "is that each item will drop,",
- "when the Boss dies.",
- "",
- "&2Right or left click &7on items",
- "to adjust the drop chances."
- };
- }
- @Override
- public boolean isActionAllowed(final MenuClickLocation location, final int slot, final ItemStack clicked, final ItemStack cursor) {
- if (mode == EditMode.DROP_CHANCES)
- return false;
- return slot < getSize() - 9 || location == MenuClickLocation.PLAYER_INVENTORY;
- }
- private Menu getNextMenu() {
- try {
- final Constructor<? extends MenuEditChances> c = getClass().getDeclaredConstructor(MenuBossIndividual.class, Menu.class, EditMode.class);
- c.setAccessible(true);
- return c.newInstance(MenuBossIndividual.this, getParent(), mode.next());
- } catch (final ReflectiveOperationException ex) {
- Common.throwError(ex, "Error generating next menu " + this);
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement