Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. package com.elvarg.game.model.commands.impl;
  2.  
  3. import com.elvarg.game.content.skill.skillable.impl.Prayer;
  4. import com.elvarg.game.definition.NpcDropDefinition;
  5. import com.elvarg.game.entity.impl.npc.NPCDropGenerator;
  6. import com.elvarg.game.entity.impl.player.Player;
  7. import com.elvarg.game.model.Item;
  8. import com.elvarg.game.model.commands.Command;
  9. import com.elvarg.game.model.container.impl.Bank;
  10. import com.elvarg.game.model.rights.PlayerRights;
  11.  
  12. import java.util.Optional;
  13.  
  14. public class Simulate implements Command {
  15.  
  16. @Override
  17. public void execute(Player player, String command, String[] parts) {
  18. int npcId = Integer.parseInt(parts[1]);
  19. int amount = 1;
  20. if (parts.length > 2) {
  21. amount = Integer.parseInt(parts[2]);
  22. }
  23.  
  24. for (int i = 0; i < Bank.TOTAL_BANK_TABS; i++) {
  25. if (player.getBank(i) != null) {
  26. player.getBank(i).resetItems();
  27. }
  28. }
  29.  
  30. Optional<NpcDropDefinition> def = NpcDropDefinition.get(npcId);
  31. if(def.isPresent()) {
  32. NPCDropGenerator gen = new NPCDropGenerator(player, def.get());
  33. for (int j = 0; j < amount; j++) {
  34. for (Item item : gen.getDropList()) {
  35. Optional<Prayer.BuriableBone> b = Prayer.BuriableBone.forId(item.getId());
  36. if (!item.getDefinition().isStackable()) {
  37. for (int i = 0; i < item.getAmount(); i++) {
  38. if(b.isPresent())
  39. player.getBank(Bank.getTabForItem(player, item.getId())).add(new Item(item.getId() + 1, 1));
  40. else
  41. player.getBank(Bank.getTabForItem(player, item.getId())).add(new Item(item.getId(), 1));
  42.  
  43. }
  44. } else {
  45. player.getBank(Bank.getTabForItem(player, item.getId())).add(item);
  46. }
  47. }
  48. }
  49. }
  50. }
  51.  
  52. @Override
  53. public boolean canUse(Player player) {
  54. PlayerRights rights = player.getRights();
  55. return (rights == PlayerRights.OWNER || rights == PlayerRights.DEVELOPER);
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement