Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean addMaquina(Player p, Block b, ItemStack hand, int quantia, Object type) {
- List<String> locs = getAllLocs(type);
- int radius = 5;
- boolean aa = true;
- final Block block = new Location(b.getWorld(), b.getLocation().getX(), b.getLocation().getY(), b.getLocation().getZ()).getBlock();
- final int x = block.getX();
- final int y = block.getY();
- final int z = block.getZ();
- final int minX = x - radius;
- final int minY = y - radius;
- final int minZ = z - radius;
- final int maxX = x + radius;
- final int maxY = y + radius;
- final int maxZ = z + radius;
- for (int counterX = minX; counterX <= maxX; counterX++) {
- for (int counterY = minY; counterY <= maxY; counterY++) {
- for (int counterZ = minZ; counterZ <= maxZ; counterZ++) {
- final Block blockName = b.getLocation().getWorld().getBlockAt(counterX, counterY, counterZ);
- if (locs.contains(blockName.getLocation().toString()) && DBManager.getOwner(blockName.getLocation().toString()).equals(p.getName())&& Settings.getAllNames().contains(hand.getItemMeta().getDisplayName())) {
- int stack = getStack(blockName.getLocation().toString());
- PreparedStatement stm = null;
- try {
- if(aa) {
- stm = Conexao.getConnection().prepareStatement("UPDATE `fanMaquinas` SET `quantia` = ? WHERE `location` = ?");
- stm.setInt(1, stack + quantia);
- stm.setString(2, blockName.getLocation().toString());
- stm.executeUpdate();
- stm.close();
- aa = false;
- } else {
- return true;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- p.sendMessage("§aFoi adicionado " + quantia + " máquinas. Agora há " + (stack + quantia) + " no total.");
- }
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement