private void allocatePoints(int points, Player plr) { if ((points > 0 && pLevel.getTempFreePoints() >= points || (points < 0 && (this.points - pLevel.getIntPoints()) >= Math.abs(points))) && this.points + points <= 600) { this.points += points; pLevel.setTempFreePoints(pLevel.getTempFreePoints() - points); plr.playSound(plr.getLocation(), Sound.SHEEP_SHEAR, 1.0F, 1.3F); for (Entry<Integer, MenuItem> entry : DynamicMenuModel.getMenu(plr).getDynamicItems().entrySet()) { DynamicMenuModel.getMenu(plr) .getInventory() .setItem(entry.getKey(), entry.getValue().getItem()); } } }
@Override public void execute(Player plr, ClickType click) { if (slot == -1) { for (Entry<Integer, MenuItem> entry : DynamicMenuModel.getMenu(plr).getDynamicItems().entrySet()) { if (((MenuItem) entry.getValue()).getItem().equals(getItem())) { slot = entry.getKey(); } } } if (pLevel.getTempFreePoints() > 0) { switch (click) { case LEFT: allocatePoints(1, plr); break; case MIDDLE: plr.closeInventory(); StatsGUIWorker.setCustomStatAllocationSlot(slot, plr, getItem()); break; case RIGHT: allocatePoints(-1, plr); break; case SHIFT_LEFT: allocatePoints(3, plr); break; case SHIFT_RIGHT: allocatePoints(-3, plr); break; default: break; } } }