2015-02-03 13:46:25 +11:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
|
|
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
|
|
|
// /
|
|
|
|
// This program is free software; you can redistribute it and/or modify /
|
|
|
|
// it under the terms of the GNU General Public License as published by /
|
|
|
|
// the Free Software Foundation; either version 3 of the License, or /
|
|
|
|
// (at your option) any later version. /
|
|
|
|
// /
|
|
|
|
// This program is distributed in the hope that it will be useful, /
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
|
|
|
// GNU General Public License for more details. /
|
|
|
|
// /
|
|
|
|
// You should have received a copy of the GNU General Public License /
|
|
|
|
// along with this program; if not, write to the Free Software Foundation, /
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
|
|
|
// /
|
|
|
|
// You can contact us via: support@intellectualsites.com /
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
package com.intellectualcrafters.plot.commands;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2015-02-19 19:51:10 +11:00
|
|
|
import com.intellectualcrafters.plot.PlotSquared;
|
2015-02-03 13:46:25 +11:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
|
|
|
import com.intellectualcrafters.plot.database.DBFunc;
|
|
|
|
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
|
|
|
import com.intellectualcrafters.plot.flag.Flag;
|
|
|
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
|
|
|
import com.intellectualcrafters.plot.object.Plot;
|
2015-02-21 22:38:44 +11:00
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2015-02-22 17:47:15 +11:00
|
|
|
import com.intellectualcrafters.plot.util.BlockManager;
|
2015-02-21 22:38:44 +11:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-02-03 13:46:25 +11:00
|
|
|
|
|
|
|
public class DebugFixFlags extends SubCommand {
|
|
|
|
public DebugFixFlags() {
|
|
|
|
super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false);
|
|
|
|
}
|
2015-02-20 17:34:19 +11:00
|
|
|
|
2015-02-03 13:46:25 +11:00
|
|
|
@Override
|
2015-02-21 18:30:55 +11:00
|
|
|
public boolean execute(final PlotPlayer plr, final String... args) {
|
2015-02-03 13:46:25 +11:00
|
|
|
if (plr != null) {
|
2015-02-21 22:24:46 +11:00
|
|
|
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
|
2015-02-03 13:46:25 +11:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (args.length != 1) {
|
2015-02-21 22:24:46 +11:00
|
|
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags <world>");
|
2015-02-03 13:46:25 +11:00
|
|
|
return false;
|
|
|
|
}
|
2015-02-22 17:47:15 +11:00
|
|
|
final String world = args[0];
|
|
|
|
if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) {
|
2015-02-21 22:24:46 +11:00
|
|
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
|
2015-02-03 13:46:25 +11:00
|
|
|
return false;
|
|
|
|
}
|
2015-02-21 22:24:46 +11:00
|
|
|
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
2015-02-20 17:34:19 +11:00
|
|
|
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
|
|
|
final Set<Flag> flags = plot.settings.flags;
|
|
|
|
final ArrayList<Flag> toRemove = new ArrayList<Flag>();
|
|
|
|
for (final Flag flag : flags) {
|
|
|
|
final AbstractFlag af = FlagManager.getFlag(flag.getKey());
|
2015-02-03 13:46:25 +11:00
|
|
|
if (af == null) {
|
|
|
|
toRemove.add(flag);
|
|
|
|
}
|
|
|
|
}
|
2015-02-20 17:34:19 +11:00
|
|
|
for (final Flag flag : toRemove) {
|
2015-02-03 13:46:25 +11:00
|
|
|
plot.settings.flags.remove(flag);
|
|
|
|
}
|
|
|
|
if (toRemove.size() > 0) {
|
|
|
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
|
|
|
}
|
|
|
|
}
|
2015-02-21 22:24:46 +11:00
|
|
|
MainUtil.sendMessage(plr, "&aDone!");
|
2015-02-03 13:46:25 +11:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|