Skip to content

Commit

Permalink
Update UltimateShopsAdapter.java
Browse files Browse the repository at this point in the history
fix ultimateshops
  • Loading branch information
fapret committed Jul 6, 2021
1 parent 4eb979b commit df99354
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package net.alex9849.armshopbridge.adapters;

import java.util.concurrent.Semaphore;

import net.alex9849.arm.regions.Region;
import net.alex9849.armshopbridge.interfaces.IShopPluginAdapter;
import org.bukkit.Location;
import thirtyvirus.ultimateshops.UltimateShops;
import thirtyvirus.ultimateshops.UShop;

public class UltimateShopsAdapter implements IShopPluginAdapter {
private final Semaphore mutex = new Semaphore(1, true);

@Override
public void deleteShops(Region region) {
for(UShop uShop : UltimateShops.shopsList) {
Location shopLoc = uShop.getLocation();
if(region.getRegion().contains(shopLoc.getBlockX(), shopLoc.getBlockY(), shopLoc.getBlockZ())) {
uShop.destroy(false);
try{
for(UShop uShop : UltimateShops.shopsList) {
mutex.acquire();
Location shopLoc = uShop.getLocation();
if(region.getRegion().contains(shopLoc.getBlockX(), shopLoc.getBlockY(), shopLoc.getBlockZ())) {
uShop.destroy(false);
}
mutex.release();
}
} catch(InterruptedException ie) {
mutex.release();
}
}
}

0 comments on commit df99354

Please sign in to comment.