* Commit WIP flag work.

* More ported flag types, and additions to the flag API.

* Make PlotFlag more generic to allow generic flag creation

* Pull Captions methods into a Caption interface.

* Port MusicFlag

* Port flight flag

* Port UntrustedVisitFlag

* Port DenyExitFlag

* Remove paper suggestion

* Make ListFlag lists immutable

* Update Flag containers. Add javadocs. Add missing methods.

* Port description flag

* Port greeting and farewell flags

* Port weather flag

* Move getExample implementation to BooleanFlag

* Port reserved flags

* Port all boolean flags.

* Remove unused flag types

* Invert liquid-flow flag

* Find the real (legacy) flag name

* Change NOITFY -> NOTIFY in Captions

* Make IntegerFlag extendable

* Port integer flags

* Update Flag command to current API state

* Begin remaking flag command

* Create DoubleFlag + extract common parsing stuff

* Supply arguments in flag parse exceptions

* Implement missing flag subcommands

* Update Flag command to current API state

* Implement PriceFlag

* Port deny-teleport

* Port gamemode flags

* Port BreakFlag

* Port PlaceFlag

* Port UseFlag

* Remove old unused flag constants

* Port blocked-cmds flag

* Fix entity util

* Port TimeFlag

* Use CaptionUtility for formatting

* Port keep flag

* Fix imports

* Reformat code

* Remove unused classes

* Fix MainUtil.java

* Remove FlagCmd

* Add flag info header and footer

* Comment out flag related stuff in SchematicHandler

* Remove FlagManager

* Finalize Plot.java

* Finalize PlotArea.java

* Finalize PlotListener

* Fix API issues

* Fix a bunch of compile errors

* Fix `/plot flag remove`

* Fix initialization of GlobalFlagContainer

* Apply API changes to events

* Update SQLManager to new API

* Invert default value for DenyExitFlag

* Replace flag.getValue().toString() with flag.toString()

* Make FlagContainer instance in Plot final

* Fix various command issues

* Clean up PlotSettings

* Don't show internal flags in flag list

* Fix `/plot flag add`

* Remove the info inventory as it's 100% broken

* Add plot info entries and fix up the default format

* Fix default flag state in Captions

* 781c200 part 2

* Fix odd grammar in captions

* Fix odd grammar in captions v2

* Add create table statements for plot_flags

* Remove old flag references in SQLManager

* Use the new plot_flags table

* Add tab completion to `/plot flag`

* Improve parse error handling

* Make flag permission check recognize parse exceptions

* Initial progress towards flag conversion

* Fix minor issues

* Don't validate flags during flag conversion

* Allow unrecognized flags to be parsed

* Filter out internal flags from command sugguestions

* Use the wrong caption when there's no plot description set

* Limit command suggestions for boolean flags

* Make blocktypelistflags accept blockcategories

* Require categories to be prefixed with '#' and fix some minor display issues

* Fix plot database conversion

* Update PlotFlagEvent.java

Updated return description

* Fix command annotation wrapping

* Add FLAG_UPDATE event for FlagContainer listeners

* Make getParentContainer nullable

* Document castUnsafe in FlagContainer

* Document FlagContainer constructors

* Add missing documentation to FlagContainer

* Document FlagParseException

* Fix wording in FlagContainer javadoc

* Document InternalFlag

* Document PlotFlag

* Minor changes

