@Override public void setBonusData(PlayerModel player) { drPlayer = player; pLevel = drPlayer.getPlayerLevel(); points = pLevel.getIntPoints(); pLevel.setTempFreePoints(pLevel.getFreePoints()); }
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; } } }
@Override public ItemStack getItem() { return new Builder(Material.EMPTY_MAP) .setName(ChatColor.DARK_PURPLE + "Intellect") .setLore( Arrays.asList( ChatColor.GRAY + "Adds energy regeneration, ", ChatColor.GRAY + "elemental damage, critical ", ChatColor.GRAY + "hit chance, and staff damage.", ChatColor.AQUA + "Allocated Points: " + pLevel.getIntPoints() + (points - pLevel.getIntPoints() > 0 ? ChatColor.GREEN + " [+" + (points - pLevel.getIntPoints()) + "]" : ""), ChatColor.RED + "Free Points: " + pLevel.getTempFreePoints())) .getItem(); }