From 1438cb553e27ca1551ed7c9fd7287aeb47a767c1 Mon Sep 17 00:00:00 2001 From: DaniFoldi Date: Tue, 30 Mar 2021 11:53:27 +0200 Subject: [PATCH] Fix plotsquared listeners --- .../listeners/PlotSquaredListener.java | 38 ++++++++----------- .../java/de/epiceric/shopchest/sql/MySQL.java | 2 +- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/external/listeners/PlotSquaredListener.java b/src/main/java/de/epiceric/shopchest/external/listeners/PlotSquaredListener.java index ee6a096..a94ef81 100644 --- a/src/main/java/de/epiceric/shopchest/external/listeners/PlotSquaredListener.java +++ b/src/main/java/de/epiceric/shopchest/external/listeners/PlotSquaredListener.java @@ -5,6 +5,8 @@ import com.plotsquared.core.events.PlotClearEvent; import com.plotsquared.core.events.PlotDeleteEvent; import com.plotsquared.core.location.Location; import com.plotsquared.core.plot.Plot; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.CuboidRegion; import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.config.Config; import de.epiceric.shopchest.event.ShopCreateEvent; @@ -51,33 +53,25 @@ public class PlotSquaredListener implements Listener { @Subscribe public void onDeletePlot(PlotDeleteEvent event) { - for (Shop shop: plugin.getShopUtils().getShops()) { - org.bukkit.Location l = shop.getLocation(); - Location location = new Location(l.getWorld().getName(),l.getBlockX(), l.getBlockY(), l.getBlockZ()); - if (!location.isPlotArea()) { - continue; - } - if (!event.getPlot().getArea().contains(location)) { - return; - } - - plugin.getShopUtils().removeShop(shop, true); - } + removeShopsFromPlot(event.getPlot()); } @Subscribe public void onClearPlot(PlotClearEvent event) { - for (Shop shop: plugin.getShopUtils().getShops()) { - org.bukkit.Location l = shop.getLocation(); - Location location = new Location(l.getWorld().getName(),l.getBlockX(), l.getBlockY(), l.getBlockZ()); - if (!location.isPlotArea()) { - continue; - } - if (!event.getPlot().getArea().contains(location)) { - return; - } + removeShopsFromPlot(event.getPlot()); + } - plugin.getShopUtils().removeShop(shop, true); + private void removeShopsFromPlot(Plot plot) { + Set regions = plot.getRegions(); + for (Shop shop : plugin.getShopUtils().getShops()) { + for (CuboidRegion region : regions) { + org.bukkit.Location loc = shop.getLocation(); + if (!region.contains(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()))) { + continue; + } + + plugin.getShopUtils().removeShop(shop, true); + } } } diff --git a/src/main/java/de/epiceric/shopchest/sql/MySQL.java b/src/main/java/de/epiceric/shopchest/sql/MySQL.java index 3a6df4e..6f1ebe1 100644 --- a/src/main/java/de/epiceric/shopchest/sql/MySQL.java +++ b/src/main/java/de/epiceric/shopchest/sql/MySQL.java @@ -21,7 +21,7 @@ public class MySQL extends Database { @Override HikariDataSource getDataSource() { HikariConfig config = new HikariConfig(); - config.setJdbcUrl(String.format("jdbc:mysql://%s:%d/%s?autoReconnect=true&useSSL=false&serverTimezone=UTC", + config.setJdbcUrl(String.format("jdbc:mariadb://%s:%d/%s", Config.databaseMySqlHost, Config.databaseMySqlPort, Config.databaseMySqlDatabase)); config.setUsername(Config.databaseMySqlUsername); config.setPassword(Config.databaseMySqlPassword);