* Remove revisit comments

Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
Co-authored-by: NotMyFault <mc.cache@web.de>
Co-authored-by: Matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
Alexander Söderberg 2020-02-24 18:42:02 +01:00 committed by GitHub
parent b99631f1bd
commit 9868648fcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
250 changed files with 6229 additions and 3216 deletions

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.bukkit.events; package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -8,10 +8,9 @@ import org.bukkit.event.HandlerList;
/** /**
* Called when a Flag is added to a plot. * Called when a Flag is added to a plot.
*/ */
public class PlotFlagAddEvent extends PlotEvent implements Cancellable { public class PlotFlagAddEvent extends PlotFlagEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final Flag flag;
private boolean cancelled; private boolean cancelled;
/** /**
@ -20,24 +19,14 @@ public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
* @param flag Flag that was added * @param flag Flag that was added
* @param plot Plot to which the flag was added * @param plot Plot to which the flag was added
*/ */
public PlotFlagAddEvent(Flag flag, Plot plot) { public PlotFlagAddEvent(PlotFlag<?, ?> flag, Plot plot) {
super(plot); super(plot, flag);
this.flag = flag;
} }
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
/**
* Get the flag involved.
*
* @return Flag
*/
public Flag getFlag() {
return this.flag;
}
@Override public HandlerList getHandlers() { @Override public HandlerList getHandlers() {
return handlers; return handlers;
} }

View File

@ -0,0 +1,22 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
public abstract class PlotFlagEvent extends PlotEvent {
private final PlotFlag<?, ?> flag;
protected PlotFlagEvent(Plot plot, PlotFlag<?, ?> flag) {
super(plot);
this.flag = flag;
}
/**
* Get the flag involved
*
* @return the flag involved
*/
public PlotFlag<?, ?> getFlag() {
return flag;
}
}

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.bukkit.events; package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -8,10 +8,9 @@ import org.bukkit.event.HandlerList;
/** /**
* Called when a flag is removed from a plot * Called when a flag is removed from a plot
*/ */
public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable { public class PlotFlagRemoveEvent extends PlotFlagEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final Flag flag;
private boolean cancelled; private boolean cancelled;
/** /**
@ -20,24 +19,14 @@ public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
* @param flag Flag that was removed * @param flag Flag that was removed
* @param plot Plot from which the flag was removed * @param plot Plot from which the flag was removed
*/ */
public PlotFlagRemoveEvent(Flag flag, Plot plot) { public PlotFlagRemoveEvent(PlotFlag<?, ?> flag, Plot plot) {
super(plot); super(plot, flag);
this.flag = flag;
} }
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
/**
* Get the flag involved
*
* @return Flag
*/
public Flag getFlag() {
return this.flag;
}
@Override public HandlerList getHandlers() { @Override public HandlerList getHandlers() {
return handlers; return handlers;
} }

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -118,7 +118,7 @@ public class EntitySpawnListener implements Listener {
} }
return; return;
} }
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
event.setCancelled(true); event.setCancelled(true);
} }
switch (entity.getType()) { switch (entity.getType()) {

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.ForcefieldFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -80,7 +80,7 @@ import java.util.UUID;
} }
public static void handleForcefield(Player player, PlotPlayer plotPlayer, Plot plot) { public static void handleForcefield(Player player, PlotPlayer plotPlayer, Plot plot) {
if (Flags.FORCEFIELD.isTrue(plot)) { if (plot.getFlag(ForcefieldFlag.class)) {
UUID uuid = plotPlayer.getUUID(); UUID uuid = plotPlayer.getUUID();
if (plot.isAdded(uuid)) { if (plot.isAdded(uuid)) {
Set<PlotPlayer> players = getNearbyPlayers(player, plot); Set<PlotPlayer> players = getNearbyPlayers(player, plot);

View File

@ -7,10 +7,63 @@ import com.github.intellectualsites.plotsquared.bukkit.util.UpdateUtility;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalAttackFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalCapFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockedCmdsFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.EntityCapFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GrassGrowFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingBreakFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingPlaceFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileAttackFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileCapFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileInteractFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceFormFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceMeltFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.KelpGrowFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.LiquidFlowFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscBreakFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscCapFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscInteractFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobCapFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MycelGrowFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlayerInteractFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PveFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PvpFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.RedstoneFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowFormFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowMeltFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SoilDryFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedAttackFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UseFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleCapFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VillagerInteractFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VineGrowFlag;
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeWrapper;
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType; import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotHandler;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.EntityUtil; import com.github.intellectualsites.plotsquared.plot.util.EntityUtil;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil; import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -135,7 +188,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -185,7 +237,7 @@ import java.util.regex.Pattern;
public static boolean checkEntity(Entity entity, Plot plot) { public static boolean checkEntity(Entity entity, Plot plot) {
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot
.getArea().DEFAULT_FLAGS.isEmpty()) { .getArea().getFlagContainer().getFlagMap().isEmpty()) {
return false; return false;
} }
switch (entity.getType()) { switch (entity.getType()) {
@ -220,11 +272,13 @@ import java.util.regex.Pattern;
case UNKNOWN: case UNKNOWN:
case WITHER_SKULL: case WITHER_SKULL:
// non moving / unmovable // non moving / unmovable
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP); return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED);
case ARMOR_STAND: case ARMOR_STAND:
case ITEM_FRAME: case ITEM_FRAME:
case PAINTING: case PAINTING:
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP); return EntityUtil.checkEntity(plot,
EntityCapFlag.ENTITY_CAP_UNLIMITED,
MiscCapFlag.MISC_CAP_UNLIMITED);
// misc // misc
case BOAT: case BOAT:
case MINECART: case MINECART:
@ -234,7 +288,9 @@ import java.util.regex.Pattern;
case MINECART_HOPPER: case MINECART_HOPPER:
case MINECART_MOB_SPAWNER: case MINECART_MOB_SPAWNER:
case MINECART_TNT: case MINECART_TNT:
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP); return EntityUtil.checkEntity(plot,
EntityCapFlag.ENTITY_CAP_UNLIMITED,
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
case BAT: case BAT:
case CHICKEN: case CHICKEN:
case CAT: case CAT:
@ -267,8 +323,10 @@ import java.util.regex.Pattern;
case WOLF: case WOLF:
case ZOMBIE_HORSE: case ZOMBIE_HORSE:
// animal // animal
return EntityUtil return EntityUtil.checkEntity(plot,
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); EntityCapFlag.ENTITY_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED,
AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
case BLAZE: case BLAZE:
case CAVE_SPIDER: case CAVE_SPIDER:
case CREEPER: case CREEPER:
@ -303,26 +361,39 @@ import java.util.regex.Pattern;
case RAVAGER: case RAVAGER:
// monster // monster
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); .checkEntity(plot,
EntityCapFlag.ENTITY_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED,
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
default: default:
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
if (entity instanceof Animals || entity instanceof WaterMob) { if (entity instanceof Animals || entity instanceof WaterMob) {
return EntityUtil return EntityUtil.checkEntity(plot,
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); EntityCapFlag.ENTITY_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED,
AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
} else if (entity instanceof Monster) { } else if (entity instanceof Monster) {
return EntityUtil return EntityUtil.checkEntity(plot,
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); EntityCapFlag.ENTITY_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED,
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
} else { } else {
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP); return EntityUtil.checkEntity(plot,
EntityCapFlag.ENTITY_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED);
} }
} }
if (entity instanceof Vehicle) { if (entity instanceof Vehicle) {
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP); return EntityUtil.checkEntity(plot,
EntityCapFlag.ENTITY_CAP_UNLIMITED,
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
} }
if (entity instanceof Hanging) { if (entity instanceof Hanging) {
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP); return EntityUtil.checkEntity(plot,
EntityCapFlag.ENTITY_CAP_UNLIMITED,
MiscCapFlag.MISC_CAP_UNLIMITED);
} }
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP); return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED);
} }
} }
@ -409,7 +480,7 @@ import java.util.regex.Pattern;
if (plot == null) { if (plot == null) {
return; return;
} }
if (Flags.REDSTONE.isFalse(plot)) { if (!plot.getFlag(RedstoneFlag.class)) {
event.setNewCurrent(0); event.setNewCurrent(0);
return; return;
} }
@ -463,7 +534,7 @@ import java.util.regex.Pattern;
if (plot == null) { if (plot == null) {
return; return;
} }
if (Flags.REDSTONE.isFalse(plot)) { if (!plot.getFlag(RedstoneFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
@ -485,7 +556,7 @@ import java.util.regex.Pattern;
if (plot == null) { if (plot == null) {
return; return;
} }
if (Flags.DISABLE_PHYSICS.isFalse(plot)) { if (plot.getFlag(DisablePhysicsFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
@ -631,10 +702,10 @@ import java.util.regex.Pattern;
if (plot == null) { if (plot == null) {
return; return;
} }
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
if (flag.isPresent() && !Permissions List<String> blockedCommands = plot.getFlag(BlockedCmdsFlag.class);
if (!blockedCommands.isEmpty() && !Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
List<String> blockedCommands = flag.get();
String part = parts[0]; String part = parts[0];
if (parts[0].contains(":")) { if (parts[0].contains(":")) {
part = parts[0].split(":")[1]; part = parts[0].split(":")[1];
@ -771,12 +842,12 @@ import java.util.regex.Pattern;
} }
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot != null) { if (plot != null) {
final boolean result = Flags.DENY_TELEPORT.allowsTeleport(pp, plot); final boolean result = DenyTeleportFlag.allowsTeleport(pp, plot);
// there is one possibility to still allow teleportation: // there is one possibility to still allow teleportation:
// to is identical to the plot's home location, and untrusted-visit is true // to is identical to the plot's home location, and untrusted-visit is true
// i.e. untrusted-visit can override deny-teleport // i.e. untrusted-visit can override deny-teleport
// this is acceptable, because otherwise it wouldn't make sense to have both flags set // this is acceptable, because otherwise it wouldn't make sense to have both flags set
if (!result && !(Flags.UNTRUSTED_VISIT.isTrue(plot) && plot.getHome().equals(BukkitUtil.getLocationFull(to)))) { if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHome().equals(BukkitUtil.getLocationFull(to)))) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_ENTRY_DENIED); Captions.PERMISSION_ADMIN_ENTRY_DENIED);
event.setCancelled(true); event.setCancelled(true);
@ -1078,11 +1149,13 @@ import java.util.regex.Pattern;
return; return;
} }
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK); List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
.contains(BukkitAdapter.asBlockType(block.getType()))) { for (final BlockTypeWrapper blockTypeWrapper : destroy) {
return; if (blockTypeWrapper.accepts(blockType)) {
return;
}
} }
if (Permissions if (Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
@ -1091,7 +1164,7 @@ import java.util.regex.Pattern;
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_DESTROY_OTHER); Captions.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -1129,7 +1202,7 @@ import java.util.regex.Pattern;
} }
Plot plot = area.getOwnedPlot(location); Plot plot = area.getOwnedPlot(location);
if (plot != null) { if (plot != null) {
if (Flags.EXPLOSION.isTrue(plot)) { if (plot.getFlag(ExplosionFlag.class)) {
List<MetadataValue> meta = event.getEntity().getMetadata("plot"); List<MetadataValue> meta = event.getEntity().getMetadata("plot");
Plot origin; Plot origin;
if (meta.isEmpty()) { if (meta.isEmpty()) {
@ -1204,7 +1277,7 @@ import java.util.regex.Pattern;
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area != null) { if (area != null) {
Plot plot = area.getOwnedPlot(location); Plot plot = area.getOwnedPlot(location);
if (plot != null && Flags.MOB_BREAK.isTrue(plot)) { if (plot != null && plot.getFlag(MobPlaceFlag.class)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -1233,7 +1306,7 @@ import java.util.regex.Pattern;
Player player = (Player) entity; Player player = (Player) entity;
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (Flags.ICE_FORM.isTrue(plot)) { if (plot.getFlag(IceFormFlag.class)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -1241,7 +1314,7 @@ import java.util.regex.Pattern;
} }
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
if (Flags.ICE_FORM.isTrue(plot)) { if (plot.getFlag(IceFormFlag.class)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -1249,7 +1322,7 @@ import java.util.regex.Pattern;
} }
return; return;
} }
if (!Flags.ICE_FORM.isTrue(plot)) { if (!plot.getFlag(IceFormFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -1272,22 +1345,22 @@ import java.util.regex.Pattern;
} }
switch (event.getSource().getType()) { switch (event.getSource().getType()) {
case GRASS: case GRASS:
if (Flags.GRASS_GROW.isFalse(plot)) { if (!plot.getFlag(GrassGrowFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case MYCELIUM: case MYCELIUM:
if (Flags.MYCEL_GROW.isFalse(plot)) { if (!plot.getFlag(MycelGrowFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case VINE: case VINE:
if (Flags.VINE_GROW.isFalse(plot)) { if (!plot.getFlag(VineGrowFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case KELP: case KELP:
if (Flags.KELP_GROW.isFalse(plot)) { if (!plot.getFlag(KelpGrowFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
@ -1313,14 +1386,14 @@ import java.util.regex.Pattern;
switch (event.getNewState().getType()) { switch (event.getNewState().getType()) {
case SNOW: case SNOW:
case SNOW_BLOCK: case SNOW_BLOCK:
if (Flags.SNOW_FORM.isFalse(plot)) { if (!plot.getFlag(SnowFormFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
case ICE: case ICE:
case FROSTED_ICE: case FROSTED_ICE:
case PACKED_ICE: case PACKED_ICE:
if (Flags.ICE_FORM.isFalse(plot)) { if (!plot.getFlag(IceFormFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -1351,10 +1424,9 @@ import java.util.regex.Pattern;
} }
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK); List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType()))) || Permissions
.contains(BukkitAdapter.asBlockType(block.getType())) || Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
@ -1385,17 +1457,17 @@ import java.util.regex.Pattern;
} }
switch (block.getType()) { switch (block.getType()) {
case ICE: case ICE:
if (Flags.ICE_MELT.isFalse(plot)) { if (!plot.getFlag(IceMeltFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case SNOW: case SNOW:
if (Flags.SNOW_MELT.isFalse(plot)) { if (!plot.getFlag(SnowMeltFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case FARMLAND: case FARMLAND:
if (Flags.SOIL_DRY.isFalse(plot)) { if (!plot.getFlag(SoilDryFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
@ -1414,7 +1486,7 @@ import java.util.regex.Pattern;
Plot plot = area.getOwnedPlot(tLocation); Plot plot = area.getOwnedPlot(tLocation);
Location fLocation = BukkitUtil.getLocation(from.getLocation()); Location fLocation = BukkitUtil.getLocation(from.getLocation());
if (plot != null) { if (plot != null) {
if (Flags.DISABLE_PHYSICS.isFalse(plot)) { if (plot.getFlag(DisablePhysicsFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
@ -1422,7 +1494,7 @@ import java.util.regex.Pattern;
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (Flags.LIQUID_FLOW.isFalse(plot)) { if (!plot.getFlag(LiquidFlowFlag.class)) {
switch (to.getType()) { switch (to.getType()) {
case WATER: case WATER:
case LAVA: case LAVA:
@ -1816,7 +1888,7 @@ import java.util.regex.Pattern;
e.setCancelled(true); e.setCancelled(true);
} }
} else { } else {
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true); e.setCancelled(true);
@ -1834,7 +1906,7 @@ import java.util.regex.Pattern;
if (plot.isAdded(uuid)) { if (plot.isAdded(uuid)) {
return; return;
} }
if (Flags.MISC_INTERACT.isTrue(plot)) { if (plot.getFlag(MiscInteractFlag.class)) {
return; return;
} }
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
@ -1866,7 +1938,7 @@ import java.util.regex.Pattern;
return; return;
} }
Plot plot = area.getOwnedPlot(location); Plot plot = area.getOwnedPlot(location);
if (plot == null || !plot.getFlag(Flags.EXPLOSION).orElse(false)) { if (plot == null || !plot.getFlag(ExplosionFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
event.blockList().removeIf( event.blockList().removeIf(
@ -2119,7 +2191,7 @@ import java.util.regex.Pattern;
return; return;
} }
Plot plot = area.getOwnedPlotAbs(location); Plot plot = area.getOwnedPlotAbs(location);
if (plot == null || plot.getFlag(Flags.DISABLE_PHYSICS, false)) { if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -2155,7 +2227,7 @@ import java.util.regex.Pattern;
} }
Plot plot = location.getOwnedPlot(); Plot plot = location.getOwnedPlot();
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN, false)) { if (plot == null || !plot.getFlag(BlockBurnFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -2198,7 +2270,7 @@ import java.util.regex.Pattern;
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
} else if (Flags.BLOCK_IGNITION.isFalse(plot)) { } else if (!plot.getFlag(BlockIgnitionFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
} else { } else {
@ -2207,7 +2279,7 @@ import java.util.regex.Pattern;
return; return;
} }
if (ignitingEntity != null) { if (ignitingEntity != null) {
if (!plot.getFlag(Flags.BLOCK_IGNITION, false)) { if (!plot.getFlag(BlockIgnitionFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -2233,11 +2305,11 @@ import java.util.regex.Pattern;
Block ignitingBlock = event.getIgnitingBlock(); Block ignitingBlock = event.getIgnitingBlock();
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot(); Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && ( if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
!plot.getFlag(Flags.BLOCK_IGNITION, false) || plotIgnited == null !plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null
|| !plotIgnited.equals(plot)) || || !plotIgnited.equals(plot)) ||
(igniteCause == BlockIgniteEvent.IgniteCause.SPREAD (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && ( || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
!plot.getFlag(Flags.BLOCK_IGNITION).orElse(false) || plotIgnited == null !plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null
|| !plotIgnited.equals(plot))) { || !plotIgnited.equals(plot))) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -2273,8 +2345,12 @@ import java.util.regex.Pattern;
Captions.PERMISSION_ADMIN_BUILD_UNOWNED); Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
if (Flags.USE.contains(plot, BukkitAdapter.asItemType(block.getType()))) { List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
return; final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
for (final BlockTypeWrapper blockTypeWrapper : use) {
if (blockTypeWrapper.accepts(blockType)) {
return;
}
} }
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
@ -2282,7 +2358,7 @@ import java.util.regex.Pattern;
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -2333,10 +2409,13 @@ import java.util.regex.Pattern;
Captions.PERMISSION_ADMIN_BUILD_UNOWNED); Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<Set<BlockType>> use = plot.getFlag(Flags.USE); List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
if (use.isPresent() && use.get().contains(BukkitAdapter.asBlockType(block.getType()))) { final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
return; for (final BlockTypeWrapper blockTypeWrapper : use) {
if (blockTypeWrapper.accepts(blockType)) {
return;
}
} }
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
@ -2344,7 +2423,7 @@ import java.util.regex.Pattern;
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -2404,7 +2483,7 @@ import java.util.regex.Pattern;
return; return;
} }
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(pp.getUUID())) {
if (!plot.getFlag(Flags.HANGING_PLACE, false)) { if (!plot.getFlag(HangingPlaceFlag.class)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -2445,7 +2524,7 @@ import java.util.regex.Pattern;
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
if (plot.getFlag(Flags.HANGING_BREAK, false)) { if (plot.getFlag(HangingBreakFlag.class)) {
return; return;
} }
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
@ -2474,7 +2553,7 @@ import java.util.regex.Pattern;
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.isAdded(player.getUUID())) { } else if (!plot.isAdded(player.getUUID())) {
if (!plot.getFlag(Flags.HANGING_BREAK, false)) { if (!plot.getFlag(HangingBreakFlag.class)) {
if (!Permissions if (!Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(player, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT,
@ -2514,26 +2593,26 @@ import java.util.regex.Pattern;
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
Entity entity = event.getRightClicked(); Entity entity = event.getRightClicked();
if (entity instanceof Monster && plot.getFlag(Flags.HOSTILE_INTERACT, false)) { if (entity instanceof Monster && plot.getFlag(HostileInteractFlag.class)) {
return; return;
} }
if (entity instanceof Animals && plot.getFlag(Flags.ANIMAL_INTERACT, false)) { if (entity instanceof Animals && plot.getFlag(AnimalInteractFlag.class)) {
return; return;
} }
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot.getFlag(
.getFlag(Flags.TAMED_INTERACT, false)) { TamedInteractFlag.class)) {
return; return;
} }
if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE, false)) { if (entity instanceof Vehicle && plot.getFlag(VehicleUseFlag.class)) {
return; return;
} }
if (entity instanceof Player && plot.getFlag(Flags.PLAYER_INTERACT, false)) { if (entity instanceof Player && plot.getFlag(PlayerInteractFlag.class)) {
return; return;
} }
if (entity instanceof Villager && plot.getFlag(Flags.VILLAGER_INTERACT, false)) { if (entity instanceof Villager && plot.getFlag(VillagerInteractFlag.class)) {
return; return;
} }
if (entity instanceof ItemFrame && plot.getFlag(Flags.MISC_INTERACT, false)) { if (entity instanceof ItemFrame && plot.getFlag(MiscInteractFlag.class)) {
return; return;
} }
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
@ -2573,7 +2652,7 @@ import java.util.regex.Pattern;
return; return;
} }
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(pp.getUUID())) {
if (plot.getFlag(Flags.VEHICLE_BREAK, false)) { if (plot.getFlag(VehicleBreakFlag.class)) {
return; return;
} }
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
@ -2739,9 +2818,9 @@ import java.util.regex.Pattern;
if (player != null) { if (player != null) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (victim instanceof Hanging) { // hanging if (victim instanceof Hanging) { // hanging
if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
.isAdded(plotPlayer.getUUID()))) { .isAdded(plotPlayer.getUUID())) {
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
return false; return false;
@ -2755,7 +2834,7 @@ import java.util.regex.Pattern;
return false; return false;
} }
} else if (victim.getType() == EntityType.ARMOR_STAND) { } else if (victim.getType() == EntityType.ARMOR_STAND) {
if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot if (plot != null && (plot.getFlag(MiscBreakFlag.class) || plot
.isAdded(plotPlayer.getUUID()))) { .isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
@ -2766,8 +2845,8 @@ import java.util.regex.Pattern;
} }
} else if (victim instanceof Monster } else if (victim instanceof Monster
|| victim instanceof EnderDragon) { // victim is monster || victim instanceof EnderDragon) { // victim is monster
if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot if (plot != null && (plot.getFlag(HostileAttackFlag.class) || plot.getFlag(PveFlag.class) ||
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) { plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
@ -2776,8 +2855,8 @@ import java.util.regex.Pattern;
return false; return false;
} }
} else if (victim instanceof Tameable) { // victim is tameable } else if (victim instanceof Tameable) { // victim is tameable
if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot if (plot != null && (plot.getFlag(TamedAttackFlag.class) || plot.getFlag(PveFlag.class) ||
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) { plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
@ -2787,7 +2866,7 @@ import java.util.regex.Pattern;
} }
} else if (victim instanceof Player) { } else if (victim instanceof Player) {
if (plot != null) { if (plot != null) {
if (Flags.PVP.isFalse(plot) && !Permissions if (!plot.getFlag(PvpFlag.class) && !Permissions
.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { .hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.pvp." + stub); "plots.admin.pvp." + stub);
@ -2802,8 +2881,8 @@ import java.util.regex.Pattern;
return false; return false;
} }
} else if (victim instanceof Creature) { // victim is animal } else if (victim instanceof Creature) { // victim is animal
if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class)
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) { || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
@ -2814,7 +2893,7 @@ import java.util.regex.Pattern;
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event } else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
return true; return true;
} else { // victim is something else } else { // victim is something else
if (plot != null && (plot.getFlag(Flags.PVE, false) || plot if (plot != null && (plot.getFlag(PveFlag.class) || plot
.isAdded(plotPlayer.getUUID()))) { .isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
@ -2827,7 +2906,7 @@ import java.util.regex.Pattern;
return true; return true;
} else if (dplot != null && (!dplot.equals(vplot) || Objects } else if (dplot != null && (!dplot.equals(vplot) || Objects
.equals(dplot.guessOwner(), vplot.guessOwner()))) { .equals(dplot.guessOwner(), vplot.guessOwner()))) {
return vplot != null && Flags.PVE.isTrue(vplot); return vplot != null && vplot.getFlag(PveFlag.class);
} }
//disable the firework damage. too much of a headache to support at the moment. //disable the firework damage. too much of a headache to support at the moment.
if (vplot != null) { if (vplot != null) {
@ -2836,7 +2915,7 @@ import java.util.regex.Pattern;
return false; return false;
} }
} }
return ((vplot != null && Flags.PVE.isTrue(vplot)) || !(damager instanceof Arrow return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
&& !(victim instanceof Creature))); && !(victim instanceof Creature)));
} }
@ -2896,10 +2975,10 @@ import java.util.regex.Pattern;
return; return;
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
Set<BlockType> place = plot.getFlag(Flags.PLACE, null); List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
if (place != null) { if (place != null) {
Block block = event.getBlock(); Block block = event.getBlock();
if (place.contains(BukkitAdapter.asBlockType(block.getType()))) { if (place.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
return; return;
} }
} }
@ -2909,7 +2988,7 @@ import java.util.regex.Pattern;
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER); Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -2917,7 +2996,7 @@ import java.util.regex.Pattern;
return; return;
} }
} }
if (plot.getFlag(Flags.DISABLE_PHYSICS, false)) { if (plot.getFlag(DisablePhysicsFlag.class)) {
Block block = event.getBlockPlaced(); Block block = event.getBlockPlaced();
if (block.getType().hasGravity()) { if (block.getType().hasGravity()) {
sendBlockChange(block.getLocation(), block.getBlockData()); sendBlockChange(block.getLocation(), block.getBlockData());

View File

@ -3,8 +3,13 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent; import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent; import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DropProtectionFlag;
import com.github.intellectualsites.plotsquared.plot.flag.IntervalFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.FeedFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HealFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.InstabreakFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.InvincibleFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ItemDropFlag;
import com.github.intellectualsites.plotsquared.plot.flags.types.TimedFlag;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -28,7 +33,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener { @SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener {
@ -90,7 +94,7 @@ import java.util.UUID;
if (plot == null) { if (plot == null) {
return; return;
} }
if (Flags.INSTABREAK.isTrue(plot)) { if (plot.getFlag(InstabreakFlag.class)) {
Block block = event.getBlock(); Block block = event.getBlock();
BlockBreakEvent call = new BlockBreakEvent(block, player); BlockBreakEvent call = new BlockBreakEvent(block, player);
Bukkit.getServer().getPluginManager().callEvent(call); Bukkit.getServer().getPluginManager().callEvent(call);
@ -108,7 +112,7 @@ import java.util.UUID;
if (plot == null) { if (plot == null) {
return; return;
} }
if (Flags.INVINCIBLE.isTrue(plot)) { if (plot.getFlag(InvincibleFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -122,7 +126,7 @@ import java.util.UUID;
} }
UUID uuid = pp.getUUID(); UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) { if (!plot.isAdded(uuid)) {
if (Flags.ITEM_DROP.isFalse(plot)) { if (!plot.getFlag(ItemDropFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -131,12 +135,14 @@ import java.util.UUID;
@EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) { @EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
Optional<IntervalFlag.Interval> feed = plot.getFlag(Flags.FEED); TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
feed.ifPresent(value -> feedRunnable if (feed.getInterval() != 0 && feed.getValue() != 0) {
.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20))); feedRunnable.put(player.getUniqueId(), new Interval(feed.getInterval(), feed.getValue(), 20));
Optional<IntervalFlag.Interval> heal = plot.getFlag(Flags.HEAL); }
heal.ifPresent(value -> healRunnable TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20))); if (heal.getInterval() != 0 && heal.getValue() != 0) {
healRunnable.put(player.getUniqueId(), new Interval(heal.getInterval(), heal.getValue(), 20));
}
} }
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) { @EventHandler public void onPlayerQuit(PlayerQuitEvent event) {
@ -166,7 +172,7 @@ import java.util.UUID;
return; return;
} }
UUID uuid = pp.getUUID(); UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) { if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -18,7 +18,7 @@ import com.github.intellectualsites.plotsquared.bukkit.events.PlotMergeEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotRateEvent; import com.github.intellectualsites.plotsquared.bukkit.events.PlotRateEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotUnlinkEvent; import com.github.intellectualsites.plotsquared.bukkit.events.PlotUnlinkEvent;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -75,11 +75,11 @@ public final class BukkitEventUtil extends EventUtil {
return callEvent(new PlotDeleteEvent(plot)); return callEvent(new PlotDeleteEvent(plot));
} }
@Override public boolean callFlagAdd(Flag flag, Plot plot) { @Override public boolean callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
return callEvent(new PlotFlagAddEvent(flag, plot)); return callEvent(new PlotFlagAddEvent(flag, plot));
} }
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) { @Override public boolean callFlagRemove(PlotFlag<?, ?> flag, Plot plot, Object value) {
return callEvent(new PlotFlagRemoveEvent(flag, plot)); return callEvent(new PlotFlagRemoveEvent(flag, plot));
} }

View File

@ -15,6 +15,7 @@ dependencies {
annotationProcessor("org.projectlombok:lombok:1.18.8") annotationProcessor("org.projectlombok:lombok:1.18.8")
testAnnotationProcessor("org.projectlombok:lombok:1.18.8") testAnnotationProcessor("org.projectlombok:lombok:1.18.8")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.61") implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.61")
implementation("org.jetbrains:annotations:18.0.0")
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8

View File

@ -2,9 +2,8 @@ package com.github.intellectualsites.plotsquared.api;
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration; import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Caption;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -164,19 +163,10 @@ import java.util.UUID;
* @see #sendConsoleMessage(String) * @see #sendConsoleMessage(String)
* @see Captions * @see Captions
*/ */
public void sendConsoleMessage(Captions caption) { public void sendConsoleMessage(Caption caption) {
sendConsoleMessage(caption.getTranslated()); sendConsoleMessage(caption.getTranslated());
} }
/**
* Registers a flag for use in plots.
*
* @param flag the flag to register
*/
public void addFlag(Flag<?> flag) {
Flags.registerFlag(flag);
}
/** /**
* Gets the PlotSquared class. * Gets the PlotSquared class.
* *

View File

@ -81,7 +81,8 @@ public abstract class Command {
&& types[2] == String[].class && types[3] == RunnableVal3.class && types[2] == String[].class && types[3] == RunnableVal3.class
&& types[4] == RunnableVal2.class) { && types[4] == RunnableVal2.class) {
Command tmp = new Command(this, true) { Command tmp = new Command(this, 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) {
try { try {
@ -264,14 +265,13 @@ public abstract class Command {
if (totalPages != 0) { // Back if (totalPages != 0) { // Back
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ") new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ")
.color("$3").text("->").color("$3").text(Captions.CLICKABLE.getTranslated()) .color("$3").text("->").color("$3").text(Captions.CLICKABLE.getTranslated())
.color("$2") .color("$2").send(player);
.send(player);
} }
} }
/** /**
* @param player Caller * @param player Caller
* @param args Arguments * @param args Arguments
* @param confirm Instance, Success, Failure * @param confirm Instance, Success, Failure
* @return CompletableFuture true if the command executed fully, false in * @return CompletableFuture true if the command executed fully, false in
* any other case * any other case

View File

@ -186,7 +186,7 @@ public class JSONObject {
* @param object An object that has fields that should be used to make a JSONObject. * @param object An object that has fields that should be used to make a JSONObject.
* @param names An array of strings, the names of the fields to be obtained from the object. * @param names An array of strings, the names of the fields to be obtained from the object.
*/ */
public JSONObject(Object object, String names[]) { public JSONObject(Object object, String[] names) {
this(); this();
Class c = object.getClass(); Class c = object.getClass();
for (String name : names) { for (String name : names) {

View File

@ -5,6 +5,8 @@ import com.github.intellectualsites.plotsquared.configuration.MemorySection;
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration; import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerialization; import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerialization;
import com.github.intellectualsites.plotsquared.plot.commands.WE_Anywhere; import com.github.intellectualsites.plotsquared.plot.commands.WE_Anywhere;
import com.github.intellectualsites.plotsquared.plot.config.Caption;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
@ -151,7 +153,7 @@ import java.util.zip.ZipInputStream;
// //
// Register configuration serializable classes // Register configuration serializable classes
// //
// ConfigurationSerialization.registerClass(BlockState.class, "BlockState"); // ConfigurationSerialization.registerClass(BlockState.class, "BlockState");
ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket"); ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket");
try { try {
@ -193,6 +195,17 @@ import java.util.zip.ZipInputStream;
if (Settings.Enabled_Components.DATABASE) { if (Settings.Enabled_Components.DATABASE) {
setupDatabase(); setupDatabase();
} }
// Check if we need to convert old flag values, etc
if (!getConfigurationVersion().equalsIgnoreCase("v5")) {
// Perform upgrade
if (DBFunc.dbManager.convertFlags()) {
log(Captions.PREFIX.getTranslated() + "Flags were converted successfully!");
// Update the config version
setConfigurationVersion("v5");
}
}
// Comments // Comments
CommentManager.registerDefaultInboxes(); CommentManager.registerDefaultInboxes();
// Kill entities // Kill entities
@ -243,7 +256,8 @@ import java.util.zip.ZipInputStream;
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) { if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
try { try {
if (this.IMP.initWorldEdit()) { if (this.IMP.initWorldEdit()) {
PlotSquared.log(Captions.PREFIX + "&6" + IMP.getPluginName() + " hooked into WorldEdit."); PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + IMP.getPluginName()
+ " hooked into WorldEdit.");
this.worldedit = WorldEdit.getInstance(); this.worldedit = WorldEdit.getInstance();
WorldEdit.getInstance().getEventBus().register(new WESubscriber()); WorldEdit.getInstance().getEventBus().register(new WESubscriber());
if (Settings.Enabled_Components.COMMANDS) { if (Settings.Enabled_Components.COMMANDS) {
@ -280,7 +294,7 @@ import java.util.zip.ZipInputStream;
} }
if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) { if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
debug("`" + world + "` was not properly loaded - " + IMP.getPluginName() debug("`" + world + "` was not properly loaded - " + IMP.getPluginName()
+ " will now try to load it properly: "); + " will now try to load it properly: ");
debug( debug(
" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml"); " - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
debug( debug(
@ -316,7 +330,7 @@ import java.util.zip.ZipInputStream;
e.printStackTrace(); e.printStackTrace();
} }
PlotSquared.log(Captions.PREFIX + Captions PlotSquared.log(Captions.PREFIX + CaptionUtility
.format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(), IMP.getPluginName())); .format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(), IMP.getPluginName()));
} }
@ -343,7 +357,9 @@ import java.util.zip.ZipInputStream;
* @see IPlotMain#log(String) * @see IPlotMain#log(String)
*/ */
public static void log(Object message) { public static void log(Object message) {
if (message == null || message.toString().isEmpty()) { if (message == null || (message instanceof Caption ?
((Caption) message).getTranslated().isEmpty() :
message.toString().isEmpty())) {
return; return;
} }
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) { if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
@ -1644,9 +1660,9 @@ import java.util.zip.ZipInputStream;
this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile); this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile);
if (this.worlds.contains("worlds")) { if (this.worlds.contains("worlds")) {
if (!this.worlds.contains("configuration_version") || !this.worlds if (!this.worlds.contains("configuration_version") ||
.getString("configuration_version") (!this.worlds.getString("configuration_version").equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION) &&
.equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION)) { !this.worlds.getString("configuration_version").equalsIgnoreCase("v5"))) {
// Conversion needed // Conversion needed
log(Captions.LEGACY_CONFIG_FOUND.getTranslated()); log(Captions.LEGACY_CONFIG_FOUND.getTranslated());
try { try {
@ -1657,10 +1673,8 @@ import java.util.zip.ZipInputStream;
this.worlds.getConfigurationSection("worlds"); this.worlds.getConfigurationSection("worlds");
final LegacyConverter converter = new LegacyConverter(worlds); final LegacyConverter converter = new LegacyConverter(worlds);
converter.convert(); converter.convert();
this.worlds this.worlds.set("worlds", worlds);
.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION); this.setConfigurationVersion(LegacyConverter.CONFIGURATION_VERSION);
this.worlds.set("worlds", worlds); // Redundant, but hey... ¯\_()_/¯
this.worlds.save(this.worldsFile);
log(Captions.LEGACY_CONFIG_DONE.getTranslated()); log(Captions.LEGACY_CONFIG_DONE.getTranslated());
} catch (final Exception e) { } catch (final Exception e) {
log(Captions.LEGACY_CONFIG_CONVERSION_FAILED.getTranslated()); log(Captions.LEGACY_CONFIG_CONVERSION_FAILED.getTranslated());
@ -1736,6 +1750,15 @@ import java.util.zip.ZipInputStream;
return true; return true;
} }
public String getConfigurationVersion() {
return this.worlds.get("configuration_version", LegacyConverter.CONFIGURATION_VERSION).toString();
}
public void setConfigurationVersion(final String newVersion) throws IOException {
this.worlds.set("configuration_version", newVersion);
this.worlds.save(this.worldsFile);
}
/** /**
* Setup the storage file (load + save missing nodes). * Setup the storage file (load + save missing nodes).
*/ */
@ -1766,7 +1789,8 @@ import java.util.zip.ZipInputStream;
if (this.version != null) { if (this.version != null) {
this.style.set("Version", this.version.toString()); this.style.set("Version", this.version.toString());
} }
this.style.set("Information", "Left Row: PlotSquared color codes ($), right row: Minecraft color codes (&)"); this.style.set("Information",
"Left Row: PlotSquared color codes ($), right row: Minecraft color codes (&)");
Map<String, Object> object = new HashMap<>(16); Map<String, Object> object = new HashMap<>(16);
object.put("color.1", "6"); object.put("color.1", "6");
object.put("color.2", "7"); object.put("color.2", "7");

View File

@ -19,8 +19,11 @@ import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "add", @CommandDeclaration(command = "add",
description = "Allow a user to build in a plot while the plot owner is online.", description = "Allow a user to build in a plot while the plot owner is online.",
usage = "/plot add <player|*>", category = CommandCategory.SETTINGS, permission = "plots.add", usage = "/plot add <player|*>",
requiredType = RequiredType.PLAYER) public class Add extends Command { category = CommandCategory.SETTINGS,
permission = "plots.add",
requiredType = RequiredType.PLAYER)
public class Add extends Command {
public Add() { public Add() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -12,11 +12,14 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
@CommandDeclaration(command = "setalias", permission = "plots.alias", @CommandDeclaration(command = "setalias",
description = "Set the plot name", usage = "/plot alias <set|remove> <alias>", permission = "plots.alias",
description = "Set the plot name",
usage = "/plot alias <set|remove> <alias>",
aliases = {"alias", "sa", "name", "rename", "setname", "seta", "nameplot"}, aliases = {"alias", "sa", "name", "rename", "setname", "seta", "nameplot"},
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Alias category = CommandCategory.SETTINGS,
extends SubCommand { requiredType = RequiredType.PLAYER)
public class Alias extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {

View File

@ -33,11 +33,15 @@ import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "area", permission = "plots.area", @CommandDeclaration(command = "area",
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, permission = "plots.area",
description = "Create a new PlotArea", aliases = "world", category = CommandCategory.ADMINISTRATION,
usage = "/plot area <create|info|list|tp|regen>", confirmation = true) public class Area requiredType = RequiredType.NONE,
extends SubCommand { description = "Create a new PlotArea",
aliases = "world",
usage = "/plot area <create|info|list|tp|regen>",
confirmation = true)
public class Area extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
@ -135,14 +139,14 @@ import java.util.Set;
if (WorldUtil.IMP.isWorld(world)) { if (WorldUtil.IMP.isWorld(world)) {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
Captions.SETUP_FINISHED.send(player); Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(world),
TeleportCause.COMMAND);
if (area.TERRAIN != 3) { if (area.TERRAIN != 3) {
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 AugmentedUtils.generate(world, value.getX(),
.generate(world, value.getX(), value.getZ(), value.getZ(), null);
null);
} }
}, null); }, null);
} }
@ -258,7 +262,8 @@ import java.util.Set;
String world = SetupUtils.manager.setupWorld(object); String world = SetupUtils.manager.setupWorld(object);
if (WorldUtil.IMP.isWorld(world)) { if (WorldUtil.IMP.isWorld(world)) {
Captions.SETUP_FINISHED.send(player); Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(world),
TeleportCause.COMMAND);
} else { } else {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"An error occurred while creating the world: " "An error occurred while creating the world: "
@ -285,13 +290,15 @@ import java.util.Set;
} }
if (WorldUtil.IMP.isWorld(pa.worldname)) { if (WorldUtil.IMP.isWorld(pa.worldname)) {
if (!player.getLocation().getWorld().equals(pa.worldname)) { if (!player.getLocation().getWorld().equals(pa.worldname)) {
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(pa.worldname),
TeleportCause.COMMAND);
} }
} else { } else {
object.terrain = 0; object.terrain = 0;
object.type = 0; object.type = 0;
SetupUtils.manager.setupWorld(object); SetupUtils.manager.setupWorld(object);
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(pa.worldname),
TeleportCause.COMMAND);
} }
player.setMeta("area_create_area", pa); player.setMeta("area_create_area", pa);
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
@ -432,10 +439,11 @@ import java.util.Set;
"$4Stop the server and delete: " + area.worldname + "/region"); "$4Stop the server and delete: " + area.worldname + "/region");
return false; return false;
} }
ChunkManager ChunkManager.largeRegionTask(area.worldname, area.getRegion(),
.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils.generate(area.worldname, value.getX(), value.getZ(), null); AugmentedUtils
.generate(area.worldname, value.getX(), value.getZ(), null);
} }
}, () -> player.sendMessage("Regen complete")); }, () -> player.sendMessage("Regen complete"));
return true; return true;
@ -463,9 +471,10 @@ import java.util.Set;
center = WorldUtil.IMP.getSpawn(area.worldname); center = WorldUtil.IMP.getSpawn(area.worldname);
} else { } else {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
center = center = new Location(area.worldname, region.getMinimumPoint().getX()
new Location(area.worldname, region.getMinimumPoint().getX() + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.getMinimumPoint().getZ() + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2); 0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
center.setY(1 + WorldUtil.IMP center.setY(1 + WorldUtil.IMP
.getHighestBlock(area.worldname, center.getX(), center.getZ())); .getHighestBlock(area.worldname, center.getX(), center.getZ()));
} }

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
@ -22,9 +23,13 @@ import org.jetbrains.annotations.Nullable;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "auto", permission = "plots.auto", @CommandDeclaration(command = "auto",
category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, permission = "plots.auto",
description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]") category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
description = "Claim the nearest plot",
aliases = "a",
usage = "/plot auto [length,width]")
public class Auto extends SubCommand { public class Auto extends SubCommand {
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) { @Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
@ -176,7 +181,7 @@ public class Auto extends SubCommand {
try { try {
String[] split = args[0].split(",|;"); String[] split = args[0].split(",|;");
if (split[1] == null) { if (split[1] == null) {
MainUtil.sendMessage(player,"Correct use /plot auto [length,width]"); MainUtil.sendMessage(player, "Correct use /plot auto [length,width]");
size_x = 1; size_x = 1;
size_z = 1; size_z = 1;
} else { } else {
@ -219,12 +224,13 @@ public class Auto extends SubCommand {
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic); sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true; return true;
} }
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player, CaptionUtility
Captions.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) .format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
Captions.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)); .format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(),
schematic));
return true; return true;
} }
} }

View File

@ -9,16 +9,21 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
@CommandDeclaration(command = "setbiome", permission = "plots.set.biome", @CommandDeclaration(command = "setbiome",
description = "Set the plot biome", usage = "/plot biome [biome]", permission = "plots.set.biome",
aliases = {"biome", "sb", "setb", "b"}, category = CommandCategory.APPEARANCE, description = "Set the plot biome",
requiredType = RequiredType.NONE) public class Biome extends SetCommand { usage = "/plot biome [biome]",
aliases = {"biome", "sb", "setb", "b"},
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.NONE)
public class Biome extends SetCommand {
@Override public boolean set(final PlotPlayer player, final Plot plot, final String value) { @Override public boolean set(final PlotPlayer player, final Plot plot, final String value) {
BiomeType biome = null; BiomeType biome = null;
try { try {
biome = BiomeTypes.get(value.toLowerCase()); biome = BiomeTypes.get(value.toLowerCase());
} catch (final Exception ignore) {} } catch (final Exception ignore) {
}
if (biome == null) { if (biome == null) {
String biomes = StringMan String biomes = StringMan
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated()); .join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
@ -12,13 +12,16 @@ import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "buy", description = "Buy the plot you are standing on", @CommandDeclaration(command = "buy",
usage = "/plot buy", permission = "plots.buy", category = CommandCategory.CLAIMING, description = "Buy the plot you are standing on",
requiredType = RequiredType.NONE) public class Buy extends Command { usage = "/plot buy",
permission = "plots.buy",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE)
public class Buy extends Command {
public Buy() { public Buy() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
@ -41,11 +44,10 @@ import java.util.concurrent.CompletableFuture;
Set<Plot> plots = plot.getConnectedPlots(); Set<Plot> plots = plot.getConnectedPlots();
checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(),
Captions.CANT_CLAIM_MORE_PLOTS); Captions.CANT_CLAIM_MORE_PLOTS);
Optional<Double> flag = plot.getFlag(Flags.PRICE); double price = plot.getFlag(PriceFlag.class);
if (!flag.isPresent()) { if (price <= 0) {
throw new CommandException(Captions.NOT_FOR_SALE); throw new CommandException(Captions.NOT_FOR_SALE);
} }
final double price = flag.get();
checkTrue(player.getMoney() >= price, Captions.CANNOT_AFFORD_PLOT); checkTrue(player.getMoney() >= price, Captions.CANNOT_AFFORD_PLOT);
player.withdraw(price); player.withdraw(price);
// Failure // Failure
@ -58,7 +60,7 @@ import java.util.concurrent.CompletableFuture;
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);
} }
plot.removeFlag(Flags.PRICE); plot.removeFlag(PriceFlag.class);
plot.setOwner(player.getUUID()); plot.setOwner(player.getUUID());
Captions.CLAIMED.send(player); Captions.CLAIMED.send(player);
whenDone.run(Buy.this, CommandResult.SUCCESS); whenDone.run(Buy.this, CommandResult.SUCCESS);

View File

@ -3,9 +3,13 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "chat", description = "Toggle plot chat on or off", @CommandDeclaration(command = "chat",
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT, description = "Toggle plot chat on or off",
requiredType = RequiredType.PLAYER) public class Chat extends SubCommand { usage = "/plot chat [on|off]",
permission = "plots.chat",
category = CommandCategory.CHAT,
requiredType = RequiredType.PLAYER)
public class Chat extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null); MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);

View File

@ -1,6 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.commands; package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
@ -16,9 +17,13 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
@CommandDeclaration(command = "claim", aliases = "c", @CommandDeclaration(command = "claim",
description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, aliases = "c",
requiredType = RequiredType.PLAYER, permission = "plots.claim", usage = "/plot claim") description = "Claim the current plot you're standing on",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER,
permission = "plots.claim",
usage = "/plot claim")
public class Claim extends SubCommand { public class Claim extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
@ -37,8 +42,7 @@ public class Claim extends SubCommand {
int grants = 0; int grants = 0;
if (currentPlots >= player.getAllowedPlots()) { if (currentPlots >= player.getAllowedPlots()) {
if (player.hasPersistentMeta("grantedPlots")) { if (player.hasPersistentMeta("grantedPlots")) {
grants = grants = Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
if (grants <= 0) { if (grants <= 0) {
player.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS); return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
@ -57,9 +61,8 @@ public class Claim extends SubCommand {
return sendMessage(player, Captions.SCHEMATIC_INVALID, return sendMessage(player, Captions.SCHEMATIC_INVALID,
"non-existent: " + schematic); "non-existent: " + schematic);
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, Captions .format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic); return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic);
@ -85,8 +88,7 @@ public class Claim extends SubCommand {
if (grants == 1) { if (grants == 1) {
player.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
} else { } else {
player.setPersistentMeta("grantedPlots", player.setPersistentMeta("grantedPlots", Ints.toByteArray(grants - 1));
Ints.toByteArray(grants - 1));
} }
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
} }

View File

@ -4,8 +4,8 @@ import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
@ -16,9 +16,15 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "clear", description = "Clear the plot you stand on", requiredType = RequiredType.NONE, @CommandDeclaration(command = "clear",
permission = "plots.clear", category = CommandCategory.APPEARANCE, usage = "/plot clear", description = "Clear the plot you stand on",
aliases = "reset", confirmation = true) public class Clear extends Command { requiredType = RequiredType.NONE,
permission = "plots.clear",
category = CommandCategory.APPEARANCE,
usage = "/plot clear",
aliases = "reset",
confirmation = true)
public class Clear extends Command {
// Note: To clear a specific plot use /plot <plot> clear // Note: To clear a specific plot use /plot <plot> clear
// The syntax also works with any command: /plot <plot> <command> // The syntax also works with any command: /plot <plot> <command>
@ -36,7 +42,7 @@ import java.util.concurrent.CompletableFuture;
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CLEAR), .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CLEAR),
Captions.NO_PLOT_PERMS); Captions.NO_PLOT_PERMS);
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER); checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions checkTrue(!Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions
.hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE); .hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE);
confirm.run(this, () -> { confirm.run(this, () -> {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
@ -45,11 +51,11 @@ import java.util.concurrent.CompletableFuture;
GlobalBlockQueue.IMP.addEmptyTask(() -> { GlobalBlockQueue.IMP.addEmptyTask(() -> {
plot.removeRunning(); plot.removeRunning();
// If the state changes, then mark it as no longer done // If the state changes, then mark it as no longer done
if (plot.getFlag(Flags.DONE).isPresent()) { if (DoneFlag.isDone(plot)) {
FlagManager.removePlotFlag(plot, Flags.DONE); plot.removeFlag(DoneFlag.class);
} }
if (plot.getFlag(Flags.ANALYSIS).isPresent()) { if (!plot.getFlag(AnalysisFlag.class).isEmpty()) {
FlagManager.removePlotFlag(plot, Flags.ANALYSIS); plot.removeFlag(AnalysisFlag.class);
} }
MainUtil.sendMessage(player, Captions.CLEARING_DONE, MainUtil.sendMessage(player, Captions.CLEARING_DONE,
"" + (System.currentTimeMillis() - start)); "" + (System.currentTimeMillis() - start));

View File

@ -22,10 +22,13 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "cluster", aliases = "clusters", @CommandDeclaration(command = "cluster",
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, aliases = "clusters",
permission = "plots.cluster", description = "Manage a plot cluster") public class Cluster category = CommandCategory.ADMINISTRATION,
extends SubCommand { requiredType = RequiredType.NONE,
permission = "plots.cluster",
description = "Manage a plot cluster")
public class Cluster extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {

View File

@ -6,7 +6,8 @@ import lombok.RequiredArgsConstructor;
/** /**
* CommandCategory. * CommandCategory.
*/ */
@RequiredArgsConstructor public enum CommandCategory { @RequiredArgsConstructor
public enum CommandCategory {
/** /**
* Claiming CommandConfig. * Claiming CommandConfig.
* Such as: /plot claim * Such as: /plot claim

View File

@ -16,8 +16,12 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map.Entry; import java.util.Map.Entry;
@CommandDeclaration(command = "comment", aliases = {"msg"}, description = "Comment on a plot", @CommandDeclaration(command = "comment",
category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER, permission = "plots.comment") aliases = {"msg"},
description = "Comment on a plot",
category = CommandCategory.CHAT,
requiredType = RequiredType.PLAYER,
permission = "plots.comment")
public class Comment extends SubCommand { public class Comment extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {

View File

@ -19,10 +19,13 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@CommandDeclaration(command = "condense", permission = "plots.admin", @CommandDeclaration(command = "condense",
permission = "plots.admin",
usage = "/plot condense <area> <start|stop|info> [radius]", usage = "/plot condense <area> <start|stop|info> [radius]",
description = "Condense a plotworld", category = CommandCategory.ADMINISTRATION, description = "Condense a plotworld",
requiredType = RequiredType.CONSOLE) public class Condense extends SubCommand { category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE)
public class Condense extends SubCommand {
public static boolean TASK = false; public static boolean TASK = false;

View File

@ -9,9 +9,11 @@ import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@CommandDeclaration(command = "confirm", permission = "plots.use", @CommandDeclaration(command = "confirm",
description = "Confirm an action", category = CommandCategory.INFO) public class Confirm permission = "plots.use",
extends SubCommand { description = "Confirm an action",
category = CommandCategory.INFO)
public class Confirm extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
CmdInstance command = CmdConfirm.getPending(player); CmdInstance command = CmdConfirm.getPending(player);

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -11,8 +11,10 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(command = "continue", @CommandDeclaration(command = "continue",
description = "Continue a plot that was previously marked as done", description = "Continue a plot that was previously marked as done",
permission = "plots.continue", category = CommandCategory.SETTINGS, permission = "plots.continue",
requiredType = RequiredType.PLAYER) public class Continue extends SubCommand { category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER)
public class Continue extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
@ -24,7 +26,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
return false; return false;
} }
if (!plot.hasFlag(Flags.DONE)) { if (!DoneFlag.isDone(plot)) {
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE); MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
return false; return false;
} }
@ -39,7 +41,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
return false; return false;
} }
plot.removeFlag(Flags.DONE); plot.removeFlag(DoneFlag.class);
MainUtil.sendMessage(player, Captions.DONE_REMOVED); MainUtil.sendMessage(player, Captions.DONE_REMOVED);
return true; return true;
} }

View File

@ -8,9 +8,14 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(command = "copy", permission = "plots.copy", aliases = {"copypaste"}, @CommandDeclaration(command = "copy",
category = CommandCategory.CLAIMING, description = "Copy a plot", usage = "/plot copy <X;Z>", permission = "plots.copy",
requiredType = RequiredType.NONE) public class Copy extends SubCommand { aliases = {"copypaste"},
category = CommandCategory.CLAIMING,
description = "Copy a plot",
usage = "/plot copy <X;Z>",
requiredType = RequiredType.NONE)
public class Copy extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -9,11 +9,14 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "createroadschematic", aliases = {"crs"}, @CommandDeclaration(command = "createroadschematic",
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.PLAYER, aliases = {"crs"},
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.PLAYER,
permission = "plots.createroadschematic", permission = "plots.createroadschematic",
description = "Add a road schematic to your world using the roads around your current plot", description = "Add a road schematic to your world using the roads around your current plot",
usage = "/plot createroadschematic") public class CreateRoadSchematic extends SubCommand { usage = "/plot createroadschematic")
public class CreateRoadSchematic extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -22,11 +22,14 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
@CommandDeclaration(command = "database", aliases = {"convert"}, @CommandDeclaration(command = "database",
category = CommandCategory.ADMINISTRATION, permission = "plots.database", aliases = {"convert"},
description = "Convert/Backup Storage", requiredType = RequiredType.CONSOLE, category = CommandCategory.ADMINISTRATION,
usage = "/plot database [area] <sqlite|mysql|import>") public class Database permission = "plots.database",
extends SubCommand { description = "Convert/Backup Storage",
requiredType = RequiredType.CONSOLE,
usage = "/plot database [area] <sqlite|mysql|import>")
public class DatabaseCommand extends SubCommand {
public static void insertPlots(final SQLManager manager, final List<Plot> plots, public static void insertPlots(final SQLManager manager, final List<Plot> plots,
final PlotPlayer player) { final PlotPlayer player) {
@ -159,7 +162,7 @@ import java.util.Map.Entry;
} }
try { try {
SQLManager manager = new SQLManager(implementation, prefix, true); SQLManager manager = new SQLManager(implementation, prefix, true);
Database.insertPlots(manager, plots, player); DatabaseCommand.insertPlots(manager, plots, player);
return true; return true;
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info"); MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info");

View File

@ -9,8 +9,11 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.Map; import java.util.Map;
@CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, @CommandDeclaration(command = "debug",
description = "Show debug information", usage = "/plot debug [msg]", permission = "plots.admin") category = CommandCategory.DEBUG,
description = "Show debug information",
usage = "/plot debug [msg]",
permission = "plots.admin")
public class Debug extends SubCommand { public class Debug extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {

View File

@ -9,9 +9,12 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "debugallowunsafe", @CommandDeclaration(command = "debugallowunsafe",
description = "Allow unsafe actions until toggled off", usage = "/plot debugallowunsafe", description = "Allow unsafe actions until toggled off",
category = CommandCategory.DEBUG, requiredType = RequiredType.NONE, usage = "/plot debugallowunsafe",
permission = "plots.debugallowunsafe") public class DebugAllowUnsafe extends SubCommand { category = CommandCategory.DEBUG,
requiredType = RequiredType.NONE,
permission = "plots.debugallowunsafe")
public class DebugAllowUnsafe extends SubCommand {
public static final List<UUID> unsafeAllowed = new ArrayList<>(); public static final List<UUID> unsafeAllowed = new ArrayList<>();

View File

@ -22,9 +22,13 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugclaimtest", description = @CommandDeclaration(command = "debugclaimtest",
"If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot signs. " description =
+ "Execution time may vary", category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE, permission = "plots.debugclaimtest") "If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot signs. "
+ "Execution time may vary",
category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE,
permission = "plots.debugclaimtest")
public class DebugClaimTest extends SubCommand { public class DebugClaimTest extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
@ -56,7 +60,8 @@ public class DebugClaimTest extends SubCommand {
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(min, max); ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(min, max);
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: " + ids.size() + " plot ids to check!"); MainUtil.sendMessage(player,
"&3Sign Block&8->&3Plot&8: " + ids.size() + " plot ids to check!");
for (PlotId id : ids) { for (PlotId id : ids) {
Plot plot = area.getPlotAbs(id); Plot plot = area.getPlotAbs(id);
if (plot.hasOwner()) { if (plot.hasOwner()) {
@ -74,7 +79,8 @@ public class DebugClaimTest extends SubCommand {
BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap(); BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
UUID uuid = map.get(new StringWrapper(line)); UUID uuid = map.get(new StringWrapper(line));
if (uuid == null) { if (uuid == null) {
for (Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map.entrySet()) { for (Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map
.entrySet()) {
if (stringWrapperUUIDEntry.getKey().value.toLowerCase() if (stringWrapperUUIDEntry.getKey().value.toLowerCase()
.startsWith(line.toLowerCase())) { .startsWith(line.toLowerCase())) {
uuid = stringWrapperUUIDEntry.getValue(); uuid = stringWrapperUUIDEntry.getValue();
@ -86,11 +92,13 @@ public class DebugClaimTest extends SubCommand {
uuid = UUIDHandler.getUUID(line, null); uuid = UUIDHandler.getUUID(line, null);
} }
if (uuid != null) { if (uuid != null) {
MainUtil.sendMessage(player, " - &aFound plot: " + plot.getId() + " : " + line); MainUtil.sendMessage(player,
" - &aFound plot: " + plot.getId() + " : " + line);
plot.setOwner(uuid); plot.setOwner(uuid);
MainUtil.sendMessage(player, " - &8Updated plot: " + plot.getId()); MainUtil.sendMessage(player, " - &8Updated plot: " + plot.getId());
} else { } else {
MainUtil.sendMessage(player, " - &cInvalid PlayerName: " + plot.getId() + " : " + line); MainUtil.sendMessage(player,
" - &cInvalid PlayerName: " + plot.getId() + " : " + line);
} }
} }
} }

View File

@ -6,8 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.listener.WEManager; import com.github.intellectualsites.plotsquared.plot.listener.WEManager;
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer; import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
@ -55,9 +55,12 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugexec", permission = "plots.admin", @CommandDeclaration(command = "debugexec",
description = "Mutli-purpose debug command", aliases = {"exec", "$"}, permission = "plots.admin",
category = CommandCategory.DEBUG) public class DebugExec extends SubCommand { description = "Mutli-purpose debug command",
aliases = {"exec", "$"},
category = CommandCategory.DEBUG)
public class DebugExec extends SubCommand {
private ScriptEngine engine; private ScriptEngine engine;
private Bindings scope; private Bindings scope;
@ -120,7 +123,6 @@ import java.util.concurrent.CompletableFuture;
this.scope.put("Settings", new Settings()); this.scope.put("Settings", new Settings());
this.scope.put("StringMan", new StringMan()); this.scope.put("StringMan", new StringMan());
this.scope.put("MathMan", new MathMan()); this.scope.put("MathMan", new MathMan());
this.scope.put("FlagManager", new FlagManager());
// Classes // Classes
this.scope.put("Location", Location.class); this.scope.put("Location", Location.class);
@ -220,10 +222,11 @@ import java.util.concurrent.CompletableFuture;
return false; return false;
} }
String flag = args[1]; String flag = args[1];
for (Plot plot : PlotSquared.get().getBasePlots()) { final PlotFlag<?, ?> flagInstance =
Flag<?> flag1 = FlagManager.getFlag(flag); GlobalFlagContainer.getInstance().getFlagFromString(flag);
if (plot.getFlag(flag1).isPresent()) { if (flagInstance != null) {
plot.removeFlag(flag1); for (Plot plot : PlotSquared.get().getBasePlots()) {
plot.removeFlag(flagInstance);
} }
} }
return MainUtil.sendMessage(player, "Cleared flag: " + flag); return MainUtil.sendMessage(player, "Cleared flag: " + flag);
@ -306,8 +309,8 @@ import java.util.concurrent.CompletableFuture;
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, String[] args, @Override public CompletableFuture<Boolean> execute(PlotPlayer player,
RunnableVal3<Command, Runnable, Runnable> confirm, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
try { try {
DebugExec.this.scope.put("PlotPlayer", player); DebugExec.this.scope.put("PlotPlayer", player);

View File

@ -1,52 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Argument;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
@CommandDeclaration(command = "debugfixflags", usage = "/plot debugfixflags <world>",
permission = "plots.debugfixflags", description = "Attempt to fix all flags for a world",
requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG)
public class DebugFixFlags extends SubCommand {
public DebugFixFlags() {
super(Argument.String);
}
@Override public boolean onCommand(PlotPlayer player, String[] args) {
PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD, args[0]);
return false;
}
MainUtil.sendMessage(player, "&8--- &6Starting task &8 ---");
for (Plot plot : area.getPlots()) {
HashMap<Flag<?>, Object> flags = plot.getFlags();
Iterator<Entry<Flag<?>, Object>> i = flags.entrySet().iterator();
boolean changed = false;
while (i.hasNext()) {
if (i.next().getKey() == null) {
changed = true;
i.remove();
}
}
if (changed) {
DBFunc.setFlags(plot, plot.getFlags());
}
}
MainUtil.sendMessage(player, "&aDone!");
return true;
}
}

View File

@ -18,9 +18,12 @@ import java.io.File;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugimportworlds", permission = "plots.admin", @CommandDeclaration(command = "debugimportworlds",
description = "Import worlds by player name", requiredType = RequiredType.CONSOLE, permission = "plots.admin",
category = CommandCategory.TELEPORT) public class DebugImportWorlds extends Command { description = "Import worlds by player name",
requiredType = RequiredType.CONSOLE,
category = CommandCategory.TELEPORT)
public class DebugImportWorlds extends Command {
public DebugImportWorlds() { public DebugImportWorlds() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }

View File

@ -5,10 +5,13 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "debugloadtest", permission = "plots.debugloadtest", @CommandDeclaration(command = "debugloadtest",
permission = "plots.debugloadtest",
description = "This debug command will force the reload of all plots in the DB", description = "This debug command will force the reload of all plots in the DB",
usage = "/plot debugloadtest", category = CommandCategory.DEBUG, usage = "/plot debugloadtest",
requiredType = RequiredType.CONSOLE) public class DebugLoadTest extends SubCommand { category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE)
public class DebugLoadTest extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
PlotSquared.get().plots_tmp = DBFunc.getPlots(); PlotSquared.get().plots_tmp = DBFunc.getPlots();

View File

@ -28,9 +28,14 @@ import java.util.stream.Collectors;
import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.getDownloadID; import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.getDownloadID;
import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.getUserID; import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.getUserID;
@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste", @CommandDeclaration(command = "debugpaste",
aliases = "dp",
usage = "/plot debugpaste",
description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml your latest.log and Multiverse's worlds.yml (if being used) to https://athion.net/ISPaster/paste", description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml your latest.log and Multiverse's worlds.yml (if being used) to https://athion.net/ISPaster/paste",
permission = "plots.debugpaste", category = CommandCategory.DEBUG, confirmation = true, requiredType = RequiredType.NONE) permission = "plots.debugpaste",
category = CommandCategory.DEBUG,
confirmation = true,
requiredType = RequiredType.NONE)
public class DebugPaste extends SubCommand { public class DebugPaste extends SubCommand {
private static String readFile(@NonNull final File file) throws IOException { private static String readFile(@NonNull final File file) throws IOException {
@ -54,14 +59,16 @@ public class DebugPaste extends SubCommand {
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your " "# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
+ "problem\n\n"); + "problem\n\n");
b.append("# PlotSquared Information\n"); b.append("# PlotSquared Information\n");
b.append("This PlotSquared version is licensed to the spigot user ").append(getUserID()).append(" under ").append(getDownloadID()).append("\n"); b.append("This PlotSquared version is licensed to the spigot user ")
.append(getUserID()).append(" under ").append(getDownloadID()).append("\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");
b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';') b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';')
.append(!Settings.UUID.OFFLINE).append('\n'); .append(!Settings.UUID.OFFLINE).append('\n');
b.append("Plugins:"); b.append("Plugins:");
for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared.get().IMP.getPluginIds()) { for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared
.get().IMP.getPluginIds()) {
Map.Entry<String, String> nameVersion = pluginInfo.getKey(); Map.Entry<String, String> nameVersion = pluginInfo.getKey();
String name = nameVersion.getKey(); String name = nameVersion.getKey();
String version = nameVersion.getValue(); String version = nameVersion.getValue();
@ -72,12 +79,17 @@ public class DebugPaste extends SubCommand {
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n"); b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean(); RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
b.append("Uptime: ").append(TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS) + " minutes").append('\n'); b.append("Uptime: ").append(
TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS) + " minutes")
.append('\n');
b.append("JVM Flags: ").append(rb.getInputArguments()).append('\n'); b.append("JVM Flags: ").append(rb.getInputArguments()).append('\n');
b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024 + " MB").append('\n'); b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024 + " MB")
b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024 + " MB").append('\n'); .append('\n');
b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024 + " MB")
.append('\n');
b.append("Java Name: ").append(rb.getVmName()).append('\n'); b.append("Java Name: ").append(rb.getVmName()).append('\n');
b.append("Java Version: '").append(System.getProperty("java.version")).append("'\n"); b.append("Java Version: '").append(System.getProperty("java.version"))
.append("'\n");
b.append("Java Vendor: '").append(System.getProperty("java.vendor")).append("'\n"); b.append("Java Vendor: '").append(System.getProperty("java.vendor")).append("'\n");
b.append("Operating System: '").append(System.getProperty("os.name")).append("'\n"); b.append("Operating System: '").append(System.getProperty("os.name")).append("'\n");
b.append("OS Version: ").append(System.getProperty("os.version")).append('\n'); b.append("OS Version: ").append(System.getProperty("os.version")).append('\n');
@ -124,12 +136,13 @@ public class DebugPaste extends SubCommand {
} }
try { try {
final File MultiverseWorlds = final File MultiverseWorlds = new File(PlotSquared.get().IMP.getDirectory(),
new File(PlotSquared.get().IMP.getDirectory(), "../Multiverse-Core/worlds.yml"); "../Multiverse-Core/worlds.yml");
incendoPaster incendoPaster.addFile(new IncendoPaster.PasteFile("MultiverseCore/worlds.yml",
.addFile(new IncendoPaster.PasteFile("MultiverseCore/worlds.yml", readFile(MultiverseWorlds))); readFile(MultiverseWorlds)));
} catch (final IOException ignored) { } catch (final IOException ignored) {
MainUtil.sendMessage(player, "&cSkipping Multiverse worlds.yml because the plugin is not in use"); MainUtil.sendMessage(player,
"&cSkipping Multiverse worlds.yml because the plugin is not in use");
} }
try { try {

View File

@ -13,10 +13,12 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.Arrays; import java.util.Arrays;
@CommandDeclaration(command = "debugroadregen", usage = DebugRoadRegen.USAGE, @CommandDeclaration(command = "debugroadregen",
usage = DebugRoadRegen.USAGE,
requiredType = RequiredType.NONE, requiredType = RequiredType.NONE,
description = "Regenerate roads in the plot or region the user is, based on the road schematic", description = "Regenerate roads in the plot or region the user is, based on the road schematic",
category = CommandCategory.DEBUG, permission = "plots.debugroadregen") category = CommandCategory.DEBUG,
permission = "plots.debugroadregen")
public class DebugRoadRegen extends SubCommand { public class DebugRoadRegen extends SubCommand {
public static final String USAGE = "/plot debugroadregen <plot|region [height]>"; public static final String USAGE = "/plot debugroadregen <plot|region [height]>";
@ -67,13 +69,11 @@ public class DebugRoadRegen extends SubCommand {
height = Integer.parseInt(args[0]); height = Integer.parseInt(args[0]);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0, 256)"); MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0, 256)");
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE);
DebugRoadRegen.USAGE);
return false; return false;
} }
} else if (args.length != 0) { } else if (args.length != 0) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE);
DebugRoadRegen.USAGE);
return false; return false;
} }

View File

@ -9,8 +9,10 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.ArrayList; import java.util.ArrayList;
@CommandDeclaration(command = "debugsavetest", permission = "plots.debugsavetest", @CommandDeclaration(command = "debugsavetest",
category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE, permission = "plots.debugsavetest",
category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE,
usage = "/plot debugsavetest", usage = "/plot debugsavetest",
description = "This command will force the recreation of all plots in the DB") description = "This command will force the recreation of all plots in the DB")
public class DebugSaveTest extends SubCommand { public class DebugSaveTest extends SubCommand {

View File

@ -15,10 +15,15 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@CommandDeclaration(command = "delete", permission = "plots.delete", @CommandDeclaration(command = "delete",
description = "Delete the plot you stand on", usage = "/plot delete", permission = "plots.delete",
aliases = {"dispose", "del", "unclaim"}, category = CommandCategory.CLAIMING, description = "Delete the plot you stand on",
requiredType = RequiredType.NONE, confirmation = true) public class Delete extends SubCommand { usage = "/plot delete",
aliases = {"dispose", "del", "unclaim"},
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
confirmation = true)
public class Delete extends SubCommand {
// Note: To delete a specific plot use /plot <plot> delete // Note: To delete a specific plot use /plot <plot> delete
// The syntax also works with any command: /plot <plot> <command> // The syntax also works with any command: /plot <plot> <command>

View File

@ -18,10 +18,13 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "deny", aliases = {"d", "ban"}, @CommandDeclaration(command = "deny",
description = "Deny a user from entering a plot", usage = "/plot deny <player|*>", aliases = {"d", "ban"},
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Deny description = "Deny a user from entering a plot",
extends SubCommand { usage = "/plot deny <player|*>",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER)
public class Deny extends SubCommand {
public Deny() { public Deny() {
super(Argument.PlayerName); super(Argument.PlayerName);

View File

@ -2,24 +2,30 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "setdescription", permission = "plots.set.desc", @CommandDeclaration(command = "setdescription",
description = "Set the plot description", usage = "/plot desc <description>", permission = "plots.set.desc",
aliases = {"desc", "setdesc", "setd", "description"}, category = CommandCategory.SETTINGS, description = "Set the plot description",
requiredType = RequiredType.PLAYER) public class Desc extends SetCommand { usage = "/plot desc <description>",
aliases = {"desc", "setdesc", "setd", "description"},
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER)
public class Desc extends SetCommand {
@Override public boolean set(PlotPlayer player, Plot plot, String desc) { @Override public boolean set(PlotPlayer player, Plot plot, String desc) {
if (desc.isEmpty()) { if (desc.isEmpty()) {
plot.removeFlag(Flags.DESCRIPTION); plot.removeFlag(DescriptionFlag.class);
MainUtil.sendMessage(player, Captions.DESC_UNSET); MainUtil.sendMessage(player, Captions.DESC_UNSET);
return true; return true;
} }
boolean result = FlagManager.addPlotFlag(plot, Flags.DESCRIPTION, desc); boolean result = plot.setFlag(
GlobalFlagContainer.getInstance().getFlag(DescriptionFlag.class)
.createFlagInstance(desc));
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED); MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
return false; return false;

View File

@ -3,10 +3,13 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "dislike", permission = "plots.dislike", @CommandDeclaration(command = "dislike",
description = "Dislike the plot", usage = "/plot dislike [next|purge]", permission = "plots.dislike",
category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) public class Dislike description = "Dislike the plot",
extends SubCommand { usage = "/plot dislike [next|purge]",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
public class Dislike extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
return Like.handleLike(player, args, false); return Like.handleLike(player, args, false);

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -14,9 +14,13 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
@CommandDeclaration(command = "done", aliases = {"submit"}, description = "Mark a plot as done", @CommandDeclaration(command = "done",
permission = "plots.done", category = CommandCategory.SETTINGS, aliases = {"submit"},
requiredType = RequiredType.NONE) public class Done extends SubCommand { description = "Mark a plot as done",
permission = "plots.done",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE)
public class Done extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
@ -29,7 +33,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
return false; return false;
} }
if (plot.hasFlag(Flags.DONE)) { if (DoneFlag.isDone(plot)) {
MainUtil.sendMessage(player, Captions.DONE_ALREADY_DONE); MainUtil.sendMessage(player, Captions.DONE_ALREADY_DONE);
return false; return false;
} }
@ -59,7 +63,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
private void finish(Plot plot, PlotPlayer pp, boolean success) { private void finish(Plot plot, PlotPlayer pp, boolean success) {
if (success) { if (success) {
long flagValue = System.currentTimeMillis() / 1000; long flagValue = System.currentTimeMillis() / 1000;
plot.setFlag(Flags.DONE, flagValue); plot.setFlag(DoneFlag.class, Long.toString(flagValue));
MainUtil.sendMessage(pp, Captions.DONE_SUCCESS); MainUtil.sendMessage(pp, Captions.DONE_SUCCESS);
} else { } else {
MainUtil.sendMessage(pp, Captions.DONE_INSUFFICIENT_COMPLEXITY); MainUtil.sendMessage(pp, Captions.DONE_INSUFFICIENT_COMPLEXITY);

View File

@ -4,7 +4,7 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@ -17,10 +17,14 @@ import com.sk89q.jnbt.CompoundTag;
import java.net.URL; import java.net.URL;
@CommandDeclaration(usage = "/plot download [schematic|world]", command = "download", @CommandDeclaration(usage = "/plot download [schematic|world]",
aliases = {"dl"}, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, command = "download",
description = "Download your plot", permission = "plots.download") public class Download aliases = {"dl"},
extends SubCommand { category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
description = "Download your plot",
permission = "plots.download")
public class Download extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorld();
@ -35,8 +39,8 @@ import java.net.URL;
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
return false; return false;
} }
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!plot.getFlag(Flags.DONE).isPresent())) if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot))) && !Permissions
&& !Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE); MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
return false; return false;
} }

View File

@ -1,343 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.BlockStateListFlag;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag;
import com.github.intellectualsites.plotsquared.plot.flag.ListFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@CommandDeclaration(command = "setflag", aliases = {"f", "flag",
"setflag"}, usage = "/plot flag <set|remove|add|list|info> <flag> <value>", description = "Set plot flags", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.flag")
public class FlagCmd extends SubCommand {
private boolean checkPermValue(PlotPlayer player, Flag flag, String key, String value) {
key = key.toLowerCase();
value = value.toLowerCase();
String perm = Captions
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(),
value.toLowerCase());
if (flag instanceof IntegerFlag && MathMan.isInteger(value)) {
try {
int numeric = Integer.parseInt(value);
perm = perm.substring(0, perm.length() - value.length() - 1);
if (numeric > 0) {
int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
numeric :
Settings.Limit.MAX_PLOTS;
final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric;
if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), value.toLowerCase()));
}
return result;
}
} catch (NumberFormatException ignore) {
}
} else if (flag instanceof BlockStateListFlag) {
final BlockStateListFlag blockListFlag = (BlockStateListFlag) flag;
Set<BlockType> parsedBlocks = blockListFlag.parseValue(value);
for (final BlockType block : parsedBlocks) {
final String permission = Captions
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), block.toString().toLowerCase());
final boolean result = Permissions.hasPermission(player, permission);
if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), value.toLowerCase()));
return false;
}
}
return true;
}
final boolean result = Permissions.hasPermission(player, perm);
if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(),
value.toLowerCase()));
}
return result;
}
@Override public boolean onCommand(PlotPlayer player, String[] args) {
/*
* plot flag set fly true
* plot flag remove fly
* plot flag remove use 1,3
* plot flag add use 2,4
* plot flag list
*/
if (args.length == 0) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, getUsage());
return false;
}
Location location = player.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
return false;
}
if (!plot.hasOwner()) {
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_SET_FLAG_OTHER)) {
MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG_OTHER);
return false;
}
Flag<?> flag = null;
if (args.length > 1) {
flag = FlagManager.getFlag(args[1]);
if (flag == null || flag.isReserved()) {
boolean suggested = false;
try {
StringComparison<Flag<?>> stringComparison =
new StringComparison<>(args[1], Flags.getFlags());
String best = stringComparison.getBestMatch();
if (best != null) {
MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG_SUGGESTED, best);
suggested = true;
}
} catch (final Exception ignored) { /* Happens sometimes because of mean code */ }
if (!suggested) {
MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG);
}
return false;
}
}
switch (args[0].toLowerCase()) {
case "info": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_SET_FLAG)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, "plots.flag.info");
return false;
}
if (args.length != 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag info <flag>");
return false;
}
// flag key
MainUtil.sendMessage(player, Captions.FLAG_KEY, flag.getName());
// flag type
MainUtil.sendMessage(player, Captions.FLAG_TYPE, flag.getClass().getSimpleName());
// Flag type description
MainUtil.sendMessage(player, Captions.FLAG_DESC, flag.getValueDescription());
return true;
}
case "set": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_SET_FLAG)) {
MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG);
return false;
}
if (args.length < 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot flag set <flag> <value>");
return false;
}
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
if (!checkPermValue(player, flag, args[1], value)) {
return false;
}
Object parsed = flag.parseValue(value);
if (parsed == null) {
MainUtil.sendMessage(player, "&c" + flag.getValueDescription());
return false;
}
if (flag instanceof ListFlag) {
if (!(parsed instanceof Collection) || ((Collection) parsed).isEmpty()) {
return !MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
}
}
boolean result = plot.setFlag(flag, parsed);
if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
return false;
}
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
return true;
}
case "remove": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_REMOVE)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_FLAG_REMOVE);
return false;
}
if (args.length != 2 && args.length != 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot flag remove <flag> [values]");
return false;
}
if (!Permissions.hasPermission(player, Captions
.format(player, Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[1].toLowerCase()))) {
if (args.length != 3) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
.format(player, Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[1].toLowerCase()));
return false;
}
for (String entry : args[2].split(",")) {
if (!checkPermValue(player, flag, args[1], entry)) {
return false;
}
}
}
if (args.length == 3 && flag instanceof ListFlag) {
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
final ListFlag<? extends Collection> listFlag = (ListFlag<? extends Collection>) flag;
final Optional<? extends Collection> collectionOptional = plot.getFlag(listFlag);
if (collectionOptional.isPresent()) {
final Collection parsedCollection = (Collection) flag.parseValue(value);
if (parsedCollection.isEmpty()) {
return !MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
}
final Collection flagCollection = collectionOptional.get();
if (flagCollection.removeAll(parsedCollection)) {
if (flagCollection.isEmpty()) {
if (plot.removeFlag(flag)) {
return MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
} else {
return !MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
}
} else {
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
}
} else {
return !MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
}
}
DBFunc.setFlags(plot, plot.getFlags());
return true;
} else {
boolean result = plot.removeFlag(flag);
if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
return false;
}
}
if (flag == Flags.TIME) {
player.setTime(Long.MAX_VALUE);
} else if (flag == Flags.WEATHER) {
player.setWeather(PlotWeather.RESET);
}
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
return true;
}
case "add":
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_ADD)) {
MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_ADD);
return false;
}
if (args.length < 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot flag add <flag> <values>");
return false;
}
for (String entry : args[2].split(",")) {
if (!checkPermValue(player, flag, args[1], entry)) {
return false;
}
}
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
Object parsed = flag.parseValue(value);
if (parsed == null) {
MainUtil.sendMessage(player, "&c" + flag.getValueDescription());
return false;
}
Object val = parsed;
if (flag instanceof ListFlag) {
final Collection parsedCollection = (Collection<?>) parsed;
if (parsedCollection.isEmpty()) {
return !MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
}
final ListFlag<? extends Collection> listFlag = (ListFlag<? extends Collection>) flag;
final Optional<? extends Collection> collectionOptional = plot.getFlag(listFlag);
if (collectionOptional.isPresent()) {
final Collection flagCollection = collectionOptional.get();
if (flagCollection.addAll(parsedCollection)) {
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
val = flagCollection;
} else {
return !MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
}
}
}
boolean result = plot.setFlag(flag, val);
if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
return false;
}
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
return true;
case "list":
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_LIST)) {
MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_LIST);
return false;
}
if (args.length > 1) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag list");
return false;
}
final Map<String, ArrayList<String>> flags = new HashMap<>();
for (Flag<?> flag1 : Flags.getFlags()) {
final String category = flag1.getCategoryCaption();
final Collection<String> flagList =
flags.computeIfAbsent(category, k -> new ArrayList<>());
flagList.add(flag1.getName());
}
final StringBuilder message = new StringBuilder();
final Iterator<Map.Entry<String, ArrayList<String>>> iterator =
flags.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<String, ArrayList<String>> flagsEntry = iterator.next();
final List<String> flagNames = flagsEntry.getValue();
Collections.sort(flagNames);
message.append(String.format(Captions.FLAG_LIST_ENTRY.formatted(),
flagsEntry.getKey(), StringMan.join(flagNames, ", ")));
if (iterator.hasNext()) {
message.append("\n");
}
}
MainUtil.sendMessage(player, message.toString());
return true;
}
MainUtil
.sendMessage(player, Captions.COMMAND_SYNTAX, getUsage());
return false;
}
}

