Sponge stuff + done flag

This commit is contained in:
boy0001
2015-08-14 08:52:31 +10:00
parent 393a85c1bc
commit ccbd2ab30f
19 changed files with 211 additions and 40 deletions

View File

@ -88,6 +88,10 @@ public class Clear extends SubCommand {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false;
}
if (Settings.DONE_COUNTS_TOWARDS_LIMIT && FlagManager.isPlotFlagTrue(plot, "done" ) && MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr)) {
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
return false;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
@ -96,7 +100,7 @@ public class Clear extends SubCommand {
@Override
public void run() {
// If the state changes, then mark it as no longer done
if (FlagManager.isPlotFlagTrue(plot, "done" )) {
if (FlagManager.getPlotFlag(plot, "done" ) != null) {
FlagManager.removePlotFlag(plot, "done");
}
if (FlagManager.getPlotFlag(plot, "analysis") != null) {

View File

@ -0,0 +1,71 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// 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 com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "continue",
description = "Continue a plot that was previously marked as done",
permission = "plots.done",
category = CommandCategory.ACTIONS,
requiredType = RequiredType.NONE
)
public class Continue extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();
final Plot plot = MainUtil.getPlot(loc);
if (plot == null || !plot.hasOwner()) {
return !sendMessage(plr, C.NOT_IN_PLOT);
}
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
if (!plot.getSettings().flags.containsKey("done")) {
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
return false;
}
if (MainUtil.runners.containsKey(plot)) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false;
}
FlagManager.removePlotFlag(plot, "done");
MainUtil.sendMessage(plr, C.DONE_REMOVED);
return true;
}
}

View File

@ -103,6 +103,14 @@ public class DebugExec extends SubCommand {
}
}
public ScriptEngine getEngine() {
return engine;
}
public Bindings getScope() {
return scope;
}
public void init() {
if (engine != null) {
return;

View File

@ -100,11 +100,12 @@ public class DebugUUID extends SubCommand {
if (args.length != 2 || !args[1].equals("-o")) {
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o");
MainUtil.sendMessage(player, "&cBe aware of the following!");
MainUtil.sendMessage(player, "&8 - &cUse the database command or another method to backup your plots beforehand");
MainUtil.sendMessage(player, "&8 - &cIf the process is interrupted, all plots could be deleted");
MainUtil.sendMessage(player, "&8 - &cIf an error occurs, all plots could be deleted");
MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion");
MainUtil.sendMessage(player, "&cBACK UP YOUR DATABASE BEFORE USING THIS!!!");
MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready");
MainUtil.sendMessage(player, "&cTO REITERATE: BACK UP YOUR DATABASE BEFORE USING THIS!!!");
MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready :)");
return false;
}
@ -114,10 +115,8 @@ public class DebugUUID extends SubCommand {
}
MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion");
MainUtil.sendConsoleMessage("&7 - Disconnecting players");
for (PlotPlayer user : UUIDHandler.getPlayers().values()) {
for (PlotPlayer pp : UUIDHandler.getPlayers().values()) {
pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
}
for (PlotPlayer pp : UUIDHandler.getPlayers().values()) {
pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
}
MainUtil.sendConsoleMessage("&7 - Initializing map");
@ -240,7 +239,7 @@ public class DebugUUID extends SubCommand {
MainUtil.sendConsoleMessage("&7 - Creating tables");
try {
database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite");
database.createTables();
if (!result) {
MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery");
for (Plot plot : PS.get().getPlots()) {

View File

@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;

View File

@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.bukkit.ChatColor;
@ -41,6 +42,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.Rating;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
@ -101,6 +103,9 @@ public class list extends SubCommand {
if (Permissions.hasPermission(player, "plots.list.world")) {
args.add("<world>");
}
if (Permissions.hasPermission(player, "plots.list.done")) {
args.add("<world>");
}
return args.toArray(new String[args.size()]);
}
@ -175,6 +180,50 @@ public class list extends SubCommand {
plots = new ArrayList<>(PS.get().getPlots());
break;
}
case "done": {
if (!Permissions.hasPermission(plr, "plots.list.done")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.done");
return false;
}
plots = new ArrayList<>();
String match;
if (args.length == 2) {
match = args[2];
}
else {
match = null;
}
for (Plot plot : PS.get().getPlots()) {
Flag flag = plot.getSettings().flags.get("done");
if (flag == null) {
return false;
}
if (match != null) {
flag.getValueString().matches(match);
}
else {
plots.add(plot);
}
}
if (match != null) {
Collections.sort(plots, new Comparator<Plot>() {
@Override
public int compare(Plot a, Plot b) {
String va = a.getSettings().flags.get("done").getValueString();
String vb = b.getSettings().flags.get("done").getValueString();
if (MathMan.isInteger(va)) {
if (MathMan.isInteger(vb)) {
return Integer.parseInt(va) - Integer.parseInt(vb);
}
return -1;
}
return 1;
}
});
sort = false;
}
break;
}
case "top": {
if (!Permissions.hasPermission(plr, "plots.list.top")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top");