mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
parent
9d77b422df
commit
f2431c869f
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>3.2.7</version>
|
||||
<version>3.2.8</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
@ -1994,6 +1994,7 @@ public class PS {
|
||||
Settings.FANCY_CHAT = false;
|
||||
}
|
||||
Settings.METRICS = config.getBoolean("metrics");
|
||||
Settings.UPDATE_NOTIFICATIONS = config.getBoolean("update-notifications");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setalias",
|
||||
permission = "plots.set.alias",
|
||||
description = "Set the plot name",
|
||||
usage = "/plot alias <alias>",
|
||||
aliases = { "alias", "sa", "name", "rename", "setname", "seta" },
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Alias extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, final String alias) {
|
||||
if (alias.length() == 0) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
if (alias.length() >= 50) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG);
|
||||
return false;
|
||||
}
|
||||
if (!StringMan.isAlphanumericUnd(alias)) {
|
||||
C.NOT_VALID_VALUE.send(plr);
|
||||
return false;
|
||||
}
|
||||
for (final Plot p : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
|
||||
if (p.getAlias().equalsIgnoreCase(alias)) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (UUIDHandler.nameExists(new StringWrapper(alias)) || PS.get().isPlotWorld(alias)) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
plot.setAlias(alias);
|
||||
MainUtil.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setbiome",
|
||||
permission = "plots.set.biome",
|
||||
description = "Set the plot biome",
|
||||
usage = "/plot biome [biome]",
|
||||
aliases = { "biome", "sb", "setb", "b" },
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Biome extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, final String value) {
|
||||
final int biome = BlockManager.manager.getBiomeFromString(value);
|
||||
if (biome == -1) {
|
||||
String biomes = StringMan.join(BlockManager.manager.getBiomeList(), C.BLOCK_LIST_SEPARATER.s());
|
||||
C.NEED_BIOME.send(plr);
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
plot.setBiome(value.toUpperCase(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + value.toLowerCase());
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
@ -20,21 +20,16 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
@ -52,7 +47,6 @@ public class Buy extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
|
||||
if (EconHandler.manager == null) {
|
||||
return sendMessage(plr, C.ECON_DISABLED);
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setdescription",
|
||||
permission = "plots.set.desc",
|
||||
description = "Set the plot description",
|
||||
usage = "/plot desc <description>",
|
||||
aliases = { "desc", "setdesc", "setd", "description" },
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Desc extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, Plot plot, String desc) {
|
||||
if (desc.length() == 0) {
|
||||
plot.removeFlag("description");
|
||||
MainUtil.sendMessage(plr, C.DESC_UNSET);
|
||||
return true;
|
||||
}
|
||||
final Flag flag = new Flag(FlagManager.getFlag("description"), desc);
|
||||
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.DESC_SET);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -39,10 +39,10 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "flag",
|
||||
aliases = { "f" },
|
||||
command = "setflag",
|
||||
aliases = { "f", "flag", "setf", "setflag" },
|
||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
||||
description = "Manage plot flags",
|
||||
description = "Set plot flags",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.flag")
|
||||
|
@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -51,6 +52,7 @@ import com.plotsquared.general.commands.CommandManager;
|
||||
public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
|
||||
private static MainCommand instance;
|
||||
private HashMap<String, Command<PlotPlayer>> setCommands;
|
||||
|
||||
public static MainCommand getInstance() {
|
||||
if (instance == null) {
|
||||
@ -86,7 +88,6 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
createCommand(new Toggle());
|
||||
createCommand(new Clear());
|
||||
createCommand(new Delete());
|
||||
createCommand(new SetOwner());
|
||||
createCommand(new Trust());
|
||||
createCommand(new Add());
|
||||
createCommand(new Deny());
|
||||
@ -127,11 +128,17 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
createCommand(new Done());
|
||||
createCommand(new Continue());
|
||||
createCommand(new BO3());
|
||||
// set commands
|
||||
createCommand(new Owner());
|
||||
createCommand(new Desc());
|
||||
createCommand(new Biome());
|
||||
createCommand(new Alias());
|
||||
createCommand(new SetHome());
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean no_permission(final PlotPlayer player, final String permission) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, permission);
|
||||
return false;
|
||||
@ -391,7 +398,6 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
cmd = current;
|
||||
}
|
||||
}
|
||||
System.out.print(StringMan.getString(allargs) + " | " + cmd + " | " + best);
|
||||
if (cmd == null) {
|
||||
cmd = new StringComparison<>(label, getCommandAndAliases(null, plr)).getMatchObject();
|
||||
}
|
||||
|
@ -20,22 +20,16 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -43,57 +37,36 @@ command = "setowner",
|
||||
permission = "plots.set.owner",
|
||||
description = "Set the plot owner",
|
||||
usage = "/plot setowner <player>",
|
||||
aliases = { "so" },
|
||||
aliases = { "owner", "so", "seto" },
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class SetOwner extends SubCommand {
|
||||
|
||||
public SetOwner() {
|
||||
requiredArguments = new Argument[] { Argument.PlayerName };
|
||||
}
|
||||
|
||||
private UUID getUUID(final String string) {
|
||||
return UUIDHandler.getUUID(string, null);
|
||||
}
|
||||
public class Owner extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if ((plot == null) || ((plot.owner == null) && !Permissions.hasPermission(plr, "plots.admin.command.setowner"))) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
if (args.length < 1) {
|
||||
MainUtil.sendMessage(plr, C.NEED_USER);
|
||||
return false;
|
||||
}
|
||||
public boolean set(PlotPlayer plr, Plot plot, String value) {
|
||||
HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
|
||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
final PlotPlayer other = UUIDHandler.getPlayer(args[0]);
|
||||
if (other == null) {
|
||||
if (uuid == null || !Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
final int size = plots.size();
|
||||
final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(other) : MainUtil.getPlayerPlotCount(loc.getWorld(), other)) + size;
|
||||
if (currentPlots > MainUtil.getAllowedPlots(other)) {
|
||||
sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final PlotPlayer other = UUIDHandler.getPlayer(value);
|
||||
UUID uuid;
|
||||
uuid = other == null ? (Permissions.hasPermission(plr, "plots.admin.command.setowner") ? UUIDHandler.getUUID(value, null) : null) : other.getUUID();
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, value);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
|
||||
String name = other == null ? UUIDHandler.getName(uuid) : other.getName();
|
||||
if (plot.isOwner(uuid)) {
|
||||
C.ALREADY_OWNER.send(plr);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
final int size = plots.size();
|
||||
final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(other) : MainUtil.getPlayerPlotCount(plot.world, other)) + size;
|
||||
if (currentPlots > MainUtil.getAllowedPlots(other)) {
|
||||
sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
plot.setOwner(uuid);
|
||||
MainUtil.setSign(args[0], plot);
|
||||
MainUtil.setSign(name, plot);
|
||||
MainUtil.sendMessage(plr, C.SET_OWNER);
|
||||
if (other != null) {
|
||||
MainUtil.sendMessage(other, C.NOW_OWNER, plot.world + ";" + plot.id);
|
@ -22,29 +22,25 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -59,228 +55,125 @@ public class Set extends SubCommand {
|
||||
public final static String[] values = new String[] { "biome", "alias", "home", "flag" };
|
||||
public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" };
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args.length < 1) {
|
||||
final PlotManager manager = PS.get().getPlotManager(loc.getWorld());
|
||||
final ArrayList<String> newValues = new ArrayList<String>();
|
||||
newValues.addAll(Arrays.asList(values));
|
||||
newValues.addAll(Arrays.asList(manager.getPlotComponents(PS.get().getPlotWorld(loc.getWorld()), plot.id)));
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues));
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < aliases.length; i++) {
|
||||
if (aliases[i].equalsIgnoreCase(args[0])) {
|
||||
args[0] = values[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("flag")) {
|
||||
List<String> arglist = new ArrayList<>(Arrays.asList("flag", "set"));
|
||||
for (String arg : Arrays.copyOfRange(args, 1, args.length)) {
|
||||
arglist.add(arg);
|
||||
}
|
||||
return MainCommand.onCommand(plr, "plot", arglist.toArray(new String[0]));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("home")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set.home")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.home");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("none")) {
|
||||
plot.setHome(null);
|
||||
return true;
|
||||
}
|
||||
return MainUtil.sendMessage(plr, C.HOME_ARGUMENT);
|
||||
}
|
||||
//set to current location
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final Location base = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1);
|
||||
base.setY(0);
|
||||
final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ());
|
||||
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ(), relative.getYaw(), relative.getPitch());
|
||||
plot.setHome(blockloc);
|
||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("desc")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set.desc")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.desc");
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(plr, C.MISSING_DESC);
|
||||
return false;
|
||||
}
|
||||
final StringBuilder desc = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
desc.append(args[i]).append(" ");
|
||||
}
|
||||
final String descValue = desc.substring(0, desc.length() - 1);
|
||||
|
||||
final Flag flag = new Flag(FlagManager.getFlag("description"), descValue);
|
||||
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.DESC_SET);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("alias")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set.alias")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.alias");
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(plr, C.MISSING_ALIAS);
|
||||
return false;
|
||||
}
|
||||
final String alias = args[1];
|
||||
if (alias.length() >= 50) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG);
|
||||
return false;
|
||||
}
|
||||
for (final Plot p : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
|
||||
if (p.getAlias().equalsIgnoreCase(alias)) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
if (UUIDHandler.nameExists(new StringWrapper(alias))) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
plot.setAlias(alias);
|
||||
MainUtil.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("biome")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set.biome")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.biome");
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(plr, C.NEED_BIOME);
|
||||
return false;
|
||||
}
|
||||
if (args[1].length() < 2) {
|
||||
sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2");
|
||||
return false;
|
||||
}
|
||||
final int biome = BlockManager.manager.getBiomeFromString(args[1]);
|
||||
if (biome == -1) {
|
||||
MainUtil.sendMessage(plr, getBiomeList(BlockManager.manager.getBiomeList()));
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
plot.setBiome(args[1].toUpperCase(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + args[1].toLowerCase());
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("limit")) {
|
||||
// /plot set limit Empire92 +1
|
||||
return true;
|
||||
}
|
||||
// Get components
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final PlotManager manager = PS.get().getPlotManager(world);
|
||||
final String[] components = manager.getPlotComponents(plotworld, plot.id);
|
||||
|
||||
final boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
|
||||
|
||||
for (final String component : components) {
|
||||
if (component.equalsIgnoreCase(args[0])) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set." + component)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + component);
|
||||
return false;
|
||||
}
|
||||
PlotBlock[] blocks;
|
||||
try {
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
final String[] split = args[1].split(",");
|
||||
blocks = Configuration.BLOCKLIST.parseString(args[1]);
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
final PlotBlock block = blocks[i];
|
||||
if (block == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, split[i]);
|
||||
String name;
|
||||
if (split[i].contains("%")) {
|
||||
name = split[i].split("%")[1];
|
||||
} else {
|
||||
name = split[i];
|
||||
private final SetCommand component;
|
||||
|
||||
public Set() {
|
||||
component = new SetCommand() {
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, final Plot plot, String value) {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final PlotManager manager = PS.get().getPlotManager(world);
|
||||
final String[] components = manager.getPlotComponents(plotworld, plot.id);
|
||||
final boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
|
||||
|
||||
String[] args = value.split(" ");
|
||||
String material = StringMan.join(Arrays.copyOfRange(args, 1, args.length), ",").trim();
|
||||
|
||||
for (final String component : components) {
|
||||
if (component.equalsIgnoreCase(args[0])) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set." + component)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + component);
|
||||
return false;
|
||||
}
|
||||
PlotBlock[] blocks;
|
||||
try {
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
final StringComparison<PlotBlock>.ComparisonResult match = BlockManager.manager.getClosestBlock(name);
|
||||
if (match != null) {
|
||||
name = BlockManager.manager.getClosestMatchingName(match.best);
|
||||
if (name != null) {
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, name.toLowerCase());
|
||||
final String[] split = material.split(",");
|
||||
blocks = Configuration.BLOCKLIST.parseString(material);
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
final PlotBlock block = blocks[i];
|
||||
if (block == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, split[i]);
|
||||
String name;
|
||||
if (split[i].contains("%")) {
|
||||
name = split[i].split("%")[1];
|
||||
} else {
|
||||
name = split[i];
|
||||
}
|
||||
final StringComparison<PlotBlock>.ComparisonResult match = BlockManager.manager.getClosestBlock(name);
|
||||
if (match != null) {
|
||||
name = BlockManager.manager.getClosestMatchingName(match.best);
|
||||
if (name != null) {
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, name.toLowerCase());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (!allowUnsafe && !BlockManager.manager.isBlockSolid(block)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (!allowUnsafe && !BlockManager.manager.isBlockSolid(block)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!allowUnsafe) {
|
||||
for (final PlotBlock block : blocks) {
|
||||
if (!BlockManager.manager.isBlockSolid(block)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
|
||||
return false;
|
||||
if (!allowUnsafe) {
|
||||
for (final PlotBlock block : blocks) {
|
||||
if (!BlockManager.manager.isBlockSolid(block)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e2) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, material);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
for (Plot current : MainUtil.getConnectedPlots(plot)) {
|
||||
manager.setComponent(plotworld, current.id, component, blocks);
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
} catch (final Exception e2) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, args[1]);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
for (Plot current : MainUtil.getConnectedPlots(plot)) {
|
||||
manager.setComponent(plotworld, current.id, component, blocks);
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean noArgs(PlotPlayer plr) {
|
||||
final ArrayList<String> newValues = new ArrayList<String>();
|
||||
newValues.addAll(Arrays.asList("biome", "alias", "home", "flag"));
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.id)));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(newValues, C.BLOCK_LIST_SEPARATER.formatted()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
if (args.length == 0) {
|
||||
return noArgs(plr);
|
||||
}
|
||||
Command<PlotPlayer> cmd = MainCommand.getInstance().getCommand("set" + args[0]);
|
||||
if (cmd != null) {
|
||||
return cmd.onCommand(plr, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
// Additional checks
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
// components
|
||||
HashSet<String> components = new HashSet<String>(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.id)));
|
||||
if (components.contains(args[0].toLowerCase())) {
|
||||
return component.set(plr, plot, StringMan.join(args, " "));
|
||||
}
|
||||
// flag
|
||||
{
|
||||
AbstractFlag af;
|
||||
try {
|
||||
@ -299,31 +192,6 @@ public class Set extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final ArrayList<String> newValues = new ArrayList<String>();
|
||||
newValues.addAll(Arrays.asList(values));
|
||||
newValues.addAll(Arrays.asList(manager.getPlotComponents(PS.get().getPlotWorld(loc.getWorld()), plot.id)));
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues));
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getString(final String s) {
|
||||
return StringMan.replaceAll(C.BLOCK_LIST_ITEM.s(), "%mat%", s);
|
||||
}
|
||||
|
||||
private String getArgumentList(final List<String> newValues) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final String s : newValues) {
|
||||
builder.append(getString(s));
|
||||
}
|
||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||
}
|
||||
|
||||
private String getBiomeList(final String[] biomes) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.NEED_BIOME.s());
|
||||
for (final String b : biomes) {
|
||||
builder.append(getString(b));
|
||||
}
|
||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||
return noArgs(plr);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
public abstract class SetCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getCommand())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getCommand());
|
||||
MainUtil.sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getCommand())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getCommand());
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args.length == 0) {
|
||||
return set(plr, plot, "");
|
||||
}
|
||||
return set(plr, plot, StringMan.join(args, " "));
|
||||
}
|
||||
|
||||
public abstract boolean set(PlotPlayer plr, Plot plot, String value);
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "sethome",
|
||||
permission = "plots.set.home",
|
||||
description = "Set the plot home",
|
||||
usage = "/plot sethome [none]",
|
||||
aliases = { "sh", "seth" },
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class SetHome extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, final String value) {
|
||||
switch (value.toLowerCase()) {
|
||||
case "unset":
|
||||
case "remove":
|
||||
case "none": {
|
||||
plot.setHome(null);
|
||||
MainUtil.sendMessage(plr, C.POSITION_UNSET);
|
||||
return true;
|
||||
}
|
||||
case "": {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final Location base = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1);
|
||||
base.setY(0);
|
||||
final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ());
|
||||
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ(), relative.getYaw(), relative.getPitch());
|
||||
plot.setHome(blockloc);
|
||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||
}
|
||||
default: {
|
||||
MainUtil.sendMessage(plr, C.HOME_ARGUMENT);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -298,6 +298,7 @@ public enum C {
|
||||
BOSSBAR_CLEARING("$2Clearing plot: $1%id%", "Bar API"),
|
||||
|
||||
DESC_SET("$2Plot description set", "Desc"),
|
||||
DESC_UNSET("$2Plot description unset", "Desc"),
|
||||
MISSING_DESC("$2You need to specify a description", "Desc"),
|
||||
|
||||
/*
|
||||
@ -312,6 +313,7 @@ public enum C {
|
||||
*/
|
||||
MISSING_POSITION("$2You need to specify a position. Possible values: $1none", "Position"),
|
||||
POSITION_SET("$1Home position set to your current location", "Position"),
|
||||
POSITION_UNSET("$1Home position reset to the default location", "Position"),
|
||||
HOME_ARGUMENT("$2Use /plot set home [none]", "Position"),
|
||||
INVALID_POSITION("$2That is not a valid position value", "Position"),
|
||||
/*
|
||||
@ -389,7 +391,6 @@ public enum C {
|
||||
/*
|
||||
* Block List
|
||||
*/
|
||||
BLOCK_LIST_ITEM(" $1%mat%$2,", "Block List"),
|
||||
BLOCK_LIST_SEPARATER("$1,$2 ", "Block List"),
|
||||
/*
|
||||
* Biome
|
||||
@ -539,7 +540,6 @@ public enum C {
|
||||
FLAG_KEY("$2Key: %s", "Flag"),
|
||||
FLAG_TYPE("$2Type: %s", "Flag"),
|
||||
FLAG_DESC("$2Desc: %s", "Flag"),
|
||||
NEED_KEY("$2Possible values: $1%values%", "Flag"),
|
||||
NOT_VALID_FLAG("$2That is not a valid flag", "Flag"),
|
||||
NOT_VALID_VALUE("$2Flag values must be alphanumerical", "Flag"),
|
||||
FLAG_NOT_IN_PLOT("$2The plot does not have that flag", "Flag"),
|
||||
|
@ -30,6 +30,11 @@ import java.util.List;
|
||||
public class Settings {
|
||||
public static boolean USE_SQLUUIDHANDLER = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static boolean UPDATE_NOTIFICATIONS = true;
|
||||
|
||||
public static boolean ENABLE_CLUSTERS = false;
|
||||
public static boolean FAST_CLEAR = false;
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||
final Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
final Location top = getPlotTopLocAbs(hpw, id);
|
||||
final Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ());
|
||||
final Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ() - 1);
|
||||
final Location pos2 = new Location(plot.world, bot.getX(), 255, top.getZ() + 1);
|
||||
createSchemAbs(hpw, pos1, pos2, hpw.ROAD_HEIGHT, true);
|
||||
return true;
|
||||
@ -137,7 +137,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||
final Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
final Location top = getPlotTopLocAbs(hpw, id);
|
||||
final Location pos1 = new Location(plot.world, bot.getX(), 0, top.getZ() + 1);
|
||||
final Location pos1 = new Location(plot.world, bot.getX() - 1, 0, top.getZ() + 1);
|
||||
final Location pos2 = new Location(plot.world, top.getX() + 1, 255, bot.getZ());
|
||||
createSchemAbs(hpw, pos1, pos2, hpw.ROAD_HEIGHT, true);
|
||||
return true;
|
||||
|
@ -172,7 +172,9 @@ public class PlotAnalysis {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
wait(10000);
|
||||
synchronized (this) {
|
||||
wait(10000);
|
||||
}
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -66,6 +65,11 @@ public class PlotHandler {
|
||||
}
|
||||
|
||||
public static void setOwner(Plot plot, UUID owner) {
|
||||
if (!plot.hasOwner()) {
|
||||
plot.owner = owner;
|
||||
plot.create();
|
||||
return;
|
||||
}
|
||||
if (!plot.isMerged()) {
|
||||
if (!plot.owner.equals(owner)) {
|
||||
plot.owner = owner;
|
||||
|
@ -1803,6 +1803,8 @@ public class MainUtil {
|
||||
occupied = true;
|
||||
}
|
||||
}
|
||||
// world border
|
||||
updateWorldBorder(destination);
|
||||
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(getRegions(origin));
|
||||
// move / swap data
|
||||
for (Plot plot : plots) {
|
||||
@ -1918,6 +1920,8 @@ public class MainUtil {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// world border
|
||||
updateWorldBorder(destination);
|
||||
// copy data
|
||||
for (Plot plot : plots) {
|
||||
Plot other = MainUtil.getPlotAbs(destination.world , new PlotId(plot.id.x + offset.x, plot.id.y + offset.y));
|
||||
|
@ -2,6 +2,7 @@ package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -40,10 +41,11 @@ public class ChunkListener implements Listener {
|
||||
|
||||
private Chunk lastChunk = null;
|
||||
|
||||
final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
final RefMethod methodGetHandleChunk;
|
||||
final RefField mustSave = classChunk.getField("mustSave");
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private RefMethod methodGetHandleChunk;
|
||||
private final RefField mustSave = classChunk.getField("mustSave");
|
||||
|
||||
|
||||
public ChunkListener() {
|
||||
RefMethod method;
|
||||
@ -58,10 +60,11 @@ public class ChunkListener implements Listener {
|
||||
if (!Settings.CHUNK_PROCESSOR_GC) {
|
||||
return;
|
||||
}
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final int distance = Bukkit.getViewDistance() + 1;
|
||||
int time = 300;
|
||||
final int distance = Bukkit.getViewDistance() + 2;
|
||||
final HashMap<String, HashMap<ChunkLoc, Integer>> players = new HashMap<>();
|
||||
for (final Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
final PlotPlayer pp = entry.getValue();
|
||||
@ -101,38 +104,53 @@ public class ChunkListener implements Listener {
|
||||
if ((val == null) || (val < weight)) {
|
||||
map.put(chunk, weight);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
final String name = world.getName();
|
||||
final boolean autosave = world.isAutoSave();
|
||||
if (!PS.get().isPlotWorld(name)) {
|
||||
continue;
|
||||
}
|
||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autosave) {
|
||||
final boolean autosave = world.isAutoSave();
|
||||
if (autosave) {
|
||||
world.setAutoSave(false);
|
||||
}
|
||||
final HashMap<ChunkLoc, Integer> map = players.get(name);
|
||||
if ((map == null) || (map.size() == 0)) {
|
||||
continue;
|
||||
}
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
Chunk[] chunks = world.getLoadedChunks();
|
||||
ArrayDeque<Chunk> toUnload = new ArrayDeque<Chunk>();
|
||||
for (final Chunk chunk : chunks) {
|
||||
final int x = chunk.getX();
|
||||
final int z = chunk.getZ();
|
||||
if (!map.containsKey(new ChunkLoc(x, z))) {
|
||||
toUnload.add(chunk);
|
||||
}
|
||||
}
|
||||
if (toUnload.size() > 0) {
|
||||
long start = System.currentTimeMillis();
|
||||
Chunk chunk;
|
||||
while ((chunk = toUnload.poll()) != null && (System.currentTimeMillis() - start < 5)) {
|
||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE || !unloadChunk(name, chunk)) {
|
||||
chunk.unload(true, false);
|
||||
if (chunk.isLoaded()) {
|
||||
chunk.unload(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toUnload.size() > 0) {
|
||||
time = 1;
|
||||
}
|
||||
}
|
||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autosave) {
|
||||
world.setAutoSave(true);
|
||||
}
|
||||
}
|
||||
TaskManager.runTaskLater(this, time);
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
|
||||
public boolean unloadChunk(final String world, final Chunk chunk) {
|
||||
@ -165,7 +183,9 @@ public class ChunkListener implements Listener {
|
||||
}
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
mustSave.of(c).set(false);
|
||||
chunk.unload(false, false);
|
||||
if (chunk.isLoaded()) {
|
||||
chunk.unload(false, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -43,7 +42,6 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
@ -88,7 +86,6 @@ import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.help.HelpTopic;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.LazyMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
@ -111,7 +108,6 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
@ -454,7 +450,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
|
||||
}
|
||||
}
|
||||
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN)) {
|
||||
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN) && Settings.UPDATE_NOTIFICATIONS) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -74,7 +74,7 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
return this.requiredType;
|
||||
}
|
||||
|
||||
final protected void create() {
|
||||
final public void create() {
|
||||
final Annotation annotation = getClass().getAnnotation(CommandDeclaration.class);
|
||||
if (annotation == null) {
|
||||
throw new RuntimeException("Command does not have a CommandDeclaration");
|
||||
|
@ -13,8 +13,8 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
@SuppressWarnings("unused")
|
||||
public class CommandManager<T extends CommandCaller> {
|
||||
|
||||
protected final ConcurrentHashMap<String, Command<T>> commands;
|
||||
protected final Character initialCharacter;
|
||||
final public ConcurrentHashMap<String, Command<T>> commands;
|
||||
final private Character initialCharacter;
|
||||
|
||||
public CommandManager() {
|
||||
this('/', new ArrayList<Command<T>>());
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user