View File

@ -0,0 +1,519 @@
package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.flags.types.IntegerFlag;
import com.github.intellectualsites.plotsquared.plot.flags.types.ListFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.helpmenu.HelpMenu;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@CommandDeclaration(command = "flag",
aliases = {"f", "flag"},
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
description = "Manage plot flags",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag")
@SuppressWarnings("unused")
public final class FlagCommand extends Command {
public FlagCommand() {
super(MainCommand.getInstance(), true);
}
private static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
message.send(player, args);
return true;
}
private static boolean checkPermValue(@Nonnull final PlotPlayer player,
@NotNull final PlotFlag<?, ?> flag, @NotNull String key, @NotNull String value) {
key = key.toLowerCase();
value = value.toLowerCase();
String perm = CaptionUtility
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), value.toLowerCase());
if (flag instanceof IntegerFlag && MathMan.isInteger(value)) {
try {
int numeric = Integer.parseInt(value);
perm = perm.substring(0, perm.length() - value.length() - 1);
if (numeric > 0) {
int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
numeric :
Settings.Limit.MAX_PLOTS;
final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric;
if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), value.toLowerCase()));
}
return result;
}
} catch (NumberFormatException ignore) {
}
} else if (flag instanceof ListFlag) {
final ListFlag<?, ?> listFlag = (ListFlag<?, ?>) flag;
try {
PlotFlag<? extends List<?>, ?> parsedFlag = listFlag.parse(value);
for (final Object entry : parsedFlag.getValue()) {
final String permission = CaptionUtility
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), entry.toString().toLowerCase());
final boolean result = Permissions.hasPermission(player, permission);
if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), value.toLowerCase()));
return false;
}
}
} catch (final FlagParseException e) {
MainUtil.sendMessage(player,
Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", flag.getName())
.replace("%flag_value%", e.getValue())
.replace("%error%", e.getErrorMessage()));
return false;
} catch (final Exception e) {
return false;
}
return true;
}
final boolean result = Permissions.hasPermission(player, perm);
if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(player, Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), value.toLowerCase()));
}
return result;
}
/**
* Checks if the player is allowed to modify the flags at their current location
*
* @return true if the player is allowed to modify the flags at their current location
*/
private static boolean checkRequirements(@NotNull final PlotPlayer player) {
final Location location = player.getLocation();
final Plot plot = location.getPlotAbs();
if (plot == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
return false;
}
if (!plot.hasOwner()) {
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_SET_FLAG_OTHER)) {
MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG_OTHER);
return false;
}
return true;
}
/**
* Attempt to extract the plot flag from the command arguments. If the flag cannot
* be found, a flag suggestion may be sent to the player.
*
* @param player Player executing the command
* @param arg String to extract flag from
* @return The flag, if found, else null
*/
@Nullable private static PlotFlag<?, ?> getFlag(@NotNull final PlotPlayer player,
@NotNull final String arg) {
if (arg != null && arg.length() > 0) {
final PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(arg);
if (flag instanceof InternalFlag || flag == null) {
boolean suggested = false;
try {
final StringComparison<PlotFlag<?, ?>> stringComparison =
new StringComparison<>(arg,
GlobalFlagContainer.getInstance().getFlagMap().values());
final String best = stringComparison.getBestMatch();
if (best != null) {
MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG_SUGGESTED, best);
suggested = true;
}
} catch (final Exception ignored) { /* Happens sometimes because of mean code */ }
if (!suggested) {
MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG);
}
return null;
}
return flag;
}
return null;
}
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
if (args.length == 0 || !Arrays
.asList("set", "s", "list", "l", "delete", "remove", "r", "add", "a", "info", "i")
.contains(args[0].toLowerCase(Locale.ENGLISH))) {
new HelpMenu(player).setCategory(CommandCategory.SETTINGS)
.setCommands(this.getCommands()).generateMaxPages()
.generatePage(0, getParent().toString()).render();
return CompletableFuture.completedFuture(true);
}
return super.execute(player, args, confirm, whenDone);
}
@Override public Collection<Command> tab(final PlotPlayer player, final String[] args,
final boolean space) {
if (args.length == 1) {
return Stream
.of("s", "set", "add", "a", "remove", "r", "delete", "info", "i", "list", "l")
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
.map(value -> new Command(null, false, value, "", RequiredType.NONE, null) {
}).collect(Collectors.toList());
} else if (Arrays.asList("s", "set", "add", "a", "remove", "r", "delete", "info", "i")
.contains(args[0].toLowerCase(Locale.ENGLISH)) && args.length == 2) {
return GlobalFlagContainer.getInstance().getRecognizedPlotFlags().stream()
.filter(flag -> !(flag instanceof InternalFlag))
.filter(flag -> flag.getName().startsWith(args[1].toLowerCase(Locale.ENGLISH)))
.map(flag -> new Command(null, false, flag.getName(), "", RequiredType.NONE, null) {
}).collect(Collectors.toList());
} else if (Arrays.asList("s", "set", "add", "a", "remove", "r", "delete")
.contains(args[0].toLowerCase(Locale.ENGLISH)) && args.length == 3) {
try {
final PlotFlag<?, ?> flag =
GlobalFlagContainer.getInstance().getFlagFromString(args[1]);
if (flag != null) {
Stream<String> stream = flag.getTabCompletions().stream();
if (flag instanceof ListFlag && args[2].contains(",")) {
final String[] split = args[2].split(",");
// Prefix earlier values onto all suggestions
StringBuilder prefix = new StringBuilder();
for (int i = 0; i < split.length - 1; i++) {
prefix.append(split[i]).append(",");
}
final String cmp;
if (!args[2].endsWith(",")) {
cmp = split[split.length - 1];
} else {
prefix.append(split[split.length - 1]).append(",");
cmp = "";
}
return stream
.filter(value -> value.startsWith(cmp.toLowerCase(Locale.ENGLISH))).map(
value -> new Command(null, false, prefix + value, "",
RequiredType.NONE, null) {
}).collect(Collectors.toList());
} else {
return stream
.filter(value -> value.startsWith(args[2].toLowerCase(Locale.ENGLISH)))
.map(value -> new Command(null, false, value, "", RequiredType.NONE,
null) {
}).collect(Collectors.toList());
}
}
} catch (final Exception e) {
}
}
return tabOf(player, args, space);
}
@CommandDeclaration(command = "set",
aliases = {"s", "set"},
usage = "/plot flag set <flag> <value>",
description = "Set a plot flag",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.set.flag")
public void set(final Command command, final PlotPlayer player, final String[] args,
final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) {
if (!checkRequirements(player)) {
return;
}
if (args.length < 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag set <flag> <value>");
return;
}
final PlotFlag<?, ?> plotFlag = getFlag(player, args[0]);
if (plotFlag == null) {
return;
}
final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
if (!checkPermValue(player, plotFlag, args[0], value)) {
return;
}
final PlotFlag<?, ?> parsed;
try {
parsed = plotFlag.parse(value);
} catch (final FlagParseException e) {
MainUtil.sendMessage(player,
Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", plotFlag.getName())
.replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage()));
return;
}
player.getLocation().getPlotAbs().setFlag(parsed);
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
}
@CommandDeclaration(command = "add",
aliases = {"a", "add"},
usage = "/plot flag add <flag> <value>",
description = "Add a plot flag value",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.add")
public void add(final Command command, PlotPlayer player, final String[] args,
final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) {
if (!checkRequirements(player)) {
return;
}
if (args.length < 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
return;
}
final PlotFlag flag = getFlag(player, args[0]);
if (flag == null) {
return;
}
final PlotFlag localFlag =
player.getLocation().getPlotAbs().getFlagContainer().getFlag(flag.getClass());
for (String entry : args[1].split(",")) {
if (!checkPermValue(player, flag, args[0], entry)) {
return;
}
}
final String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
final PlotFlag parsed;
try {
parsed = flag.parse(value);
} catch (FlagParseException e) {
MainUtil.sendMessage(player,
Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", flag.getName())
.replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage()));
return;
}
boolean result =
player.getLocation().getPlotAbs().setFlag(localFlag.merge(parsed.getValue()));
if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
return;
}
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
}
@CommandDeclaration(command = "remove",
aliases = {"r", "remove", "delete"},
usage = "/plot flag remove <flag> [values]",
description = "Remove a flag",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.add")
public void remove(final Command command, PlotPlayer player, final String[] args,
final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) {
if (!checkRequirements(player)) {
return;
}
if (args.length != 1 && args.length != 2) {
MainUtil
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
return;
}
final PlotFlag<?, ?> flag = getFlag(player, args[0]);
if (flag == null) {
return;
}
if (!Permissions.hasPermission(player, CaptionUtility
.format(player, Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[0].toLowerCase()))) {
if (args.length != 2) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(player, Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[0].toLowerCase()));
return;
}
}
final Plot plot = player.getLocation().getPlotAbs();
if (args.length == 2 && flag instanceof ListFlag) {
String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
final ListFlag listFlag = (ListFlag) flag;
final List list =
new ArrayList(plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass()));
final PlotFlag parsedFlag;
try {
parsedFlag = listFlag.parse(value);
} catch (final FlagParseException e) {
MainUtil.sendMessage(player,
Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", flag.getName())
.replace("%flag_value%", e.getValue())
.replace("%error%", e.getErrorMessage()));
return;
}
if (((List) parsedFlag.getValue()).isEmpty()) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
return;
}
if (list.removeAll((List) parsedFlag.getValue())) {
if (list.isEmpty()) {
if (plot.removeFlag(flag)) {
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
return;
} else {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
return;
}
} else {
// MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
if (plot.setFlag(parsedFlag.createFlagInstance(list))) {
MainUtil.sendMessage(player, Captions.FLAG_PARTIALLY_REMOVED);
return;
} else {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
return;
}
}
} else {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
return;
}
} else {
boolean result = plot.removeFlag(flag);
if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
return;
}
}
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
}
@CommandDeclaration(command = "list",
aliases = {"l", "list", "flags"},
usage = "/plot flag list",
description = "List all available plot flags",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.list")
public void list(final Command command, final PlotPlayer player, final String[] args,
final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) {
if (!checkRequirements(player)) {
return;
}
final Map<String, ArrayList<String>> flags = new HashMap<>();
for (PlotFlag<?, ?> plotFlag : GlobalFlagContainer.getInstance().getRecognizedPlotFlags()) {
if (plotFlag instanceof InternalFlag) {
continue;
}
final String category = plotFlag.getFlagCategory().getTranslated();
final Collection<String> flagList =
flags.computeIfAbsent(category, k -> new ArrayList<>());
flagList.add(plotFlag.getName());
}
for (final Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) {
Collections.sort(entry.getValue());
PlotMessage plotMessage = new PlotMessage(entry.getKey() + ": ")
.color(Captions.FLAG_INFO_COLOR_KEY.getTranslated());
final Iterator<String> flagIterator = entry.getValue().iterator();
while (flagIterator.hasNext()) {
final String flag = flagIterator.next();
plotMessage = plotMessage.text(flag).command("/plot flag info " + flag)
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()).tooltip(
new PlotMessage(Captions.FLAG_LIST_SEE_INFO.getTranslated())
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()));
if (flagIterator.hasNext()) {
plotMessage = plotMessage.text(", ")
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated());
}
}
plotMessage.send(player);
}
}
@CommandDeclaration(command = "info",
aliases = {"i", "info"},
usage = "/plot flag info <flag>",
description = "View information about a flag",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.info")
public void info(final Command command, final PlotPlayer player, final String[] args,
final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) {
if (!checkRequirements(player)) {
return;
}
if (args.length < 1) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag info <flag>");
return;
}
final PlotFlag<?, ?> plotFlag = getFlag(player, args[0]);
if (plotFlag != null) {
Captions.FLAG_INFO_HEADER.send(player);
// Flag name
new PlotMessage(Captions.FLAG_INFO_NAME.getTranslated())
.color(Captions.FLAG_INFO_COLOR_KEY.getTranslated()).text(plotFlag.getName())
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()).send(player);
// Flag category
new PlotMessage(Captions.FLAG_INFO_CATEGORY.getTranslated())
.color(Captions.FLAG_INFO_COLOR_KEY.getTranslated())
.text(plotFlag.getFlagCategory().getTranslated())
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()).send(player);
// Flag description
new PlotMessage(Captions.FLAG_INFO_DESCRIPTION.getTranslated())
.color(Captions.FLAG_INFO_COLOR_KEY.getTranslated()).send(player);
new PlotMessage(plotFlag.getFlagDescription().getTranslated())
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()).send(player);
// Flag example
new PlotMessage(Captions.FLAG_INFO_EXAMPLE.getTranslated())
.color(Captions.FLAG_INFO_COLOR_KEY.getTranslated())
.text("/plot flag set " + plotFlag.getName() + " " + plotFlag.getExample())
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated())
.suggest("/plot flag set " + plotFlag.getName() + " " + plotFlag.getExample())
.send(player);
// Default value
final String defaultValue = player.getLocation().getPlotArea().getFlagContainer()
.getFlagErased(plotFlag.getClass()).toString();
new PlotMessage(Captions.FLAG_INFO_DEFAULT_VALUE.getTranslated())
.color(Captions.FLAG_INFO_COLOR_KEY.getTranslated()).text(defaultValue)
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()).send(player);
// Footer. Done this way to prevent the duplicate-message-thingy from catching it
MainUtil.sendMessage(player, "&r" + Captions.FLAG_INFO_FOOTER.getTranslated());
}
}
}

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -16,9 +17,12 @@ import com.google.common.primitives.Ints;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "grant", category = CommandCategory.CLAIMING, @CommandDeclaration(command = "grant",
usage = "/plot grant <check|add> [player]", permission = "plots.grant", category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE) public class Grant extends Command { usage = "/plot grant <check|add> [player]",
permission = "plots.grant",
requiredType = RequiredType.NONE)
public class Grant extends Command {
public Grant() { public Grant() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
@ -32,10 +36,10 @@ import java.util.concurrent.CompletableFuture;
switch (arg0) { switch (arg0) {
case "add": case "add":
case "check": case "check":
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player, CaptionUtility
Captions.format(player, Captions.PERMISSION_GRANT.getTranslated(), arg0))) { .format(player, Captions.PERMISSION_GRANT.getTranslated(), arg0))) {
Captions.NO_PERMISSION.send(player, Captions.NO_PERMISSION.send(player, CaptionUtility
Captions.format(player, Captions.PERMISSION_GRANT.getTranslated(), arg0)); .format(player, Captions.PERMISSION_GRANT.getTranslated(), arg0));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
if (args.length > 2) { if (args.length > 2) {

View File

@ -13,8 +13,12 @@ import com.github.intellectualsites.plotsquared.plot.util.helpmenu.HelpMenu;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "help", description = "Get this help menu", aliases = "?", @CommandDeclaration(command = "help",
category = CommandCategory.INFO, usage = "help [category|#]", permission = "plots.use") description = "Get this help menu",
aliases = "?",
category = CommandCategory.INFO,
usage = "help [category|#]",
permission = "plots.use")
public class Help extends Command { public class Help extends Command {
public Help(Command parent) { public Help(Command parent) {
super(parent, true); super(parent, true);
@ -55,7 +59,8 @@ public class Help extends Command {
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }
public CompletableFuture<Boolean> displayHelp(final PlotPlayer player, final String catRaw, final int page) { public CompletableFuture<Boolean> displayHelp(final PlotPlayer player, final String catRaw,
final int page) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
String cat = catRaw; String cat = catRaw;
@ -80,12 +85,11 @@ public class Help extends Command {
for (CommandCategory c : CommandCategory.values()) { for (CommandCategory c : CommandCategory.values()) {
builder.append("\n").append(StringMan builder.append("\n").append(StringMan
.replaceAll(Captions.HELP_INFO_ITEM.getTranslated(), "%category%", .replaceAll(Captions.HELP_INFO_ITEM.getTranslated(), "%category%",
c.toString().toLowerCase(), c.toString().toLowerCase(), "%category_desc%", c.toString()));
"%category_desc%", c.toString()));
} }
builder.append("\n") builder.append("\n").append(
.append(Captions.HELP_INFO_ITEM.getTranslated().replaceAll("%category%", "all") Captions.HELP_INFO_ITEM.getTranslated().replaceAll("%category%", "all")
.replaceAll("%category_desc%", "Display all commands")); .replaceAll("%category_desc%", "Display all commands"));
builder.append("\n").append(Captions.HELP_FOOTER.getTranslated()); builder.append("\n").append(Captions.HELP_FOOTER.getTranslated());
MainUtil.sendMessage(player, builder.toString(), false); MainUtil.sendMessage(player, builder.toString(), false);
return true; return true;

View File

@ -13,8 +13,12 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.List; import java.util.List;
@CommandDeclaration(command = "inbox", description = "Review the comments for a plot", @CommandDeclaration(command = "inbox",
usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) description = "Review the comments for a plot",
usage = "/plot inbox [inbox] [delete <index>|clear|page]",
permission = "plots.inbox",
category = CommandCategory.CHAT,
requiredType = RequiredType.PLAYER)
public class Inbox extends SubCommand { public class Inbox extends SubCommand {
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) { public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
@ -40,8 +44,7 @@ public class Inbox extends SubCommand {
StringBuilder string = new StringBuilder(); StringBuilder string = new StringBuilder();
string.append(StringMan string.append(StringMan
.replaceAll(Captions.COMMENT_LIST_HEADER_PAGED.getTranslated(), "%amount%", .replaceAll(Captions.COMMENT_LIST_HEADER_PAGED.getTranslated(), "%amount%",
comments.length, "%cur", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + '\n');
page + 1, "%max", totalPages + 1, "%word", "all") + '\n');
// This might work xD // This might work xD
for (int x = page * 12; x < max; x++) { for (int x = page * 12; x < max; x++) {

View File

@ -4,19 +4,17 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.HideInfoFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import java.util.UUID; @CommandDeclaration(command = "info",
aliases = "i",
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info", description = "Display plot info",
usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO) usage = "/plot info <id> [-f, to force info]",
category = CommandCategory.INFO)
public class Info extends SubCommand { public class Info extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
@ -70,7 +68,7 @@ public class Info extends SubCommand {
} }
// hide-info flag // hide-info flag
if (plot.getFlag(Flags.HIDE_INFO).orElse(false)) { if (plot.getFlag(HideInfoFlag.class)) {
boolean allowed = false; boolean allowed = false;
for (final String argument : args) { for (final String argument : args) {
if (argument.equalsIgnoreCase("-f")) { if (argument.equalsIgnoreCase("-f")) {
@ -89,37 +87,6 @@ public class Info extends SubCommand {
} }
} }
if (args.length == 1 && args[0].equalsIgnoreCase("inv")) {
PlotInventory inv = new PlotInventory(player) {
@Override public boolean onClick(int index) {
// TODO InfoInventory not implemented yet!!!!!!!!
// See plot rating or musicsubcommand on examples
return false;
}
};
UUID uuid = player.getUUID();
String name = MainUtil.getName(plot.getOwner());
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info",
"&cID: &6" + plot.getId().toString(), "&cOwner:&6" + name,
"&cAlias: &6" + plot.getAlias(),
"&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(),
"&cCan Build: &6" + plot.isAdded(uuid),
"&cSeen: &6" + MainUtil.secToTime((int) (ExpireManager.IMP.getAge(plot) / 1000)),
"&cIs Denied: &6" + plot.isDenied(uuid)));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted",
"&cAmount: &6" + plot.getTrusted().size(),
"&8Click to view a list of the trusted users"));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers",
"&cAmount: &6" + plot.getMembers().size(),
"&8Click to view a list of plot members"));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", "&cDenied",
"&cAmount: &6" + plot.getDenied().size(),
"&8Click to view a list of denied players"));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", "&cFlags",
"&cAmount: &6" + plot.getFlags().size(), "&8Click to view a list of plot flags"));
inv.openInventory();
return true;
}
boolean hasOwner = plot.hasOwner(); boolean hasOwner = plot.hasOwner();
// Wildcard player {added} // Wildcard player {added}
boolean containsEveryone = plot.getTrusted().contains(DBFunc.EVERYONE); boolean containsEveryone = plot.getTrusted().contains(DBFunc.EVERYONE);
@ -130,7 +97,7 @@ public class Info extends SubCommand {
plot.getId().x + ";" + plot.getId().y); plot.getId().x + ";" + plot.getId().y);
return true; return true;
} }
String info = Captions.PLOT_INFO.getTranslated(); String info = Captions.PLOT_INFO_FORMAT.getTranslated();
boolean full; boolean full;
if (arg != null) { if (arg != null) {
info = getCaption(arg); info = getCaption(arg);

View File

@ -17,9 +17,14 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "kick", aliases = "k", description = "Kick a player from your plot", @CommandDeclaration(command = "kick",
permission = "plots.kick", usage = "/plot kick <player|*>", category = CommandCategory.TELEPORT, aliases = "k",
requiredType = RequiredType.PLAYER) public class Kick extends SubCommand { description = "Kick a player from your plot",
permission = "plots.kick",
usage = "/plot kick <player|*>",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.PLAYER)
public class Kick extends SubCommand {
public Kick() { public Kick() {
super(Argument.PlayerName); super(Argument.PlayerName);

View File

@ -15,8 +15,11 @@ import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "leave", @CommandDeclaration(command = "leave",
description = "Removes self from being trusted or a member of the plot", description = "Removes self from being trusted or a member of the plot",
permission = "plots.leave", usage = "/plot leave", category = CommandCategory.CLAIMING, permission = "plots.leave",
requiredType = RequiredType.PLAYER) public class Leave extends Command { usage = "/plot leave",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER)
public class Leave extends Command {
public Leave() { public Leave() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }

View File

@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Rating; import com.github.intellectualsites.plotsquared.plot.object.Rating;
@ -21,9 +21,13 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot", @CommandDeclaration(command = "like",
usage = "/plot like [next|purge]", category = CommandCategory.INFO, permission = "plots.like",
requiredType = RequiredType.PLAYER) public class Like extends SubCommand { description = "Like the plot",
usage = "/plot like [next|purge]",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
public class Like extends SubCommand {
protected static boolean handleLike(final PlotPlayer player, String[] args, protected static boolean handleLike(final PlotPlayer player, String[] args,
final boolean like) { final boolean like) {
@ -41,8 +45,8 @@ import java.util.UUID;
return v2 > v1 ? 1 : -1; return v2 > v1 ? 1 : -1;
}); });
for (final Plot plot : plots) { for (final Plot plot : plots) {
if ((!Settings.Done.REQUIRED_FOR_RATINGS || plot.hasFlag(Flags.DONE)) if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot
&& plot.isBasePlot() && (!plot.getLikes().containsKey(uuid))) { .isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
plot.teleportPlayer(player, TeleportCause.COMMAND); plot.teleportPlayer(player, TeleportCause.COMMAND);
MainUtil.sendMessage(player, Captions.RATE_THIS); MainUtil.sendMessage(player, Captions.RATE_THIS);
return true; return true;
@ -78,7 +82,7 @@ import java.util.UUID;
sendMessage(player, Captions.RATING_NOT_YOUR_OWN); sendMessage(player, Captions.RATING_NOT_YOUR_OWN);
return false; return false;
} }
if (Settings.Done.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) { if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
sendMessage(player, Captions.RATING_NOT_DONE); sendMessage(player, Captions.RATING_NOT_DONE);
return false; return false;
} }
@ -105,15 +109,15 @@ import java.util.UUID;
} }
} }
}; };
if (plot.getSettings().ratings == null) { if (plot.getSettings().getRatings() == null) {
if (!Settings.Enabled_Components.RATING_CACHE) { if (!Settings.Enabled_Components.RATING_CACHE) {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
plot.getSettings().ratings = DBFunc.getRatings(plot); plot.getSettings().setRatings(DBFunc.getRatings(plot));
run.run(); run.run();
}); });
return true; return true;
} }
plot.getSettings().ratings = new HashMap<>(); plot.getSettings().setRatings(new HashMap<>());
} }
run.run(); run.run();
return true; return true;

