Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. public static boolean addMaquina(Player p, Block b, ItemStack hand, int quantia, Object type) {
  2. List<String> locs = getAllLocs(type);
  3. int radius = 5;
  4. boolean aa = true;
  5. final Block block = new Location(b.getWorld(), b.getLocation().getX(), b.getLocation().getY(), b.getLocation().getZ()).getBlock();
  6. final int x = block.getX();
  7. final int y = block.getY();
  8. final int z = block.getZ();
  9. final int minX = x - radius;
  10. final int minY = y - radius;
  11. final int minZ = z - radius;
  12. final int maxX = x + radius;
  13. final int maxY = y + radius;
  14. final int maxZ = z + radius;
  15. for (int counterX = minX; counterX <= maxX; counterX++) {
  16. for (int counterY = minY; counterY <= maxY; counterY++) {
  17. for (int counterZ = minZ; counterZ <= maxZ; counterZ++) {
  18. final Block blockName = b.getLocation().getWorld().getBlockAt(counterX, counterY, counterZ);
  19. if (locs.contains(blockName.getLocation().toString()) && DBManager.getOwner(blockName.getLocation().toString()).equals(p.getName())&& Settings.getAllNames().contains(hand.getItemMeta().getDisplayName())) {
  20. int stack = getStack(blockName.getLocation().toString());
  21. PreparedStatement stm = null;
  22. try {
  23. if(aa) {
  24. stm = Conexao.getConnection().prepareStatement("UPDATE `fanMaquinas` SET `quantia` = ? WHERE `location` = ?");
  25. stm.setInt(1, stack + quantia);
  26. stm.setString(2, blockName.getLocation().toString());
  27. stm.executeUpdate();
  28. stm.close();
  29. aa = false;
  30. } else {
  31. return true;
  32. }
  33. } catch (SQLException e) {
  34. e.printStackTrace();
  35. }
  36. p.sendMessage("§aFoi adicionado " + quantia + " máquinas. Agora há " + (stack + quantia) + " no total.");
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement