diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/ClusterFlagRemoveEvent.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/ClusterFlagRemoveEvent.java deleted file mode 100644 index 40acef111..000000000 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/ClusterFlagRemoveEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.github.intellectualsites.plotsquared.bukkit.events; - -import com.github.intellectualsites.plotsquared.plot.flag.Flag; -import com.github.intellectualsites.plotsquared.plot.object.PlotCluster; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -/** - * Called when a flag is removed from a plot. - */ -public class ClusterFlagRemoveEvent extends Event implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private final PlotCluster cluster; - private final Flag flag; - private boolean cancelled; - - /** - * PlotFlagRemoveEvent: Called when a flag is removed from a plot. - * - * @param flag Flag that was removed - * @param cluster PlotCluster from which the flag was removed - */ - public ClusterFlagRemoveEvent(Flag flag, PlotCluster cluster) { - this.cluster = cluster; - this.flag = flag; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - /** - * Get the cluster involved. - * - * @return PlotCluster - */ - public PlotCluster getCluster() { - return this.cluster; - } - - /** - * Get the flag involved. - * - * @return Flag - */ - public Flag getFlag() { - return this.flag; - } - - @Override public HandlerList getHandlers() { - return handlers; - } - - @Override public boolean isCancelled() { - return this.cancelled; - } - - @Override public void setCancelled(boolean b) { - this.cancelled = b; - } -} diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitEventUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitEventUtil.java index 7fd22b55e..5a4cf885a 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitEventUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitEventUtil.java @@ -101,10 +101,6 @@ public final class BukkitEventUtil extends EventUtil { new PlotChangeOwnerEvent(getPlayer(initiator), plot, oldOwner, newOwner, hasOldOwner)); } - @Override public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) { - return callEvent(new ClusterFlagRemoveEvent(flag, cluster)); - } - @Override @Nullable public Rating callRating(PlotPlayer player, Plot plot, Rating rating) { PlotRateEvent event = new PlotRateEvent(player, rating, plot); Bukkit.getServer().getPluginManager().callEvent(event); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java index a26d4d02e..e5341103d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java @@ -143,14 +143,6 @@ public interface AbstractDB { */ void setFlags(Plot plot, HashMap, Object> flags); - /** - * Set cluster flags. - * - * @param cluster PlotCluster Object - * @param flags flags to set (flag[]) - */ - void setFlags(PlotCluster cluster, HashMap, Object> flags); - /** * Rename a cluster to the given name. * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java index 5050c699f..46ede5d3c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java @@ -298,13 +298,6 @@ public class DBFunc { DBFunc.dbManager.setFlags(plot, flags); } - public static void setFlags(PlotCluster cluster, HashMap, Object> flags) { - if (dbManager == null) { - return; - } - DBFunc.dbManager.setFlags(cluster, flags); - } - /** * @param plot * @param alias diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java index 66a21174d..a3e6aadd5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java @@ -2666,41 +2666,6 @@ import java.util.concurrent.atomic.AtomicInteger; merged[3 - i] = (m & 1 << i) != 0; } cluster.settings.setMerged(merged); - String[] flags_string; - String myflags = resultSet.getString("flags"); - if (myflags == null || myflags.isEmpty()) { - flags_string = new String[] {}; - } else { - flags_string = myflags.split(","); - } - HashMap, Object> flags = new HashMap<>(); - for (String element : flags_string) { - if (element.contains(":")) { - String[] split = element.split(":"); - String flag_str = - split[1].replaceAll("\u00AF", ":").replaceAll("´", ","); - Flag flag = FlagManager.getOrCreateFlag(split[0]); - if (flag == null) { - flag = new StringFlag(split[0]) { - @Override public String getValueDescription() { - return "Generic Filler Flag"; - } - }; - } - flags.put(flag, flag.parseValue(flag_str)); - } else { - Flag flag = FlagManager.getOrCreateFlag(element); - if (flag == null) { - flag = new StringFlag(element) { - @Override public String getValueDescription() { - return "Generic Filler Flag"; - } - }; - } - flags.put(flag, flag.parseValue("")); - } - } - cluster.settings.flags = flags; } else { PlotSquared.debug("&cCluster #" + id + "(" + cluster + ") in cluster_settings does not exist. Please create the cluster or remove this entry."); @@ -2726,32 +2691,6 @@ import java.util.concurrent.atomic.AtomicInteger; return newClusters; } - @Override public void setFlags(final PlotCluster cluster, HashMap, Object> flags) { - final StringBuilder flag_string = new StringBuilder(); - int i = 0; - for (Entry, Object> flag : flags.entrySet()) { - if (i != 0) { - flag_string.append(','); - } - flag_string.append(flag.getKey().getName()).append(':').append( - flag.getKey().valueToString(flag.getValue()).replaceAll(":", "\u00AF") - .replaceAll(",", "´")); - i++; - } - addClusterTask(cluster, new UniqueStatement("setFlags") { - @Override public void set(PreparedStatement stmt) throws SQLException { - stmt.setString(1, flag_string.toString()); - stmt.setInt(2, getClusterId(cluster)); - } - - @Override public PreparedStatement get() throws SQLException { - return SQLManager.this.connection.prepareStatement( - "UPDATE `" + SQLManager.this.prefix - + "cluster_settings` SET `flags` = ? WHERE `cluster_id` = ?"); - } - }); - } - @Override public void setClusterName(final PlotCluster cluster, final String name) { addClusterTask(cluster, new UniqueStatement("setClusterName") { @Override public void set(PreparedStatement stmt) throws SQLException { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java index 06be89e15..98c523b2e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java @@ -141,13 +141,6 @@ public class FlagManager { return true; } - public static boolean addClusterFlag(PlotCluster cluster, Flag flag, V value) { - getSettingFlag(cluster.area, cluster.settings, flag); - cluster.settings.flags.put(flag, value); - DBFunc.setFlags(cluster, cluster.settings.flags); - return true; - } - /** * Returns a map of the {@link Flag}s and their values for the specified plot. * @@ -217,20 +210,6 @@ public class FlagManager { return true; } - public static boolean removeClusterFlag(PlotCluster cluster, Flag id) { - Object object = cluster.settings.flags.remove(id); - if (object == null) { - return false; - } - boolean result = EventUtil.manager.callFlagRemove(id, object, cluster); - if (!result) { - cluster.settings.flags.put(id, object); - return false; - } - DBFunc.setFlags(cluster, cluster.settings.flags); - return true; - } - public static void setPlotFlags(Plot origin, HashMap, Object> flags) { for (Plot plot : origin.getConnectedPlots()) { if (flags != null && !flags.isEmpty()) { @@ -248,20 +227,6 @@ public class FlagManager { } } - public static void setClusterFlags(PlotCluster cluster, Set flags) { - if (flags != null && !flags.isEmpty()) { - cluster.settings.flags.clear(); - for (Flag flag : flags) { - cluster.settings.flags.put(flag, flag); - } - } else if (cluster.settings.flags.isEmpty()) { - return; - } else { - cluster.settings.flags.clear(); - } - DBFunc.setFlags(cluster, cluster.settings.flags); - } - /** * Get a list of registered {@link Flag} objects based on player permissions. * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java index b8037944e..0c608c0e9 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java @@ -43,8 +43,6 @@ public abstract class EventUtil { public abstract boolean callFlagRemove(Flag flag, Plot plot, Object value); - public abstract boolean callFlagRemove(Flag flag, Object value, PlotCluster cluster); - public abstract boolean callMerge(Plot plot, int dir, int max); public abstract boolean callAutoMerge(Plot plot, List plots); diff --git a/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java index 7b29cdf97..1ef04abba 100644 --- a/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java +++ b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java @@ -84,9 +84,6 @@ public class AbstractDBTest implements AbstractDB { @Override public void setFlags(Plot plot, HashMap, Object> flags) { } - @Override public void setFlags(PlotCluster cluster, HashMap, Object> flags) { - } - @Override public void setClusterName(PlotCluster cluster, String name) { } diff --git a/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/util/EventUtilTest.java b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/util/EventUtilTest.java index e9d1f29ec..6ae75a86d 100644 --- a/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/util/EventUtilTest.java +++ b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/util/EventUtilTest.java @@ -40,10 +40,6 @@ public class EventUtilTest extends EventUtil { return true; } - @Override public boolean callFlagRemove(Flag flag, Object value, PlotCluster cluster) { - return true; - } - @Override public boolean callMerge(Plot plot, int dir, int max) { return false; }