mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fixed flag system
This commit is contained in:
parent
ab465868ee
commit
4475290443
@ -30,6 +30,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
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;
|
||||
@ -110,7 +111,7 @@ public class FlagCmd extends SubCommand {
|
||||
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove");
|
||||
return false;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
||||
return false;
|
||||
}
|
||||
@ -128,10 +129,17 @@ public class FlagCmd extends SubCommand {
|
||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
|
||||
if (!result) {
|
||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||
return false;
|
||||
if (args.length == 3 && flag.getAbstractFlag().isList()) {
|
||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
|
||||
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||
}
|
||||
else {
|
||||
boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
|
||||
if (!result) {
|
||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, C.FLAG_REMOVED);
|
||||
PlotListener.plotEntry(player, plot);
|
||||
@ -166,13 +174,14 @@ public class FlagCmd extends SubCommand {
|
||||
flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
|
||||
}
|
||||
else {
|
||||
((FlagValue.ListValue) flag.getValue()).add(flag.getValue(), value);
|
||||
((FlagValue.ListValue) flag.getAbstractFlag().value).add(flag.getValue(), value);
|
||||
}
|
||||
boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
if (!result) {
|
||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||
PlayerFunctions.sendMessage(player, C.FLAG_ADDED);
|
||||
PlotListener.plotEntry(player, plot);
|
||||
return true;
|
||||
|
@ -49,7 +49,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
||||
*/
|
||||
public static final String MAIN_PERMISSION = "plots.use";
|
||||
|
||||
private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec()};
|
||||
private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd()};
|
||||
|
||||
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||
{
|
||||
|
@ -78,14 +78,14 @@ public class PlotMeConverter {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sendMessage("Conversion has started");
|
||||
sendMessage("Connecting to PlotMe DB");
|
||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||
final String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||
final File plotMeFile = new File(dataFolder + "config.yml");
|
||||
if (!plotMeFile.exists()) {
|
||||
return;
|
||||
}
|
||||
sendMessage("Conversion has started");
|
||||
sendMessage("Connecting to PlotMe DB");
|
||||
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
|
||||
int count = 0;
|
||||
|
||||
|
@ -704,7 +704,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (element.contains(":")) {
|
||||
final String[] split = element.split(":");
|
||||
try {
|
||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
||||
Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str);
|
||||
flags.add(flag);
|
||||
} catch (final Exception e) {
|
||||
|
@ -52,4 +52,9 @@ public class PlotBlock {
|
||||
public int hashCode() {
|
||||
return (id + data) * (id + data + 1) + data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.id + ":" + this.data;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user