-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ultimateshops
- Loading branch information
Showing
1 changed file
with
15 additions
and
4 deletions.
There are no files selected for viewing
19 changes: 15 additions & 4 deletions
19
...eshopsadapter/src/main/java/net/alex9849/armshopbridge/adapters/UltimateShopsAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
|