1919
2020package org .maxgamer .quickshop .integration .advancedregionmarket ;
2121
22+ import net .alex9849 .arm .events .RemoveRegionEvent ;
2223import net .alex9849 .arm .events .RestoreRegionEvent ;
23- import net .alex9849 .arm .events .UnsellRegionEvent ;
2424import net .alex9849 .arm .regions .Region ;
2525import org .bukkit .Chunk ;
2626import org .bukkit .Location ;
@@ -90,16 +90,17 @@ public boolean canTradeShopHere(@NotNull Player player, @NotNull Location locati
9090 */
9191 @ Override
9292 public void load () {
93+ //scanAndUnregister();
9394 registerListener ();
9495 }
95-
96+ //
9697// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
9798// public void onPluginLoad(PluginEnableEvent event) {
9899// if ("ArmShopBridge".equals(event.getPlugin().getName())) {
99100// scanAndUnregister();
100101// }
101102// }
102- //
103+
103104// private void scanAndUnregister() {
104105// try {
105106// if (Bukkit.getPluginManager().getPlugin("ArmShopBridge") == null || ArmShopBridge.getInstance() == null) {
@@ -131,9 +132,9 @@ public void unload() {
131132
132133 private void handleDeletion (Region region ) {
133134 Vector minPoint = region .getRegion ().getMinPoint ();
134- Vector maxPoint = region .getRegion ().getMinPoint ();
135+ Vector maxPoint = region .getRegion ().getMaxPoint ();
135136 World world = region .getRegionworld ();
136- Set <Chunk > chuckLocations = new HashSet <Chunk >();
137+ Set <Chunk > chuckLocations = new HashSet <>();
137138
138139 for (int x = minPoint .getBlockX (); x <= maxPoint .getBlockX () + 16 ; x += 16 ) {
139140 for (int z = minPoint .getBlockZ (); z <= maxPoint .getBlockZ () + 16 ; z += 16 ) {
@@ -150,10 +151,12 @@ private void handleDeletion(Region region) {
150151 shopMap .putAll (shopsInChunk );
151152 }
152153 }
153- for (Location shopLocation : shopMap .keySet ()) {
154+ for (Map .Entry <Location , Shop > shopEntry : shopMap .entrySet ()) {
155+ Location shopLocation = shopEntry .getKey ();
154156 if (region .getRegion ().contains (shopLocation .getBlockX (), shopLocation .getBlockY (), shopLocation .getBlockZ ())) {
155- Shop shop = shopMap . get ( shopLocation );
157+ Shop shop = shopEntry . getValue ( );
156158 if (shop != null ) {
159+ shop .onUnload ();
157160 shop .delete (false );
158161 }
159162 }
@@ -165,13 +168,8 @@ public void onShopNeedDeletion(RestoreRegionEvent event) {
165168 handleDeletion (event .getRegion ());
166169 }
167170
168- // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
169- // public void onShopNeedDeletion(RemoveRegionEvent event) {
170- // handleDeletion(event.getRegion());
171- // }
172-
173171 @ EventHandler (priority = EventPriority .MONITOR , ignoreCancelled = true )
174- public void onShopNeedDeletion (UnsellRegionEvent event ) {
172+ public void onShopNeedDeletion (RemoveRegionEvent event ) {
175173 handleDeletion (event .getRegion ());
176174 }
177175
0 commit comments