I didn't get everything first time

This commit is contained in:
dordsor21 2020-04-30 11:33:59 +01:00
parent e7216d4aef
commit 42106bb97a
98 changed files with 743 additions and 591 deletions

View File

@ -233,7 +233,7 @@ public interface IPlotMain extends ILogger {
* Gets the generator wrapper for a world (world) and generator (name). * Gets the generator wrapper for a world (world) and generator (name).
* *
* @param world the world to get the generator from * @param world the world to get the generator from
* @param name the name of the generator * @param name the name of the generator
* @return the generator being used for the provided world * @return the generator being used for the provided world
*/ */
GeneratorWrapper<?> getGenerator(String world, String name); GeneratorWrapper<?> getGenerator(String world, String name);

View File

@ -28,12 +28,12 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@ -52,7 +52,8 @@ public class Add extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);

View File

@ -28,12 +28,12 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.StringWrapper; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
@CommandDeclaration(command = "setalias", @CommandDeclaration(command = "setalias",

View File

@ -25,31 +25,31 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.generator.AugmentedUtils; import com.plotsquared.core.generator.AugmentedUtils;
import com.plotsquared.core.generator.HybridPlotWorld; import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaTerrainType; import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.plot.SetupObject; import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.RegionUtil;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal3;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
@ -170,15 +170,16 @@ public class Area extends SubCommand {
ChunkManager.largeRegionTask(world, region, ChunkManager.largeRegionTask(world, region,
new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils.generate(null, world, value.getX(), AugmentedUtils
value.getZ(), null); .generate(null, world, value.getX(),
value.getZ(), null);
} }
}, null); }, null);
} }
} else { } else {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"An error occurred while creating the world: " "An error occurred while creating the world: " + area
+ area.getWorldName()); .getWorldName());
} }
}; };
if (hasConfirmation(player)) { if (hasConfirmation(player)) {
@ -239,11 +240,13 @@ public class Area extends SubCommand {
break; break;
case "f": case "f":
case "floor": case "floor":
pa.TOP_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]); pa.TOP_BLOCK =
ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "m": case "m":
case "main": case "main":
pa.MAIN_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]); pa.MAIN_BLOCK =
ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "w": case "w":
case "wall": case "wall":
@ -252,14 +255,19 @@ public class Area extends SubCommand {
break; break;
case "b": case "b":
case "border": case "border":
pa.WALL_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]); pa.WALL_BLOCK =
ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "terrain": case "terrain":
pa.setTerrain(PlotAreaTerrainType.fromString(pair[1]).orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid terrain."))); pa.setTerrain(PlotAreaTerrainType.fromString(pair[1])
.orElseThrow(() -> new IllegalArgumentException(
pair[1] + " is not a valid terrain.")));
object.terrain = pa.getTerrain(); object.terrain = pa.getTerrain();
break; break;
case "type": case "type":
pa.setType(PlotAreaType.fromString(pair[1]).orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid type."))); pa.setType(PlotAreaType.fromString(pair[1]).orElseThrow(
() -> new IllegalArgumentException(
pair[1] + " is not a valid type.")));
object.type = pa.getType(); object.type = pa.getType();
break; break;
default: default:
@ -291,8 +299,8 @@ public class Area extends SubCommand {
TeleportCause.COMMAND); TeleportCause.COMMAND);
} else { } else {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"An error occurred while creating the world: " "An error occurred while creating the world: " + pa
+ pa.getWorldName()); .getWorldName());
} }
try { try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile); PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
@ -376,10 +384,11 @@ public class Area extends SubCommand {
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE; percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
region = "N/A"; region = "N/A";
} }
String value = "&r$1NAME: " + name + "\n$1Type: $2" + area.getType() + "\n$1Terrain: $2" String value =
+ area.getTerrain() + "\n$1Usage: $2" + String.format("%.2f", percent) + '%' "&r$1NAME: " + name + "\n$1Type: $2" + area.getType() + "\n$1Terrain: $2" + area
+ "\n$1Claimed: $2" + claimed + "\n$1Clusters: $2" + clusters + "\n$1Region: $2" .getTerrain() + "\n$1Usage: $2" + String.format("%.2f", percent) + '%'
+ region + "\n$1Generator: $2" + generator; + "\n$1Claimed: $2" + claimed + "\n$1Clusters: $2" + clusters
+ "\n$1Region: $2" + region + "\n$1Generator: $2" + generator;
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
Captions.PLOT_INFO_HEADER.getTranslated() + '\n' + value + '\n' Captions.PLOT_INFO_HEADER.getTranslated() + '\n' + value + '\n'
+ Captions.PLOT_INFO_FOOTER.getTranslated(), false); + Captions.PLOT_INFO_FOOTER.getTranslated(), false);
@ -418,7 +427,8 @@ public class Area extends SubCommand {
if (area.getType() == PlotAreaType.PARTIAL) { if (area.getType() == PlotAreaType.PARTIAL) {
PlotId min = area.getMin(); PlotId min = area.getMin();
PlotId max = area.getMax(); PlotId max = area.getMax();
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' + max; name = area.getWorldName() + ';' + area.getId() + ';' + min + ';'
+ max;
int size = (max.x - min.x + 1) * (max.y - min.y + 1); int size = (max.x - min.x + 1) * (max.y - min.y + 1);
percent = claimed == 0 ? 0 : size / (double) claimed; percent = claimed == 0 ? 0 : size / (double) claimed;
region = area.getRegion().toString(); region = area.getRegion().toString();
@ -468,7 +478,8 @@ public class Area extends SubCommand {
new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils AugmentedUtils
.generate(null, area.getWorldName(), value.getX(), value.getZ(), null); .generate(null, area.getWorldName(), value.getX(), value.getZ(),
null);
} }
}, () -> player.sendMessage("Regen complete")); }, () -> player.sendMessage("Regen complete"));
return true; return true;
@ -501,10 +512,11 @@ public class Area extends SubCommand {
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.getMinimumPoint().getZ() 0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2); + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
WorldUtil.IMP.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y -> { WorldUtil.IMP
center.setY(1 + y); .getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y -> {
player.teleport(center, TeleportCause.COMMAND); center.setY(1 + y);
}); player.teleport(center, TeleportCause.COMMAND);
});
} }
return true; return true;
case "delete": case "delete":

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.primitives.Ints;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
@ -33,20 +34,19 @@ import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlayerAutoPlotEvent; import com.plotsquared.core.events.PlayerAutoPlotEvent;
import com.plotsquared.core.events.PlotAutoMergeEvent; import com.plotsquared.core.events.PlotAutoMergeEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.util.Expression; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.util.task.AutoClaimFinishTask;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.AutoClaimFinishTask;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.google.common.primitives.Ints;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@ -117,7 +117,8 @@ public class Auto extends SubCommand {
final String schematic) { final String schematic) {
Set<Plot> plots = player.getPlots(); Set<Plot> plots = player.getPlots();
if (!plots.isEmpty()) { if (!plots.isEmpty()) {
plots.iterator().next().teleportPlayer(player, TeleportCause.COMMAND, result -> {}); plots.iterator().next().teleportPlayer(player, TeleportCause.COMMAND, result -> {
});
} else { } else {
autoClaimSafe(player, area, start, schematic); autoClaimSafe(player, area, start, schematic);
} }
@ -149,7 +150,8 @@ public class Auto extends SubCommand {
player.setMeta(Auto.class.getName(), true); player.setMeta(Auto.class.getName(), true);
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() { autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
@Override public void run(final Plot plot) { @Override public void run(final Plot plot) {
TaskManager.IMP.sync(new AutoClaimFinishTask(player, plot, area, allowedPlots, schematic)); TaskManager.IMP
.sync(new AutoClaimFinishTask(player, plot, area, allowedPlots, schematic));
} }
}); });
} }
@ -243,8 +245,8 @@ public class Auto extends SubCommand {
return false; return false;
} }
final int allowed_plots = player.getAllowedPlots(); final int allowed_plots = player.getAllowedPlots();
if (!force && (player.getMeta(Auto.class.getName(), false) || !checkAllowedPlots(player, plotarea, if (!force && (player.getMeta(Auto.class.getName(), false) || !checkAllowedPlots(player,
allowed_plots, size_x, size_z))) { plotarea, allowed_plots, size_x, size_z))) {
return false; return false;
} }

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;

View File

@ -29,14 +29,14 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.PriceFlag; import com.plotsquared.core.plot.flag.implementations.PriceFlag;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import java.util.Set; import java.util.Set;
@ -54,7 +54,8 @@ public class Buy extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) { final RunnableVal2<Command, CommandResult> whenDone) {
@ -82,15 +83,16 @@ public class Buy extends Command {
confirm.run(this, () -> { confirm.run(this, () -> {
Captions.REMOVED_BALANCE.send(player, price); Captions.REMOVED_BALANCE.send(player, price);
EconHandler.manager EconHandler.manager
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.getOwnerAbs()), price); .depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.getOwnerAbs()),
price);
PlotPlayer owner = UUIDHandler.getPlayer(plot.getOwnerAbs()); PlotPlayer owner = UUIDHandler.getPlayer(plot.getOwnerAbs());
if (owner != null) { if (owner != null) {
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price); Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
} }
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class); PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class);
PlotFlagRemoveEvent PlotFlagRemoveEvent event =
event = PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot); PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
if(event.getEventResult() != Result.DENY) { if (event.getEventResult() != Result.DENY) {
plot.removeFlag(event.getFlag()); plot.removeFlag(event.getFlag());
} }
plot.setOwner(player.getUUID()); plot.setOwner(player.getUUID());

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.primitives.Ints;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
@ -34,16 +34,16 @@ import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlayerClaimPlotEvent; import com.plotsquared.core.events.PlayerClaimPlotEvent;
import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.RunnableVal;
import com.google.common.primitives.Ints;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
@CommandDeclaration(command = "claim", @CommandDeclaration(command = "claim",
aliases = "c", aliases = "c",
@ -64,8 +64,8 @@ public class Claim extends SubCommand {
if (plot == null) { if (plot == null) {
return sendMessage(player, Captions.NOT_IN_PLOT); return sendMessage(player, Captions.NOT_IN_PLOT);
} }
PlayerClaimPlotEvent PlayerClaimPlotEvent event =
event = PlotSquared.get().getEventDispatcher().callClaim(player, plot, schematic); PlotSquared.get().getEventDispatcher().callClaim(player, plot, schematic);
schematic = event.getSchematic(); schematic = event.getSchematic();
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Claim"); sendMessage(player, Captions.EVENT_DENIED, "Claim");
@ -133,8 +133,8 @@ public class Claim extends SubCommand {
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() { DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override public void run(Object value) { @Override public void run(Object value) {
if (!plot.claim(player, true, finalSchematic, false)) { if (!plot.claim(player, true, finalSchematic, false)) {
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String
String.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString())); .format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
sendMessage(player, Captions.PLOT_NOT_CLAIMED); sendMessage(player, Captions.PLOT_NOT_CLAIMED);
plot.setOwnerAbs(null); plot.setOwnerAbs(null);
} else if (area.isAutoMerge()) { } else if (area.isAutoMerge()) {
@ -148,8 +148,9 @@ public class Claim extends SubCommand {
} }
} }
}), () -> { }), () -> {
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String
String.format("Failed to add plot %s to the database", plot.getId().toCommaSeparatedString())); .format("Failed to add plot %s to the database",
plot.getId().toCommaSeparatedString()));
sendMessage(player, Captions.PLOT_NOT_CLAIMED); sendMessage(player, Captions.PLOT_NOT_CLAIMED);
plot.setOwnerAbs(null); plot.setOwnerAbs(null);
}); });

View File

@ -30,16 +30,16 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag; import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -62,7 +62,8 @@ public class Clear extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage()); checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());

View File

@ -29,14 +29,14 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.location.BlockLoc; import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotCluster;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;

View File

@ -25,18 +25,18 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.StringComparison;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;

View File

