mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Finally fixed the bugs and add old AreaShop build.
Former-commit-id: 5cdf5822451d070eeea48221c0e2f7c98acbadcb [formerly 5c6f32e6ff7302468ee1da25bf0ebbddb0a06ef0] Former-commit-id: 3a61b72609dbdec1a128e381067c6e1e58f8f69f
This commit is contained in:
1 parent
f16c4a4dc3
commit
dd8abda2e3
2 files changed
+33
-13
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import org.maxgamer.quickshop.Util.*;
|
||||
@@ -8,6 +9,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Database.DatabaseHelper;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import me.wiefferink.areashop.events.notify.UnrentedRegionEvent;
|
||||
|
||||
@@ -16,14 +18,29 @@ public class AreaShopListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void unRentedArea(UnrentedRegionEvent e) {
|
||||
Vector areaMaxVector = e.getRegion().getMaximumPoint();
|
||||
Vector areaMinVector = e.getRegion().getMinimumPoint();
|
||||
int minX = areaMinVector.getBlockX();
|
||||
int maxX = areaMaxVector.getBlockX();
|
||||
int minY = areaMinVector.getBlockY();
|
||||
int maxY = areaMaxVector.getBlockY();
|
||||
int minZ = areaMinVector.getBlockZ();
|
||||
int maxZ = areaMaxVector.getBlockZ();
|
||||
Vector areaMaxVector = null;
|
||||
Vector areaMinVector = null;
|
||||
int minX = 0;
|
||||
int maxX= 0;
|
||||
int minY = 0;
|
||||
int maxY = 0;
|
||||
int minZ = 0;
|
||||
int maxZ = 0;
|
||||
try {
|
||||
areaMaxVector = e.getRegion().getMaximumPoint();
|
||||
areaMinVector = e.getRegion().getMinimumPoint();
|
||||
minX = areaMinVector.getBlockX();
|
||||
maxX = areaMaxVector.getBlockX();
|
||||
minY = areaMinVector.getBlockY();
|
||||
maxY = areaMaxVector.getBlockY();
|
||||
minZ = areaMinVector.getBlockZ();
|
||||
maxZ = areaMaxVector.getBlockZ();
|
||||
}catch (Exception ex) {
|
||||
plugin.getLogger().warning("You are using not incompatible AreaShop, this feature will cannot working!!!");
|
||||
plugin.getLogger().warning("Please use 2.5.0#271 or higher build!");
|
||||
plugin.getLogger().warning("You can download our recommend AreaShop build at there: https://github.com/Ghost-chu/QuickShop-Reremake/raw/master/lib/AreaShop.jar");
|
||||
return;
|
||||
}
|
||||
Iterator<Shop> shops = plugin.getShopManager().getShopIterator();
|
||||
while (shops.hasNext()) {
|
||||
Shop shop = shops.next();
|
||||
@@ -44,6 +61,11 @@ public class AreaShopListener implements Listener {
|
||||
for (Shop removeShop : waitingRemove) {
|
||||
Util.debugLog("Removed shop at:["+shop.getLocation().toString()+"] cause AreaShop region unrented!");
|
||||
removeShop.delete();
|
||||
try {
|
||||
DatabaseHelper.removeShop(plugin.getDB(), shop.getLocation().getBlockX(), shop.getLocation().getBlockY(), shop.getLocation().getBlockZ(), shop.getLocation().getWorld().getName());
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,22 +140,20 @@ public class Util {
|
||||
*/
|
||||
public static boolean canBeShop(Block b,UUID player, boolean onlyCheck) {
|
||||
if (plugin.special_region_only&&!onlyCheck) {
|
||||
Util.debugLog("Target UUID: "+player.toString());
|
||||
|
||||
List<RentRegion> regions = me.wiefferink.areashop.tools.Utils.getImportantRentRegions(b.getLocation());
|
||||
boolean passTheRegionCheck = false;
|
||||
for (RentRegion rentRegion : regions) {
|
||||
if(rentRegion.getRenter()!=null&&rentRegion.getRenter()==player) {
|
||||
if(rentRegion.getRenter()!=null&&rentRegion.getRenter().toString().equals(player.toString())) {
|
||||
passTheRegionCheck=true;
|
||||
Util.debugLog("Passed check: Same renter.");
|
||||
break;
|
||||
}
|
||||
if(rentRegion.getOwner()!=null&&rentRegion.getOwner()==player) {
|
||||
if(rentRegion.getOwner()!=null&&rentRegion.getOwner().toString().equals(player.toString())) {
|
||||
passTheRegionCheck=true;
|
||||
Util.debugLog("Passed check: Same owner.");
|
||||
break;
|
||||
}
|
||||
if(rentRegion.getLandlord()!=null&&rentRegion.getLandlord()==player) {
|
||||
if(rentRegion.getLandlord()!=null&&rentRegion.getLandlord().toString().equals(player.toString())) {
|
||||
passTheRegionCheck=true;
|
||||
Util.debugLog("Passed check: Same landlord.");
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user