View File

@ -3,8 +3,10 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.PlotSquared.SortType; import com.github.intellectualsites.plotsquared.plot.PlotSquared.SortType;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage; import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
@ -24,11 +26,13 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "list", aliases = {"l", "find", "search"}, description = "List plots", @CommandDeclaration(command = "list",
permission = "plots.list", category = CommandCategory.INFO, aliases = {"l", "find", "search"},
description = "List plots",
permission = "plots.list",
category = CommandCategory.INFO,
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]") usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]")
public class ListCmd extends SubCommand { public class ListCmd extends SubCommand {
@ -136,11 +140,11 @@ public class ListCmd extends SubCommand {
Captions.PERMISSION_LIST_WORLD); Captions.PERMISSION_LIST_WORLD);
return false; return false;
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
Captions.format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(),
Captions.format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); world));
return false; return false;
} }
plots = new ArrayList<>(PlotSquared.get().getPlots(world)); plots = new ArrayList<>(PlotSquared.get().getPlots(world));
@ -161,11 +165,11 @@ public class ListCmd extends SubCommand {
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_AREA); .sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_AREA);
return false; return false;
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
Captions.format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(),
Captions.format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); world));
return false; return false;
} }
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots()); plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
@ -186,14 +190,13 @@ public class ListCmd extends SubCommand {
} }
plots = new ArrayList<>(); plots = new ArrayList<>();
for (Plot plot : PlotSquared.get().getPlots()) { for (Plot plot : PlotSquared.get().getPlots()) {
Optional<String> flag = plot.getFlag(Flags.DONE); if (DoneFlag.isDone(plot)) {
if (flag.isPresent()) {
plots.add(plot); plots.add(plot);
} }
} }
plots.sort((a, b) -> { plots.sort((a, b) -> {
String va = "" + a.getFlags().get(Flags.DONE); String va = a.getFlag(DoneFlag.class);
String vb = "" + b.getFlags().get(Flags.DONE); String vb = b.getFlag(DoneFlag.class);
if (MathMan.isInteger(va)) { if (MathMan.isInteger(va)) {
if (MathMan.isInteger(vb)) { if (MathMan.isInteger(vb)) {
return Integer.parseInt(vb) - Integer.parseInt(va); return Integer.parseInt(vb) - Integer.parseInt(va);
@ -248,8 +251,7 @@ public class ListCmd extends SubCommand {
} }
plots = new ArrayList<>(); plots = new ArrayList<>();
for (Plot plot : PlotSquared.get().getPlots()) { for (Plot plot : PlotSquared.get().getPlots()) {
Optional<Double> price = plot.getFlag(Flags.PRICE); if (plot.getFlag(PriceFlag.class) > 0) {
if (price.isPresent()) {
plots.add(plot); plots.add(plot);
} }
} }
@ -309,11 +311,12 @@ public class ListCmd extends SubCommand {
Captions.PERMISSION_LIST_WORLD); Captions.PERMISSION_LIST_WORLD);
return false; return false;
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, Captions .format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(),
.format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]))) { args[0]))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0])); .format(player, Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(),
args[0]));
return false; return false;
} }
plots = new ArrayList<>(PlotSquared.get().getPlots(args[0])); plots = new ArrayList<>(PlotSquared.get().getPlots(args[0]));
@ -383,18 +386,10 @@ public class ListCmd extends SubCommand {
Captions.PLOT_INFO_MEMBERS.getTranslated() Captions.PLOT_INFO_MEMBERS.getTranslated()
.replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))) .replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers()))))
.color("$1"); .color("$1");
String strFlags = StringMan.join(plot.getFlags().values(), ",");
if (strFlags.isEmpty()) {
strFlags = Captions.NONE.getTranslated();
}
PlotMessage flags = new PlotMessage().text(Captions.color(
Captions.PLOT_INFO_FLAGS.getTranslated().replaceAll("%flags%", strFlags)))
.color("$1");
message.text("[").color("$3").text(i + "") message.text("[").color("$3").text(i + "")
.command("/plot visit " + plot.getArea() + ";" + plot.getId()) .command("/plot visit " + plot.getArea() + ";" + plot.getId())
.tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1") .tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1")
.text("]").color("$3").text(" " + plot.toString()) .text("]").color("$3").text(" " + plot.toString()).tooltip(trusted, members)
.tooltip(trusted, members, flags)
.command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color) .command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color)
.text(" - ").color("$2"); .text(" - ").color("$2");
String prefix = ""; String prefix = "";

View File

@ -19,9 +19,14 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
@CommandDeclaration(command = "load", aliases = "restore", category = CommandCategory.SCHEMATIC, @CommandDeclaration(command = "load",
requiredType = RequiredType.NONE, description = "Load your plot", permission = "plots.load", aliases = "restore",
usage = "/plot load") public class Load extends SubCommand { category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
description = "Load your plot",
permission = "plots.load",
usage = "/plot load")
public class Load extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorld();

View File

@ -79,15 +79,14 @@ public class MainCommand extends Command {
new DebugClaimTest(); new DebugClaimTest();
new Inbox(); new Inbox();
new Comment(); new Comment();
new Database(); new DatabaseCommand();
new Swap(); new Swap();
new Music(); new Music();
new DebugRoadRegen(); new DebugRoadRegen();
new Trust(); new Trust();
new DebugExec(); new DebugExec();
new FlagCmd(); new FlagCommand();
new Target(); new Target();
new DebugFixFlags();
new Move(); new Move();
new Condense(); new Condense();
new Copy(); new Copy();
@ -206,7 +205,8 @@ public class MainCommand extends Command {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
Plot newPlot = Plot.fromString(area, args[0]); Plot newPlot = Plot.fromString(area, args[0]);
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea() if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea()
.equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_SUDO_AREA)) .equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN)
|| Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_SUDO_AREA))
&& !newPlot.isDenied(player.getUUID())) { && !newPlot.isDenied(player.getUUID())) {
Location newLoc = newPlot.getCenter(); Location newLoc = newPlot.getCenter();
if (player.canTeleport(newLoc)) { if (player.canTeleport(newLoc)) {

View File

@ -20,10 +20,14 @@ import java.util.UUID;
import static com.github.intellectualsites.plotsquared.plot.object.Direction.getFromIndex; import static com.github.intellectualsites.plotsquared.plot.object.Direction.getFromIndex;
@CommandDeclaration(command = "merge", aliases = "m", @CommandDeclaration(command = "merge",
aliases = "m",
description = "Merge the plot you are standing on with another plot", description = "Merge the plot you are standing on with another plot",
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]", permission = "plots.merge",
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, confirmation = true) usage = "/plot merge <all|n|e|s|w> [removeroads]",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
confirmation = true)
public class Merge extends SubCommand { public class Merge extends SubCommand {
public static final String[] values = new String[] {"north", "east", "south", "west", "auto"}; public static final String[] values = new String[] {"north", "east", "south", "west", "auto"};
@ -160,8 +164,7 @@ public class Merge extends SubCommand {
} }
Plot adjacent = plot.getRelative(direction); Plot adjacent = plot.getRelative(direction);
if (adjacent == null || !adjacent.hasOwner() || adjacent if (adjacent == null || !adjacent.hasOwner() || adjacent
.getMerged((direction.getIndex() + 2) % 4) .getMerged((direction.getIndex() + 2) % 4) || adjacent.isOwner(uuid)) {
|| adjacent.isOwner(uuid)) {
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE); MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
return false; return false;
} }

View File

@ -10,10 +10,13 @@ import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
/** /**
* @author manuelgu, altered by Citymonstret * @author manuelgu, altered by Citymonstret
*/ */
@CommandDeclaration(command = "middle", aliases = {"center", "centre"}, @CommandDeclaration(command = "middle",
description = "Teleports you to the center of the plot", usage = "/plot middle", aliases = {"center", "centre"},
category = CommandCategory.TELEPORT, requiredType = RequiredType.PLAYER) public class Middle description = "Teleports you to the center of the plot",
extends SubCommand { usage = "/plot middle",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.PLAYER)
public class Middle extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] arguments) { @Override public boolean onCommand(PlotPlayer player, String[] arguments) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -10,9 +10,13 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot", @CommandDeclaration(usage = "/plot move <X;Z>",
permission = "plots.move", category = CommandCategory.CLAIMING, command = "move",
requiredType = RequiredType.PLAYER) public class Move extends SubCommand { description = "Move a plot",
permission = "plots.move",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER)
public class Move extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -2,7 +2,8 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory; import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
@ -14,10 +15,13 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Locale; import java.util.Locale;
@CommandDeclaration(command = "music", permission = "plots.music", @CommandDeclaration(command = "music",
description = "Play music in your plot", usage = "/plot music", permission = "plots.music",
category = CommandCategory.APPEARANCE, requiredType = RequiredType.PLAYER) public class Music description = "Play music in your plot",
extends SubCommand { usage = "/plot music",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.PLAYER)
public class Music extends SubCommand {
private static final Collection<String> DISCS = Arrays private static final Collection<String> DISCS = Arrays
.asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp", .asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp",
@ -41,10 +45,11 @@ import java.util.Locale;
return true; return true;
} }
if (item.getType() == ItemTypes.BEDROCK) { if (item.getType() == ItemTypes.BEDROCK) {
plot.removeFlag(Flags.MUSIC); plot.removeFlag(MusicFlag.class);
Captions.FLAG_REMOVED.send(player); Captions.FLAG_REMOVED.send(player);
} else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) { } else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) {
plot.setFlag(Flags.MUSIC, item.getType().getId()); plot.setFlag(GlobalFlagContainer.getInstance().getFlag(MusicFlag.class)
.createFlagInstance(item.getType()));
Captions.FLAG_ADDED.send(player); Captions.FLAG_ADDED.send(player);
} else { } else {
Captions.FLAG_NOT_ADDED.send(player); Captions.FLAG_NOT_ADDED.send(player);

View File

@ -11,8 +11,12 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", @CommandDeclaration(command = "near",
usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) aliases = "n",
description = "Display nearby players",
usage = "/plot near",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
public class Near extends Command { public class Near extends Command {
public Near() { public Near() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -14,10 +14,15 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "setowner", permission = "plots.set.owner", @CommandDeclaration(command = "setowner",
description = "Set the plot owner", usage = "/plot setowner <player>", permission = "plots.set.owner",
aliases = {"owner", "so", "seto"}, category = CommandCategory.CLAIMING, description = "Set the plot owner",
requiredType = RequiredType.NONE, confirmation = true) public class Owner extends SetCommand { usage = "/plot setowner <player>",
aliases = {"owner", "so", "seto"},
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
confirmation = true)
public class Owner extends SetCommand {
@Override public boolean set(final PlotPlayer player, final Plot plot, String value) { @Override public boolean set(final PlotPlayer player, final Plot plot, String value) {
if (value == null || value.isEmpty()) { if (value == null || value.isEmpty()) {

View File

@ -8,15 +8,23 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.isPremium; import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.isPremium;
@CommandDeclaration(command = "plugin", permission = "plots.use", @CommandDeclaration(command = "plugin",
description = "Show plugin information", usage = "/plot plugin", aliases = "version", permission = "plots.use",
category = CommandCategory.INFO) public class PluginCmd extends SubCommand { description = "Show plugin information",
usage = "/plot plugin",
aliases = "version",
category = CommandCategory.INFO)
public class PluginCmd extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
TaskManager.IMP.taskAsync(() -> { TaskManager.IMP.taskAsync(() -> {
MainUtil.sendMessage(player, String.format("$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)", PlotSquared.get().getVersion())); MainUtil.sendMessage(player, String.format(
MainUtil.sendMessage(player, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault"); "$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)",
MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki"); PlotSquared.get().getVersion()));
MainUtil.sendMessage(player,
"$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault");
MainUtil.sendMessage(player,
"$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki");
MainUtil.sendMessage(player, "$2>> $1&lPremium$2: $1" + isPremium()); MainUtil.sendMessage(player, "$2>> $1&lPremium$2: $1" + isPremium());
}); });
return true; return true;

View File

@ -18,11 +18,14 @@ import java.util.HashSet;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]",
usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]", command = "purge",
command = "purge", permission = "plots.admin", description = "Purge all plots for a world", permission = "plots.admin",
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE, description = "Purge all plots for a world",
confirmation = true) public class Purge extends SubCommand { category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE,
confirmation = true)
public class Purge extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) { if (args.length == 0) {

View File

@ -6,7 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory; import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack; import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack;
@ -24,9 +24,14 @@ import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot", @CommandDeclaration(command = "rate",
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO, permission = "plots.rate",
requiredType = RequiredType.PLAYER) public class Rate extends SubCommand { description = "Rate the plot",
usage = "/plot rate [#|next|purge]",
aliases = "rt",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
public class Rate extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 1) { if (args.length == 1) {
@ -53,7 +58,7 @@ import java.util.UUID;
}); });
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
for (Plot p : plots) { for (Plot p : plots) {
if ((!Settings.Done.REQUIRED_FOR_RATINGS || p.hasFlag(Flags.DONE)) && 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); p.teleportPlayer(player, TeleportCause.COMMAND);
@ -91,7 +96,7 @@ import java.util.UUID;
sendMessage(player, Captions.RATING_NOT_YOUR_OWN); sendMessage(player, Captions.RATING_NOT_YOUR_OWN);
return false; return false;
} }
if (Settings.Done.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) { if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
sendMessage(player, Captions.RATING_NOT_DONE); sendMessage(player, Captions.RATING_NOT_DONE);
return false; return false;
} }
@ -146,15 +151,15 @@ import java.util.UUID;
inventory.openInventory(); inventory.openInventory();
} }
}; };
if (plot.getSettings().ratings == null) { if (plot.getSettings().getRatings() == null) {
if (!Settings.Enabled_Components.RATING_CACHE) { if (!Settings.Enabled_Components.RATING_CACHE) {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
plot.getSettings().ratings = DBFunc.getRatings(plot); plot.getSettings().setRatings(DBFunc.getRatings(plot));
run.run(); run.run();
}); });
return true; return true;
} }
plot.getSettings().ratings = new HashMap<>(); plot.getSettings().setRatings(new HashMap<>());
} }
run.run(); run.run();
return true; return true;
@ -187,15 +192,15 @@ import java.util.UUID;
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString()); sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
} }
}; };
if (plot.getSettings().ratings == null) { if (plot.getSettings().getRatings() == null) {
if (!Settings.Enabled_Components.RATING_CACHE) { if (!Settings.Enabled_Components.RATING_CACHE) {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
plot.getSettings().ratings = DBFunc.getRatings(plot); plot.getSettings().setRatings(DBFunc.getRatings(plot));
run.run(); run.run();
}); });
return true; return true;
} }
plot.getSettings().ratings = new HashMap<>(); plot.getSettings().setRatings(new HashMap<>());
} }
run.run(); run.run();
return true; return true;

View File

@ -12,9 +12,12 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "regenallroads", @CommandDeclaration(command = "regenallroads",
description = "Regenerate all roads in the map using the set road schematic", description = "Regenerate all roads in the map using the set road schematic",
aliases = {"rgar"}, usage = "/plot regenallroads <world> [height]", aliases = {"rgar"},
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE, usage = "/plot regenallroads <world> [height]",
permission = "plots.regenallroads") public class RegenAllRoads extends SubCommand { category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE,
permission = "plots.regenallroads")
public class RegenAllRoads extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
int height = 0; int height = 0;

View File

