Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.elvarg.game.model.commands.impl;
- import com.elvarg.game.content.skill.skillable.impl.Prayer;
- import com.elvarg.game.definition.NpcDropDefinition;
- import com.elvarg.game.entity.impl.npc.NPCDropGenerator;
- import com.elvarg.game.entity.impl.player.Player;
- import com.elvarg.game.model.Item;
- import com.elvarg.game.model.commands.Command;
- import com.elvarg.game.model.container.impl.Bank;
- import com.elvarg.game.model.rights.PlayerRights;
- import java.util.Optional;
- public class Simulate implements Command {
- @Override
- public void execute(Player player, String command, String[] parts) {
- int npcId = Integer.parseInt(parts[1]);
- int amount = 1;
- if (parts.length > 2) {
- amount = Integer.parseInt(parts[2]);
- }
- for (int i = 0; i < Bank.TOTAL_BANK_TABS; i++) {
- if (player.getBank(i) != null) {
- player.getBank(i).resetItems();
- }
- }
- Optional<NpcDropDefinition> def = NpcDropDefinition.get(npcId);
- if(def.isPresent()) {
- NPCDropGenerator gen = new NPCDropGenerator(player, def.get());
- for (int j = 0; j < amount; j++) {
- for (Item item : gen.getDropList()) {
- Optional<Prayer.BuriableBone> b = Prayer.BuriableBone.forId(item.getId());
- if (!item.getDefinition().isStackable()) {
- for (int i = 0; i < item.getAmount(); i++) {
- if(b.isPresent())
- player.getBank(Bank.getTabForItem(player, item.getId())).add(new Item(item.getId() + 1, 1));
- else
- player.getBank(Bank.getTabForItem(player, item.getId())).add(new Item(item.getId(), 1));
- }
- } else {
- player.getBank(Bank.getTabForItem(player, item.getId())).add(item);
- }
- }
- }
- }
- }
- @Override
- public boolean canUse(Player player) {
- PlayerRights rights = player.getRights();
- return (rights == PlayerRights.OWNER || rights == PlayerRights.DEVELOPER);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement