mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-01 21:24:43 +02:00
restructure a couple things.
This commit is contained in:
@ -45,10 +45,6 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class FlagManager {
|
||||
// TODO add some flags
|
||||
// - Plot clear interval
|
||||
@SuppressWarnings("unused")
|
||||
public class FlagManager {
|
||||
|
||||
@ -108,7 +104,7 @@ public class FlagManager {
|
||||
flag.setKey(af);
|
||||
}
|
||||
}
|
||||
if (PS.get().getAllPlotsRaw() != null) {
|
||||
if (PS.get().getAllPlotsRaw() != null) {
|
||||
for (final Plot plot : PS.get().getPlotsRaw()) {
|
||||
final Flag flag = plot.getFlags().get(af.getKey());
|
||||
if (flag != null) {
|
||||
@ -204,14 +200,16 @@ public class FlagManager {
|
||||
/**
|
||||
* Add a flag to a plot
|
||||
* @param plot
|
||||
* @param flag
|
||||
*/
|
||||
* @param flag
|
||||
*/
|
||||
public static boolean addPlotFlag(final Plot origin, final Flag flag) {
|
||||
final boolean result = EventUtil.manager.callFlagAdd(flag, origin);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
plot.getSettings().flags.put(flag.getKey(), flag);
|
||||
return false;
|
||||
}
|
||||
for (Plot plot : MainUtil.getConnectedPlots(origin)) {
|
||||
plot.getFlags().put(flag.getKey(), flag);
|
||||
MainUtil.reEnterPlot(plot);
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
}
|
||||
return true;
|
||||
@ -220,7 +218,7 @@ public class FlagManager {
|
||||
public static boolean addPlotFlagAbs(final Plot plot, final Flag flag) {
|
||||
final boolean result = EventUtil.manager.callFlagAdd(flag, plot);
|
||||
if (!result) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
plot.getFlags().put(flag.getKey(), flag);
|
||||
return true;
|
||||
@ -270,17 +268,17 @@ public class FlagManager {
|
||||
public static HashMap<String, Flag> getSettingFlags(final String world, final PlotSettings settings) {
|
||||
return getPlotFlags(world, settings, false);
|
||||
}
|
||||
|
||||
|
||||
public static boolean removePlotFlag(final Plot plot, final String id) {
|
||||
final Flag flag = plot.getFlags().remove(id);
|
||||
if (flag == null) {
|
||||
return false;
|
||||
}
|
||||
final boolean result = EventUtil.manager.callFlagRemove(flag, plot);
|
||||
final boolean result = EventUtil.manager.callFlagRemove(flag, plot);
|
||||
if (!result) {
|
||||
plot.getFlags().put(id, flag);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
MainUtil.reEnterPlot(plot);
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
return true;
|
||||
@ -298,19 +296,21 @@ public class FlagManager {
|
||||
}
|
||||
DBFunc.setFlags(cluster, cluster.settings.flags.values());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setPlotFlags(final Plot plot, final Set<Flag> flags) {
|
||||
if ((flags != null) && (flags.size() != 0)) {
|
||||
plot.getSettings().flags.clear();
|
||||
}
|
||||
|
||||
public static void setPlotFlags(final Plot origin, final Set<Flag> flags) {
|
||||
for (Plot plot : origin.getConnectedPlots()) {
|
||||
if ((flags != null) && (flags.size() != 0)) {
|
||||
plot.getFlags().clear();
|
||||
for (final Flag flag : flags) {
|
||||
plot.getFlags().put(flag.getKey(), flag);
|
||||
}
|
||||
} else if (plot.getFlags().size() == 0) {
|
||||
return;
|
||||
} else {
|
||||
plot.getSettings().flags.put(flag.getKey(), flag);
|
||||
}
|
||||
} else if (plot.getSettings().flags.size() == 0) {
|
||||
return;
|
||||
plot.getFlags().clear();
|
||||
}
|
||||
MainUtil.reEnterPlot(plot);
|
||||
plot.getSettings().flags.clear();
|
||||
}
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user