mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Fix arm integration issue
This commit is contained in:
1 parent
2dce492ba6
commit
da58910d9b
1 file changed
+22
-13
+22
-13
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.maxgamer.quickshop.integration.advancedregionmarket;
|
||||
|
||||
import net.alex9849.arm.events.RemoveRegionEvent;
|
||||
import net.alex9849.arm.events.RestoreRegionEvent;
|
||||
import net.alex9849.arm.regions.Region;
|
||||
import net.alex9849.armshopbridge.ArmShopBridge;
|
||||
@@ -32,7 +33,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -46,7 +46,7 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
|
||||
public class AdvancedShopRegionMarketIntegration extends QSIntegratedPlugin implements Listener {
|
||||
public class AdvancedShopRegionMarketIntegration extends QSIntegratedPlugin {
|
||||
public AdvancedShopRegionMarketIntegration(QuickShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
@@ -108,15 +108,17 @@ public class AdvancedShopRegionMarketIntegration extends QSIntegratedPlugin impl
|
||||
if (Bukkit.getPluginManager().getPlugin("ArmShopBridge") == null || ArmShopBridge.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
List<IShopPluginAdapter> adapterList = new ArrayList<>();
|
||||
ArmShopBridge.getInstance().getShopPluginAdapters().forEach(adapter -> {
|
||||
Iterator<IShopPluginAdapter> adapterListIterator = ArmShopBridge.getInstance().getShopPluginAdapters().iterator();
|
||||
//noinspection
|
||||
//Use legacy way to prevent lambda internal method causing listener load failed
|
||||
while (adapterListIterator.hasNext()) {
|
||||
IShopPluginAdapter adapter = adapterListIterator.next();
|
||||
if (adapter instanceof QuickShopAdapter || adapter instanceof QuickShop4Adapter) {
|
||||
adapterList.add(adapter);
|
||||
adapterListIterator.remove();
|
||||
plugin.getLogger().log(Level.INFO, "Successfully remove redundant ARM-ShopBridge handlers!");
|
||||
}
|
||||
});
|
||||
adapterList.forEach(ArmShopBridge.getInstance().getShopPluginAdapters()::remove);
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
plugin.getLogger().log(Level.WARNING, "Cannot to handle ARM-ShopBridge handlers, ignoring...", exception);
|
||||
}
|
||||
}
|
||||
@@ -130,10 +132,7 @@ public class AdvancedShopRegionMarketIntegration extends QSIntegratedPlugin impl
|
||||
unregisterListener();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onShopNeedDeletion(RestoreRegionEvent event) {
|
||||
Region region = event.getRegion();
|
||||
private void handleDeletion(Region region) {
|
||||
Vector minPoint = region.getRegion().getMinPoint();
|
||||
Vector maxPoint = region.getRegion().getMaxPoint();
|
||||
World world = region.getRegionworld();
|
||||
@@ -165,4 +164,14 @@ public class AdvancedShopRegionMarketIntegration extends QSIntegratedPlugin impl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onShopNeedDeletion(RestoreRegionEvent event) {
|
||||
handleDeletion(event.getRegion());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onShopNeedDeletion(RemoveRegionEvent event) {
|
||||
handleDeletion(event.getRegion());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user