@ -13,8 +13,12 @@ import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "relight", description = "Relight your plot", usage = "/plot relight", @CommandDeclaration(command = "relight",
category = CommandCategory.DEBUG, requiredType = RequiredType.PLAYER) public class Relight extends Command { description = "Relight your plot",
usage = "/plot relight",
category = CommandCategory.DEBUG,
requiredType = RequiredType.PLAYER)
public class Relight extends Command {
public Relight() { public Relight() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }

View File

@ -12,9 +12,13 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
@CommandDeclaration(command = "reload", aliases = "rl", permission = "plots.admin.command.reload", @CommandDeclaration(command = "reload",
description = "Reload translations and world settings", usage = "/plot reload", aliases = "rl",
category = CommandCategory.ADMINISTRATION) public class Reload extends SubCommand { permission = "plots.admin.command.reload",
description = "Reload translations and world settings",
usage = "/plot reload",
category = CommandCategory.ADMINISTRATION)
public class Reload extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
try { try {

View File

@ -17,10 +17,14 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"}, @CommandDeclaration(command = "remove",
description = "Remove a player from a plot", usage = "/plot remove <player|*>", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"},
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, description = "Remove a player from a plot",
permission = "plots.remove") public class Remove extends SubCommand { usage = "/plot remove <player|*>",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.remove")
public class Remove extends SubCommand {
public Remove() { public Remove() {
super(Argument.PlayerName); super(Argument.PlayerName);

View File

@ -18,9 +18,13 @@ import java.net.URL;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "save", aliases = {"backup"}, description = "Save your plot", @CommandDeclaration(command = "save",
category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, aliases = {"backup"},
permission = "plots.save") public class Save extends SubCommand { description = "Save your plot",
category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
permission = "plots.save")
public class Save extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorld();

View File

@ -23,9 +23,12 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "schematic", permission = "plots.schematic", @CommandDeclaration(command = "schematic",
description = "Schematic command", aliases = {"sch", "schem"}, permission = "plots.schematic",
category = CommandCategory.SCHEMATIC, usage = "/plot schematic <save|saveall|paste>") description = "Schematic command",
aliases = {"sch", "schem"},
category = CommandCategory.SCHEMATIC,
usage = "/plot schematic <save|saveall|paste>")
public class SchematicCmd extends SubCommand { public class SchematicCmd extends SubCommand {
private boolean running = false; private boolean running = false;
@ -136,7 +139,8 @@ public class SchematicCmd extends SubCommand {
return false; return false;
} else { } else {
MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_STARTED); MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_STARTED);
MainUtil.sendMessage(player, "&3Plot&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots..."); MainUtil.sendMessage(player,
"&3Plot&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots...");
} }
break; break;
} }

View File

@ -2,10 +2,8 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -19,16 +17,18 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@CommandDeclaration(command = "set", description = "Set a plot value", aliases = {"s"}, @CommandDeclaration(command = "set",
usage = "/plot set <biome|alias|home|flag> <value...>", permission = "plots.set", description = "Set a plot value",
category = CommandCategory.APPEARANCE, requiredType = RequiredType.NONE) public class Set aliases = {"s"},
extends SubCommand { usage = "/plot set <biome|alias|home|flag> <value...>",
permission = "plots.set",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.NONE)
public class Set extends SubCommand {
public static final String[] values = new String[] {"biome", "alias", "home", "flag"}; public static final String[] values = new String[] {"biome", "alias", "home"};
public static final String[] aliases = new String[] {"b", "w", "wf", "f", "a", "h", "fl"}; public static final String[] aliases = new String[] {"b", "w", "wf", "a", "h"};
private final SetCommand component; private final SetCommand component;
@ -50,9 +50,10 @@ import java.util.stream.IntStream;
for (String component : components) { for (String component : components) {
if (component.equalsIgnoreCase(args[0])) { if (component.equalsIgnoreCase(args[0])) {
if (!Permissions.hasPermission(player, Captions if (!Permissions.hasPermission(player, CaptionUtility
.format(player, Captions.PERMISSION_SET_COMPONENT.getTranslated(), component))) { .format(player, Captions.PERMISSION_SET_COMPONENT.getTranslated(),
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions component))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(player, Captions.PERMISSION_SET_COMPONENT.getTranslated(), .format(player, Captions.PERMISSION_SET_COMPONENT.getTranslated(),
component)); component));
return false; return false;
@ -82,16 +83,14 @@ import java.util.stream.IntStream;
} }
public boolean noArgs(PlotPlayer player) { public boolean noArgs(PlotPlayer player) {
ArrayList<String> newValues = ArrayList<String> newValues = new ArrayList<>(Arrays.asList("biome", "alias", "home"));
new ArrayList<>(Arrays.asList("biome", "alias", "home", "flag"));
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if (plot != null) { if (plot != null) {
newValues.addAll( newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
} }
MainUtil MainUtil.sendMessage(player,
.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + StringMan Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + StringMan
.join(newValues, Captions.BLOCK_LIST_SEPARATOR.formatted())); .join(newValues, Captions.BLOCK_LIST_SEPARATOR.formatted()));
return false; return false;
} }
@ -114,22 +113,11 @@ import java.util.stream.IntStream;
return false; return false;
} }
// components // components
HashSet<String> components = new HashSet<>( HashSet<String> components =
Arrays.asList(plot.getManager().getPlotComponents(plot.getId()))); new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
if (components.contains(args[0].toLowerCase())) { if (components.contains(args[0].toLowerCase())) {
return this.component.onCommand(player, Arrays.copyOfRange(args, 0, args.length)); return this.component.onCommand(player, Arrays.copyOfRange(args, 0, args.length));
} }
// flag
Flag<?> flag = FlagManager.getFlag(args[0].toLowerCase());
if (Flags.getFlags().contains(flag)) {
String a = "";
if (args.length > 1) {
a = IntStream.range(1, args.length).mapToObj(x -> " " + args[x])
.collect(Collectors.joining());
}
MainCommand.onCommand(player, ("flag set " + args[0] + a).split(" "));
return true;
}
return noArgs(player); return noArgs(player);
} }
} }

View File

@ -1,5 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.commands; package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -17,21 +18,21 @@ public abstract class SetCommand extends SubCommand {
return !sendMessage(player, Captions.NOT_IN_PLOT); return !sendMessage(player, Captions.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
Captions.format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(),
Captions.format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId())); getFullId()));
MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED); MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED);
return false; return false;
} }
} }
if (!plot.isOwner(player.getUUID())) { if (!plot.isOwner(player.getUUID())) {
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
Captions.format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(),
Captions.format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId())); getFullId()));
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -8,9 +8,13 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "sethome", permission = "plots.set.home", @CommandDeclaration(command = "sethome",
description = "Set the plot home to your current position", usage = "/plot sethome [none]", permission = "plots.set.home",
aliases = {"sh", "seth"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) description = "Set the plot home to your current position",
usage = "/plot sethome [none]",
aliases = {"sh", "seth"},
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER)
public class SetHome extends SetCommand { public class SetHome extends SetCommand {
@Override public boolean set(PlotPlayer player, Plot plot, String value) { @Override public boolean set(PlotPlayer player, Plot plot, String value) {

View File

@ -34,9 +34,19 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "setup", permission = "plots.admin.command.setup", @CommandDeclaration(command = "setup",
description = "Setup wizard for plot worlds", usage = "/plot setup", aliases = {"create"}, permission = "plots.admin.command.setup",
category = CommandCategory.ADMINISTRATION) public class Setup extends SubCommand { description = "Setup wizard for plot worlds",
usage = "/plot setup",
aliases = {"create"},
category = CommandCategory.ADMINISTRATION)
public class Setup extends SubCommand {
private static boolean d(String s) {
return s.chars().allMatch((i) -> {
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46;
});
}
public void displayGenerators(PlotPlayer player) { public void displayGenerators(PlotPlayer player) {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
@ -336,11 +346,7 @@ import java.util.UUID;
return false; return false;
} }
private static boolean d(String s) {
return s.chars().allMatch((i) -> {
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46;
});
}
private static final class StepPickGenerator extends SetupStep { private static final class StepPickGenerator extends SetupStep {
@Getter private String generator; @Getter private String generator;
@ -414,7 +420,7 @@ import java.util.UUID;
} }
@Override public boolean parseInput(String input) { @Override public boolean parseInput(String input) {
if (!WORLD_TYPES.keySet().contains(input.toLowerCase())) { if (!WORLD_TYPES.containsKey(input.toLowerCase())) {
return false; return false;
} }
this.worldType = input.toLowerCase(); this.worldType = input.toLowerCase();
@ -427,7 +433,9 @@ import java.util.UUID;
} }
@ToString @EqualsAndHashCode(of = "uuid") @AllArgsConstructor @ToString
@EqualsAndHashCode(of = "uuid")
@AllArgsConstructor
private static class SetupContext { private static class SetupContext {
private final UUID uuid; private final UUID uuid;

View File

@ -8,8 +8,12 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(usage = "/plot swap <X;Z>", command = "swap", description = "Swap two plots", @CommandDeclaration(usage = "/plot swap <X;Z>",
aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER) command = "swap",
description = "Swap two plots",
aliases = {"switch"},
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER)
public class Swap extends SubCommand { public class Swap extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -10,10 +10,13 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
@CommandDeclaration(command = "target", usage = "/plot target <<plot>|nearest>", @CommandDeclaration(command = "target",
description = "Target a plot with your compass", permission = "plots.target", usage = "/plot target <<plot>|nearest>",
requiredType = RequiredType.PLAYER, category = CommandCategory.INFO) public class Target description = "Target a plot with your compass",
extends SubCommand { permission = "plots.target",
requiredType = RequiredType.PLAYER,
category = CommandCategory.INFO)
public class Target extends SubCommand {
public Target() { public Target() {
super(Argument.PlotID); super(Argument.PlotID);

View File

@ -29,10 +29,12 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@CommandDeclaration(command = "template", permission = "plots.admin", @CommandDeclaration(command = "template",
permission = "plots.admin",
description = "Create or use a world template", description = "Create or use a world template",
usage = "/plot template [import|export] <world> <template>", usage = "/plot template [import|export] <world> <template>",
category = CommandCategory.ADMINISTRATION) public class Template extends SubCommand { category = CommandCategory.ADMINISTRATION)
public class Template extends SubCommand {
public static boolean extractAllFiles(String world, String template) { public static boolean extractAllFiles(String world, String template) {
try { try {

View File

@ -8,16 +8,22 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "toggle", aliases = {"attribute"}, permission = "plots.use", @CommandDeclaration(command = "toggle",
aliases = {"attribute"},
permission = "plots.use",
usage = "/plot toggle <chat|chatspy|clear-confirmation|time|titles|worldedit>", usage = "/plot toggle <chat|chatspy|clear-confirmation|time|titles|worldedit>",
description = "Toggle per user settings", requiredType = RequiredType.NONE, description = "Toggle per user settings",
category = CommandCategory.SETTINGS) public class Toggle extends Command { requiredType = RequiredType.NONE,
category = CommandCategory.SETTINGS)
public class Toggle extends Command {
public Toggle() { public Toggle() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@CommandDeclaration(command = "chatspy", aliases = {"spy"}, @CommandDeclaration(command = "chatspy",
permission = "plots.admin.command.chat", description = "Toggle plot chat spy") aliases = {"spy"},
permission = "plots.admin.command.chat",
description = "Toggle plot chat spy")
public void chatspy(Command command, PlotPlayer player, String[] args, public void chatspy(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -28,8 +34,10 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "worldedit", aliases = {"we", "wea"}, @CommandDeclaration(command = "worldedit",
permission = "plots.worldedit.bypass", description = "Toggle worldedit area restrictions") aliases = {"we", "wea"},
permission = "plots.worldedit.bypass",
description = "Toggle worldedit area restrictions")
public void worldedit(Command command, PlotPlayer player, String[] args, public void worldedit(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -40,7 +48,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "chat", permission = "plots.toggle.chat", @CommandDeclaration(command = "chat",
permission = "plots.toggle.chat",
description = "Toggle plot chat") description = "Toggle plot chat")
public void chat(Command command, PlotPlayer player, String[] args, public void chat(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
@ -53,7 +62,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
@CommandDeclaration(command = "clear-confirmation", @CommandDeclaration(command = "clear-confirmation",
permission = "plots.admin.command.autoclear", description = "Toggle autoclear confirmation") permission = "plots.admin.command.autoclear",
description = "Toggle autoclear confirmation")
public void clearConfirmation(Command command, PlotPlayer player, String[] args, public void clearConfirmation(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -64,7 +74,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "titles", permission = "plots.toggle.titles", @CommandDeclaration(command = "titles",
permission = "plots.toggle.titles",
description = "Toggle plot title messages") description = "Toggle plot title messages")
public void titles(Command command, PlotPlayer player, String[] args, public void titles(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
@ -76,8 +87,9 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "time", permission = "plots.toggle.time", @CommandDeclaration(command = "time",
description = "Toggle plot time settings") permission = "plots.toggle.time",
description = "Toggle plot time settings")
public void time(Command command, PlotPlayer player, String[] args, public void time(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {

View File

@ -30,10 +30,13 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "trim", permission = "plots.admin", @CommandDeclaration(command = "trim",
permission = "plots.admin",
description = "Delete unmodified portions of your plotworld", description = "Delete unmodified portions of your plotworld",
usage = "/plot trim <world> [regenerate]", requiredType = RequiredType.CONSOLE, usage = "/plot trim <world> [regenerate]",
category = CommandCategory.ADMINISTRATION) public class Trim extends SubCommand { requiredType = RequiredType.CONSOLE,
category = CommandCategory.ADMINISTRATION)
public class Trim extends SubCommand {
public static ArrayList<Plot> expired = null; public static ArrayList<Plot> expired = null;
private static volatile boolean TASK = false; private static volatile boolean TASK = false;
@ -177,18 +180,20 @@ import java.util.Set;
} }
int bx = cbx << 4; int bx = cbx << 4;
int bz = cbz << 4; int bz = cbz << 4;
CuboidRegion region = RegionUtil.createRegion(bx, bx + 511, bz, bz + 511); CuboidRegion region =
RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
for (Plot plot : PlotSquared.get().getPlots(world)) { for (Plot plot : PlotSquared.get().getPlots(world)) {
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
Location top = plot.getExtendedTopAbs(); Location top = plot.getExtendedTopAbs();
CuboidRegion plotReg = CuboidRegion plotReg = RegionUtil
RegionUtil.createRegion(bot.getX(), top.getX(), bot.getZ(), .createRegion(bot.getX(), top.getX(), bot.getZ(), top.getZ());
top.getZ());
if (!RegionUtil.intersects(region, plotReg)) { if (!RegionUtil.intersects(region, plotReg)) {
continue; continue;
} }
for (int x = plotReg.getMinimumPoint().getX() >> 4; x <= plotReg.getMaximumPoint().getX() >> 4; x++) { for (int x = plotReg.getMinimumPoint().getX() >> 4;
for (int z = plotReg.getMinimumPoint().getZ() >> 4; z <= plotReg.getMaximumPoint().getZ() >> 4; z++) { x <= plotReg.getMaximumPoint().getX() >> 4; x++) {
for (int z = plotReg.getMinimumPoint().getZ() >> 4;
z <= plotReg.getMaximumPoint().getZ() >> 4; z++) {
BlockVector2 loc = BlockVector2.at(x, z); BlockVector2 loc = BlockVector2.at(x, z);
chunks.remove(loc); chunks.remove(loc);
} }

View File

@ -17,10 +17,13 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.PLAYER, @CommandDeclaration(command = "trust",
aliases = {"t"},
requiredType = RequiredType.PLAYER,
usage = "/plot trust <player|*>", usage = "/plot trust <player|*>",
description = "Allow a user to build in a plot and use WorldEdit while the plot owner is offline.", description = "Allow a user to build in a plot and use WorldEdit while the plot owner is offline.",
category = CommandCategory.SETTINGS) public class Trust extends Command { category = CommandCategory.SETTINGS)
public class Trust extends Command {
public Trust() { public Trust() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -11,9 +11,13 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"}, @CommandDeclaration(command = "unlink",
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", aliases = {"u", "unmerge"},
requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true) description = "Unlink a mega-plot",
usage = "/plot unlink [createroads]",
requiredType = RequiredType.PLAYER,
category = CommandCategory.SETTINGS,
confirmation = true)
public class Unlink extends SubCommand { public class Unlink extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -24,10 +24,14 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "visit", permission = "plots.visit", @CommandDeclaration(command = "visit",
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]", permission = "plots.visit",
aliases = {"v", "tp", "teleport", "goto", "home", "h", "warp"}, requiredType = RequiredType.PLAYER, description = "Visit someones plot",
category = CommandCategory.TELEPORT) public class Visit extends Command { usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]",
aliases = {"v", "tp", "teleport", "goto", "home", "h", "warp"},
requiredType = RequiredType.PLAYER,
category = CommandCategory.TELEPORT)
public class Visit extends Command {
public Visit() { public Visit() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
@ -139,8 +143,8 @@ import java.util.concurrent.CompletableFuture;
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
} else { } else {
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER) && if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER) && !plot
!Flags.UNTRUSTED_VISIT.isTrue(plot)) { .getFlag(UntrustedVisitFlag.class)) {
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);
} }

View File

@ -3,9 +3,13 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "weanywhere", permission = "plots.worldedit.bypass", @CommandDeclaration(command = "weanywhere",
description = "Force bypass of WorldEdit restrictions", aliases = {"wea"}, usage = "/plot weanywhere", permission = "plots.worldedit.bypass",
requiredType = RequiredType.NONE, category = CommandCategory.ADMINISTRATION) description = "Force bypass of WorldEdit restrictions",
aliases = {"wea"},
usage = "/plot weanywhere",
requiredType = RequiredType.NONE,
category = CommandCategory.ADMINISTRATION)
@Deprecated @Deprecated
public class WE_Anywhere extends SubCommand { public class WE_Anywhere extends SubCommand {

View File

@ -0,0 +1,30 @@
package com.github.intellectualsites.plotsquared.plot.config;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
public interface Caption {
String getTranslated();
default String formatted() {
return StringMan.replaceFromMap(getTranslated(), Captions.replacements);
}
default void send(PlotPlayer caller, String... args) {
send(caller, (Object[]) args);
}
default void send(PlotPlayer caller, Object... args) {
String msg = CaptionUtility.format(caller, this, args);
if (caller == null) {
PlotSquared.log(msg);
} else {
caller.sendMessage(msg);
}
}
boolean usePrefix();
}

View File

@ -0,0 +1,31 @@
package com.github.intellectualsites.plotsquared.plot.config;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
public class CaptionUtility {
public static String formatRaw(PlotPlayer recipient, String message, Object... args) {
final ChatFormatter.ChatContext chatContext = new ChatFormatter.ChatContext(recipient, message, args, true);
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
chatFormatter.format(chatContext);
}
return chatContext.getMessage();
}
public static String format(PlotPlayer recipient, String message, Object... args) {
final ChatFormatter.ChatContext chatContext = new ChatFormatter.ChatContext(recipient, message, args, false);
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
chatFormatter.format(chatContext);
}
return chatContext.getMessage();
}
public static String format(PlotPlayer recipient, Caption caption, Object... args) {
if (caption.usePrefix() && caption.getTranslated().length() > 0) {
return Captions.PREFIX.getTranslated() + format(recipient, caption.getTranslated(), args);
} else {
return format(recipient, caption.getTranslated(), args);
}
}
}

View File

@ -3,7 +3,6 @@ package com.github.intellectualsites.plotsquared.plot.config;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection; import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration; import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.io.File; import java.io.File;
@ -16,7 +15,7 @@ import java.util.Set;
/** /**
* Captions class. * Captions class.
*/ */
public enum Captions { public enum Captions implements Caption {
//@formatter:off //@formatter:off
//<editor-fold desc="Static Flags"> //<editor-fold desc="Static Flags">
@ -445,6 +444,9 @@ public enum Captions {
NOT_VALID_NUMBER("$2That's not a valid number within the range: %s", "Invalid"), NOT_VALID_NUMBER("$2That's not a valid number within the range: %s", "Invalid"),
NOT_VALID_PLOT_ID("$2That's not a valid plot id.", "Invalid"), NOT_VALID_PLOT_ID("$2That's not a valid plot id.", "Invalid"),
FOUND_NO_PLOTS("$2Found no plots with your search query", "Invalid"), FOUND_NO_PLOTS("$2Found no plots with your search query", "Invalid"),
NUMBER_NOT_IN_RANGE("That's not a valid number within the range: (%s, %s)", "Invalid"),
NUMBER_NOT_POSITIVE("That's not a positive number: %s", "Invalid"),
NOT_A_NUMBER("%s is not a valid number.", "Invalid"),
//</editor-fold> //</editor-fold>
//<editor-fold desc="Need"> //<editor-fold desc="Need">
NEED_BLOCK("$2You've got to specify a block", "Need"), NEED_BLOCK("$2You've got to specify a block", "Need"),
@ -463,10 +465,11 @@ public enum Captions {
PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"), PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"),
PLOT_INFO_HEADER("$3&m---------&r $1INFO $3&m---------", false, "Info"), PLOT_INFO_HEADER("$3&m---------&r $1INFO $3&m---------", false, "Info"),
PLOT_INFO_HIDDEN("$2You cannot view the information about this plot", "Info"), PLOT_INFO_HIDDEN("$2You cannot view the information about this plot", "Info"),
PLOT_INFO("$1ID: $2%id%$1&-" + "$1Alias:$2%alias%$1&-" + "$1Owner:$2%owner%$1&-" PLOT_INFO_FORMAT("$1ID: $2%id%$1&-" + "$1Area: $2%area%$1&-"
+"$1Alias:$2%alias%$1&-" + "$1Owner:$2%owner%$1&-"
+ "$1Biome: $2%biome%$1&-" + "$1Can Build: $2%build%$1&-" + "$1Rating: $2%rating%&-" + "$1Biome: $2%biome%$1&-" + "$1Can Build: $2%build%$1&-" + "$1Rating: $2%rating%&-"
+ "$1Seen: $2%seen%&-" + "$1Trusted:$2%trusted%$1&-" + "$1Members:$2%members%$1&-" + "$1Seen: $2%seen%&-" + "$1Trusted:$2%trusted%$1&-" + "$1Members:$2%members%$1&-"
+ "$1Denied:$2%denied%$1&-" + "$1Flags:$2%flags%", "Info"), + "$1Denied:$2%denied%$1&-" + "$1Flags:$2%flags%&-$1Description: $2%desc%$1", "Info"),
PLOT_INFO_FOOTER("$3&m---------&r $1INFO $3&m---------", false, "Info"), PLOT_INFO_FOOTER("$3&m---------&r $1INFO $3&m---------", false, "Info"),
PLOT_INFO_TRUSTED("$1Trusted:$2%trusted%", "Info"), PLOT_INFO_TRUSTED("$1Trusted:$2%trusted%", "Info"),
PLOT_INFO_MEMBERS("$1Members:$2%members%", "Info"), PLOT_INFO_MEMBERS("$1Members:$2%members%", "Info"),
@ -481,7 +484,8 @@ public enum Captions {
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"), PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
PLOT_INFO_SEEN("$1Seen:$2 %seen%", "Info"), PLOT_INFO_SEEN("$1Seen:$2 %seen%", "Info"),
PLOT_USER_LIST(" $1%user%$2,", "Info"), PLOT_USER_LIST(" $1%user%$2,", "Info"),
PLOT_FLAG_LIST("$1%s0:%s1$2", "Info"), PLOT_FLAG_LIST("$2%s0:%s1$3", "Info"),
PLOT_NO_DESCRIPTION("No description set.", "Info"),
INFO_SYNTAX_CONSOLE("$2/plot info X;Z", "Info"), INFO_SYNTAX_CONSOLE("$2/plot info X;Z", "Info"),
//</editor-fold> //</editor-fold>
//<editor-fold desc="Working"> //<editor-fold desc="Working">
@ -527,16 +531,32 @@ public enum Captions {
FLAG_NOT_REMOVED("$2The flag could not be removed", "Flag"), FLAG_NOT_REMOVED("$2The flag could not be removed", "Flag"),
FLAG_NOT_ADDED("$2The flag could not be added", "Flag"), FLAG_NOT_ADDED("$2The flag could not be added", "Flag"),
FLAG_REMOVED("$4Successfully removed flag", "Flag"), FLAG_REMOVED("$4Successfully removed flag", "Flag"),
FLAG_PARTIALLY_REMOVED("$4Successfully removed flag value(s)", "Flag"),
FLAG_ADDED("$4Successfully added flag", "Flag"), FLAG_ADDED("$4Successfully added flag", "Flag"),
FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "CommandConfig"), FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "CommandConfig"),
FLAG_LIST_ENTRY("$2%s: $1%s", "Flag"), FLAG_LIST_ENTRY("$2%s: $1%s", "Flag"),
FLAG_LIST_SEE_INFO("Click to view information about the flag", "Flag"),
FLAG_PARSE_ERROR("$2Failed to parse flag '%flag_name%', value '%flag_value%': %error%", "Flag"),
//</editor-fold>
//<editor-fold desc="Flag">
FLAG_INFO_HEADER("$3&m---------&r $1Plot² Flags $3&m---------", "Flag"),
FLAG_INFO_FOOTER("$3&m---------&r $1Plot² Flags $3&m---------", "Flag"),
FLAG_INFO_COLOR_KEY("$1", "Flag"),
FLAG_INFO_COLOR_VALUE("$2", "Flag"),
FLAG_INFO_NAME("Name: ", "Flag"),
FLAG_INFO_CATEGORY("Category: ", "Flag"),
FLAG_INFO_DESCRIPTION("Description: ", "Flag"),
FLAG_INFO_EXAMPLE("Example: ", "Flag"),
FLAG_INFO_DEFAULT_VALUE("Default Value: ", "Flag"),
//</editor-fold> //</editor-fold>
//<editor-fold desc="Flag category captions"> //<editor-fold desc="Flag category captions">
FLAG_CATEGORY_STRING("String Flags", "Flags"), FLAG_CATEGORY_STRING("String Flags", "Flags"),
FLAG_CATEGORY_INTEGERS("Integer Flags", "Flags"), FLAG_CATEGORY_INTEGERS("Integer Flags", "Flags"),
FLAG_CATEGORY_DOUBLES("Decimal Flags", "Flags"),
FLAG_CATEGORY_TELEPORT_DENY("Teleport Deny Flag", "Flags"), FLAG_CATEGORY_TELEPORT_DENY("Teleport Deny Flag", "Flags"),
FLAG_CATEGORY_STRING_LIST("String List Flags", "Flags"), FLAG_CATEGORY_STRING_LIST("String List Flags", "Flags"),
FLAG_CATEGORY_WEATHER("Weather Flags", "Flags"), FLAG_CATEGORY_WEATHER("Weather Flags", "Flags"),
FLAG_CATEGORY_MUSIC("Music Flags", "Flags"),
FLAG_CATEGORY_BLOCK_LIST("Material Flags", "Flags"), FLAG_CATEGORY_BLOCK_LIST("Material Flags", "Flags"),
FLAG_CATEGORY_INTERVALS("Interval Flags", "Flags"), FLAG_CATEGORY_INTERVALS("Interval Flags", "Flags"),
FLAG_CATEGORY_INTEGER_LIST("Integer List Flags", "Flags"), FLAG_CATEGORY_INTEGER_LIST("Integer List Flags", "Flags"),
@ -546,20 +566,97 @@ public enum Captions {
FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"), FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"),
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"), FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
//</editor-fold> //</editor-fold>
//<editor-fold desc="Flag descriptions">
FLAG_DESCRIPTION_ENTITY_CAP("Set to an integer value to limit the amount of entities on the plot.", "Flags"),
FLAG_DESCRIPTION_EXPLOSION("Set to `true` to enable explosions in the plot, and `false` to disable them.", "Flags"),
FLAG_DESCRIPTION_MUSIC("Set to a music disk ID (item name) to play the music disc inside of the plot.", "Flags"),
FLAG_DESCRIPTION_FLIGHT("Set to `true` to enable flight within the plot when in survival or adventure mode.", "Flags"),
FLAG_DESCRIPTION_UNTRUSTED("Set to `false` to disallow untrusted players from visiting the plot.", "Flags"),
FLAG_DESCRIPTION_DENY_EXIT("Set to `true` to disallow players from exiting the plot.", "Flags"),
FLAG_DESCRIPTION_DESCRIPTION("Plot description. Supports '&' color codes.", "Flags"),
FLAG_DESCRIPTION_GREETING("Message sent to players on plot entry. Supports '&' color codes.", "Flags"),
FLAG_DESCRIPTION_FAREWELL("Message sent to players when leaving the plot. Supports '&' color codes.", "Flags"),
FLAG_DESCRIPTION_WEATHER("Specifies the weather conditions inside of the plot.", "Flags"),
FLAG_DESCRIPTION_ANIMAL_ATTACK("Set to `true` to allow animals to be attacked in the plot.", "Flags"),
FLAG_DESCRIPTION_ANIMAL_CAP("Set to an integer value to limit the amount of animals on the plot.", "Flags"),
FLAG_DESCRIPTION_ANIMAL_INTERACT("Set to `true` to allow animals to be interacted with in the plot.", "Flags"),
FLAG_DESCRIPTION_BLOCK_BURN("Set to `true` to allow blocks to burn within the plot.", "Flags"),
FLAG_DESCRIPTION_BLOCK_IGNITION("Set to `false` to prevent blocks from igniting within the plot.", "Flags"),
FLAG_DESCRIPTION_BREAK("Define a list of materials players should be able to break even when they aren't added to the plot.", "Flags"),
FLAG_DESCRIPTION_DEVICE_INTERACT("Set to `true` to allow devices to be interacted with in the plot.", "Flags"),
FLAG_DESCRIPTION_DISABLE_PHYSICS("Set to `true` to disable block physics in the plot.", "Flags"),
FLAG_DESCRIPTION_DROP_PROTECTION("Set to `true` to prevent dropped items from being picked up by non-members of the plot.", "Flags"),
FLAG_DESCRIPTION_FEED("Specify an interval in seconds and an optional amount by which the players will be fed (amount is 1 by default).", "Flags"),
FLAG_DESCRIPTION_FORCEFIELD("Set to `true` to enable member forcefield in the plot.", "Flags"),
FLAG_DESCRIPTION_GRASS_GROW("Set to `false` to prevent grass from growing within the plot.", "Flags"),
FLAG_DESCRIPTION_HANGING_BREAK("Set to `true` to allow guests to break hanging objects in the plot.", "Flags"),
FLAG_DESCRIPTION_HANGING_PLACE("Set to `true` to allow guests to hang objects in the plot.", "Flags"),
FLAG_DESCRIPTION_HEAL("Specify an interval in seconds and an optional amount by which the players will be healed (amount is 1 by default).", "Flags"),
FLAG_DESCRIPTION_HIDE_INFO("Set to `true` to hide plot information.", "Flags"),
FLAG_DESCRIPTION_HOSTILE_ATTACK("Set to `true` to enable players to attack hostile mobs in the plot.", "Flags"),
FLAG_DESCRIPTION_HOSTILE_CAP("Set to an integer value to limit the amount of hostile entities on the plot.", "Flags"),
FLAG_DESCRIPTION_HOSTILE_INTERACT("Set to `true` to allow players to interact with hostile mobs in the plot.", "Flags"),
FLAG_DESCRIPTION_ICE_FORM("Set to `true` to allow ice to form in the plot.", "Flags"),
FLAG_DESCRIPTION_ICE_MELT("Set to `false` to disable ice melting in the plot.", "Flags"),
FLAG_DESCRIPTION_INSTABREAK("Set to `true` to allow blocks to be instantaneously broken in survival mode.", "Flags"),
FLAG_DESCRIPTION_INVINCIBLE("Set to `true` to prevent players from taking damage inside of the plot.", "Flags"),
FLAG_DESCRIPTION_ITEM_DROP("Set to `false` to prevent items from being dropped inside of the plot.", "Flags"),
FLAG_DESCRIPTION_KELP_GROW("Set to `false` to prevent kelp from growing in the plot.", "Flags"),
FLAG_DESCRIPTION_LIQUID_FLOW("Set to `false` to disable liquids from flowing within the plot.", "Flags"),
FLAG_DESCRIPTION_MISC_BREAK("Set to `true` to allow guests to break miscellaneous items.", "Flags"),
FLAG_DESCRIPTION_MISC_CAP("Set to an integer value to limit the amount of miscellaneous entities on the plot.", "Flags"),
FLAG_DESCRIPTION_MISC_INTERACT("Set to `true` to allow guests to interact with miscellaneous items.", "Flags"),
FLAG_DESCRIPTION_MISC_PLACE("Set to `true` to allow guests to place miscellaneous items.", "Flags"),
FLAG_DESCRIPTION_MOB_BREAK("Set to `true` to allow mobs to break blocks within the plot.", "Flags"),
FLAG_DESCRIPTION_MOB_CAP("Set to an integer value to limit the amount of mobs on the plot.", "Flags"),
FLAG_DESCRIPTION_MOB_PLACE("Set to `true` to allow mobs to place blocks within the plot.", "Flags"),
FLAG_DESCRIPTION_MYCEL_GROW("Set to `false` to prevent mycelium from growing in the plot.", "Flags"),
FLAG_DESCRIPTION_NOTIFY_ENTER("Set to `true` to notify the plot owners when someone enters the plot.", "Flags"),
FLAG_DESCRIPTION_NOTIFY_LEAVE("Set to `true` to notify the plot owners when someone leaves the plot.", "Flags"),
FLAG_DESCRIPTION_NO_WORLDEDIT("Set to `true` to disable WorldEdit usage within the plot.", "Flags"),
FLAG_DESCRIPTION_PLACE("Define a list of materials players should be able to place in the plot.", "Flags"),
FLAG_DESCRIPTION_PLAYER_INTERACT("Set to `true` to allow guests to interact with players in the plot.", "Flags"),
FLAG_DESCRIPTION_PRICE("Set a price for a plot. Must be a positive decimal number.", "Flags"),
FLAG_DESCRIPTION_PVE("Set to `true` to enable PVE inside the plot.", "Flags"),
FLAG_DESCRIPTION_PVP("Set to `true` to enable PVP inside the plot.", "Flags"),
FLAG_DESCRIPTION_REDSTONE("Set to `false` to disable redstone in the plot.", "Flags"),
FLAG_DESCRIPTION_SERVER_PLOT("Set to `true` to turn the plot into a server plot. This is equivalent to setting the server as the plot owner.", "Flags"),
FLAG_DESCRIPTION_SNOW_FORM("Set to `true` to allow snow to form within the plot.", "Flags"),
FLAG_DESCRIPTION_SNOW_MELT("Set to `true` to allow snow to melt within the plot.", "Flags"),
FLAG_DESCRIPTION_SOIL_DRY("Set to `true` to allow soil to dry within the plot.", "Flags"),
FLAG_DESCRIPTION_TAMED_ATTACK("Set to `true` to allow guests to attack tamed animals in the plot.", "Flags"),
FLAG_DESCRIPTION_TAMED_INTERACT("Set to `true` to allow guests to interact with tamed animals in the plot.", "Flags"),
FLAG_DESCRIPTION_TIME("Set the time in the plot to a fixed value.", "Flags"),
FLAG_DESCRIPTION_TITLES("Set to `false` to disable plot titles. Can be set to: `none` (to inherit world settings), `true`, or `false`", "Flags"),
FLAG_DESCRIPTION_USE("Define a list of materials players should be able to interact with in the plot.", "Flags"),
FLAG_DESCRIPTION_VEHICLE_BREAK("Set to `true` to allow guests to break vehicles in the plot.", "Flags"),
FLAG_DESCRIPTION_VEHICLE_CAP("Set to an integer value to limit the amount of vehicles on the plot.", "Flags"),
FLAG_DESCRIPTION_VEHICLE_PLACE("Set to `true` to allow guests to place vehicles in the plot.", "Flags"),
FLAG_DESCRIPTION_VEHICLE_USE("Set to `true` to allow guests to use vehicles in the plot.", "Flags"),
FLAG_DESCRIPTION_VILLAGER_INTERACT("Set to `true` to allow guests to interact with villagers in the plot.", "Flags"),
FLAG_DESCRIPTION_VINE_GROW("Set to `false` to prevent vines from growing within the plot.", "Flags"),
FLAG_DESCRIPTION_DENY_TELEPORT("Deny a certain group from teleporting to the plot. Available groups: members, nonmembers, trusted, nontrusted, nonowners", "Flags"),
FLAG_DESCRIPTION_GAMEMODE("Determines the gamemode in the plot.", "Flags"),
FLAG_DESCRIPTION_GUEST_GAMEMODE("Determines the guest gamemode in the plot.", "Flags"),
FLAG_DESCRIPTION_BLOCKED_CMDS("A list of commands that are blocked in the plot.", "Flags"),
FLAG_DESCRIPTION_KEEP("Prevents the plot from expiring. Can be set to: true, false, the number of milliseconds to keep the plot for or a timestamp (3w 2d 5h).", "Flags"),
//</editor-fold>
//<editor-fold desc="Flag category errors"> //<editor-fold desc="Flag category errors">
FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"), FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", false, "Flags"),
FLAG_ERROR_ENUM("Must be one of: %s", "Flags"), FLAG_ERROR_ENUM("Must be one of: %s", false, "Flags"),
FLAG_ERROR_GAMEMODE("Flag value must be a gamemode: 'survival', 'creative', 'adventure' or 'spectator.", "Flags"), FLAG_ERROR_GAMEMODE("Flag value must be a gamemode: 'survival', 'creative', 'adventure' or 'spectator.", false, "Flags"),
FLAG_ERROR_INTEGER("Flag value must be a whole number", "Flags"), FLAG_ERROR_INTEGER("Flag value must be a whole number", false, "Flags"),
FLAG_ERROR_INTEGER_LIST("Flag value must be an integer list", "Flags"), FLAG_ERROR_INTEGER_LIST("Flag value must be an integer list", false, "Flags"),
FLAG_ERROR_INTERVAL("Value(s) must be numeric. /plot set flag <flag> <interval> [amount]", "Flags"), FLAG_ERROR_INTERVAL("Value(s) must be numeric. /plot set flag <flag> <interval> [amount]", false, "Flags"),
FLAG_ERROR_KEEP("Flag value must be a timestamp or a boolean", "Flags"), FLAG_ERROR_KEEP("Flag value must be a timestamp or a boolean", false, "Flags"),
FLAG_ERROR_LONG("Flag value must be a whole number (large numbers allowed)", "Flags"), FLAG_ERROR_LONG("Flag value must be a whole number (large numbers allowed)", false, "Flags"),
FLAG_ERROR_PLOTBLOCKLIST("Flag value must be a block list", "Flags"), FLAG_ERROR_PLOTBLOCKLIST("Flag value must be a block list", false, "Flags"),
FLAG_ERROR_PRICE("Flag value must be a positive number.", "Flags"), FLAG_ERROR_INVALID_BLOCK("The provided value is not a valid block or block category", false, "Flags"),
FLAG_ERROR_STRING("Flag value must be alphanumeric. Some special characters are allowed.", "Flags"), FLAG_ERROR_DOUBLE("Flag value must be a decimal number.", false, "Flags"),
FLAG_ERROR_STRINGLIST("Flag value must be a string list", "Flags"), FLAG_ERROR_STRING("Flag value must be alphanumeric. Some special characters are allowed.", false, "Flags"),
FLAG_ERROR_WEATHER("Flag must be a weather: 'rain' or 'sun'", "Flags"), FLAG_ERROR_STRINGLIST("Flag value must be a string list", false, "Flags"),
FLAG_ERROR_WEATHER("Flag must be a weather: 'rain' or 'sun'", false, "Flags"),
FLAG_ERROR_MUSIC("Flag value must be a valid music disc ID.", false, "Flags"),
//</editor-fold> //</editor-fold>
//<editor-fold desc="Trusted"> //<editor-fold desc="Trusted">
TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"), TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"),
@ -653,30 +750,6 @@ public enum Captions {
this(defaultString, true, category.toLowerCase()); this(defaultString, true, category.toLowerCase());
} }
public static String formatRaw(PlotPlayer recipient, String message, Object... args) {
final ChatFormatter.ChatContext chatContext = new ChatFormatter.ChatContext(recipient, message, args, true);
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
chatFormatter.format(chatContext);
}
return chatContext.getMessage();
}
public static String format(PlotPlayer recipient, String message, Object... args) {
final ChatFormatter.ChatContext chatContext = new ChatFormatter.ChatContext(recipient, message, args, false);
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
chatFormatter.format(chatContext);
}
return chatContext.getMessage();
}
public static String format(PlotPlayer recipient, Captions caption, Object... args) {
if (caption.usePrefix() && caption.translatedString.length() > 0) {
return Captions.PREFIX.getTranslated() + format(recipient, caption.translatedString, args);
} else {
return format(recipient, caption.translatedString, args);
}
}
public static String color(String string) { public static String color(String string) {
return StringMan.replaceFromMap(string, replacements); return StringMan.replaceFromMap(string, replacements);
} }
@ -767,11 +840,7 @@ public enum Captions {
} }
} }
@Override public String toString() { @Override public String getTranslated() {
return this.translatedString;
}
public String getTranslated() {
return this.translatedString; return this.translatedString;
} }
@ -779,24 +848,12 @@ public enum Captions {
return this.prefix; return this.prefix;
} }
public String formatted() {
return StringMan.replaceFromMap(getTranslated(), replacements);
}
public String getCategory() { public String getCategory() {
return this.category; return this.category;
} }
public void send(PlotPlayer caller, String... args) { @Override public String toString() {
send(caller, (Object[]) args); return this.getTranslated();
} }
public void send(PlotPlayer caller, Object... args) {
String msg = format(caller, this, args);
if (caller == null) {
PlotSquared.log(msg);
} else {
caller.sendMessage(msg);
}
}
} }

View File

@ -19,8 +19,9 @@ public class Settings extends Config {
@Comment("Show additional information in console") public static boolean DEBUG = false; @Comment("Show additional information in console") public static boolean DEBUG = false;
@Comment({"The big annoying text that appears when you enter a plot", @Comment({"The big annoying text that appears when you enter a plot",
"For a single plot: `/plot flag set titles false`", "For just you: `/plot toggle titles`", "For all plots: Add `titles: false` in the worlds.yml flags block"}) "For a single plot: `/plot flag set titles false`", "For just you: `/plot toggle titles`",
public static boolean TITLES = true; "For all plots: Add `titles: false` in the worlds.yml flags block"}) public static boolean
TITLES = true;
@Create // This value will be generated automatically @Create // This value will be generated automatically
public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null; public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null;
@ -220,8 +221,7 @@ public class Settings extends Config {
@Comment("Schematic Settings") public static final class Schematics { @Comment("Schematic Settings") public static final class Schematics {
@Comment( @Comment("Whether schematic based generation should paste schematic on top of plots, or from Y=1")
"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;
} }
@ -247,11 +247,12 @@ public class Settings extends Config {
public static final class Done { public static final class Done {
@Comment("Require a plot marked as done to download") public static boolean REQUIRED_FOR_DOWNLOAD = @Comment("Require a plot marked as done to download") public static boolean
false; REQUIRED_FOR_DOWNLOAD = false;
@Comment("Only plots marked as done can be rated") public static boolean REQUIRED_FOR_RATINGS = false; @Comment("Only plots marked as done can be rated") public static boolean
@Comment("Restrict building when a plot is marked as done") public static boolean RESTRICT_BUILDING = REQUIRED_FOR_RATINGS = false;
false; @Comment("Restrict building when a plot is marked as done") public static boolean
RESTRICT_BUILDING = false;
@Comment("The limit being how many plots a player can claim") public static boolean @Comment("The limit being how many plots a player can claim") public static boolean
COUNTS_TOWARDS_LIMIT = true; COUNTS_TOWARDS_LIMIT = true;
} }
@ -267,9 +268,10 @@ 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", "The value covers the range to check only, you need to assign the permission to players/groups still", @Comment({"The max. range of permissions to check e.g. plots.plot.127",
"Modifying the value does NOT change the amount of plots players can claim"}) public static int "The value covers the range to check only, you need to assign the permission to players/groups still",
MAX_PLOTS = 127; "Modifying the value does NOT change the amount of plots players can claim"})
public static int MAX_PLOTS = 127;
} }
@ -283,7 +285,9 @@ public class Settings extends Config {
@Comment("Teleport to your plot on death") public static boolean ON_DEATH = false; @Comment("Teleport to your plot on death") public static boolean ON_DEATH = false;
@Comment("Teleport to your plot on login") public static boolean ON_LOGIN = false; @Comment("Teleport to your plot on login") public static boolean ON_LOGIN = false;
@Comment("Teleport to your plot on claim") public static boolean ON_CLAIM = true; @Comment("Teleport to your plot on claim") public static boolean ON_CLAIM = true;
@Comment({"Add a delay to all teleport commands", "Assign `plots.teleport.delay.bypass` to bypass the cooldown."}) public static int DELAY = 0; @Comment({"Add a delay to all teleport commands",
"Assign `plots.teleport.delay.bypass` to bypass the cooldown."}) public static int
DELAY = 0;
@Comment("The visit command is ordered by world instead of globally") public static boolean @Comment("The visit command is ordered by world instead of globally") public static boolean
PER_WORLD_VISIT = false; PER_WORLD_VISIT = false;
} }
@ -294,8 +298,7 @@ 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( @Comment("Detect and cancel invalid pistons on the edge of plots (e.g. placed with WorldEdit)")
"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;
} }
@ -313,8 +316,8 @@ public class Settings extends Config {
} }
@Comment( @Comment({"Enable or disable parts of the plugin",
{"Enable or disable parts of the plugin", "Note: A cache will use some memory if enabled"}) "Note: A cache will use some memory if enabled"})
public static final class Enabled_Components { // Group the following values into a new config section public static final class Enabled_Components { // Group the following values into a new config section
@Comment("The database stores all the plots") public static boolean DATABASE = true; @Comment("The database stores all the plots") public static boolean DATABASE = true;
@Comment("Events are needed to track a lot of things") public static boolean EVENTS = true; @Comment("Events are needed to track a lot of things") public static boolean EVENTS = true;
@ -345,8 +348,6 @@ public class Settings extends Config {
@Comment("Actively purge invalid database entries") public static boolean DATABASE_PURGER = @Comment("Actively purge invalid database entries") public static boolean DATABASE_PURGER =
false; false;
@Comment("Delete plots when a player is banned") public static boolean BAN_DELETER = false; @Comment("Delete plots when a player is banned") public static boolean BAN_DELETER = false;
@Comment({"Prevent possibly unsafe blocks from being used in plot components", "Can be bypassed with `/plot debugallowunsafe`"})
public static boolean PREVENT_UNSAFE = true;
@Comment("Allows PlaceholderAPI placeholders to be used in captions, flags, etc") @Comment("Allows PlaceholderAPI placeholders to be used in captions, flags, etc")
public static boolean EXTERNAL_PLACEHOLDERS = true; public static boolean EXTERNAL_PLACEHOLDERS = true;
} }

View File

@ -0,0 +1,22 @@
package com.github.intellectualsites.plotsquared.plot.config;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor public final class StaticCaption implements Caption {
private final String value;
private final boolean usePrefix;
public StaticCaption(final String value) {
this(value, true);
}
@Override public String getTranslated() {
return this.value;
}
@Override public boolean usePrefix() {
return this.usePrefix;
}
}

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.database; package com.github.intellectualsites.plotsquared.plot.database;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster; import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
@ -113,6 +113,8 @@ public interface AbstractDB {
*/ */
int getClusterId(PlotCluster cluster); int getClusterId(PlotCluster cluster);
boolean convertFlags();
/** /**
* @return A linked HashMap containing all plots * @return A linked HashMap containing all plots
*/ */
@ -145,12 +147,20 @@ public interface AbstractDB {
void swapPlots(Plot plot1, Plot plot2); void swapPlots(Plot plot1, Plot plot2);
/** /**
* Sets plot flags. * Sets plot flag.
* *
* @param plot Plot Object * @param plot Plot Object
* @param flags flags to set * @param flag Flag to set
*/ */
void setFlags(Plot plot, HashMap<Flag<?>, Object> flags); void setFlag(Plot plot, PlotFlag<?, ?> flag);
/**
* Remove a plot flag.
*
* @param plot Plot Object
* @param flag Flag to remove
*/
void removeFlag(Plot plot, PlotFlag<?, ?> flag);
/** /**
* Renames a cluster to the given name. * Renames a cluster to the given name.
@ -231,7 +241,7 @@ public interface AbstractDB {
/** /**
* @param cluster PlotCluster Object * @param cluster PlotCluster Object
* @param uuid Player that should be removed * @param uuid Player that should be removed
*/ */
void setHelper(PlotCluster cluster, UUID uuid); void setHelper(PlotCluster cluster, UUID uuid);
@ -283,7 +293,7 @@ public interface AbstractDB {
/** /**
* Removes the specified comment from the given plot. * Removes the specified comment from the given plot.
* *
* @param plot the plot * @param plot the plot
* @param comment the comment to remove * @param comment the comment to remove
*/ */
void removeComment(Plot plot, PlotComment comment); void removeComment(Plot plot, PlotComment comment);
@ -291,7 +301,7 @@ public interface AbstractDB {
/** /**
* Clears the specified inbox on the given plot. * Clears the specified inbox on the given plot.
* *
* @param plot the plot * @param plot the plot
* @param inbox the inbox to clear * @param inbox the inbox to clear
*/ */
void clearInbox(Plot plot, String inbox); void clearInbox(Plot plot, String inbox);
@ -299,7 +309,7 @@ public interface AbstractDB {
/** /**
* Adds the specified comment to the given plot. * Adds the specified comment to the given plot.
* *
* @param plot the plot * @param plot the plot
* @param comment the comment to add * @param comment the comment to add
*/ */
void setComment(Plot plot, PlotComment comment); void setComment(Plot plot, PlotComment comment);

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.database; package com.github.intellectualsites.plotsquared.plot.database;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster; import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
@ -84,6 +84,7 @@ public class DBFunc {
//TODO Consider Removal //TODO Consider Removal
/** /**
* Check if a {@link ResultSet} contains a column. * Check if a {@link ResultSet} contains a column.
* *
@ -302,11 +303,18 @@ public class DBFunc {
DBFunc.dbManager.setMerged(plot, merged); DBFunc.dbManager.setMerged(plot, merged);
} }
public static void setFlags(Plot plot, HashMap<Flag<?>, Object> flags) { public static void setFlag(Plot plot, PlotFlag<?, ?> flag) {
if (plot.temp == -1 || dbManager == null) { if (plot.temp == -1 || dbManager == null) {
return; return;
} }
DBFunc.dbManager.setFlags(plot, flags); DBFunc.dbManager.setFlag(plot, flag);
}
public static void removeFlag(Plot plot, PlotFlag<?, ?> flag) {
if (plot.temp == -1 || dbManager == null) {
return;
}
DBFunc.dbManager.removeFlag(plot, flag);
} }
/** /**

View File

@ -2,10 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.database;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection; import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.config.Storage; import com.github.intellectualsites.plotsquared.plot.config.Storage;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.BlockLoc; import com.github.intellectualsites.plotsquared.plot.object.BlockLoc;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -30,6 +33,7 @@ import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -540,13 +544,15 @@ import java.util.concurrent.atomic.AtomicInteger;
try { try {
// Create the plots // Create the plots
createPlots(myList, () -> { createPlots(myList, () -> {
final Map<PlotId, Integer> idMap = new HashMap<>();
try { try {
// Creating datastructures // Creating datastructures
HashMap<PlotId, Plot> plotMap = new HashMap<>(); HashMap<PlotId, Plot> plotMap = new HashMap<>();
for (Plot plot : myList) { for (Plot plot : myList) {
plotMap.put(plot.getId(), plot); plotMap.put(plot.getId(), plot);
} }
ArrayList<SettingsPair> settings = new ArrayList<>(); ArrayList<LegacySettings> settings = new ArrayList<>();
final ArrayList<UUIDPair> helpers = new ArrayList<>(); final ArrayList<UUIDPair> helpers = new ArrayList<>();
final ArrayList<UUIDPair> trusted = new ArrayList<>(); final ArrayList<UUIDPair> trusted = new ArrayList<>();
final ArrayList<UUIDPair> denied = new ArrayList<>(); final ArrayList<UUIDPair> denied = new ArrayList<>();
@ -561,8 +567,9 @@ import java.util.concurrent.atomic.AtomicInteger;
int y = result.getInt("plot_id_z"); int y = result.getInt("plot_id_z");
PlotId plotId = new PlotId(x, y); PlotId plotId = new PlotId(x, y);
Plot plot = plotMap.get(plotId); Plot plot = plotMap.get(plotId);
idMap.put(plotId, id);
if (plot != null) { if (plot != null) {
settings.add(new SettingsPair(id, plot.getSettings())); settings.add(new LegacySettings(id, plot.getSettings()));
for (UUID uuid : plot.getDenied()) { for (UUID uuid : plot.getDenied()) {
denied.add(new UUIDPair(id, uuid)); denied.add(new UUIDPair(id, uuid));
} }
@ -575,21 +582,24 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
} }
} }
createSettings(settings, () -> createTiers(helpers, "helpers",
() -> createTiers(trusted, "trusted", createFlags(idMap, myList, () ->
() -> createTiers(denied, "denied", () -> { createSettings(settings,
try { () -> createTiers(helpers, "helpers",
SQLManager.this.connection.commit(); () -> createTiers(trusted, "trusted",
} catch (SQLException e) { () -> createTiers(denied, "denied", () -> {
e.printStackTrace(); try {
} SQLManager.this.connection.commit();
if (whenDone != null) { } catch (SQLException e) {
whenDone.run(); e.printStackTrace();
} }
})))); if (whenDone != null) {
whenDone.run();
}
})))));
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
PlotSquared.debug("&7[WARN] Failed to set all helpers 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) {
@ -653,6 +663,34 @@ import java.util.concurrent.atomic.AtomicInteger;
setBulk(myList, mod, whenDone); setBulk(myList, mod, whenDone);
} }
public void createFlags(Map<PlotId, Integer> ids, List<Plot> plots, Runnable whenDone) {
try (final PreparedStatement preparedStatement =
this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) {
for (final Plot plot : plots) {
final FlagContainer flagContainer = plot.getFlagContainer();
for (final PlotFlag<?,?> flagEntry : flagContainer.getFlagMap().values()) {
preparedStatement.setInt(1, ids.get(plot.getId()));
preparedStatement.setString(2, flagEntry.getName());
preparedStatement.setString(3, flagEntry.toString());
preparedStatement.addBatch();
}
try {
preparedStatement.executeBatch();
} catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values for plot with entry ID: " + plot.getId());
e.printStackTrace();
continue;
}
PlotSquared.debug(Captions.PREFIX.getTranslated() + "- Finished converting flags for plot with entry ID: " + plot.getId());
}
} catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:");
e.printStackTrace();
}
PlotSquared.log(Captions.PREFIX.getTranslated() + "Finished converting flags (" + plots.size() + " plots processed)");
whenDone.run();
}
/** /**
* Create a plot * Create a plot
* *
@ -828,111 +866,71 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
} }
public void createSettings(final ArrayList<SettingsPair> myList, final Runnable whenDone) { public void createSettings(final ArrayList<LegacySettings> myList, final Runnable whenDone) {
final StmtMod<SettingsPair> mod = new StmtMod<SettingsPair>() { try (final PreparedStatement preparedStatement =
@Override public String getCreateMySQL(int size) { this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`"
return getCreateMySQL(size, "INSERT INTO `" + SQLManager.this.prefix + "(`plot_plot_id`,`biome`,`rain`,`custom_time`,`time`,`deny_entry`,`alias`,`merged`,`position`) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
+ "plot_settings`(`plot_plot_id`,`biome`,`rain`,`custom_time`,`time`,`deny_entry`,`alias`,`flags`,`merged`,"
+ "`position`) VALUES ", 10); int packet;
if (this.mySQL) {
packet = Math.min(myList.size(), 5000);
} else {
packet = Math.min(myList.size(), 50);
} }
@Override public String getCreateSQLite(int size) { int totalUpdated = 0;
return getCreateSQLite(size, "INSERT INTO `" + SQLManager.this.prefix int updated = 0;
+ "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS "
+ "`deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position`",
10);
}
@Override public String getCreateSQL() { for (final LegacySettings legacySettings : myList) {
return "INSERT INTO `" + SQLManager.this.prefix preparedStatement.setInt(1, legacySettings.id);
+ "plot_settings`(`plot_plot_id`) VALUES(?)"; preparedStatement.setNull(2, 4);
} preparedStatement.setNull(3, 4);
preparedStatement.setNull(4, 4);
@Override public void setMySQL(PreparedStatement statement, int i, SettingsPair pair) preparedStatement.setNull(5, 4);
throws SQLException { preparedStatement.setNull(6, 4);
statement.setInt(i * 10 + 1, pair.id); // id if (legacySettings.settings.getAlias().isEmpty()) {
statement.setNull(i * 10 + 2, 4); // biome preparedStatement.setNull(7, 4);
statement.setNull(i * 10 + 3, 4); // rain
statement.setNull(i * 10 + 4, 4); // custom_time
statement.setNull(i * 10 + 5, 4); // time
statement.setNull(i * 10 + 6, 4); // deny_entry
if (pair.settings.getAlias().isEmpty()) {
statement.setNull(i * 10 + 7, 4);
} else { } else {
statement.setString(i * 10 + 7, pair.settings.getAlias()); preparedStatement.setString(7, legacySettings.settings.getAlias());
} }
StringBuilder flag_string = new StringBuilder(); boolean[] merged = legacySettings.settings.getMerged();
int k = 0;
for (Entry<Flag<?>, ?> flag : pair.settings.flags.entrySet()) {
if (k != 0) {
flag_string.append(',');
}
flag_string.append(flag.getKey().getName()).append(':').append(
flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
.replaceAll(",", "´"));
k++;
}
statement.setString(i * 10 + 8, flag_string.toString());
boolean[] merged = pair.settings.getMerged();
int hash = MainUtil.hash(merged); int hash = MainUtil.hash(merged);
statement.setInt(i * 10 + 9, hash); preparedStatement.setInt(8, hash);
BlockLoc loc = pair.settings.getPosition(); BlockLoc loc = legacySettings.settings.getPosition();
String position; String position;
if (loc.getY() == 0) { if (loc.getY() == 0) {
position = "DEFAULT"; position = "DEFAULT";
} else { } else {
position = loc.getX() + "," + loc.getY() + ',' + loc.getZ(); position = loc.getX() + "," + loc.getY() + ',' + loc.getZ();
} }
statement.setString(i * 10 + 10, position); preparedStatement.setString( 9, position);
} preparedStatement.addBatch();
if (++updated >= packet) {
@Override public void setSQLite(PreparedStatement stmt, int i, SettingsPair pair) try {
throws SQLException { preparedStatement.executeBatch();
stmt.setInt(i * 10 + 1, pair.id); // id } catch (final Exception e) {
stmt.setNull(i * 10 + 2, 4); // biome PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values for plot with entry ID: " + legacySettings.id);
stmt.setNull(i * 10 + 3, 4); // rain e.printStackTrace();
stmt.setNull(i * 10 + 4, 4); // custom_time continue;
stmt.setNull(i * 10 + 5, 4); // time
stmt.setNull(i * 10 + 6, 4); // deny_entry
if (pair.settings.getAlias().isEmpty()) {
stmt.setNull(i * 10 + 7, 4);
} else {
stmt.setString(i * 10 + 7, pair.settings.getAlias());
}
StringBuilder flag_string = new StringBuilder();
int k = 0;
for (Entry<Flag<?>, ?> flag : pair.settings.flags.entrySet()) {
if (k != 0) {
flag_string.append(',');
} }
flag_string.append(flag.getKey().getName()).append(':').append(
flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
.replaceAll(",", "´"));
k++;
} }
stmt.setString(i * 10 + 8, flag_string.toString()); totalUpdated += 1;
boolean[] merged = pair.settings.getMerged();
int n = 0;
for (int j = 0; j < 4; ++j) {
n = (n << 1) + (merged[j] ? 1 : 0);
}
stmt.setInt(i * 10 + 9, n);
BlockLoc loc = pair.settings.getPosition();
String position;
if (loc.getY() == 0) {
position = "DEFAULT";
} else {
position = loc.getX() + "," + loc.getY() + ',' + loc.getZ();
}
stmt.setString(i * 10 + 10, position);
} }
@Override public void setSQL(PreparedStatement stmt, SettingsPair pair) if (totalUpdated < myList.size()) {
throws SQLException { try {
stmt.setInt(1, pair.id); preparedStatement.executeBatch();
} catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values");
e.printStackTrace();
}
} }
}; } catch (final Exception e) {
addGlobalTask(() -> setBulk(myList, mod, whenDone)); PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values:");
e.printStackTrace();
}
PlotSquared.log(Captions.PREFIX.getTranslated() + "Finished converting settings (" + myList.size() + " plots processed)");
whenDone.run();
} }
public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) { public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) {
@ -944,7 +942,7 @@ 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 `flags`, ? AS `merged`, ? AS `position` ", + "`deny_entry`, ? AS `alias`, ? AS `merged`, ? AS `position` ",
10); 10);
} }
@ -968,8 +966,7 @@ import java.util.concurrent.atomic.AtomicInteger;
stmt.setNull(i * 10 + 6, 4); stmt.setNull(i * 10 + 6, 4);
stmt.setNull(i * 10 + 7, 4); stmt.setNull(i * 10 + 7, 4);
stmt.setNull(i * 10 + 8, 4); stmt.setNull(i * 10 + 8, 4);
stmt.setNull(i * 10 + 9, 4); stmt.setString(i * 10 + 9, "DEFAULT");
stmt.setString(i * 10 + 10, "DEFAULT");
} }
@Override public void setSQL(PreparedStatement stmt, Integer id) throws SQLException { @Override public void setSQL(PreparedStatement stmt, Integer id) throws SQLException {
@ -1098,7 +1095,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public void createTables() throws SQLException { @Override public void createTables() throws SQLException {
String[] tables = String[] tables =
new String[] {"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", new String[] {"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted",
"plot_rating", "plot_settings", "cluster", "player_meta"}; "plot_rating", "plot_settings", "cluster", "player_meta", "plot_flags"};
DatabaseMetaData meta = this.connection.getMetaData(); DatabaseMetaData meta = this.connection.getMetaData();
int create = 0; int create = 0;
for (String s : tables) { for (String s : tables) {
@ -1142,7 +1139,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," + " `flags` VARCHAR(512) 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");
@ -1173,7 +1170,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," + " `flags` VARCHAR(512) 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");
@ -1182,6 +1179,12 @@ 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," + " PRIMARY KEY (`meta_id`)" + " `value` blob NOT NULL," + " PRIMARY KEY (`meta_id`)"
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_flags`("
+ "`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
+ "`plot_id` INT(11) NOT NULL," + " `flag` VARCHAR(256)," + " `value` VARCHAR(512),"
+ "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix + "plot` (id) ON DELETE CASCADE, "
+ "UNIQUE (plot_id, flag)"
+ ") 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` ("
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id_x` INT(11) NOT NULL,"
@ -1207,7 +1210,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," + " `flags` VARCHAR(512) 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`)" + ')');
@ -1229,7 +1232,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," + " `flags` VARCHAR(512) 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`)" + ')');
@ -1237,6 +1240,11 @@ import java.util.concurrent.atomic.AtomicInteger;
+ " `meta_id` INTEGER PRIMARY KEY AUTOINCREMENT," + " `meta_id` INTEGER PRIMARY KEY AUTOINCREMENT,"
+ " `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`("
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT,"
+ "`plot_id` INTEGER NOT NULL," + " `flag` VARCHAR(256)," + " `value` VARCHAR(512),"
+ "FOREIGN KEY (plot_id) REFERENCES `" + this.prefix + "plot` (id) ON DELETE CASCADE, "
+ "UNIQUE (plot_id, flag))");
} }
stmt.executeBatch(); stmt.executeBatch();
stmt.clearBatch(); stmt.clearBatch();
@ -1590,6 +1598,82 @@ import java.util.concurrent.atomic.AtomicInteger;
}, null); }, null);
} }
@Override public boolean convertFlags() {
final Map<Integer, Map<String, String>> flagMap = new HashMap<>();
try (Statement statement = this.connection.createStatement()) {
try (ResultSet resultSet = statement
.executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`")) {
while (resultSet.next()) {
final int id = resultSet.getInt("plot_plot_id");
final String plotFlags = resultSet.getString("flags");
if (plotFlags == null || plotFlags.isEmpty()) {
continue;
}
flagMap.put(id, new HashMap<>());
for (String element : plotFlags.split(",")) {
if (element.contains(":")) {
String[] split = element.split(":"); // splits flag:value
try {
String flag_str =
split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
/*PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(split[0]);
if (flag == null) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Flag not found and therefore ignored: " + split[0]);
continue;
}*/
flagMap.get(id).put(split[0], flag_str);
} catch (Exception e) {
e.printStackTrace();
}
} /*else {
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
if (StringMan
.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(element);
if (flag == null) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Flag not found and therefore ignored: " + element);
}
} else {
PlotSquared.log(Captions.PREFIX.getTranslated() + "INVALID FLAG: " + element);
}
}*/
}
}
}
} catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to load old flag values:");
e.printStackTrace();
return false;
}
PlotSquared.log(Captions.PREFIX.getTranslated() + "Loaded " + flagMap.size() + " plot flag collections...");
PlotSquared.log(Captions.PREFIX.getTranslated() + "Attempting to store these flags in the new table...");
//
try (final PreparedStatement preparedStatement =
this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) {
for (final Map.Entry<Integer, Map<String, String>> plotFlagEntry : flagMap.entrySet()) {
for (final Map.Entry<String, String> flagEntry : plotFlagEntry.getValue().entrySet()) {
preparedStatement.setInt(1, plotFlagEntry.getKey());
preparedStatement.setString(2, flagEntry.getKey());
preparedStatement.setString(3, flagEntry.getValue());
preparedStatement.addBatch();
}
try {
preparedStatement.executeBatch();
} catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values for plot with entry ID: " + plotFlagEntry.getKey());
e.printStackTrace();
continue;
}
PlotSquared.debug(Captions.PREFIX.getTranslated() + "- Finished converting flags for plot with entry ID: " + plotFlagEntry.getKey());
}
} catch (final Exception e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:");
e.printStackTrace();
return false;
}
return true;
}
/** /**
* Load all plots, helpers, denied, trusted, and every setting from DB into a {@link HashMap}. * Load all plots, helpers, denied, trusted, and every setting from DB into a {@link HashMap}.
*/ */
@ -1817,6 +1901,50 @@ 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`")) {
final ArrayList<Integer> toDelete = new ArrayList<>();
final Map<Plot, Collection<PlotFlag<?,?>>> invalidFlags = new HashMap<>();
while (resultSet.next()) {
id = resultSet.getInt("plot_id");
final String flag = resultSet.getString("flag");
final String value = resultSet.getString("value");
final Plot plot = plots.get(id);
if (plot != null) {
final PlotFlag<?,?> plotFlag = GlobalFlagContainer.getInstance().getFlagFromString(flag);
if (plotFlag == null) {
plot.getFlagContainer().addUnknownFlag(flag, value);
} else {
try {
plot.getFlagContainer().addFlag(plotFlag.parse(value));
} catch (final FlagParseException e) {
PlotSquared.debug("Plot with ID " + id + " has an invalid value:");
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)) {
invalidFlags.put(plot, new ArrayList<>());
}
invalidFlags.get(plot).add(plotFlag);
}
}
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id);
} else {
PlotSquared.debug("&cPlot " + id
+ " in `plot_flags` does not exist. Create this plot or set `database-purger: true` in the settings.yml.");
}
}
if (Settings.Enabled_Components.DATABASE_PURGER) {
for (final Map.Entry<Plot, Collection<PlotFlag<?,?>>> plotFlagEntry : invalidFlags.entrySet()) {
for (final PlotFlag<?,?> flag : plotFlagEntry.getValue()) {
PlotSquared.debug("&cPlot \"" + plotFlagEntry.getKey() + "\""
+ " had an invalid flag (" + flag.getName() + "). A fix has been attempted.");
removeFlag(plotFlagEntry.getKey(), flag);
}
}
}
deleteRows(toDelete, this.prefix + "plot_flags", "plot_id");
}
try (ResultSet resultSet = statement try (ResultSet resultSet = statement
.executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`")) { .executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`")) {
ArrayList<Integer> toDelete = new ArrayList<>(); ArrayList<Integer> toDelete = new ArrayList<>();
@ -1848,46 +1976,6 @@ import java.util.concurrent.atomic.AtomicInteger;
merged[3 - i] = (m & 1 << i) != 0; merged[3 - i] = (m & 1 << i) != 0;
} }
plot.getSettings().setMerged(merged); plot.getSettings().setMerged(merged);
String[] flags_string;
String myflags = resultSet.getString("flags");
if (myflags == null || myflags.isEmpty()) {
flags_string = new String[] {};
} else {
flags_string = myflags.split(",");
}
HashMap<Flag<?>, Object> flags = new HashMap<>();
boolean exception = false;
for (String element : flags_string) {
if (element.contains(":")) {
String[] split = element.split(":");
try {
String flag_str =
split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
Flag<?> flag = FlagManager.getOrCreateFlag(split[0]);
flags.put(flag, flag.parseValue(flag_str));
} catch (Exception e) {
e.printStackTrace();
exception = true;
}
} else {
element =
element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
if (StringMan
.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
Flag flag = FlagManager.getOrCreateFlag(element);
flags.put(flag, flag.parseValue(""));
} else {
PlotSquared.debug("INVALID FLAG: " + element);
}
}
}
if (exception) {
PlotSquared.debug("&cPlot #" + id + "(" + plot + ") | " + plot
+ " had an invalid flag. A fix has been attempted.");
PlotSquared.debug("&c" + myflags);
this.setFlags(plot, flags);
}
plot.getSettings().flags = flags;
} else if (Settings.Enabled_Components.DATABASE_PURGER) { } else if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
} else { } else {
@ -1991,18 +2079,39 @@ import java.util.concurrent.atomic.AtomicInteger;
addPlotTask(newPlot, null); addPlotTask(newPlot, null);
} }
@Override public void setFlags(final Plot plot, HashMap<Flag<?>, Object> flags) { @Override public void setFlag(final Plot plot, final PlotFlag<?, ?> flag) {
final String flag_string = FlagManager.toString(flags); addPlotTask(plot, new UniqueStatement("setFlag") {
addPlotTask(plot, new UniqueStatement("setFlags") {
@Override public void set(PreparedStatement statement) throws SQLException { @Override public void set(PreparedStatement statement) throws SQLException {
statement.setString(1, flag_string); statement.setInt(1, getId(plot));
statement.setInt(2, getId(plot)); statement.setString(2, flag.getName());
statement.setString(3, flag.toString());
statement.setString(4, flag.toString());
} }
@Override public PreparedStatement get() throws SQLException { @Override public PreparedStatement get() throws SQLException {
return SQLManager.this.connection.prepareStatement( final String statement;
"UPDATE `" + SQLManager.this.prefix if (SQLManager.this.mySQL) {
+ "plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?"); statement = "INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?) "
+ "ON DUPLICATE KEY UPDATE `value` = ?";
} else {
statement = "INSERT INTO `" + SQLManager.this.prefix + "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?) "
+ "ON CONFLICT(`plot_id`,`flag`) DO UPDATE SET `value` = ?";
}
return SQLManager.this.connection.prepareStatement(statement);
}
});
}
@Override public void removeFlag(final Plot plot, final PlotFlag<?, ?> flag) {
addPlotTask(plot, new UniqueStatement("removeFlag") {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, getId(plot));
statement.setString(2, flag.getName());
}
@Override public PreparedStatement get() throws SQLException {
return SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix
+ "plot_flags` WHERE `plot_id` = ? AND `flag` = ?");
} }
}); });
} }
@ -2966,14 +3075,15 @@ import java.util.concurrent.atomic.AtomicInteger;
PlotSquared.debug(" - Correcting merge for: " + plot); PlotSquared.debug(" - Correcting merge for: " + plot);
setMerged(dataPlot, plot.getMerged()); setMerged(dataPlot, plot.getMerged());
} }
HashMap<Flag<?>, Object> pf = plot.getFlags(); Set<PlotFlag<?, ?>> pf = plot.getFlags();
HashMap<Flag<?>, Object> 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.values(), ","), .isEqual(StringMan.joinOrdered(pf, ","),
StringMan.joinOrdered(df.values(), ","))) { StringMan.joinOrdered(df, ","))) {
PlotSquared.debug(" - Correcting flags for: " + plot); PlotSquared.debug(" - Correcting flags for: " + plot);
setFlags(plot, pf); // setFlags(plot, pf);
// TODO: Re-implement
} }
} }
} }
@ -3104,7 +3214,6 @@ 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;
@ -3117,12 +3226,12 @@ import java.util.concurrent.atomic.AtomicInteger;
} }
private class SettingsPair { private static class LegacySettings {
public final int id; public final int id;
public final PlotSettings settings; public final PlotSettings settings;
public SettingsPair(int id, PlotSettings settings) { public LegacySettings(int id, PlotSettings settings) {
this.id = id; this.id = id;
this.settings = settings; this.settings = settings;
} }

View File

@ -1,36 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Arrays;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
public class BlockStateListFlag extends ListFlag<Set<BlockType>> {
public BlockStateListFlag(String name) {
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
}
@Override public String valueToString(Object value) {
return StringMan.join((Set<BlockType>) value, ",");
}
@Override public Set<BlockType> parseValue(final String value) {
return Arrays.stream(BlockUtil.parse(value)).filter(Objects::nonNull).map(BlockState::getBlockType).collect(Collectors.toSet());
}
@Override public String getValueDescription() {
return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated();
}
public boolean contains(Plot plot, BlockState value) {
return contains(plot, value.getBlockType());
}
}

View File

@ -1,46 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
public class BooleanFlag extends Flag<Boolean> {
public BooleanFlag(String name) {
super(Captions.FLAG_CATEGORY_BOOLEAN, name);
}
@Override public String valueToString(Object value) {
return value + "";
}
@Override public Boolean parseValue(String value) {
switch (value.toLowerCase()) {
case "1":
case "yes":
case "allow":
case "true":
return true;
case "0":
case "no":
case "deny":
case "false":
return false;
default:
return null;
}
}
@Override public String getValueDescription() {
return Captions.FLAG_ERROR_BOOLEAN.getTranslated();
}
public boolean isTrue(Plot plot) {
Boolean value = FlagManager.getPlotFlagRaw(plot, this);
return Boolean.TRUE == value;
}
public boolean isFalse(Plot plot) {
Boolean value = FlagManager.getPlotFlagRaw(plot, this);
return Boolean.FALSE == value;
}
}

View File

@ -1,27 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
public class DoubleFlag extends Flag<Double> {
public DoubleFlag(String name) {
super(Captions.FLAG_CATEGORY_DECIMAL, name);
}
@Override public String valueToString(Object value) {
return value.toString();
}
@Override public Double parseValue(String value) {
try {
return Double.parseDouble(value);
} catch (NumberFormatException ignored) {
return null;
}
}
@Override public String getValueDescription() {
return Captions.FLAG_ERROR_BOOLEAN.getTranslated();
}
}

View File

@ -1,33 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.Arrays;
import java.util.HashSet;
public class EnumFlag extends Flag<String> {
private final HashSet<String> values;
public EnumFlag(String name, String... values) {
super(Captions.FLAG_CATEGORY_ENUM, name);
this.values = new HashSet<>(Arrays.asList(values));
}
@Override public String valueToString(Object value) {
return value.toString();
}
@Override public String parseValue(String value) {
value = value.toLowerCase();
if (values.contains(value)) {
return value;
}
return null;
}
@Override public String getValueDescription() {
return Captions.FLAG_ERROR_ENUM.getTranslated() + StringMan.getString(values);
}
}

View File

@ -1,75 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import lombok.Getter;
public abstract class Flag<V> implements StringComparison.StringComparable {
@Getter private final Captions typeCaption;
private final String name;
private boolean reserved = false;
public Flag(Captions typeCaption, String name) {
this.typeCaption = typeCaption;
this.name = name;
}
/**
* Flag object used to store basic information for a Plot. Flags are a
* key/value pair. For a flag to be usable by a player, you need to
* register it with PlotSquared.
*
* @param name the flag name
*/
public Flag(String name) {
this(null, name);
}
public Flag<V> reserve() {
this.reserved = true;
return this;
}
public boolean isReserved() {
return this.reserved;
}
public void unreserve() {
this.reserved = false;
}
public void register() {
Flags.registerFlag(this);
}
public abstract String valueToString(Object value);
@Override public final String toString() {
return "Flag { name='" + getName() + "'}";
}
public abstract V parseValue(String value);
public abstract String getValueDescription();
public final String getName() {
return this.name;
}
public boolean isSet(Plot plot) {
return FlagManager.getPlotFlagRaw(plot, this) != null;
}
@Override public String getComparableString() {
return getName();
}
public String getCategoryCaption() {
return this.typeCaption == null ?
getClass().getSimpleName() :
this.typeCaption.getTranslated();
}
}

Some files were not shown because too many files have changed in this diff Show More