@ -30,7 +30,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandDeclaration { public @interface CommandDeclaration {
String command(); String command();

View File

@ -26,11 +26,11 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.comment.CommentInbox; import com.plotsquared.core.plot.comment.CommentInbox;
import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.plot.comment.CommentManager; import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
@ -87,8 +87,8 @@ public class Comment extends SubCommand {
String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " "); String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " ");
PlotComment comment = PlotComment comment =
new PlotComment(player.getLocation().getWorld(), plot.getId(), message, player.getName(), inbox.toString(), new PlotComment(player.getLocation().getWorld(), plot.getId(), message,
System.currentTimeMillis()); player.getName(), inbox.toString(), System.currentTimeMillis());
boolean result = inbox.addComment(plot, comment); boolean result = inbox.addComment(plot, comment);
if (!result) { if (!result) {
sendMessage(player, Captions.NO_PLOT_INBOX, ""); sendMessage(player, Captions.NO_PLOT_INBOX, "");

View File

@ -26,14 +26,14 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;

View File

@ -30,10 +30,10 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;

View File

@ -27,8 +27,8 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;

View File

@ -29,8 +29,8 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.generator.HybridPlotWorld; import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
@CommandDeclaration(command = "createroadschematic", @CommandDeclaration(command = "createroadschematic",

View File

@ -27,17 +27,17 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.database.Database;
import com.plotsquared.core.database.MySQL; import com.plotsquared.core.database.MySQL;
import com.plotsquared.core.database.SQLManager; import com.plotsquared.core.database.SQLManager;
import com.plotsquared.core.database.SQLite; import com.plotsquared.core.database.SQLite;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.database.Database;
import java.io.File; import java.io.File;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -58,34 +58,35 @@ public class Debug extends SubCommand {
if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) { if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
MainUtil.sendMessage(player, "Fetching loaded chunks..."); MainUtil.sendMessage(player, "Fetching loaded chunks...");
TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player,"Loaded chunks: " + TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player,
ChunkManager.manager.getChunkChunks(player.getLocation().getWorld()).size() + "(" + (System.currentTimeMillis() - start) + "ms) using thread: " + "Loaded chunks: " + ChunkManager.manager
Thread.currentThread().getName())); .getChunkChunks(player.getLocation().getWorld()).size() + "(" + (
System.currentTimeMillis() - start) + "ms) using thread: " + Thread
.currentThread().getName()));
return true; return true;
} }
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) { if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
EntityCategories.init(); EntityCategories.init();
player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: "); player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: ");
EntityCategory.REGISTRY.forEach(category -> { EntityCategory.REGISTRY.forEach(category -> {
final StringBuilder builder = new StringBuilder("§7- §6") final StringBuilder builder =
.append(category.getId()).append("§7: §6"); new StringBuilder("§7- §6").append(category.getId()).append("§7: §6");
for (final EntityType entityType : category.getAll()) { for (final EntityType entityType : category.getAll()) {
builder.append(entityType.getId()).append(" "); builder.append(entityType.getId()).append(" ");
} }
player.sendMessage(Captions.PREFIX.getTranslated() + builder.toString()); player.sendMessage(Captions.PREFIX.getTranslated() + builder.toString());
}); });
EntityType.REGISTRY.values().stream() EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId))
.sorted(Comparator.comparing(EntityType::getId)) .forEach(entityType -> {
.forEach(entityType -> { long categoryCount = EntityCategory.REGISTRY.values().stream()
long categoryCount = EntityCategory.REGISTRY.values() .filter(category -> category.contains(entityType)).count();
.stream() if (categoryCount > 0) {
.filter(category -> category.contains(entityType)) return;
.count(); }
if (categoryCount > 0) { player.sendMessage(
return; Captions.PREFIX.getTranslated() + entityType.getName() + " is in "
} + categoryCount + " categories");
player.sendMessage(Captions.PREFIX.getTranslated() + entityType.getName() + " is in " + categoryCount + " categories"); });
});
return true; return true;
} }
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {

View File

@ -25,20 +25,20 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.collect.BiMap;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.google.common.collect.BiMap; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -25,27 +25,27 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.io.Files;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.util.WEManager;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
@ -53,13 +53,13 @@ import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WEManager;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.google.common.io.Files;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import javax.script.Bindings; import javax.script.Bindings;
@ -72,7 +72,12 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugexec", @CommandDeclaration(command = "debugexec",
@ -267,8 +272,8 @@ public class DebugExec extends SubCommand {
} }
boolean result; boolean result;
if (HybridUtils.regions != null) { if (HybridUtils.regions != null) {
result = result = HybridUtils.manager
HybridUtils.manager.scheduleRoadUpdate(area, HybridUtils.regions, 0, new HashSet<>()); .scheduleRoadUpdate(area, HybridUtils.regions, 0, new HashSet<>());
} else { } else {
result = HybridUtils.manager.scheduleRoadUpdate(area, 0); result = HybridUtils.manager.scheduleRoadUpdate(area, 0);
} }
@ -333,7 +338,8 @@ public class DebugExec extends SubCommand {
System.getProperty("line.separator")); System.getProperty("line.separator"));
new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null, new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null,
RequiredType.NONE, CommandCategory.DEBUG) { RequiredType.NONE, CommandCategory.DEBUG) {
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player,
String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
try { try {

View File

@ -25,17 +25,17 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.base.Charsets;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager; import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.google.common.base.Charsets; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.uuid.UUIDHandler;
import java.io.File; import java.io.File;
import java.util.UUID; import java.util.UUID;
@ -51,7 +51,8 @@ public class DebugImportWorlds extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)) // UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))

View File

@ -25,17 +25,17 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.net.IncendoPaster;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.net.IncendoPaster;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.plotsquared.core.util.PremiumVerification;
import lombok.NonNull; import lombok.NonNull;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -83,7 +83,8 @@ public class DebugPaste extends SubCommand {
b.append("# PlotSquared Information\n"); b.append("# PlotSquared Information\n");
b.append("Resource ID: ").append(PremiumVerification.getResourceID()).append("\n"); b.append("Resource ID: ").append(PremiumVerification.getResourceID()).append("\n");
b.append("Download ID: ").append(PremiumVerification.getDownloadID()).append("\n"); b.append("Download ID: ").append(PremiumVerification.getDownloadID()).append("\n");
b.append("This PlotSquared version is licensed to the spigot user ").append(PremiumVerification.getUserID()).append("\n\n"); b.append("This PlotSquared version is licensed to the spigot user ")
.append(PremiumVerification.getUserID()).append("\n\n");
b.append("# Server Information\n"); b.append("# Server Information\n");
b.append("Server Version: ").append(PlotSquared.get().IMP.getServerImplementation()) b.append("Server Version: ").append(PlotSquared.get().IMP.getServerImplementation())
.append("\n"); .append("\n");

View File

@ -29,10 +29,10 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.generator.HybridPlotManager; import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import java.util.Arrays; import java.util.Arrays;

View File

@ -27,8 +27,8 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -29,12 +29,12 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
@ -62,7 +62,8 @@ public class Delete extends SubCommand {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return !sendMessage(player, Captions.PLOT_UNOWNED); return !sendMessage(player, Captions.PLOT_UNOWNED);
} }
Result eventResult = PlotSquared.get().getEventDispatcher().callDelete(plot).getEventResult(); Result eventResult =
PlotSquared.get().getEventDispatcher().callDelete(plot).getEventResult();
if (eventResult == Result.DENY) { if (eventResult == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Delete"); sendMessage(player, Captions.EVENT_DENIED, "Delete");
return true; return true;

View File

@ -29,12 +29,12 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import java.util.Set; import java.util.Set;

View File

@ -30,9 +30,9 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
@CommandDeclaration(command = "setdescription", @CommandDeclaration(command = "setdescription",

View File

@ -31,17 +31,17 @@ import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotDoneEvent; import com.plotsquared.core.events.PlotDoneEvent;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.plot.expiration.ExpireManager; import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.PlotAnalysis; import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal;
@CommandDeclaration(command = "done", @CommandDeclaration(command = "done",
aliases = {"submit"}, aliases = {"submit"},

View File

@ -28,15 +28,15 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import java.net.URL; import java.net.URL;

View File

@ -32,24 +32,24 @@ import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.FlagParseException; import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.InternalFlag; import com.plotsquared.core.plot.flag.InternalFlag;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.types.IntegerFlag; import com.plotsquared.core.plot.flag.types.IntegerFlag;
import com.plotsquared.core.plot.flag.types.ListFlag; import com.plotsquared.core.plot.flag.types.ListFlag;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.StringComparison;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.helpmenu.HelpMenu; import com.plotsquared.core.util.helpmenu.HelpMenu;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -206,7 +206,8 @@ public final class FlagCommand extends Command {
return null; return null;
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
if (args.length == 0 || !Arrays if (args.length == 0 || !Arrays
@ -220,7 +221,8 @@ public final class FlagCommand extends Command {
return super.execute(player, args, confirm, whenDone); return super.execute(player, args, confirm, whenDone);
} }
@Override public Collection<Command> tab(final PlotPlayer player, final String[] args, @Override
public Collection<Command> tab(final PlotPlayer player, final String[] args,
final boolean space) { final boolean space) {
if (args.length == 1) { if (args.length == 1) {
return Stream return Stream
@ -356,7 +358,8 @@ public final class FlagCommand extends Command {
return; return;
} }
} }
} final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " "); }
final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
final PlotFlag parsed; final PlotFlag parsed;
try { try {
parsed = event.getFlag().parse(value); parsed = event.getFlag().parse(value);
@ -448,7 +451,8 @@ public final class FlagCommand extends Command {
PlotFlag plotFlag = parsedFlag.createFlagInstance(list); PlotFlag plotFlag = parsedFlag.createFlagInstance(list);
PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot); PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot);
if (addEvent.getEventResult() == Result.DENY) { if (addEvent.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Re-addition of " + plotFlag.getName()); sendMessage(player, Captions.EVENT_DENIED,
"Re-addition of " + plotFlag.getName());
return; return;
} }
if (plot.setFlag(addEvent.getFlag())) { if (plot.setFlag(addEvent.getFlag())) {

View File

@ -25,17 +25,17 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.primitives.Ints;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.google.common.primitives.Ints;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -51,7 +51,8 @@ public class Grant extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage()); checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage());

View File

@ -27,12 +27,12 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.helpmenu.HelpMenu; import com.plotsquared.core.util.helpmenu.HelpMenu;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -51,7 +51,8 @@ public class Help extends Command {
return true; return true;
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
switch (args.length) { switch (args.length) {

View File

@ -26,14 +26,14 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.comment.CommentInbox; import com.plotsquared.core.plot.comment.CommentInbox;
import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.plot.comment.CommentManager; import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal;
import java.util.List; import java.util.List;

View File

@ -28,11 +28,11 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.plot.flag.implementations.HideInfoFlag;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.HideInfoFlag;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.RunnableVal;
@CommandDeclaration(command = "info", @CommandDeclaration(command = "info",
aliases = "i", aliases = "i",

View File

@ -29,12 +29,12 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.uuid.UUIDHandler;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;

View File

@ -27,11 +27,11 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -47,7 +47,8 @@ public class Leave extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);

View File

@ -30,11 +30,11 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotRateEvent; import com.plotsquared.core.events.PlotRateEvent;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Rating;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.Rating;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
@ -71,7 +71,8 @@ public class Like extends SubCommand {
for (final Plot plot : plots) { for (final Plot plot : plots) {
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot
.isBasePlot() && (!plot.getLikes().containsKey(uuid))) { .isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {}); plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {
});
MainUtil.sendMessage(player, Captions.RATE_THIS); MainUtil.sendMessage(player, Captions.RATE_THIS);
return true; return true;
} }
@ -123,8 +124,8 @@ public class Like extends SubCommand {
rating = 1; rating = 1;
} }
plot.addRating(uuid, new Rating(rating)); plot.addRating(uuid, new Rating(rating));
final PlotRateEvent final PlotRateEvent event =
event = PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating)); PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating));
if (event.getRating() != null) { if (event.getRating() != null) {
plot.addRating(uuid, event.getRating()); plot.addRating(uuid, event.getRating());
if (like) { if (like) {

View File

@ -29,22 +29,22 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.PlotSquared.SortType; import com.plotsquared.core.PlotSquared.SortType;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Rating; import com.plotsquared.core.plot.Rating;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.StringComparison;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.plot.expiration.ExpireManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;

View File

@ -28,15 +28,15 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import java.net.MalformedURLException; import java.net.MalformedURLException;

View File

@ -27,16 +27,16 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Permissions;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -167,7 +167,8 @@ public class MainCommand extends Command {
if (EconHandler.manager != null) { if (EconHandler.manager != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = area.getPrices().get(cmd.getFullId()); Expression<Double> priceEval =
area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != null if (price != null
&& EconHandler.manager.getMoney(player) < price) { && EconHandler.manager.getMoney(player) < price) {
@ -215,7 +216,8 @@ public class MainCommand extends Command {
return true; return true;
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
// Clear perm caching // // Clear perm caching //
@ -253,7 +255,8 @@ public class MainCommand extends Command {
if (EconHandler.manager != null) { if (EconHandler.manager != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = area.getPrices().get(cmd.getFullId()); Expression<Double> priceEval =
area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d if (price != 0d
&& EconHandler.manager.getMoney(player) < price) { && EconHandler.manager.getMoney(player) < price) {

View File

@ -31,12 +31,12 @@ import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
@ -182,7 +182,8 @@ public class Merge extends SubCommand {
} else { } else {
terrain = true; terrain = true;
} }
if (!force && !terrain && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) { if (!force && !terrain && !Permissions
.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated()); Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated());
return true; return true;

View File

@ -26,10 +26,10 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
/** /**
* @author manuelgu, altered by Citymonstret * @author manuelgu, altered by Citymonstret

View File

@ -28,13 +28,13 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -46,7 +46,8 @@ import java.util.concurrent.CompletableFuture;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Move extends SubCommand { public class Move extends SubCommand {
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
Location location = player.getLocation(); Location location = player.getLocation();
@ -94,16 +95,16 @@ public class Move extends SubCommand {
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
return plot1.move(plot2, () -> {}, false) return plot1.move(plot2, () -> {
.thenApply(result -> { }, false).thenApply(result -> {
if (result) { if (result) {
MainUtil.sendMessage(player, Captions.MOVE_SUCCESS); MainUtil.sendMessage(player, Captions.MOVE_SUCCESS);
return true; return true;
} else { } else {
MainUtil.sendMessage(player, Captions.REQUIRES_UNOWNED); MainUtil.sendMessage(player, Captions.REQUIRES_UNOWNED);
return false; return false;
} }
}); });
} }
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -25,17 +25,17 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.MusicFlag;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotInventory; import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.PlotItemStack; import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.MusicFlag;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import java.util.Arrays; import java.util.Arrays;

View File

@ -26,11 +26,11 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.StringMan;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -45,7 +45,8 @@ public class Near extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);

View File

@ -28,8 +28,8 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.PremiumVerification; import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.task.TaskManager;
@CommandDeclaration(command = "plugin", @CommandDeclaration(command = "plugin",
permission = "plots.use", permission = "plots.use",
@ -48,7 +48,8 @@ public class PluginCmd extends SubCommand {
"$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault $2& $1SirYwell"); "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault $2& $1SirYwell");
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki"); "$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki");
MainUtil.sendMessage(player, "$2>> $1&lPremium$2: $1" + PremiumVerification.isPremium()); MainUtil
.sendMessage(player, "$2>> $1&lPremium$2: $1" + PremiumVerification.isPremium());
}); });
return true; return true;
} }

View File

@ -29,10 +29,10 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;

View File

@ -30,13 +30,13 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotRateEvent; import com.plotsquared.core.events.PlotRateEvent;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotInventory; import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.PlotItemStack; import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Rating; import com.plotsquared.core.plot.Rating;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
@ -84,7 +84,8 @@ public class Rate extends SubCommand {
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p
.isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p .isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p
.isAdded(uuid)) { .isAdded(uuid)) {
p.teleportPlayer(player, TeleportCause.COMMAND, result -> {}); p.teleportPlayer(player, TeleportCause.COMMAND, result -> {
});
MainUtil.sendMessage(player, Captions.RATE_THIS); MainUtil.sendMessage(player, Captions.RATE_THIS);
return true; return true;
} }
@ -140,8 +141,8 @@ public class Rate extends SubCommand {
index.increment(); index.increment();
if (index.getValue() >= Settings.Ratings.CATEGORIES.size()) { if (index.getValue() >= Settings.Ratings.CATEGORIES.size()) {
int rV = rating.getValue(); int rV = rating.getValue();
PlotRateEvent event = PlotRateEvent event = PlotSquared.get().getEventDispatcher()
PlotSquared.get().getEventDispatcher().callRating(this.player, plot, new Rating(rV)); .callRating(this.player, plot, new Rating(rV));
if (event.getRating() != null) { if (event.getRating() != null) {
plot.addRating(this.player.getUUID(), event.getRating()); plot.addRating(this.player.getUUID(), event.getRating());
sendMessage(this.player, Captions.RATING_APPLIED, sendMessage(this.player, Captions.RATING_APPLIED,
@ -209,7 +210,8 @@ public class Rate extends SubCommand {
sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString()); sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString());
return; return;
} }
PlotRateEvent event = PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating)); PlotRateEvent event =
PlotSquared.get().getEventDispatcher().callRating(player, plot, new Rating(rating));
if (event.getRating() != null) { if (event.getRating() != null) {
plot.addRating(uuid, event.getRating()); plot.addRating(uuid, event.getRating());
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString()); sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());

View File

@ -29,9 +29,9 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.generator.HybridPlotManager; import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
@CommandDeclaration(command = "regenallroads", @CommandDeclaration(command = "regenallroads",

View File

@ -26,13 +26,13 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.queue.LocalBlockQueue;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -46,7 +46,8 @@ public class Relight extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();

View File

@ -25,13 +25,13 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.MemorySection; import com.plotsquared.core.configuration.MemorySection;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import java.io.IOException; import java.io.IOException;
@ -52,8 +52,8 @@ public class Reload extends SubCommand {
PlotSquared.get().setupConfigs(); PlotSquared.get().setupConfigs();
Captions.load(PlotSquared.get().translationFile); Captions.load(PlotSquared.get().translationFile);
PlotSquared.get().forEachPlotArea(area -> { PlotSquared.get().forEachPlotArea(area -> {
ConfigurationSection worldSection = ConfigurationSection worldSection = PlotSquared.get().worlds
PlotSquared.get().worlds.getConfigurationSection("worlds." + area.getWorldName()); .getConfigurationSection("worlds." + area.getWorldName());
if (worldSection == null) { if (worldSection == null) {
return; return;
} }

View File

@ -29,8 +29,8 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
@ -95,29 +95,34 @@ public class Remove extends SubCommand {
for (UUID uuid : uuids) { for (UUID uuid : uuids) {
if (plot.getTrusted().contains(uuid)) { if (plot.getTrusted().contains(uuid)) {
if (plot.removeTrusted(uuid)) { if (plot.removeTrusted(uuid)) {
PlotSquared PlotSquared.get().getEventDispatcher()
.get().getEventDispatcher().callTrusted(player, plot, uuid, false); .callTrusted(player, plot, uuid, false);
count++; count++;
} }
} else if (plot.getMembers().contains(uuid)) { } else if (plot.getMembers().contains(uuid)) {
if (plot.removeMember(uuid)) { if (plot.removeMember(uuid)) {
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, false); PlotSquared.get().getEventDispatcher()
.callMember(player, plot, uuid, false);
count++; count++;
} }
} else if (plot.getDenied().contains(uuid)) { } else if (plot.getDenied().contains(uuid)) {
if (plot.removeDenied(uuid)) { if (plot.removeDenied(uuid)) {
PlotSquared.get().getEventDispatcher().callDenied(player, plot, uuid, false); PlotSquared.get().getEventDispatcher()
.callDenied(player, plot, uuid, false);
count++; count++;
} }
} else if (uuid == DBFunc.EVERYONE) { } else if (uuid == DBFunc.EVERYONE) {
if (plot.removeTrusted(uuid)) { if (plot.removeTrusted(uuid)) {
PlotSquared.get().getEventDispatcher().callTrusted(player, plot, uuid, false); PlotSquared.get().getEventDispatcher()
.callTrusted(player, plot, uuid, false);
count++; count++;
} else if (plot.removeMember(uuid)) { } else if (plot.removeMember(uuid)) {
PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, false); PlotSquared.get().getEventDispatcher()
.callMember(player, plot, uuid, false);
count++; count++;
} else if (plot.removeDenied(uuid)) { } else if (plot.removeDenied(uuid)) {
PlotSquared.get().getEventDispatcher().callDenied(player, plot, uuid, false); PlotSquared.get().getEventDispatcher()
.callDenied(player, plot, uuid, false);
count++; count++;
} }
} }

View File

@ -28,13 +28,13 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;

View File

@ -25,22 +25,22 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.collect.Lists;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.google.common.collect.Lists;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -27,14 +27,14 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.PatternUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.PatternUtil;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -28,8 +28,8 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;

View File

@ -28,8 +28,8 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.BlockLoc; import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
@CommandDeclaration(command = "sethome", @CommandDeclaration(command = "sethome",

View File

@ -27,17 +27,17 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.generator.GeneratorWrapper; import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaTerrainType; import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.SetupObject; import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
@ -152,7 +152,8 @@ public class Setup extends SubCommand {
types.add("augmented"); types.add("augmented");
types.add("partial"); types.add("partial");
Optional<PlotAreaType> plotAreaType; Optional<PlotAreaType> plotAreaType;
if (args.length != 1 || !(plotAreaType = PlotAreaType.fromString(args[0])).isPresent()) { if (args.length != 1 || !(plotAreaType = PlotAreaType.fromString(args[0]))
.isPresent()) {
MainUtil.sendMessage(player, "&cYou must choose a world type!"); MainUtil.sendMessage(player, "&cYou must choose a world type!");
for (String type : types) { for (String type : types) {
int i = allTypes.indexOf(type); int i = allTypes.indexOf(type);
@ -272,7 +273,8 @@ public class Setup extends SubCommand {
break; break;
case 5: { // Choose terrain case 5: { // Choose terrain
Optional<PlotAreaTerrainType> optTerrain; Optional<PlotAreaTerrainType> optTerrain;
if (args.length != 1 || !(optTerrain = PlotAreaTerrainType.fromString(args[0])).isPresent()) { if (args.length != 1 || !(optTerrain = PlotAreaTerrainType.fromString(args[0]))
.isPresent()) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all"
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees"

View File

@ -53,7 +53,8 @@ public abstract class SubCommand extends Command {
return true; return true;
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
return CompletableFuture.completedFuture(onCommand(player, args)); return CompletableFuture.completedFuture(onCommand(player, args));

View File

@ -27,12 +27,12 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -44,13 +44,15 @@ import java.util.concurrent.CompletableFuture;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Swap extends SubCommand { public class Swap extends SubCommand {
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot1 = location.getPlotAbs(); Plot plot1 = location.getPlotAbs();
if (plot1 == null) { if (plot1 == null) {
return CompletableFuture.completedFuture(!MainUtil.sendMessage(player, Captions.NOT_IN_PLOT)); return CompletableFuture
.completedFuture(!MainUtil.sendMessage(player, Captions.NOT_IN_PLOT));
} }
if (!plot1.isOwner(player.getUUID()) && !Permissions if (!plot1.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) { .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) {
@ -79,16 +81,16 @@ public class Swap extends SubCommand {
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
return plot1.move(plot2, () -> {}, true) return plot1.move(plot2, () -> {
.thenApply(result -> { }, true).thenApply(result -> {
if (result) { if (result) {
MainUtil.sendMessage(player, Captions.SWAP_SUCCESS); MainUtil.sendMessage(player, Captions.SWAP_SUCCESS);
return true; return true;
} else { } else {
MainUtil.sendMessage(player, Captions.SWAP_OVERLAP); MainUtil.sendMessage(player, Captions.SWAP_OVERLAP);
return false; return false;
} }
}); });
} }
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -28,8 +28,8 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;

View File

@ -25,24 +25,24 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.InvalidConfigurationException;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.InvalidConfigurationException;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.util.FileBytes; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.SetupObject; import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.FileBytes;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.util.task.TaskManager;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;

View File

@ -27,9 +27,9 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil;
@CommandDeclaration(command = "toggle", @CommandDeclaration(command = "toggle",
aliases = {"attribute"}, aliases = {"attribute"},

View File

@ -28,18 +28,18 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.plot.expiration.ExpireManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.RegionUtil;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;

View File

@ -28,12 +28,12 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@ -52,7 +52,8 @@ public class Trust extends Command {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot currentPlot = player.getCurrentPlot(); final Plot currentPlot = player.getCurrentPlot();

View File

@ -30,8 +30,8 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;

View File

@ -28,16 +28,16 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.flag.implementations.UntrustedVisitFlag; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.flag.implementations.UntrustedVisitFlag;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import java.util.ArrayList; import java.util.ArrayList;
@ -64,7 +64,8 @@ public class Visit extends Command {
return tabOf(player, args, space, getUsage()); return tabOf(player, args, space, getUsage());
} }
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) throws CommandException { final RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
if (args.length == 1 && args[0].contains(":")) { if (args.length == 1 && args[0].contains(":")) {
@ -170,14 +171,13 @@ public class Visit extends Command {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER); Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER);
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
if (!plot.getFlag(UntrustedVisitFlag.class) && if (!plot.getFlag(UntrustedVisitFlag.class) && !Permissions
!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_VISIT_UNTRUSTED)) { .hasPermission(player, Captions.PERMISSION_ADMIN_VISIT_UNTRUSTED)) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_ADMIN_VISIT_UNTRUSTED); Captions.NO_PERMISSION.send(player, Captions.PERMISSION_ADMIN_VISIT_UNTRUSTED);
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
} }
confirm.run(this, () -> confirm.run(this, () -> plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {
plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {
if (result) { if (result) {
whenDone.run(Visit.this, CommandResult.SUCCESS); whenDone.run(Visit.this, CommandResult.SUCCESS);
} else { } else {

View File

@ -30,7 +30,8 @@ import com.plotsquared.core.player.PlotPlayer;
public class CaptionUtility { public class CaptionUtility {
public static String formatRaw(PlotPlayer recipient, String message, Object... args) { public static String formatRaw(PlotPlayer recipient, String message, Object... args) {
final ChatFormatter.ChatContext chatContext = new ChatFormatter.ChatContext(recipient, message, args, true); final ChatFormatter.ChatContext chatContext =
new ChatFormatter.ChatContext(recipient, message, args, true);
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) { for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
chatFormatter.format(chatContext); chatFormatter.format(chatContext);
} }
@ -38,7 +39,8 @@ public class CaptionUtility {
} }
public static String format(PlotPlayer recipient, String message, Object... args) { public static String format(PlotPlayer recipient, String message, Object... args) {
final ChatFormatter.ChatContext chatContext = new ChatFormatter.ChatContext(recipient, message, args, false); final ChatFormatter.ChatContext chatContext =
new ChatFormatter.ChatContext(recipient, message, args, false);
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) { for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
chatFormatter.format(chatContext); chatFormatter.format(chatContext);
} }
@ -47,7 +49,8 @@ public class CaptionUtility {
public static String format(PlotPlayer recipient, Caption caption, Object... args) { public static String format(PlotPlayer recipient, Caption caption, Object... args) {
if (caption.usePrefix() && caption.getTranslated().length() > 0) { if (caption.usePrefix() && caption.getTranslated().length() > 0) {
return Captions.PREFIX.getTranslated() + format(recipient, caption.getTranslated(), args); return Captions.PREFIX.getTranslated() + format(recipient, caption.getTranslated(),
args);
} else { } else {
return format(recipient, caption.getTranslated(), args); return format(recipient, caption.getTranslated(), args);
} }

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.configuration; package com.plotsquared.core.configuration;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import java.io.File; import java.io.File;

View File

@ -34,13 +34,16 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@FunctionalInterface public interface ChatFormatter { @FunctionalInterface
public interface ChatFormatter {
Collection<ChatFormatter> formatters = new ArrayList<>(Collections.singletonList(new PlotSquaredChatFormatter())); Collection<ChatFormatter> formatters =
new ArrayList<>(Collections.singletonList(new PlotSquaredChatFormatter()));
void format(ChatContext context); void format(ChatContext context);
@AllArgsConstructor final class ChatContext { @AllArgsConstructor
final class ChatContext {
@Getter private final PlotPlayer recipient; @Getter private final PlotPlayer recipient;
@Getter @Setter private String message; @Getter @Setter private String message;

View File

@ -25,9 +25,9 @@
*/ */
package com.plotsquared.core.configuration; package com.plotsquared.core.configuration;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings.Enabled_Components; import com.plotsquared.core.configuration.Settings.Enabled_Components;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import java.io.File; import java.io.File;
@ -394,21 +394,26 @@ public class Config {
/** /**
* Indicates that a field should be instantiated / created. * Indicates that a field should be instantiated / created.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface Create { @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Create {
} }
/** /**
* Indicates that a field cannot be modified. * Indicates that a field cannot be modified.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface Final { @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Final {
} }
/** /**
* Creates a comment. * Creates a comment.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface Comment { public @interface Comment {
String[] value(); String[] value();
} }
@ -417,7 +422,8 @@ public class Config {
/** /**
* The names of any default blocks. * The names of any default blocks.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface BlockName { public @interface BlockName {
String[] value(); String[] value();
} }
@ -426,7 +432,8 @@ public class Config {
/** /**
* Any field or class with is not part of the config. * Any field or class with is not part of the config.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface Ignore { public @interface Ignore {
} }

View File

@ -28,7 +28,8 @@ package com.plotsquared.core.configuration;
/** /**
* Exception thrown when attempting to load an invalid {@link Configuration}. * Exception thrown when attempting to load an invalid {@link Configuration}.
*/ */
@SuppressWarnings("serial") public class InvalidConfigurationException extends Exception { @SuppressWarnings("serial")
public class InvalidConfigurationException extends Exception {
/** /**
* Creates a new instance of InvalidConfigurationException without a * Creates a new instance of InvalidConfigurationException without a

View File

@ -34,7 +34,8 @@ public class PlotSquaredChatFormatter implements ChatFormatter {
@Override public void format(final ChatContext context) { @Override public void format(final ChatContext context) {
if (context.isRawOutput()) { if (context.isRawOutput()) {
context.setMessage(context.getMessage().replace('&', '\u2020').replace('\u00A7', '\u2030')); context.setMessage(
context.getMessage().replace('&', '\u2020').replace('\u00A7', '\u2030'));
} }
if (context.getArgs().length == 0) { if (context.getArgs().length == 0) {
return; return;

View File

@ -150,7 +150,8 @@ public class Settings extends Config {
TITLES = config.getBoolean("titles", TITLES); TITLES = config.getBoolean("titles", TITLES);
// Update Notifications // Update Notifications
Enabled_Components.UPDATE_NOTIFICATIONS = config.getBoolean("update-notifications", Enabled_Components.UPDATE_NOTIFICATIONS); Enabled_Components.UPDATE_NOTIFICATIONS =
config.getBoolean("update-notifications", Enabled_Components.UPDATE_NOTIFICATIONS);
// Teleportation // Teleportation
Teleport.DELAY = config.getInt("teleport.delay", Teleport.DELAY); Teleport.DELAY = config.getInt("teleport.delay", Teleport.DELAY);
@ -191,7 +192,8 @@ public class Settings extends Config {
return true; return true;
} }
@Comment("This is an auto clearing task called `task1`") @BlockName("task1") @Comment("This is an auto clearing task called `task1`")
@BlockName("task1")
// The name for the default block // The name for the default block
public static final class Auto_Clear extends ConfigBlock { public static final class Auto_Clear extends ConfigBlock {
@Create // This value has to be generated since an instance isn't static @Create // This value has to be generated since an instance isn't static
@ -239,24 +241,31 @@ public class Settings extends Config {
} }
@Comment("General settings") public static final class General { @Comment("General settings")
public static final class General {
@Comment("Display scientific numbers (4.2E8)") public static boolean SCIENTIFIC = false; @Comment("Display scientific numbers (4.2E8)") public static boolean SCIENTIFIC = false;
@Comment("Replace wall when merging") public static boolean MERGE_REPLACE_WALL = true; @Comment("Replace wall when merging") public static boolean MERGE_REPLACE_WALL = true;
} }
@Comment("Update checker settings") public static final class UpdateChecker {
@Comment("Update checker settings")
public static final class UpdateChecker {
@Comment("How often to poll for updates (in minutes)") public static int POLL_RATE = 360; @Comment("How often to poll for updates (in minutes)") public static int POLL_RATE = 360;
@Comment("Only notify console once after an update is found") public static boolean NOTIFY_ONCE = true; @Comment("Only notify console once after an update is found") public static boolean
NOTIFY_ONCE = true;
} }
@Comment("Schematic Settings") public static final class Schematics { @Comment("Schematic Settings")
@Comment("Whether schematic based generation should paste schematic on top of plots, or from Y=1") public static final class Schematics {
@Comment(
"Whether schematic based generation should paste schematic on top of plots, or from Y=1")
public static boolean PASTE_ON_TOP = true; public static boolean PASTE_ON_TOP = true;
} }
@Comment("Configure the paths that will be used") public static final class Paths { @Comment("Configure the paths that will be used")
public static final class Paths {
public static String SCHEMATICS = "schematics"; public static String SCHEMATICS = "schematics";
public static String SCRIPTS = "scripts"; public static String SCRIPTS = "scripts";
public static String TEMPLATES = "templates"; public static String TEMPLATES = "templates";
@ -295,7 +304,8 @@ public class Settings extends Config {
} }
@Comment("Relating to how many plots someone can claim ") public static final class Limit { @Comment("Relating to how many plots someone can claim ")
public static final class Limit {
@Comment("Should the limit be global (over multiple worlds)") public static boolean GLOBAL = @Comment("Should the limit be global (over multiple worlds)") public static boolean GLOBAL =
false; false;
@Comment({"The max. range of permissions to check e.g. plots.plot.127", @Comment({"The max. range of permissions to check e.g. plots.plot.127",
@ -328,7 +338,8 @@ public class Settings extends Config {
false; false;
@Comment("Disable redstone when all owners/trusted/members are offline") @Comment("Disable redstone when all owners/trusted/members are offline")
public static boolean DISABLE_OFFLINE = false; public static boolean DISABLE_OFFLINE = false;
@Comment("Detect and cancel invalid pistons on the edge of plots (e.g. placed with WorldEdit)") @Comment(
"Detect and cancel invalid pistons on the edge of plots (e.g. placed with WorldEdit)")
public static boolean DETECT_INVALID_EDGE_PISTONS = false; public static boolean DETECT_INVALID_EDGE_PISTONS = false;
} }
@ -355,7 +366,8 @@ public class Settings extends Config {
true; true;
@Comment("The UUID cacher is used to resolve player names") public static boolean @Comment("The UUID cacher is used to resolve player names") public static boolean
UUID_CACHE = true; UUID_CACHE = true;
@Comment("Whether we should notify you about updates or not.") public static boolean UPDATE_NOTIFICATIONS = true; @Comment("Whether we should notify you about updates or not.") public static boolean
UPDATE_NOTIFICATIONS = true;
@Comment("Stores user metadata in a database") public static boolean PERSISTENT_META = true; @Comment("Stores user metadata in a database") public static boolean PERSISTENT_META = true;
@Comment("Optimizes permission checks") public static boolean PERMISSION_CACHE = true; @Comment("Optimizes permission checks") public static boolean PERMISSION_CACHE = true;
@Comment("Optimizes block changing code") public static boolean BLOCK_CACHE = true; @Comment("Optimizes block changing code") public static boolean BLOCK_CACHE = true;

View File

@ -27,7 +27,8 @@ package com.plotsquared.core.configuration;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor public final class StaticCaption implements Caption { @RequiredArgsConstructor
public final class StaticCaption implements Caption {
private final String value; private final String value;
private final boolean usePrefix; private final boolean usePrefix;

View File

@ -42,7 +42,8 @@ public class Storage extends Config {
load(file, Storage.class); load(file, Storage.class);
} }
@Comment("MySQL section") public static final class MySQL { @Comment("MySQL section")
public static final class MySQL {
@Comment("Should MySQL be used?") public static boolean USE = false; @Comment("Should MySQL be used?") public static boolean USE = false;
public static String HOST = "localhost"; public static String HOST = "localhost";
public static String PORT = "3306"; public static String PORT = "3306";
@ -55,7 +56,8 @@ public class Storage extends Config {
} }
@Comment("SQLite section") public static final class SQLite { @Comment("SQLite section")
public static final class SQLite {
@Comment("Should SQLite be used?") public static boolean USE = true; @Comment("Should SQLite be used?") public static boolean USE = true;
@Comment("The file to use") public static String DB = "storage"; @Comment("The file to use") public static String DB = "storage";
} }

View File

@ -25,10 +25,10 @@
*/ */
package com.plotsquared.core.configuration.file; package com.plotsquared.core.configuration.file;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Configuration; import com.plotsquared.core.configuration.Configuration;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.InvalidConfigurationException; import com.plotsquared.core.configuration.InvalidConfigurationException;
import com.plotsquared.core.PlotSquared;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.error.YAMLException;

View File

@ -34,7 +34,8 @@ import java.lang.annotation.Target;
* Applies to a {@link ConfigurationSerializable} that will delegate all * Applies to a {@link ConfigurationSerializable} that will delegate all
* deserialization to another {@link ConfigurationSerializable}. * deserialization to another {@link ConfigurationSerializable}.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface DelegateDeserialization { public @interface DelegateDeserialization {
/** /**
* Which class should be used as a delegate for this classes * Which class should be used as a delegate for this classes

View File

@ -44,7 +44,9 @@ import java.lang.annotation.Target;
* *
* @see ConfigurationSerialization#registerClass(Class, String) * @see ConfigurationSerialization#registerClass(Class, String)
*/ */
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface SerializableAs { @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SerializableAs {
/** /**
* This is the name your class will be stored and retrieved as. * This is the name your class will be stored and retrieved as.
* <p> * <p>

View File

@ -25,13 +25,13 @@
*/ */
package com.plotsquared.core.database; package com.plotsquared.core.database;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotCluster;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.comment.PlotComment; import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.task.RunnableVal;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;

View File

@ -25,13 +25,13 @@
*/ */
package com.plotsquared.core.database; package com.plotsquared.core.database;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotCluster;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.comment.PlotComment; import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.task.RunnableVal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;

View File

@ -25,27 +25,27 @@
*/ */
package com.plotsquared.core.database; package com.plotsquared.core.database;
import com.plotsquared.core.configuration.ConfigurationSection; import com.google.common.base.Charsets;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.Storage; import com.plotsquared.core.configuration.Storage;
import com.plotsquared.core.plot.flag.FlagContainer;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.location.BlockLoc; import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotCluster;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotSettings; import com.plotsquared.core.plot.PlotSettings;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.comment.PlotComment; import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.plot.flag.FlagContainer;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.google.common.base.Charsets;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.sql.Connection; import java.sql.Connection;
@ -75,7 +75,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@SuppressWarnings("SqlDialectInspection") public class SQLManager implements AbstractDB { @SuppressWarnings("SqlDialectInspection")
public class SQLManager implements AbstractDB {
// Public final // Public final
public final String SET_OWNER; public final String SET_OWNER;
@ -606,23 +607,23 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
} }
createFlags(idMap, myList, () -> createFlags(idMap, myList, () -> createSettings(settings,
createSettings(settings, () -> createTiers(helpers, "helpers",
() -> createTiers(helpers, "helpers", () -> createTiers(trusted, "trusted",
() -> createTiers(trusted, "trusted", () -> createTiers(denied, "denied", () -> {
() -> createTiers(denied, "denied", () -> { try {
try { SQLManager.this.connection.commit();
SQLManager.this.connection.commit(); } catch (SQLException e) {
} catch (SQLException e) { e.printStackTrace();
e.printStackTrace(); }
} if (whenDone != null) {
if (whenDone != null) { whenDone.run();
whenDone.run(); }
}
}))))); })))));
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
PlotSquared.debug("&7[WARN] Failed to set all flags and member tiers for plots"); PlotSquared
.debug("&7[WARN] Failed to set all flags and member tiers for plots");
try { try {
SQLManager.this.connection.commit(); SQLManager.this.connection.commit();
} catch (SQLException e1) { } catch (SQLException e1) {
@ -687,11 +688,12 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
public void createFlags(Map<PlotId, Integer> ids, List<Plot> plots, Runnable whenDone) { public void createFlags(Map<PlotId, Integer> ids, List<Plot> plots, Runnable whenDone) {
try (final PreparedStatement preparedStatement = try (final PreparedStatement preparedStatement = this.connection.prepareStatement(
this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) { "INSERT INTO `" + SQLManager.this.prefix
+ "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) {
for (final Plot plot : plots) { for (final Plot plot : plots) {
final FlagContainer flagContainer = plot.getFlagContainer(); final FlagContainer flagContainer = plot.getFlagContainer();
for (final PlotFlag<?,?> flagEntry : flagContainer.getFlagMap().values()) { for (final PlotFlag<?, ?> flagEntry : flagContainer.getFlagMap().values()) {
preparedStatement.setInt(1, ids.get(plot.getId())); preparedStatement.setInt(1, ids.get(plot.getId()));
preparedStatement.setString(2, flagEntry.getName()); preparedStatement.setString(2, flagEntry.getName());
preparedStatement.setString(3, flagEntry.toString()); preparedStatement.setString(3, flagEntry.toString());
@ -700,17 +702,21 @@ import java.util.concurrent.atomic.AtomicInteger;
try { try {
preparedStatement.executeBatch(); preparedStatement.executeBatch();
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values for plot with entry ID: " + plot.getId()); PlotSquared.log(Captions.PREFIX.getTranslated()
+ "Failed to store flag values for plot with entry ID: " + plot.getId());
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
PlotSquared.debug(Captions.PREFIX.getTranslated() + "- Finished converting flags for plot with entry ID: " + plot.getId()); PlotSquared.debug(Captions.PREFIX.getTranslated()
+ "- Finished converting flags for plot with entry ID: " + plot.getId());
} }
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:"); PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:");
e.printStackTrace(); e.printStackTrace();
} }
PlotSquared.log(Captions.PREFIX.getTranslated() + "Finished converting flags (" + plots.size() + " plots processed)"); PlotSquared.log(
Captions.PREFIX.getTranslated() + "Finished converting flags (" + plots.size()
+ " plots processed)");
whenDone.run(); whenDone.run();
} }
@ -890,8 +896,8 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
public void createSettings(final ArrayList<LegacySettings> myList, final Runnable whenDone) { public void createSettings(final ArrayList<LegacySettings> myList, final Runnable whenDone) {
try (final PreparedStatement preparedStatement = try (final PreparedStatement preparedStatement = this.connection.prepareStatement(
this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`" "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`"
+ "(`plot_plot_id`,`biome`,`rain`,`custom_time`,`time`,`deny_entry`,`alias`,`merged`,`position`) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)")) { + "(`plot_plot_id`,`biome`,`rain`,`custom_time`,`time`,`deny_entry`,`alias`,`merged`,`position`) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
int packet; int packet;
@ -926,13 +932,15 @@ import java.util.concurrent.atomic.AtomicInteger;
} else { } else {
position = loc.getX() + "," + loc.getY() + ',' + loc.getZ(); position = loc.getX() + "," + loc.getY() + ',' + loc.getZ();
} }
preparedStatement.setString( 9, position); preparedStatement.setString(9, position);
preparedStatement.addBatch(); preparedStatement.addBatch();
if (++updated >= packet) { if (++updated >= packet) {
try { try {
preparedStatement.executeBatch(); preparedStatement.executeBatch();
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values for plot with entry ID: " + legacySettings.id); PlotSquared.log(Captions.PREFIX.getTranslated()
+ "Failed to store settings values for plot with entry ID: "
+ legacySettings.id);
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
@ -944,7 +952,8 @@ import java.util.concurrent.atomic.AtomicInteger;
try { try {
preparedStatement.executeBatch(); preparedStatement.executeBatch();
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values"); PlotSquared
.log(Captions.PREFIX.getTranslated() + "Failed to store settings values");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -952,7 +961,9 @@ import java.util.concurrent.atomic.AtomicInteger;
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values:"); PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values:");
e.printStackTrace(); e.printStackTrace();
} }
PlotSquared.log(Captions.PREFIX.getTranslated() + "Finished converting settings (" + myList.size() + " plots processed)"); PlotSquared.log(
Captions.PREFIX.getTranslated() + "Finished converting settings (" + myList.size()
+ " plots processed)");
whenDone.run(); whenDone.run();
} }
@ -964,9 +975,8 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public String getCreateSQLite(int size) { @Override public String getCreateSQLite(int size) {
return getCreateSQLite(size, "INSERT INTO `" + SQLManager.this.prefix return getCreateSQLite(size, "INSERT INTO `" + SQLManager.this.prefix
+ "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS " + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS "
+ "`deny_entry`, ? AS `alias`, ? AS `merged`, ? AS `position` ", + "`deny_entry`, ? AS `alias`, ? AS `merged`, ? AS `position` ", 10);
10);
} }
@Override public String getCreateSQL() { @Override public String getCreateSQL() {
@ -1161,8 +1171,7 @@ import java.util.concurrent.atomic.AtomicInteger;
+ " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0,"
+ " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000',"
+ " `deny_entry` TINYINT(1) DEFAULT '0'," + " `deny_entry` TINYINT(1) DEFAULT '0',"
+ " `alias` VARCHAR(50) DEFAULT NULL," + " `alias` VARCHAR(50) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL,"
+ " `merged` INT(11) DEFAULT NULL,"
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
+ " PRIMARY KEY (`plot_plot_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + " PRIMARY KEY (`plot_plot_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix
@ -1192,8 +1201,7 @@ import java.util.concurrent.atomic.AtomicInteger;
+ " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST',"
+ " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0',"
+ " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0',"
+ " `alias` VARCHAR(50) DEFAULT NULL," + " `alias` VARCHAR(50) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL,"
+ " `merged` INT(11) DEFAULT NULL,"
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
+ " PRIMARY KEY (`cluster_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + " PRIMARY KEY (`cluster_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "player_meta` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "player_meta` ("
@ -1203,9 +1211,9 @@ import java.util.concurrent.atomic.AtomicInteger;
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_flags`(" stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_flags`("
+ "`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY," + "`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
+ "`plot_id` INT(11) NOT NULL," + " `flag` VARCHAR(256)," + " `value` VARCHAR(512)," + "`plot_id` INT(11) NOT NULL," + " `flag` VARCHAR(256),"
+ "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix + "plot` (id) ON DELETE CASCADE, " + " `value` VARCHAR(512)," + "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix
+ "UNIQUE (plot_id, flag)" + "plot` (id) ON DELETE CASCADE, " + "UNIQUE (plot_id, flag)"
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
} else { } else {
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` ("
@ -1232,8 +1240,7 @@ import java.util.concurrent.atomic.AtomicInteger;
+ " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0,"
+ " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000',"
+ " `deny_entry` TINYINT(1) DEFAULT '0'," + " `deny_entry` TINYINT(1) DEFAULT '0',"
+ " `alias` VARCHAR(50) DEFAULT NULL," + " `alias` VARCHAR(50) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL,"
+ " `merged` INT(11) DEFAULT NULL,"
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
+ " PRIMARY KEY (`plot_plot_id`)" + ')'); + " PRIMARY KEY (`plot_plot_id`)" + ')');
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix
@ -1254,8 +1261,7 @@ import java.util.concurrent.atomic.AtomicInteger;
+ " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST',"
+ " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0',"
+ " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0',"
+ " `alias` VARCHAR(50) DEFAULT NULL," + " `alias` VARCHAR(50) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL,"
+ " `merged` INT(11) DEFAULT NULL,"
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
+ " PRIMARY KEY (`cluster_id`)" + ')'); + " PRIMARY KEY (`cluster_id`)" + ')');
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "player_meta` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "player_meta` ("
@ -1263,10 +1269,10 @@ import java.util.concurrent.atomic.AtomicInteger;
+ " `uuid` VARCHAR(40) NOT NULL," + " `key` VARCHAR(32) NOT NULL," + " `uuid` VARCHAR(40) NOT NULL," + " `key` VARCHAR(32) NOT NULL,"
+ " `value` blob NOT NULL" + ')'); + " `value` blob NOT NULL" + ')');
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_flags`(" stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_flags`("
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id` INTEGER NOT NULL,"
+ "`plot_id` INTEGER NOT NULL," + " `flag` VARCHAR(256)," + " `value` VARCHAR(512)," + " `flag` VARCHAR(256)," + " `value` VARCHAR(512),"
+ "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix + "plot` (id) ON DELETE CASCADE, " + "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix
+ "UNIQUE (plot_id, flag))"); + "plot` (id) ON DELETE CASCADE, " + "UNIQUE (plot_id, flag))");
} }
stmt.executeBatch(); stmt.executeBatch();
stmt.clearBatch(); stmt.clearBatch();
@ -1667,11 +1673,14 @@ import java.util.concurrent.atomic.AtomicInteger;
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
PlotSquared.log(Captions.PREFIX.getTranslated() + "Loaded " + flagMap.size() + " plot flag collections..."); PlotSquared.log(Captions.PREFIX.getTranslated() + "Loaded " + flagMap.size()
PlotSquared.log(Captions.PREFIX.getTranslated() + "Attempting to store these flags in the new table..."); + " plot flag collections...");
PlotSquared.log(Captions.PREFIX.getTranslated()
+ "Attempting to store these flags in the new table...");
// //
try (final PreparedStatement preparedStatement = try (final PreparedStatement preparedStatement = this.connection.prepareStatement(
this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) { "INSERT INTO `" + SQLManager.this.prefix
+ "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) {
long timeStarted = System.currentTimeMillis(); long timeStarted = System.currentTimeMillis();
int flagsProcessed = 0; int flagsProcessed = 0;
@ -1683,7 +1692,8 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
for (final Map.Entry<Integer, Map<String, String>> plotFlagEntry : flagMap.entrySet()) { for (final Map.Entry<Integer, Map<String, String>> plotFlagEntry : flagMap.entrySet()) {
for (final Map.Entry<String, String> flagEntry : plotFlagEntry.getValue().entrySet()) { for (final Map.Entry<String, String> flagEntry : plotFlagEntry.getValue()
.entrySet()) {
preparedStatement.setInt(1, plotFlagEntry.getKey()); preparedStatement.setInt(1, plotFlagEntry.getKey());
preparedStatement.setString(2, flagEntry.getKey()); preparedStatement.setString(2, flagEntry.getKey());
preparedStatement.setString(3, flagEntry.getValue()); preparedStatement.setString(3, flagEntry.getValue());
@ -1695,17 +1705,25 @@ import java.util.concurrent.atomic.AtomicInteger;
try { try {
preparedStatement.executeBatch(); preparedStatement.executeBatch();
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values for plot with entry ID: " + plotFlagEntry.getKey()); PlotSquared.log(Captions.PREFIX.getTranslated()
+ "Failed to store flag values for plot with entry ID: " + plotFlagEntry
.getKey());
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
if (System.currentTimeMillis() - timeStarted >= 1000L || plotsProcessed >= flagMap.size()) { if (System.currentTimeMillis() - timeStarted >= 1000L || plotsProcessed >= flagMap
.size()) {
timeStarted = System.currentTimeMillis(); timeStarted = System.currentTimeMillis();
PlotSquared.log(Captions.PREFIX.getTranslated() + "... Flag conversion in progress. " + String.format("%.1f", ((float) flagsProcessed / totalFlags) * 100) + "% Done"); PlotSquared.log(
Captions.PREFIX.getTranslated() + "... Flag conversion in progress. "
+ String.format("%.1f", ((float) flagsProcessed / totalFlags) * 100)
+ "% Done");
} }
PlotSquared.debug(Captions.PREFIX.getTranslated() + "- Finished converting flags for plot with entry ID: " + plotFlagEntry.getKey()); PlotSquared.debug(Captions.PREFIX.getTranslated()
+ "- Finished converting flags for plot with entry ID: " + plotFlagEntry
.getKey());
} }
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:"); PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:");
@ -1942,25 +1960,30 @@ import java.util.concurrent.atomic.AtomicInteger;
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id"); deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
} }
try (final ResultSet resultSet = statement.executeQuery("SELECT * FROM `" + this.prefix + "plot_flags`")) { try (final ResultSet resultSet = statement
.executeQuery("SELECT * FROM `" + this.prefix + "plot_flags`")) {
final ArrayList<Integer> toDelete = new ArrayList<>(); final ArrayList<Integer> toDelete = new ArrayList<>();
final Map<Plot, Collection<PlotFlag<?,?>>> invalidFlags = new HashMap<>(); final Map<Plot, Collection<PlotFlag<?, ?>>> invalidFlags = new HashMap<>();
while (resultSet.next()) { while (resultSet.next()) {
id = resultSet.getInt("plot_id"); id = resultSet.getInt("plot_id");
final String flag = resultSet.getString("flag"); final String flag = resultSet.getString("flag");
final String value = resultSet.getString("value"); final String value = resultSet.getString("value");
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
final PlotFlag<?,?> plotFlag = GlobalFlagContainer.getInstance().getFlagFromString(flag); final PlotFlag<?, ?> plotFlag =
GlobalFlagContainer.getInstance().getFlagFromString(flag);
if (plotFlag == null) { if (plotFlag == null) {
plot.getFlagContainer().addUnknownFlag(flag, value); plot.getFlagContainer().addUnknownFlag(flag, value);
} else { } else {
try { try {
plot.getFlagContainer().addFlag(plotFlag.parse(value)); plot.getFlagContainer().addFlag(plotFlag.parse(value));
} catch (final FlagParseException e) { } catch (final FlagParseException e) {
PlotSquared.debug("Plot with ID " + id + " has an invalid value:"); PlotSquared
PlotSquared.debug(Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", plotFlag.getName()) .debug("Plot with ID " + id + " has an invalid value:");
.replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage())); PlotSquared.debug(Captions.FLAG_PARSE_ERROR.getTranslated()
.replace("%flag_name%", plotFlag.getName())
.replace("%flag_value%", e.getValue())
.replace("%error%", e.getErrorMessage()));
if (!invalidFlags.containsKey(plot)) { if (!invalidFlags.containsKey(plot)) {
invalidFlags.put(plot, new ArrayList<>()); invalidFlags.put(plot, new ArrayList<>());
} }
@ -1975,10 +1998,12 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
} }
if (Settings.Enabled_Components.DATABASE_PURGER) { if (Settings.Enabled_Components.DATABASE_PURGER) {
for (final Map.Entry<Plot, Collection<PlotFlag<?,?>>> plotFlagEntry : invalidFlags.entrySet()) { for (final Map.Entry<Plot, Collection<PlotFlag<?, ?>>> plotFlagEntry : invalidFlags
for (final PlotFlag<?,?> flag : plotFlagEntry.getValue()) { .entrySet()) {
for (final PlotFlag<?, ?> flag : plotFlagEntry.getValue()) {
PlotSquared.debug("&cPlot \"" + plotFlagEntry.getKey() + "\"" PlotSquared.debug("&cPlot \"" + plotFlagEntry.getKey() + "\""
+ " had an invalid flag (" + flag.getName() + "). A fix has been attempted."); + " had an invalid flag (" + flag.getName()
+ "). A fix has been attempted.");
removeFlag(plotFlagEntry.getKey(), flag); removeFlag(plotFlagEntry.getKey(), flag);
} }
} }
@ -2076,8 +2101,9 @@ import java.util.concurrent.atomic.AtomicInteger;
final int id2 = getId(plot2); final int id2 = getId(plot2);
final PlotId pos1 = plot1.getId(); final PlotId pos1 = plot1.getId();
final PlotId pos2 = plot2.getId(); final PlotId pos2 = plot2.getId();
try (final PreparedStatement preparedStatement = this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix try (final PreparedStatement preparedStatement = this.connection.prepareStatement(
+ "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?")) { "UPDATE `" + SQLManager.this.prefix
+ "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?")) {
preparedStatement.setInt(1, pos1.getX()); preparedStatement.setInt(1, pos1.getX());
preparedStatement.setInt(2, pos1.getY()); preparedStatement.setInt(2, pos1.getY());
preparedStatement.setInt(3, id1); preparedStatement.setInt(3, id1);
@ -2087,7 +2113,9 @@ import java.util.concurrent.atomic.AtomicInteger;
preparedStatement.setInt(3, id2); preparedStatement.setInt(3, id2);
preparedStatement.execute(); preparedStatement.execute();
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to persist swap of " + plot1 + " and " + plot2 + "!"); PlotSquared.log(
Captions.PREFIX.getTranslated() + "Failed to persist swap of " + plot1 + " and "
+ plot2 + "!");
e.printStackTrace(); e.printStackTrace();
future.complete(false); future.complete(false);
return; return;
@ -2127,10 +2155,12 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public PreparedStatement get() throws SQLException { @Override public PreparedStatement get() throws SQLException {
final String statement; final String statement;
if (SQLManager.this.mySQL) { if (SQLManager.this.mySQL) {
statement = "INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?) " statement = "INSERT INTO `" + SQLManager.this.prefix
+ "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?) "
+ "ON DUPLICATE KEY UPDATE `value` = ?"; + "ON DUPLICATE KEY UPDATE `value` = ?";
} else { } else {
statement = "INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?) " statement = "INSERT INTO `" + SQLManager.this.prefix
+ "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?) "
+ "ON CONFLICT(`plot_id`,`flag`) DO UPDATE SET `value` = ?"; + "ON CONFLICT(`plot_id`,`flag`) DO UPDATE SET `value` = ?";
} }
return SQLManager.this.connection.prepareStatement(statement); return SQLManager.this.connection.prepareStatement(statement);
@ -2146,8 +2176,9 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
@Override public PreparedStatement get() throws SQLException { @Override public PreparedStatement get() throws SQLException {
return SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix return SQLManager.this.connection.prepareStatement(
+ "plot_flags` WHERE `plot_id` = ? AND `flag` = ?"); "DELETE FROM `" + SQLManager.this.prefix
+ "plot_flags` WHERE `plot_id` = ? AND `flag` = ?");
} }
}); });
} }
@ -2337,7 +2368,8 @@ import java.util.concurrent.atomic.AtomicInteger;
}); });
} }
@Override public void getComments(@NotNull Plot plot, final String inbox, @Override
public void getComments(@NotNull Plot plot, final String inbox,
final RunnableVal<List<PlotComment>> whenDone) { final RunnableVal<List<PlotComment>> whenDone) {
addPlotTask(plot, new UniqueStatement("getComments_" + plot) { addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
@Override public void set(PreparedStatement statement) throws SQLException { @Override public void set(PreparedStatement statement) throws SQLException {
@ -2583,7 +2615,8 @@ import java.util.concurrent.atomic.AtomicInteger;
}); });
} }
@Override public void addPersistentMeta(final UUID uuid, final String key, final byte[] meta, @Override
public void addPersistentMeta(final UUID uuid, final String key, final byte[] meta,
final boolean replace) { final boolean replace) {
addPlayerTask(uuid, new UniqueStatement("addPersistentMeta") { addPlayerTask(uuid, new UniqueStatement("addPersistentMeta") {
@Override public void set(PreparedStatement statement) throws SQLException { @Override public void set(PreparedStatement statement) throws SQLException {
@ -3044,8 +3077,8 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
// owner // owner
if (!plot.getOwnerAbs().equals(dataPlot.getOwnerAbs())) { if (!plot.getOwnerAbs().equals(dataPlot.getOwnerAbs())) {
PlotSquared PlotSquared.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil
.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.getOwnerAbs())); .getName(plot.getOwnerAbs()));
setOwner(plot, plot.getOwnerAbs()); setOwner(plot, plot.getOwnerAbs());
} }
// trusted // trusted
@ -3116,8 +3149,7 @@ import java.util.concurrent.atomic.AtomicInteger;
Set<PlotFlag<?, ?>> df = dataPlot.getFlags(); Set<PlotFlag<?, ?>> df = dataPlot.getFlags();
if (!pf.isEmpty() && !df.isEmpty()) { if (!pf.isEmpty() && !df.isEmpty()) {
if (pf.size() != df.size() || !StringMan if (pf.size() != df.size() || !StringMan
.isEqual(StringMan.joinOrdered(pf, ","), .isEqual(StringMan.joinOrdered(pf, ","), StringMan.joinOrdered(df, ","))) {
StringMan.joinOrdered(df, ","))) {
PlotSquared.debug(" - Correcting flags for: " + plot); PlotSquared.debug(" - Correcting flags for: " + plot);
// setFlags(plot, pf); // setFlags(plot, pf);
// TODO: Re-implement // TODO: Re-implement
@ -3251,6 +3283,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public abstract void set(PreparedStatement statement) throws SQLException; public abstract void set(PreparedStatement statement) throws SQLException;
} }
private class UUIDPair { private class UUIDPair {
public final int id; public final int id;

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
/** /**
* Called when a player teleports to a plot * Called when a player teleports to a plot

View File

@ -55,8 +55,8 @@ public class AugmentedUtils {
enabled = true; enabled = true;
} }
public static boolean generate(@Nullable Object chunkObject, @NotNull final String world, final int chunkX, final int chunkZ, public static boolean generate(@Nullable Object chunkObject, @NotNull final String world,
LocalBlockQueue queue) { final int chunkX, final int chunkZ, LocalBlockQueue queue) {
if (!enabled) { if (!enabled) {
return false; return false;
} }
@ -134,8 +134,8 @@ public class AugmentedUtils {
continue; continue;
} }
generationResult = true; generationResult = true;
secondaryMask = new LocationOffsetDelegateLocalBlockQueue(canPlace, blockX, secondaryMask = new LocationOffsetDelegateLocalBlockQueue(canPlace, blockX, blockZ,
blockZ, primaryMask); primaryMask);
} else { } else {
secondaryMask = primaryMask; secondaryMask = primaryMask;
for (int x = relativeBottomX; x <= relativeTopX; x++) { for (int x = relativeBottomX; x <= relativeTopX; x++) {
@ -152,8 +152,9 @@ public class AugmentedUtils {
secondaryMask.setChunkObject(chunkObject); secondaryMask.setChunkObject(chunkObject);
secondaryMask.setForceSync(true); secondaryMask.setForceSync(true);
ScopedLocalBlockQueue scoped = new ScopedLocalBlockQueue(secondaryMask, new Location(world, blockX, 0, blockZ), ScopedLocalBlockQueue scoped =
new Location(world, blockX + 15, 255, blockZ + 15)); new ScopedLocalBlockQueue(secondaryMask, new Location(world, blockX, 0, blockZ),
new Location(world, blockX + 15, 255, blockZ + 15));
generator.generateChunk(scoped, area); generator.generateChunk(scoped, area);
generator.populateChunk(scoped, area); generator.populateChunk(scoped, area);
} }

View File

@ -26,16 +26,16 @@
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotAreaTerrainType; import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.BlockUtil; import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.MathMan;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -223,11 +223,11 @@ public class ClassicPlotManager extends SquarePlotManager {
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (CuboidRegion region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), maxY, new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
region.getMinimumPoint().getZ()); maxY, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), maxY, new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
region.getMaximumPoint().getZ()); maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
} }
@ -356,19 +356,21 @@ public class ClassicPlotManager extends SquarePlotManager {
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1,
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), sz + 1),
classicPlotWorld.WALL_BLOCK.toPattern()); new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1,
ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), ex, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), ex, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, sz + 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1,
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), sz + 1),
classicPlotWorld.WALL_BLOCK.toPattern()); new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1,
ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
classicPlotWorld.ROAD_BLOCK.toPattern()); ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -392,19 +394,21 @@ public class ClassicPlotManager extends SquarePlotManager {
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz), new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, sz), sz),
classicPlotWorld.WALL_BLOCK.toPattern()); new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1,
sz), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, ez), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, ez),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez),
classicPlotWorld.WALL_FILLING.toPattern()); classicPlotWorld.WALL_FILLING.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, ez), new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), ez),
classicPlotWorld.WALL_BLOCK.toPattern()); new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1,
ez), classicPlotWorld.WALL_BLOCK.toPattern());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
classicPlotWorld.ROAD_BLOCK.toPattern()); ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -424,8 +428,8 @@ public class ClassicPlotManager extends SquarePlotManager {
new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1),
BlockUtil.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
classicPlotWorld.ROAD_BLOCK.toPattern()); ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
return queue.enqueue(); return queue.enqueue();
} }
@ -443,8 +447,8 @@ public class ClassicPlotManager extends SquarePlotManager {
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1,
classicPlotWorld.MAIN_BLOCK.toPattern()); ez - 1), classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1),
@ -466,8 +470,8 @@ public class ClassicPlotManager extends SquarePlotManager {
classicPlotWorld.getPlotManager().getWorldHeight(), ez), classicPlotWorld.getPlotManager().getWorldHeight(), ez),
BlockTypes.AIR.getDefaultState()); BlockTypes.AIR.getDefaultState());
queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz), queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1,
classicPlotWorld.MAIN_BLOCK.toPattern()); ez), classicPlotWorld.MAIN_BLOCK.toPattern());
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz), new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez),

View File

@ -25,10 +25,10 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
@ -38,7 +38,8 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Locale; import java.util.Locale;
@SuppressWarnings("WeakerAccess") public abstract class ClassicPlotWorld extends SquarePlotWorld { @SuppressWarnings("WeakerAccess")
public abstract class ClassicPlotWorld extends SquarePlotWorld {
public int ROAD_HEIGHT = 62; public int ROAD_HEIGHT = 62;
public int PLOT_HEIGHT = 62; public int PLOT_HEIGHT = 62;
@ -116,8 +117,8 @@ import java.util.Locale;
// Dump world settings // Dump world settings
if (Settings.DEBUG) { if (Settings.DEBUG) {
PlotSquared.debug(String PlotSquared.debug(String.format("- Dumping settings for ClassicPlotWorld with name %s",
.format("- Dumping settings for ClassicPlotWorld with name %s", this.getWorldName())); this.getWorldName()));
final Field[] fields = this.getClass().getFields(); final Field[] fields = this.getClass().getFields();
for (final Field field : fields) { for (final Field field : fields) {
final String name = field.getName().toLowerCase(Locale.ENGLISH); final String name = field.getName().toLowerCase(Locale.ENGLISH);

View File

@ -25,14 +25,14 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.google.common.base.Preconditions;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.queue.ScopedLocalBlockQueue; import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.google.common.base.Preconditions; import com.plotsquared.core.util.MathMan;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -66,7 +66,8 @@ public class HybridGen extends IndependentPlotGenerator {
} }
} }
@Override public void generateChunk(@NotNull ScopedLocalBlockQueue result, @NotNull PlotArea settings) { @Override
public void generateChunk(@NotNull ScopedLocalBlockQueue result, @NotNull PlotArea settings) {
Preconditions.checkNotNull(result, "result cannot be null"); Preconditions.checkNotNull(result, "result cannot be null");
Preconditions.checkNotNull(settings, "settings cannot be null"); Preconditions.checkNotNull(settings, "settings cannot be null");
@ -114,8 +115,10 @@ public class HybridGen extends IndependentPlotGenerator {
} }
relativeX[i] = v; relativeX[i] = v;
if (hybridPlotWorld.ROAD_WIDTH != 0) { if (hybridPlotWorld.ROAD_WIDTH != 0) {
insideRoadX[i] = v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER; insideRoadX[i] =
insideWallX[i] = v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER; v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
insideWallX[i] =
v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
} }
} }
// The Z-coordinate of a given Z coordinate, relative to the // The Z-coordinate of a given Z coordinate, relative to the
@ -133,8 +136,10 @@ public class HybridGen extends IndependentPlotGenerator {
} }
relativeZ[i] = v; relativeZ[i] = v;
if (hybridPlotWorld.ROAD_WIDTH != 0) { if (hybridPlotWorld.ROAD_WIDTH != 0) {
insideRoadZ[i] = v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER; insideRoadZ[i] =
insideWallZ[i] = v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER; v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
insideWallZ[i] =
v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
} }
} }
// generation // generation
@ -157,7 +162,8 @@ public class HybridGen extends IndependentPlotGenerator {
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern()); result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
} }
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true); placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
true);
} }
} else { } else {
// wall // wall
@ -165,9 +171,11 @@ public class HybridGen extends IndependentPlotGenerator {
result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern()); result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern());
} }
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern()); result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z,
hybridPlotWorld.WALL_BLOCK.toPattern());
} else { } else {
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true); placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
true);
} }
} }
} }
@ -179,7 +187,8 @@ public class HybridGen extends IndependentPlotGenerator {
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern()); result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
} }
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true); placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
true);
} }
} else if (insideWallZ[z]) { } else if (insideWallZ[z]) {
// wall // wall
@ -187,18 +196,22 @@ public class HybridGen extends IndependentPlotGenerator {
result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern()); result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern());
} }
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern()); result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z,
hybridPlotWorld.WALL_BLOCK.toPattern());
} else { } else {
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true); placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
true);
} }
} else { } else {
// plot // plot
for (int y = 1; y < hybridPlotWorld.PLOT_HEIGHT; y++) { for (int y = 1; y < hybridPlotWorld.PLOT_HEIGHT; y++) {
result.setBlock(x, y, z, hybridPlotWorld.MAIN_BLOCK.toPattern()); result.setBlock(x, y, z, hybridPlotWorld.MAIN_BLOCK.toPattern());
} }
result.setBlock(x, hybridPlotWorld.PLOT_HEIGHT, z, hybridPlotWorld.TOP_BLOCK.toPattern()); result.setBlock(x, hybridPlotWorld.PLOT_HEIGHT, z,
hybridPlotWorld.TOP_BLOCK.toPattern());
if (hybridPlotWorld.PLOT_SCHEMATIC) { if (hybridPlotWorld.PLOT_SCHEMATIC) {
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, false); placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
false);
} }
} }
} }

View File

@ -67,8 +67,9 @@ public class HybridPlotManager extends ClassicPlotManager {
HashSet<FileBytes> files = Sets.newHashSet( HashSet<FileBytes> files = Sets.newHashSet(
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml",
Template.getBytes(hybridPlotWorld))); Template.getBytes(hybridPlotWorld)));
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator String dir =
+ hybridPlotWorld.getWorldName() + File.separator; "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + hybridPlotWorld
.getWorldName() + File.separator;
try { try {
File sideRoad = File sideRoad =
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem"); MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem");
@ -100,10 +101,10 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x + 1, id.y); PlotId id2 = new PlotId(id.x + 1, id.y);
Location bot = getPlotBottomLocAbs(id2); Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id); Location top = getPlotTopLocAbs(id);
Location pos1 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1); Location pos1 =
Location pos2 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
new Location(hybridPlotWorld.getWorldName(), bot.getX(), Math.min(getWorldHeight(), 255), Location pos2 = new Location(hybridPlotWorld.getWorldName(), bot.getX(),
top.getZ() + 1); Math.min(getWorldHeight(), 255), top.getZ() + 1);
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2); MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
return true; return true;
@ -160,10 +161,10 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x, id.y + 1); PlotId id2 = new PlotId(id.x, id.y + 1);
Location bot = getPlotBottomLocAbs(id2); Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id); Location top = getPlotTopLocAbs(id);
Location pos1 = new Location(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1); Location pos1 =
Location pos2 = new Location(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, Math.min(getWorldHeight(), 255), Location pos2 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1,
bot.getZ()); Math.min(getWorldHeight(), 255), bot.getZ());
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2); MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
return true; return true;
@ -203,8 +204,8 @@ public class HybridPlotManager extends ClassicPlotManager {
Location pos2 = plot.getExtendedTopAbs(); Location pos2 = plot.getExtendedTopAbs();
// If augmented // If augmented
final boolean canRegen = final boolean canRegen =
(hybridPlotWorld.getType() == PlotAreaType.AUGMENTED) (hybridPlotWorld.getType() == PlotAreaType.AUGMENTED) && (hybridPlotWorld.getTerrain()
&& (hybridPlotWorld.getTerrain() != PlotAreaTerrainType.NONE) && REGENERATIVE_CLEAR; != PlotAreaTerrainType.NONE) && REGENERATIVE_CLEAR;
// The component blocks // The component blocks
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern(); final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern(); final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();

View File

@ -25,9 +25,9 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;

View File

@ -29,9 +29,6 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.listener.WEExtent; import com.plotsquared.core.listener.WEExtent;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
@ -39,18 +36,21 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.queue.ChunkBlockQueue; import com.plotsquared.core.queue.ChunkBlockQueue;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.plot.expiration.PlotAnalysis; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.RegionUtil;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -469,14 +469,15 @@ public abstract class HybridUtils {
BlockVector2 loc = iterator.next(); BlockVector2 loc = iterator.next();
iterator.remove(); iterator.remove();
PlotSquared.debug( PlotSquared.debug(
"[ERROR] Could not update '" + area.getWorldName() + "/region/r." + loc "[ERROR] Could not update '" + area.getWorldName() + "/region/r."
.getX() + "." + loc.getZ() + ".mca' (Corrupt chunk?)"); + loc.getX() + "." + loc.getZ() + ".mca' (Corrupt chunk?)");
int sx = loc.getX() << 5; int sx = loc.getX() << 5;
int sz = loc.getZ() << 5; int sz = loc.getZ() << 5;
for (int x = sx; x < sx + 32; x++) { for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) { for (int z = sz; z < sz + 32; z++) {
ChunkManager.manager ChunkManager.manager
.unloadChunk(area.getWorldName(), BlockVector2.at(x, z), true); .unloadChunk(area.getWorldName(), BlockVector2.at(x, z),
true);
} }
} }
PlotSquared.debug(" - Potentially skipping 1024 chunks"); PlotSquared.debug(" - Potentially skipping 1024 chunks");

View File

@ -228,8 +228,9 @@ public abstract class SquarePlotManager extends GridPlotManager {
} }
PlotSquared.debug("invalid location: " + Arrays.toString(merged)); PlotSquared.debug("invalid location: " + Arrays.toString(merged));
} catch (Exception ignored) { } catch (Exception ignored) {
PlotSquared.debug("Invalid plot / road width in settings.yml for world: " PlotSquared.debug(
+ squarePlotWorld.getWorldName()); "Invalid plot / road width in settings.yml for world: " + squarePlotWorld
.getWorldName());
} }
return null; return null;
} }
@ -246,6 +247,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math + squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
.floor(squarePlotWorld.ROAD_WIDTH / 2); .floor(squarePlotWorld.ROAD_WIDTH / 2);
return new Location(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z); return new Location(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(),
z);
} }
} }

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -26,11 +26,18 @@
package com.plotsquared.core.listener; package com.plotsquared.core.listener;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.PlotWeather; import com.plotsquared.core.collection.ByteArrayUtilities;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotWeather;
import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DenyExitFlag; import com.plotsquared.core.plot.flag.implementations.DenyExitFlag;
@ -48,20 +55,13 @@ import com.plotsquared.core.plot.flag.implementations.TimeFlag;
import com.plotsquared.core.plot.flag.implementations.TitlesFlag; import com.plotsquared.core.plot.flag.implementations.TitlesFlag;
import com.plotsquared.core.plot.flag.implementations.WeatherFlag; import com.plotsquared.core.plot.flag.implementations.WeatherFlag;
import com.plotsquared.core.plot.flag.types.TimedFlag; import com.plotsquared.core.plot.flag.types.TimedFlag;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.collection.ByteArrayUtilities;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
@ -94,7 +94,8 @@ public class PlotListener {
} }
double level = WorldUtil.IMP.getHealth(player); double level = WorldUtil.IMP.getHealth(player);
if (level != value.max) { if (level != value.max) {
WorldUtil.IMP.setHealth(player, Math.min(level + value.amount, value.max)); WorldUtil.IMP
.setHealth(player, Math.min(level + value.amount, value.max));
} }
} }
} }
@ -114,7 +115,8 @@ public class PlotListener {
} }
int level = WorldUtil.IMP.getFoodLevel(player); int level = WorldUtil.IMP.getFoodLevel(player);
if (level != value.max) { if (level != value.max) {
WorldUtil.IMP.setFoodLevel(player, Math.min(level + value.amount, value.max)); WorldUtil.IMP
.setFoodLevel(player, Math.min(level + value.amount, value.max));
} }
} }
} }
@ -148,13 +150,12 @@ public class PlotListener {
final String greeting = plot.getFlag(GreetingFlag.class); final String greeting = plot.getFlag(GreetingFlag.class);
if (!greeting.isEmpty()) { if (!greeting.isEmpty()) {
MainUtil MainUtil.format(Captions.PREFIX_GREETING.getTranslated() + greeting, plot, player,
.format(Captions.PREFIX_GREETING.getTranslated() + greeting, plot, player, false, new RunnableVal<String>() {
false, new RunnableVal<String>() { @Override public void run(String value) {
@Override public void run(String value) { MainUtil.sendMessage(player, value);
MainUtil.sendMessage(player, value); }
} });
});
} }
if (plot.getFlag(NotifyEnterFlag.class)) { if (plot.getFlag(NotifyEnterFlag.class)) {
@ -174,8 +175,7 @@ public class PlotListener {
if (flyStatus != FlyFlag.FlyStatus.DEFAULT) { if (flyStatus != FlyFlag.FlyStatus.DEFAULT) {
boolean flight = player.getFlight(); boolean flight = player.getFlight();
GameMode gamemode = player.getGameMode(); GameMode gamemode = player.getGameMode();
if (flight != (gamemode == GameModes.CREATIVE if (flight != (gamemode == GameModes.CREATIVE || gamemode == GameModes.SPECTATOR)) {
|| gamemode == GameModes.SPECTATOR)) {
player.setPersistentMeta("flight", player.setPersistentMeta("flight",
ByteArrayUtilities.booleanToBytes(player.getFlight())); ByteArrayUtilities.booleanToBytes(player.getFlight()));
} }
@ -189,8 +189,8 @@ public class PlotListener {
player.setGameMode(gameMode); player.setGameMode(gameMode);
} else { } else {
MainUtil.sendMessage(player, StringMan MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), .replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), "{plot}",
"{plot}", plot.getId(), "{gamemode}", gameMode)); plot.getId(), "{gamemode}", gameMode));
} }
} }
} }
@ -202,15 +202,14 @@ public class PlotListener {
player.setGameMode(guestGameMode); player.setGameMode(guestGameMode);
} else { } else {
MainUtil.sendMessage(player, StringMan MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), .replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), "{plot}",
"{plot}", plot.getId(), "{gamemode}", guestGameMode)); plot.getId(), "{gamemode}", guestGameMode));
} }
} }
} }
long time = plot.getFlag(TimeFlag.class); long time = plot.getFlag(TimeFlag.class);
if (time != TimeFlag.TIME_DISABLED.getValue() && !player if (time != TimeFlag.TIME_DISABLED.getValue() && !player.getAttribute("disabletime")) {
.getAttribute("disabletime")) {
try { try {
player.setTime(time); player.setTime(time);
} catch (Exception ignored) { } catch (Exception ignored) {
@ -282,11 +281,13 @@ public class PlotListener {
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class); TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
if (feed != null && feed.getInterval() != 0 && feed.getValue() != 0) { if (feed != null && feed.getInterval() != 0 && feed.getValue() != 0) {
feedRunnable.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20)); feedRunnable
.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20));
} }
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class); TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
if (heal != null && heal.getInterval() != 0 && heal.getValue() != 0) { if (heal != null && heal.getInterval() != 0 && heal.getValue() != 0) {
healRunnable.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20)); healRunnable
.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20));
} }
return true; return true;
} }

View File

@ -28,8 +28,8 @@ package com.plotsquared.core.listener;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.WEManager; import com.plotsquared.core.util.WEManager;
@ -67,9 +67,8 @@ public class WESubscriber {
Player player = (Player) actor; Player player = (Player) actor;
Location location = player.getLocation(); Location location = player.getLocation();
com.plotsquared.core.location.Location pLoc = com.plotsquared.core.location.Location pLoc =
new com.plotsquared.core.location.Location( new com.plotsquared.core.location.Location(player.getWorld().getName(),
player.getWorld().getName(), location.getBlockX(), location.getBlockX(), location.getBlockX(), location.getBlockX(), location.getBlockZ());
location.getBlockZ());
Plot plot = pLoc.getPlot(); Plot plot = pLoc.getPlot();
if (plot == null) { if (plot == null) {
event.setExtent(new NullExtent()); event.setExtent(new NullExtent());

View File

@ -30,10 +30,13 @@ import lombok.AllArgsConstructor;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
//todo better description needed //todo better description needed
/** /**
* (x,y,z) or (x,z) representation for PlotSquared (hence the "Plot" prefix) * (x,y,z) or (x,z) representation for PlotSquared (hence the "Plot" prefix)
*/ */
@AllArgsConstructor public final class PlotLoc { @AllArgsConstructor
public final class PlotLoc {
private final int x; private final int x;
private final int y; private final int y;

View File

@ -28,9 +28,9 @@ package com.plotsquared.core.player;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.RequiredType; import com.plotsquared.core.command.RequiredType;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.plot.PlotWeather; import com.plotsquared.core.plot.PlotWeather;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;

View File

@ -25,31 +25,31 @@
*/ */
package com.plotsquared.core.player; package com.plotsquared.core.player;
import com.plotsquared.core.command.CommandCaller; import com.google.common.base.Preconditions;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.CommandCaller;
import com.plotsquared.core.command.RequiredType; import com.plotsquared.core.command.RequiredType;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotCluster;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.plot.PlotWeather;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager; import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.plot.PlotWeather; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.util.task.RunnableVal;
import com.google.common.base.Preconditions;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
@ -652,25 +652,25 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
TaskManager.runTask(() -> { TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin", true)) { if (getMeta("teleportOnLogin", true)) {
teleport(location); teleport(location);
sendMessage( sendMessage(CaptionUtility.format(PlotPlayer.this,
CaptionUtility.format(PlotPlayer.this, Captions.TELEPORTED_TO_PLOT.getTranslated()) Captions.TELEPORTED_TO_PLOT.getTranslated())
+ " (quitLoc) (" + plotX + " (quitLoc) (" + plotX + "," + plotZ + ")");
+ "," + plotZ + ")");
} }
}); });
} else if (!PlotSquared.get().isMainThread(Thread.currentThread())) { } else if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
if (getMeta("teleportOnLogin", true)) { if (getMeta("teleportOnLogin", true)) {
plot.teleportPlayer(PlotPlayer.this, result -> TaskManager.runTask(() -> { plot.teleportPlayer(PlotPlayer.this,
if (getMeta("teleportOnLogin", true)) { result -> TaskManager.runTask(() -> {
if (plot.isLoaded()) { if (getMeta("teleportOnLogin", true)) {
teleport(location); if (plot.isLoaded()) {
sendMessage(CaptionUtility.format(PlotPlayer.this, teleport(location);
Captions.TELEPORTED_TO_PLOT.getTranslated()) sendMessage(CaptionUtility.format(PlotPlayer.this,
+ " (quitLoc-unloaded) (" + plotX + "," + plotZ Captions.TELEPORTED_TO_PLOT.getTranslated())
+ ")"); + " (quitLoc-unloaded) (" + plotX + "," + plotZ
+ ")");
}
} }
} }));
}));
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -727,7 +727,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
} }
} }
@FunctionalInterface public interface PlotPlayerConverter<BaseObject> { @FunctionalInterface
public interface PlotPlayerConverter<BaseObject> {
PlotPlayer convert(BaseObject object); PlotPlayer convert(BaseObject object);
} }
} }