Beautify code

This commit is contained in:
MattBDev 2016-06-02 11:38:47 -04:00
parent 8e306a92e3
commit da58c7b411
77 changed files with 1319 additions and 1311 deletions

View File

@ -28,6 +28,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -192,9 +193,9 @@ public class PlotAPI {
@Deprecated @Deprecated
public String[] getPermissions() { public String[] getPermissions() {
ArrayList<String> perms = new ArrayList<>(); ArrayList<String> perms = new ArrayList<>();
for (C c : C.values()) { for (C caption : C.values()) {
if ("static.permissions".equals(c.getCategory())) { if ("static.permissions".equals(caption.getCategory())) {
perms.add(c.s()); perms.add(caption.s());
} }
} }
return perms.toArray(new String[perms.size()]); return perms.toArray(new String[perms.size()]);
@ -249,7 +250,7 @@ public class PlotAPI {
*/ */
public Set<PlotArea> getPlotAreas(World world) { public Set<PlotArea> getPlotAreas(World world) {
if (world == null) { if (world == null) {
return new HashSet<>(); return Collections.emptySet();
} }
return PS.get().getPlotAreas(world.getName()); return PS.get().getPlotAreas(world.getName());
} }
@ -661,8 +662,8 @@ public class PlotAPI {
* *
*/ */
public int getAllowedPlots(Player player) { public int getAllowedPlots(Player player) {
PlotPlayer pp = PlotPlayer.wrap(player); PlotPlayer plotPlayer = PlotPlayer.wrap(player);
return pp.getAllowedPlots(); return plotPlayer.getAllowedPlots();
} }
/** /**

View File

@ -42,17 +42,17 @@ public abstract class APlotMeConnector {
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height); PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
} }
public Location getPlotTopLocAbs(int path, int plot, PlotId plotid) { public Location getPlotTopLocAbs(int path, int plot, PlotId plotId) {
int px = plotid.x; int px = plotId.x;
int pz = plotid.y; int pz = plotId.y;
int x = px * (path + plot) - (int) Math.floor(path / 2) - 1; int x = px * (path + plot) - (int) Math.floor(path / 2) - 1;
int z = pz * (path + plot) - (int) Math.floor(path / 2) - 1; int z = pz * (path + plot) - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 256, z); return new Location(null, x, 256, z);
} }
public Location getPlotBottomLocAbs(int path, int plot, PlotId plotid) { public Location getPlotBottomLocAbs(int path, int plot, PlotId plotId) {
int px = plotid.x; int px = plotId.x;
int pz = plotid.y; int pz = plotId.y;
int x = px * (path + plot) - plot - (int) Math.floor(path / 2) - 1; int x = px * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
int z = pz * (path + plot) - plot - (int) Math.floor(path / 2) - 1; int z = pz * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 1, z); return new Location(null, x, 1, z);

View File

@ -1,5 +1,7 @@
package com.plotsquared.bukkit.listeners; package com.plotsquared.bukkit.listeners;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -8,8 +10,6 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import java.lang.reflect.Method;
import java.util.HashSet;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
@ -28,8 +28,8 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
import java.lang.reflect.Method;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import java.util.HashSet;
public class ChunkListener implements Listener { public class ChunkListener implements Listener {
@ -134,10 +134,7 @@ public class ChunkListener implements Listener {
return true; return true;
} }
plot = new Location(world, x + 7, 1, z + 7).getOwnedPlotAbs(); plot = new Location(world, x + 7, 1, z + 7).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) { return plot != null && plot.hasOwner();
return true;
}
return false;
} }
@EventHandler @EventHandler

View File

@ -13,6 +13,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -22,12 +23,12 @@ public class ForceFieldListener implements Listener {
private Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) { private Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
Set<PlotPlayer> players = new HashSet<>(); Set<PlotPlayer> players = new HashSet<>();
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
PlotPlayer pp; PlotPlayer plotPlayer;
if (!(entity instanceof Player) || ((pp = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(pp.getCurrentPlot())) { if (!(entity instanceof Player) || ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(plotPlayer.getCurrentPlot())) {
continue; continue;
} }
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
players.add(pp); players.add(plotPlayer);
} }
} }
return players; return players;
@ -38,22 +39,22 @@ public class ForceFieldListener implements Listener {
if (!(entity instanceof Player)) { if (!(entity instanceof Player)) {
continue; continue;
} }
PlotPlayer pp; PlotPlayer plotPlayer;
if ((pp = BukkitUtil.getPlayer((Player) entity)) == null) { if ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) {
continue; continue;
} }
if (!plot.equals(pp.getCurrentPlot())) { if (!plot.equals(plotPlayer.getCurrentPlot())) {
continue; continue;
} }
if (plot.isAdded(pp.getUUID())) { if (plot.isAdded(plotPlayer.getUUID())) {
return pp; return plotPlayer;
} }
} }
return null; return null;
} }
private Vector calculateVelocity(PlotPlayer pp, PlotPlayer e) { private Vector calculateVelocity(PlotPlayer player, PlotPlayer e) {
Location playerLocation = pp.getLocationFull(); Location playerLocation = player.getLocationFull();
Location oPlayerLocation = e.getLocation(); Location oPlayerLocation = e.getLocation();
double playerX = playerLocation.getX(); double playerX = playerLocation.getX();
double playerY = playerLocation.getY(); double playerY = playerLocation.getY();
@ -85,25 +86,25 @@ public class ForceFieldListener implements Listener {
@EventHandler @EventHandler
public void onPlotEntry(PlayerMoveEvent event) { public void onPlotEntry(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
Plot plot = pp.getCurrentPlot(); Plot plot = plotPlayer.getCurrentPlot();
if (plot == null) { if (plot == null) {
return; return;
} }
Optional<Boolean> forcefield = plot.getFlag(Flags.FORCEFIELD); Optional<Boolean> forcefield = plot.getFlag(Flags.FORCEFIELD);
if (forcefield.isPresent() && forcefield.get()) { if (forcefield.isPresent() && forcefield.get()) {
UUID uuid = pp.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);
for (PlotPlayer oPlayer : players) { for (PlotPlayer oPlayer : players) {
((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(pp, oPlayer)); ((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer));
} }
} else { } else {
PlotPlayer oPlayer = hasNearbyPermitted(player, plot); PlotPlayer oPlayer = hasNearbyPermitted(player, plot);
if (oPlayer == null) { if (oPlayer == null) {
return; return;
} }
player.setVelocity(calculateVelocity(oPlayer, pp)); player.setVelocity(calculateVelocity(oPlayer, plotPlayer));
} }
} }
} }

View File

@ -109,6 +109,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@ -609,44 +610,44 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void blockDestroy(BlockBreakEvent event) { public void blockDestroy(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = loc.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
return; return;
} }
Plot plot = area.getPlotAbs(loc); Plot plot = area.getPlotAbs(location);
if (plot != null) { if (plot != null) {
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (event.getBlock().getY() == 0) { if (event.getBlock().getY() == 0) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { .contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; return;
} }
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey(Flags.DONE)) { } else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey(Flags.DONE)) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -822,19 +823,19 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get().contains(new PlotBlock((short) block.getTypeId(), block.getData())) || Permissions if (destroy.isPresent() && destroy.get().contains(new PlotBlock((short) block.getTypeId(), block.getData())) || Permissions
.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -842,8 +843,8 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
return; return;
} }
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -2169,70 +2170,70 @@ public class PlayerEvents extends PlotListener implements Listener {
player = null; player = null;
} }
if (player != null) { if (player != null) {
PlotPlayer pp = 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.isAdded(pp.getUUID()))) { if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
return false; return false;
} }
} else if (victim.getEntityId() == 30) { } else if (victim.getEntityId() == 30) {
if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot.isAdded(pp.getUUID()))) { if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
return false; return false;
} }
} else if (victim instanceof Monster || victim instanceof EnderDragon) { // victim is monster } else if (victim instanceof Monster || victim instanceof EnderDragon) { // victim is monster
if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot
.isAdded(pp.getUUID()))) { .isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
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.getFlag(Flags.PVE, false) || plot.isAdded(pp.getUUID()))) { if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false; return false;
} }
} else if (victim instanceof Player) { } else if (victim instanceof Player) {
if (plot != null) { if (plot != null) {
if (Flags.PVP.isFalse(plot) && !Permissions.hasPermission(pp, "plots.admin.pvp." + stub)) { if (Flags.PVP.isFalse(plot) && !Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
return false; return false;
} else { } else {
return true; return true;
} }
} }
if (!Permissions.hasPermission(pp, "plots.admin.pvp." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
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.getFlag(Flags.PVE, false) || plot if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot
.isAdded(pp.getUUID()))) { .isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false; return false;
} }
} 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.isAdded(pp.getUUID()))) { if (plot != null && (plot.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false; return false;
} }
} }
@ -2249,22 +2250,22 @@ public class PlayerEvents extends PlotListener implements Listener {
if (area == null) { if (area == null) {
return; return;
} }
Player p = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(p); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(l); Plot plot = area.getPlot(l);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road"); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
event.setHatching(false); event.setHatching(false);
} }
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned"); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned");
event.setHatching(false); event.setHatching(false);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other"); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
event.setHatching(false); event.setHatching(false);
} }
} }
@ -2272,14 +2273,14 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void blockCreate(BlockPlaceEvent event) { public void blockCreate(BlockPlaceEvent event) {
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = loc.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlotAbs(loc); Plot plot = area.getPlotAbs(location);
if (plot != null) { if (plot != null) {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
@ -2313,7 +2314,7 @@ public class PlayerEvents extends PlotListener implements Listener {
sendBlockChange(block.getLocation(), block.getType(), block.getData()); sendBlockChange(block.getLocation(), block.getType(), block.getData());
} }
} }
if (loc.getY() > area.MAX_BUILD_HEIGHT && loc.getY() < area.MIN_BUILD_HEIGHT && !Permissions if (location.getY() > area.MAX_BUILD_HEIGHT && location.getY() < area.MIN_BUILD_HEIGHT && !Permissions
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) { .hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT))); MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));

View File

@ -18,23 +18,23 @@ public class PlayerEvents183 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBigBoom(BlockExplodeEvent event) { public void onBigBoom(BlockExplodeEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
Location loc = BukkitUtil.getLocation(block.getLocation()); Location location = BukkitUtil.getLocation(block.getLocation());
String world = loc.getWorld(); String world = location.getWorld();
if (!PS.get().hasPlotArea(world)) { if (!PS.get().hasPlotArea(world)) {
return; return;
} }
PlotArea area = loc.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
Iterator<Block> iterator = event.blockList().iterator(); Iterator<Block> iterator = event.blockList().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
loc = BukkitUtil.getLocation(iterator.next().getLocation()); location = BukkitUtil.getLocation(iterator.next().getLocation());
if (loc.getPlotArea() != null) { if (location.getPlotArea() != null) {
iterator.remove(); iterator.remove();
} }
} }
return; return;
} }
Plot plot = area.getOwnedPlot(loc); Plot plot = area.getOwnedPlot(location);
if (plot == null || !plot.getFlag(Flags.EXPLOSION).or(false)) { if (plot == null || !plot.getFlag(Flags.EXPLOSION).or(false)) {
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -61,12 +61,12 @@ public class EntityWrapper {
public EntityWrapper(Entity entity, short depth) { public EntityWrapper(Entity entity, short depth) {
this.hash = entity.getEntityId(); this.hash = entity.getEntityId();
this.depth = depth; this.depth = depth;
Location loc = entity.getLocation(); Location location = entity.getLocation();
this.yaw = loc.getYaw(); this.yaw = location.getYaw();
this.pitch = loc.getPitch(); this.pitch = location.getPitch();
this.x = loc.getX(); this.x = location.getX();
this.y = loc.getY(); this.y = location.getY();
this.z = loc.getZ(); this.z = location.getZ();
this.type = entity.getType(); this.type = entity.getType();
if (depth == 0) { if (depth == 0) {
return; return;
@ -376,10 +376,10 @@ public class EntityWrapper {
this.lived.persistent = lived.getRemoveWhenFarAway(); this.lived.persistent = lived.getRemoveWhenFarAway();
this.lived.leashed = lived.isLeashed(); this.lived.leashed = lived.isLeashed();
if (this.lived.leashed) { if (this.lived.leashed) {
Location loc = lived.getLeashHolder().getLocation(); Location location = lived.getLeashHolder().getLocation();
this.lived.leash_x = (short) (this.x - loc.getBlockX()); this.lived.leash_x = (short) (this.x - location.getBlockX());
this.lived.leash_y = (short) (this.y - loc.getBlockY()); this.lived.leash_y = (short) (this.y - location.getBlockY());
this.lived.leash_z = (short) (this.z - loc.getBlockZ()); this.lived.leash_z = (short) (this.z - location.getBlockZ());
} }
EntityEquipment equipment = lived.getEquipment(); EntityEquipment equipment = lived.getEquipment();
this.lived.equipped = equipment != null; this.lived.equipped = equipment != null;
@ -435,27 +435,27 @@ public class EntityWrapper {
} }
public Entity spawn(World world, int x_offset, int z_offset) { public Entity spawn(World world, int x_offset, int z_offset) {
Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset); Location location = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
loc.setYaw(this.yaw); location.setYaw(this.yaw);
loc.setPitch(this.pitch); location.setPitch(this.pitch);
if (!this.type.isSpawnable()) { if (!this.type.isSpawnable()) {
return null; return null;
} }
Entity entity; Entity entity;
switch (this.type) { switch (this.type) {
case DROPPED_ITEM: case DROPPED_ITEM:
return world.dropItem(loc, this.stack); return world.dropItem(location, this.stack);
case PLAYER: case PLAYER:
case LEASH_HITCH: case LEASH_HITCH:
return null; return null;
case ITEM_FRAME: case ITEM_FRAME:
entity = world.spawn(loc, ItemFrame.class); entity = world.spawn(location, ItemFrame.class);
break; break;
case PAINTING: case PAINTING:
entity = world.spawn(loc, Painting.class); entity = world.spawn(location, Painting.class);
break; break;
default: default:
entity = world.spawnEntity(loc, this.type); entity = world.spawnEntity(location, this.type);
break; break;
} }
if (this.depth == 0) { if (this.depth == 0) {

View File

@ -376,8 +376,8 @@ public class BukkitChunkManager extends ChunkManager {
int tz = pos2.getZ(); int tz = pos2.getZ();
for (Entity entity : entities) { for (Entity entity : entities) {
if (!(entity instanceof Player)) { if (!(entity instanceof Player)) {
org.bukkit.Location loc = entity.getLocation(); org.bukkit.Location location = entity.getLocation();
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) { if (location.getX() >= bx && location.getX() <= tx && location.getZ() >= bz && location.getZ() <= tz) {
entity.remove(); entity.remove();
} }
} }
@ -472,15 +472,15 @@ public class BukkitChunkManager extends ChunkManager {
int[] count = new int[6]; int[] count = new int[6];
if (doWhole) { if (doWhole) {
for (Entity entity : entities) { for (Entity entity : entities) {
org.bukkit.Location loc = entity.getLocation(); org.bukkit.Location location = entity.getLocation();
Chunk chunk = loc.getChunk(); Chunk chunk = location.getChunk();
if (chunks.contains(chunk)) { if (chunks.contains(chunk)) {
int X = chunk.getX(); int X = chunk.getX();
int Z = chunk.getZ(); int Z = chunk.getZ();
if (X > bx && X < tx && Z > bz && Z < tz) { if (X > bx && X < tx && Z > bz && Z < tz) {
count(count, entity); count(count, entity);
} else { } else {
Plot other = area.getPlot(BukkitUtil.getLocation(loc)); Plot other = area.getPlot(BukkitUtil.getLocation(location));
if (plot.equals(other)) { if (plot.equals(other)) {
count(count, entity); count(count, entity);
} }

View File

@ -179,11 +179,11 @@ public class BukkitSetupUtils extends SetupUtils {
} }
@Override @Override
public String getGenerator(PlotArea plotworld) { public String getGenerator(PlotArea plotArea) {
if (SetupUtils.generators.isEmpty()) { if (SetupUtils.generators.isEmpty()) {
updateGenerators(); updateGenerators();
} }
World world = Bukkit.getWorld(plotworld.worldname); World world = Bukkit.getWorld(plotArea.worldname);
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -43,7 +43,7 @@ public class BukkitUtil extends WorldUtil {
private static Player lastPlayer = null; private static Player lastPlayer = null;
private static PlotPlayer lastPlotPlayer = null; private static PlotPlayer lastPlotPlayer = null;
public static void removePlayer(String plr) { public static void removePlayer(String player) {
lastPlayer = null; lastPlayer = null;
lastPlotPlayer = null; lastPlotPlayer = null;
} }
@ -62,9 +62,9 @@ public class BukkitUtil extends WorldUtil {
return lastPlotPlayer; return lastPlotPlayer;
} }
String name = player.getName(); String name = player.getName();
PlotPlayer pp = UUIDHandler.getPlayer(name); PlotPlayer plotPlayer = UUIDHandler.getPlayer(name);
if (pp != null) { if (plotPlayer != null) {
return pp; return plotPlayer;
} }
lastPlotPlayer = new BukkitPlayer(player); lastPlotPlayer = new BukkitPlayer(player);
UUIDHandler.getPlayers().put(name, lastPlotPlayer); UUIDHandler.getPlayers().put(name, lastPlotPlayer);
@ -102,15 +102,15 @@ public class BukkitUtil extends WorldUtil {
} }
public static Location getLocation(Entity entity) { public static Location getLocation(Entity entity) {
org.bukkit.Location loc = entity.getLocation(); org.bukkit.Location location = entity.getLocation();
String world = loc.getWorld().getName(); String world = location.getWorld().getName();
return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); return new Location(world, location.getBlockX(), location.getBlockY(), location.getBlockZ());
} }
public static Location getLocationFull(Entity entity) { public static Location getLocationFull(Entity entity) {
org.bukkit.Location loc = entity.getLocation(); org.bukkit.Location location = entity.getLocation();
return new Location(loc.getWorld().getName(), MathMan.roundInt(loc.getX()), MathMan.roundInt(loc.getY()), MathMan.roundInt(loc.getZ()), return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()),
loc.getYaw(), loc.getPitch()); location.getYaw(), location.getPitch());
} }
@Override @Override
@ -158,8 +158,8 @@ public class BukkitUtil extends WorldUtil {
} }
@Override @Override
public Location getSpawn(PlotPlayer pp) { public Location getSpawn(PlotPlayer player) {
return getLocation(((BukkitPlayer) pp).player.getBedSpawnLocation()); return getLocation(((BukkitPlayer) player).player.getBedSpawnLocation());
} }
@Override @Override
@ -190,9 +190,9 @@ public class BukkitUtil extends WorldUtil {
} }
@Override @Override
public int getBiomeFromString(String biomeStr) { public int getBiomeFromString(String biomeString) {
try { try {
Biome biome = Biome.valueOf(biomeStr.toUpperCase()); Biome biome = Biome.valueOf(biomeString.toUpperCase());
return Arrays.asList(Biome.values()).indexOf(biome); return Arrays.asList(Biome.values()).indexOf(biome);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
return -1; return -1;
@ -300,9 +300,9 @@ public class BukkitUtil extends WorldUtil {
} }
@Override @Override
public void setBiomes(String worldName, RegionWrapper region, String biomeStr) { public void setBiomes(String worldName, RegionWrapper region, String biomeString) {
World world = getWorld(worldName); World world = getWorld(worldName);
Biome biome = Biome.valueOf(biomeStr.toUpperCase()); Biome biome = Biome.valueOf(biomeString.toUpperCase());
for (int x = region.minX; x <= region.maxX; x++) { for (int x = region.minX; x <= region.maxX; x++) {
for (int z = region.minZ; z <= region.maxZ; z++) { for (int z = region.minZ; z <= region.maxZ; z++) {
world.setBiome(x, z, biome); world.setBiome(x, z, biome);

View File

@ -86,23 +86,23 @@ public class SendChunk {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) { for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue(); PlotPlayer pp = entry.getValue();
Plot plot = pp.getCurrentPlot(); Plot plot = pp.getCurrentPlot();
Location loc = null; Location location = null;
String world; String world;
if (plot != null) { if (plot != null) {
world = plot.getArea().worldname; world = plot.getArea().worldname;
} else { } else {
loc = pp.getLocation(); location = pp.getLocation();
world = loc.getWorld(); world = location.getWorld();
} }
ArrayList<Chunk> list = map.get(world); ArrayList<Chunk> list = map.get(world);
if (list == null) { if (list == null) {
continue; continue;
} }
if (loc == null) { if (location == null) {
loc = pp.getLocation(); location = pp.getLocation();
} }
int cx = loc.getX() >> 4; int cx = location.getX() >> 4;
int cz = loc.getZ() >> 4; int cz = location.getZ() >> 4;
Player player = ((BukkitPlayer) pp).player; Player player = ((BukkitPlayer) pp).player;
Object entity = this.methodGetHandlePlayer.of(player).call(); Object entity = this.methodGetHandlePlayer.of(player).call();

View File

@ -280,7 +280,6 @@ public class FastQueue_1_8_3 extends SlowQueue {
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) { if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
World world = chunk.getWorld(); World world = chunk.getWorld();
ChunkWrapper wrapper = bc.getChunkWrapper(); ChunkWrapper wrapper = bc.getChunkWrapper();
String worldName = wrapper.world;
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) { for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) { for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
if (x != 0 && z != 0) { if (x != 0 && z != 0) {
@ -288,7 +287,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
while (!other.isLoaded()) { while (!other.isLoaded()) {
other.load(true); other.load(true);
} }
ChunkManager.manager.loadChunk(worldName, new ChunkLoc(x, z), true); ChunkManager.manager.loadChunk(wrapper.world, new ChunkLoc(x, z), true);
} }
} }
} }

View File

@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -36,7 +37,7 @@ public class Add extends Command {
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.trust"), C.NO_PLOT_PERMS); checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.trust"), C.NO_PLOT_PERMS);
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage()); checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]); final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
checkTrue(uuids != null && !uuids.isEmpty(), C.INVALID_PLAYER, args[0]); checkTrue(!uuids.isEmpty(), C.INVALID_PLAYER, args[0]);
Iterator<UUID> iter = uuids.iterator(); Iterator<UUID> iter = uuids.iterator();
int size = plot.getTrusted().size() + plot.getMembers().size(); int size = plot.getTrusted().size() + plot.getMembers().size();
while (iter.hasNext()) { while (iter.hasNext()) {

View File

@ -21,31 +21,31 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Alias extends SetCommand { public class Alias extends SetCommand {
@Override @Override
public boolean set(PlotPlayer plr, Plot plot, String alias) { public boolean set(PlotPlayer player, Plot plot, String alias) {
if (alias.isEmpty()) { if (alias.isEmpty()) {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
if (alias.length() >= 50) { if (alias.length() >= 50) {
MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG); MainUtil.sendMessage(player, C.ALIAS_TOO_LONG);
return false; return false;
} }
if (alias.contains(" ") || !StringMan.isAsciiPrintable(alias)) { if (alias.contains(" ") || !StringMan.isAsciiPrintable(alias)) {
C.NOT_VALID_VALUE.send(plr); C.NOT_VALID_VALUE.send(player);
return false; return false;
} }
for (Plot p : PS.get().getPlots(plot.getArea())) { for (Plot p : PS.get().getPlots(plot.getArea())) {
if (p.getAlias().equalsIgnoreCase(alias)) { if (p.getAlias().equalsIgnoreCase(alias)) {
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
return false; return false;
} }
} }
if (UUIDHandler.nameExists(new StringWrapper(alias)) || PS.get().hasPlotArea(alias)) { if (UUIDHandler.nameExists(new StringWrapper(alias)) || PS.get().hasPlotArea(alias)) {
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
return false; return false;
} }
plot.setAlias(alias); plot.setAlias(alias);
MainUtil.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); MainUtil.sendMessage(player, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
return true; return true;
} }
} }

View File

@ -51,23 +51,23 @@ public class Auto extends SubCommand {
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
PlotArea plotarea = plr.getApplicablePlotArea(); PlotArea plotarea = player.getApplicablePlotArea();
if (plotarea == null) { if (plotarea == null) {
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
return false; return false;
} }
int size_x = 1; int size_x = 1;
int size_z = 1; int size_z = 1;
String schematic = null; String schematic = null;
if (args.length > 0) { if (args.length > 0) {
if (Permissions.hasPermission(plr, "plots.auto.mega")) { if (Permissions.hasPermission(player, "plots.auto.mega")) {
try { try {
String[] split = args[0].split(",|;"); String[] split = args[0].split(",|;");
size_x = Integer.parseInt(split[0]); size_x = Integer.parseInt(split[0]);
size_z = Integer.parseInt(split[1]); size_z = Integer.parseInt(split[1]);
if (size_x < 1 || size_z < 1) { if (size_x < 1 || size_z < 1) {
MainUtil.sendMessage(plr, "&cError: size<=0"); MainUtil.sendMessage(player, "&cError: size<=0");
} }
if (args.length > 1) { if (args.length > 1) {
schematic = args[1]; schematic = args[1];
@ -87,31 +87,31 @@ public class Auto extends SubCommand {
} }
} }
if (size_x * size_z > Settings.MAX_AUTO_SIZE) { if (size_x * size_z > Settings.MAX_AUTO_SIZE) {
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
return false; return false;
} }
int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname); int currentPlots = Settings.GLOBAL_LIMIT ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
int diff = currentPlots - plr.getAllowedPlots(); int diff = currentPlots - player.getAllowedPlots();
if (diff + size_x * size_z > 0) { if (diff + size_x * size_z > 0) {
if (diff < 0) { if (diff < 0) {
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + ""); MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
return false; return false;
} else if (plr.hasPersistentMeta("grantedPlots")) { } else if (player.hasPersistentMeta("grantedPlots")) {
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots")); int grantedPlots = ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
if (grantedPlots - diff < size_x * size_z) { if (grantedPlots - diff < size_x * size_z) {
plr.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
} else { } else {
int left = grantedPlots - diff - size_x * size_z; int left = grantedPlots - diff - size_x * size_z;
if (left == 0) { if (left == 0) {
plr.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
} else { } else {
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(left)); player.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(left));
} }
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + left, "" + (grantedPlots - left)); sendMessage(player, C.REMOVED_GRANTED_PLOT, "" + left, "" + (grantedPlots - left));
} }
} else { } else {
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
return false; return false;
} }
} }
@ -119,21 +119,21 @@ public class Auto extends SubCommand {
double cost = plotarea.PRICES.get("claim"); double cost = plotarea.PRICES.get("claim");
cost = (size_x * size_z) * cost; cost = (size_x * size_z) * cost;
if (cost > 0d) { if (cost > 0d) {
if (EconHandler.manager.getMoney(plr) < cost) { if (EconHandler.manager.getMoney(player) < cost) {
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
return true; return true;
} }
EconHandler.manager.withdrawMoney(plr, cost); EconHandler.manager.withdrawMoney(player, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + ""); sendMessage(player, C.REMOVED_BALANCE, cost + "");
} }
} }
if (schematic != null && !schematic.isEmpty()) { if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) { if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true; return true;
} }
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) { if (!Permissions.hasPermission(player, "plots.claim." + schematic) && !Permissions.hasPermission(player, "plots.admin.command.schematic")) {
MainUtil.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); MainUtil.sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
return true; return true;
} }
} }
@ -149,14 +149,14 @@ public class Auto extends SubCommand {
for (int i = 0; i <= max; i++) { for (int i = 0; i <= max; i++) {
PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
Plot current = plotarea.getPlotAbs(currentId); Plot current = plotarea.getPlotAbs(currentId);
if (current.canClaim(plr)) { if (current.canClaim(player)) {
current.claim(plr, true, null); current.claim(player, true, null);
return true; return true;
} }
id = getNextPlotId(id, 1); id = getNextPlotId(id, 1);
} }
// no free plots // no free plots
MainUtil.sendMessage(plr, C.NO_FREE_PLOTS); MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
return false; return false;
} }
plotarea.setMeta("lastPlot", new PlotId(0, 0)); plotarea.setMeta("lastPlot", new PlotId(0, 0));
@ -164,12 +164,12 @@ public class Auto extends SubCommand {
PlotId start = getNextPlotId(getLastPlotId(plotarea), 1); PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1); PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
plotarea.setMeta("lastPlot", start); plotarea.setMeta("lastPlot", start);
if (plotarea.canClaim(plr, start, end)) { if (plotarea.canClaim(player, start, end)) {
for (int i = start.x; i <= end.x; i++) { for (int i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) { for (int j = start.y; j <= end.y; j++) {
Plot plot = plotarea.getPlotAbs(new PlotId(i, j)); Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
boolean teleport = i == end.x && j == end.y; boolean teleport = i == end.x && j == end.y;
plot.claim(plr, teleport, null); plot.claim(player, teleport, null);
} }
} }
if (size_x != 1 || size_z != 1) { if (size_x != 1 || size_z != 1) {

View File

@ -17,40 +17,40 @@ import com.plotsquared.general.commands.CommandDeclaration;
requiredType = RequiredType.NONE) requiredType = RequiredType.NONE)
public class BO3 extends SubCommand { public class BO3 extends SubCommand {
public void noArgs(PlotPlayer plr) { public void noArgs(PlotPlayer player) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
Plot plot = loc.getPlotAbs(); Plot plot = loc.getPlotAbs();
if (plot == null || !plot.hasOwner()) { if (plot == null || !plot.hasOwner()) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.bo3")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (args.length == 0) { if (args.length == 0) {
noArgs(plr); noArgs(player);
return false; return false;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "output": case "output":
case "save": case "save":
case "export": case "export":
return BO3Handler.saveBO3(plr, plot); return BO3Handler.saveBO3(player, plot);
case "paste": case "paste":
case "load": case "load":
case "import": case "import":
case "input": case "input":
// TODO NOT IMPLEMENTED YET // TODO NOT IMPLEMENTED YET
MainUtil.sendMessage(plr, "NOT IMPLEMENTED YET!!!"); MainUtil.sendMessage(player, "NOT IMPLEMENTED YET!!!");
return false; return false;
default: default:
noArgs(plr); noArgs(player);
return false; return false;
} }
} }

View File

@ -19,16 +19,16 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Biome extends SetCommand { public class Biome extends SetCommand {
@Override @Override
public boolean set(final PlotPlayer plr, final Plot plot, final String value) { public boolean set(final PlotPlayer player, final Plot plot, final String value) {
int biome = WorldUtil.IMP.getBiomeFromString(value); int biome = WorldUtil.IMP.getBiomeFromString(value);
if (biome == -1) { if (biome == -1) {
String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), C.BLOCK_LIST_SEPARATER.s()); String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), C.BLOCK_LIST_SEPARATER.s());
C.NEED_BIOME.send(plr); C.NEED_BIOME.send(player);
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes); MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes);
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return false; return false;
} }
plot.addRunning(); plot.addRunning();
@ -36,7 +36,7 @@ public class Biome extends SetCommand {
@Override @Override
public void run() { public void run() {
plot.removeRunning(); plot.removeRunning();
MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + value.toLowerCase()); MainUtil.sendMessage(player, C.BIOME_SET_TO.s() + value.toLowerCase());
} }
}); });
return true; return true;

View File

@ -20,61 +20,61 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Claim extends SubCommand { public class Claim extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
String schematic = ""; String schematic = "";
if (args.length >= 1) { if (args.length >= 1) {
schematic = args[0]; schematic = args[0];
} }
Location loc = plr.getLocation(); Location loc = player.getLocation();
Plot plot = loc.getPlotAbs(); Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
return sendMessage(plr, C.NOT_IN_PLOT); return sendMessage(player, C.NOT_IN_PLOT);
} }
int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(loc.getWorld()); int currentPlots = Settings.GLOBAL_LIMIT ? player.getPlotCount() : player.getPlotCount(loc.getWorld());
int grants = 0; int grants = 0;
if (currentPlots >= plr.getAllowedPlots()) { if (currentPlots >= player.getAllowedPlots()) {
if (plr.hasPersistentMeta("grantedPlots")) { if (player.hasPersistentMeta("grantedPlots")) {
grants = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots")); grants = ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
if (grants <= 0) { if (grants <= 0) {
plr.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
} }
} else { } else {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
} }
} }
if (!plot.canClaim(plr)) { if (!plot.canClaim(player)) {
return sendMessage(plr, C.PLOT_IS_CLAIMED); return sendMessage(player, C.PLOT_IS_CLAIMED);
} }
PlotArea world = plot.getArea(); PlotArea world = plot.getArea();
if ((EconHandler.manager != null) && world.USE_ECONOMY) { if ((EconHandler.manager != null) && world.USE_ECONOMY) {
double cost = world.PRICES.get("claim"); double cost = world.PRICES.get("claim");
if (cost > 0d) { if (cost > 0d) {
if (EconHandler.manager.getMoney(plr) < cost) { if (EconHandler.manager.getMoney(player) < cost) {
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
} }
EconHandler.manager.withdrawMoney(plr, cost); EconHandler.manager.withdrawMoney(player, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + ""); sendMessage(player, C.REMOVED_BALANCE, cost + "");
} }
} }
if (grants > 0) { if (grants > 0) {
if (grants == 1) { if (grants == 1) {
plr.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
} else { } else {
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(grants - 1)); player.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(grants - 1));
} }
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); sendMessage(player, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
} }
if (!schematic.isEmpty()) { if (!schematic.isEmpty()) {
if (world.SCHEMATIC_CLAIM_SPECIFY) { if (world.SCHEMATIC_CLAIM_SPECIFY) {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
} }
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) { if (!Permissions.hasPermission(player, "plots.claim." + schematic) && !Permissions.hasPermission(player, "plots.admin.command.schematic")) {
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
} }
} }
} }
return plot.claim(plr, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED); return plot.claim(player, false, schematic) || sendMessage(player, C.PLOT_NOT_CLAIMED);
} }
} }

View File

@ -30,74 +30,74 @@ import java.util.UUID;
public class Cluster extends SubCommand { public class Cluster extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
if (args.length == 0) { if (args.length == 0) {
// return arguments // return arguments
MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); MainUtil.sendMessage(player, C.CLUSTER_AVAILABLE_ARGS);
return false; return false;
} }
String sub = args[0].toLowerCase(); String sub = args[0].toLowerCase();
switch (sub) { switch (sub) {
case "l": case "l":
case "list": { case "list": {
if (!Permissions.hasPermission(plr, "plots.cluster.list")) { if (!Permissions.hasPermission(player, "plots.cluster.list")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.list"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.list");
return false; return false;
} }
if (args.length != 1) { if (args.length != 1) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster list");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
return false; return false;
} }
Set<PlotCluster> clusters = area.getClusters(); Set<PlotCluster> clusters = area.getClusters();
MainUtil.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); MainUtil.sendMessage(player, C.CLUSTER_LIST_HEADING, clusters.size() + "");
for (PlotCluster cluster : clusters) { for (PlotCluster cluster : clusters) {
// Ignore unmanaged clusters // Ignore unmanaged clusters
String name = "'" + cluster.getName() + "' : " + cluster.toString(); String name = "'" + cluster.getName() + "' : " + cluster.toString();
if (plr.getUUID().equals(cluster.owner)) { if (player.getUUID().equals(cluster.owner)) {
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name); MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&a" + name);
} else if (cluster.helpers.contains(plr.getUUID())) { } else if (cluster.helpers.contains(player.getUUID())) {
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name); MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&3" + name);
} else if (cluster.invited.contains(plr.getUUID())) { } else if (cluster.invited.contains(player.getUUID())) {
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name); MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&9" + name);
} else { } else {
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString()); MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, cluster.toString());
} }
} }
return true; return true;
} }
case "c": case "c":
case "create": { case "create": {
if (!Permissions.hasPermission(plr, "plots.cluster.create")) { if (!Permissions.hasPermission(player, "plots.cluster.create")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.create");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
return false; return false;
} }
if (args.length != 4) { if (args.length != 4) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>");
return false; return false;
} }
// check pos1 / pos2 // check pos1 / pos2
PlotId pos1 = PlotId.fromString(args[2]); PlotId pos1 = PlotId.fromString(args[2]);
PlotId pos2 = PlotId.fromString(args[3]); PlotId pos2 = PlotId.fromString(args[3]);
if (pos1 == null || pos2 == null) { if (pos1 == null || pos2 == null) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
return false; return false;
} }
// check if name is taken // check if name is taken
String name = args[1]; String name = args[1];
if (area.getCluster(name) != null) { if (area.getCluster(name) != null) {
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
return false; return false;
} }
if (pos2.x < pos1.x || pos2.y < pos1.y) { if (pos2.x < pos1.x || pos2.y < pos1.y) {
@ -108,33 +108,33 @@ public class Cluster extends SubCommand {
//check if overlap //check if overlap
PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2); PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2);
if (cluster != null) { if (cluster != null) {
MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, cluster.getName()); MainUtil.sendMessage(player, C.CLUSTER_INTERSECTION, cluster.getName());
return false; return false;
} }
// Check if it occupies existing plots // Check if it occupies existing plots
Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2); Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2);
if (!plots.isEmpty()) { if (!plots.isEmpty()) {
if (!Permissions.hasPermission(plr, "plots.cluster.create.other")) { if (!Permissions.hasPermission(player, "plots.cluster.create.other")) {
UUID uuid = plr.getUUID(); UUID uuid = player.getUUID();
for (Plot plot : plots) { for (Plot plot : plots) {
if (!plot.isOwner(uuid)) { if (!plot.isOwner(uuid)) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.create.other");
return false; return false;
} }
} }
} }
} }
// Check allowed cluster size // Check allowed cluster size
cluster = new PlotCluster(area, pos1, pos2, plr.getUUID()); cluster = new PlotCluster(area, pos1, pos2, player.getUUID());
int current; int current;
if (Settings.GLOBAL_LIMIT) { if (Settings.GLOBAL_LIMIT) {
current = plr.getPlayerClusterCount(); current = player.getPlayerClusterCount();
} else { } else {
current = plr.getPlayerClusterCount(plr.getLocation().getWorld()); current = player.getPlayerClusterCount(player.getLocation().getWorld());
} }
int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS); int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.MAX_PLOTS);
if (current + cluster.getArea() > allowed) { if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea())); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
return false; return false;
} }
// create cluster // create cluster
@ -150,64 +150,64 @@ public class Cluster extends SubCommand {
} }
} }
} }
MainUtil.sendMessage(plr, C.CLUSTER_ADDED); MainUtil.sendMessage(player, C.CLUSTER_ADDED);
return true; return true;
} }
case "disband": case "disband":
case "del": case "del":
case "delete": { case "delete": {
if (!Permissions.hasPermission(plr, "plots.cluster.delete")) { if (!Permissions.hasPermission(player, "plots.cluster.delete")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.delete");
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
return false; return false;
} }
PlotCluster cluster; PlotCluster cluster;
if (args.length == 2) { if (args.length == 2) {
cluster = area.getCluster(args[1]); cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
return false; return false;
} }
} else { } else {
cluster = area.getCluster(plr.getLocation()); cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
} }
if (!cluster.owner.equals(plr.getUUID())) { if (!cluster.owner.equals(player.getUUID())) {
if (!Permissions.hasPermission(plr, "plots.cluster.delete.other")) { if (!Permissions.hasPermission(player, "plots.cluster.delete.other")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.delete.other");
return false; return false;
} }
} }
DBFunc.delete(cluster); DBFunc.delete(cluster);
MainUtil.sendMessage(plr, C.CLUSTER_DELETED); MainUtil.sendMessage(player, C.CLUSTER_DELETED);
return true; return true;
} }
case "res": case "res":
case "resize": { case "resize": {
if (!Permissions.hasPermission(plr, "plots.cluster.resize")) { if (!Permissions.hasPermission(player, "plots.cluster.resize")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize");
return false; return false;
} }
if (args.length != 3) { if (args.length != 3) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster resize <pos1> <pos2>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster resize <pos1> <pos2>");
return false; return false;
} }
// check pos1 / pos2 // check pos1 / pos2
PlotId pos1 = PlotId.fromString(args[1]); PlotId pos1 = PlotId.fromString(args[1]);
PlotId pos2 = PlotId.fromString(args[2]); PlotId pos2 = PlotId.fromString(args[2]);
if (pos1 == null || pos2 == null) { if (pos1 == null || pos2 == null) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
return false; return false;
} }
if (pos2.x < pos1.x || pos2.y < pos1.y) { if (pos2.x < pos1.x || pos2.y < pos1.y) {
@ -215,26 +215,26 @@ public class Cluster extends SubCommand {
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y)); pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
} }
// check if in cluster // check if in cluster
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
return false; return false;
} }
PlotCluster cluster = area.getCluster(plr.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
if (!cluster.hasHelperRights(plr.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions.hasPermission(plr, "plots.cluster.resize.other")) { if (!Permissions.hasPermission(player, "plots.cluster.resize.other")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.other");
return false; return false;
} }
} }
//check if overlap //check if overlap
PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2); PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2);
if (intersect != null) { if (intersect != null) {
MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, intersect.getName()); MainUtil.sendMessage(player, C.CLUSTER_INTERSECTION, intersect.getName());
return false; return false;
} }
HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2()); HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
@ -243,116 +243,116 @@ public class Cluster extends SubCommand {
removed.removeAll(newPlots); removed.removeAll(newPlots);
// Check expand / shrink // Check expand / shrink
if (!removed.isEmpty()) { if (!removed.isEmpty()) {
if (!Permissions.hasPermission(plr, "plots.cluster.resize.shrink")) { if (!Permissions.hasPermission(player, "plots.cluster.resize.shrink")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.shrink"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.shrink");
return false; return false;
} }
} }
newPlots.removeAll(existing); newPlots.removeAll(existing);
if (!newPlots.isEmpty()) { if (!newPlots.isEmpty()) {
if (!Permissions.hasPermission(plr, "plots.cluster.resize.expand")) { if (!Permissions.hasPermission(player, "plots.cluster.resize.expand")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.expand"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.expand");
return false; return false;
} }
} }
// Check allowed cluster size // Check allowed cluster size
int current; int current;
if (Settings.GLOBAL_LIMIT) { if (Settings.GLOBAL_LIMIT) {
current = plr.getPlayerClusterCount(); current = player.getPlayerClusterCount();
} else { } else {
current = plr.getPlayerClusterCount(plr.getLocation().getWorld()); current = player.getPlayerClusterCount(player.getLocation().getWorld());
} }
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS); int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.MAX_PLOTS);
if (current + cluster.getArea() > allowed) { if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea())); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
return false; return false;
} }
// resize cluster // resize cluster
DBFunc.resizeCluster(cluster, pos1, pos2); DBFunc.resizeCluster(cluster, pos1, pos2);
MainUtil.sendMessage(plr, C.CLUSTER_RESIZED); MainUtil.sendMessage(player, C.CLUSTER_RESIZED);
return true; return true;
} }
case "add": case "add":
case "inv": case "inv":
case "invite": { case "invite": {
if (!Permissions.hasPermission(plr, "plots.cluster.invite")) { if (!Permissions.hasPermission(player, "plots.cluster.invite")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.invite");
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster invite <player>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster invite <player>");
return false; return false;
} }
// check if in cluster // check if in cluster
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
} }
PlotCluster cluster = area.getCluster(plr.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
if (!cluster.hasHelperRights(plr.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions.hasPermission(plr, "plots.cluster.invite.other")) { if (!Permissions.hasPermission(player, "plots.cluster.invite.other")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.invite.other");
return false; return false;
} }
} }
// check uuid // check uuid
UUID uuid = UUIDHandler.getUUID(args[1], null); UUID uuid = UUIDHandler.getUUID(args[1], null);
if (uuid == null) { if (uuid == null) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]); MainUtil.sendMessage(player, C.INVALID_PLAYER, args[2]);
return false; return false;
} }
if (!cluster.isAdded(uuid)) { if (!cluster.isAdded(uuid)) {
// add the user if not added // add the user if not added
cluster.invited.add(uuid); cluster.invited.add(uuid);
DBFunc.setInvited(cluster, uuid); DBFunc.setInvited(cluster, uuid);
PlotPlayer player = UUIDHandler.getPlayer(uuid); PlotPlayer player2 = UUIDHandler.getPlayer(uuid);
if (player != null) { if (player2 != null) {
MainUtil.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); MainUtil.sendMessage(player2, C.CLUSTER_INVITED, cluster.getName());
} }
} }
MainUtil.sendMessage(plr, C.CLUSTER_ADDED_USER); MainUtil.sendMessage(player, C.CLUSTER_ADDED_USER);
return true; return true;
} }
case "k": case "k":
case "remove": case "remove":
case "kick": { case "kick": {
if (!Permissions.hasPermission(plr, "plots.cluster.kick")) { if (!Permissions.hasPermission(player, "plots.cluster.kick")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.kick");
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick <player>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster kick <player>");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
} }
PlotCluster cluster = area.getCluster(plr.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
if (!cluster.hasHelperRights(plr.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions.hasPermission(plr, "plots.cluster.kick.other")) { if (!Permissions.hasPermission(player, "plots.cluster.kick.other")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.kick.other");
return false; return false;
} }
} }
// check uuid // check uuid
UUID uuid = UUIDHandler.getUUID(args[1], null); UUID uuid = UUIDHandler.getUUID(args[1], null);
if (uuid == null) { if (uuid == null) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); MainUtil.sendMessage(player, C.INVALID_PLAYER, args[1]);
return false; return false;
} }
// Can't kick if the player is yourself, the owner, or not added to the cluster // Can't kick if the player is yourself, the owner, or not added to the cluster
if (uuid.equals(plr.getUUID()) || uuid.equals(cluster.owner) || !cluster.isAdded(uuid)) { if (uuid.equals(player.getUUID()) || uuid.equals(cluster.owner) || !cluster.isAdded(uuid)) {
MainUtil.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName()); MainUtil.sendMessage(player, C.CANNOT_KICK_PLAYER, cluster.getName());
return false; return false;
} }
if (cluster.helpers.contains(uuid)) { if (cluster.helpers.contains(uuid)) {
@ -361,54 +361,54 @@ public class Cluster extends SubCommand {
} }
cluster.invited.remove(uuid); cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid); DBFunc.removeInvited(cluster, uuid);
PlotPlayer player = UUIDHandler.getPlayer(uuid); PlotPlayer player2 = UUIDHandler.getPlayer(uuid);
if (player != null) { if (player2 != null) {
MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); MainUtil.sendMessage(player2, C.CLUSTER_REMOVED, cluster.getName());
} }
for (Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) { for (Plot plot : new ArrayList<>(PS.get().getPlots(player2.getLocation().getWorld(), uuid))) {
PlotCluster current = plot.getCluster(); PlotCluster current = plot.getCluster();
if (current != null && current.equals(cluster)) { if (current != null && current.equals(cluster)) {
plot.unclaim(); plot.unclaim();
} }
} }
MainUtil.sendMessage(plr, C.CLUSTER_KICKED_USER); MainUtil.sendMessage(player2, C.CLUSTER_KICKED_USER);
return true; return true;
} }
case "quit": case "quit":
case "leave": { case "leave": {
if (!Permissions.hasPermission(plr, "plots.cluster.leave")) { if (!Permissions.hasPermission(player, "plots.cluster.leave")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.leave");
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
} }
PlotCluster cluster; PlotCluster cluster;
if (args.length == 2) { if (args.length == 2) {
cluster = area.getCluster(args[1]); cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
return false; return false;
} }
} else { } else {
cluster = area.getCluster(plr.getLocation()); cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
} }
UUID uuid = plr.getUUID(); UUID uuid = player.getUUID();
if (!cluster.isAdded(uuid)) { if (!cluster.isAdded(uuid)) {
MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED); MainUtil.sendMessage(player, C.CLUSTER_NOT_ADDED);
return false; return false;
} }
if (uuid.equals(cluster.owner)) { if (uuid.equals(cluster.owner)) {
MainUtil.sendMessage(plr, C.CLUSTER_CANNOT_LEAVE); MainUtil.sendMessage(player, C.CLUSTER_CANNOT_LEAVE);
return false; return false;
} }
if (cluster.helpers.contains(uuid)) { if (cluster.helpers.contains(uuid)) {
@ -417,11 +417,11 @@ public class Cluster extends SubCommand {
} }
cluster.invited.remove(uuid); cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid); DBFunc.removeInvited(cluster, uuid);
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
for (Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) { for (Plot plot : new ArrayList<>(PS.get().getPlots(player.getLocation().getWorld(), uuid))) {
PlotCluster current = plot.getCluster(); PlotCluster current = plot.getCluster();
if (current != null && current.equals(cluster)) { if (current != null && current.equals(cluster)) {
plr.getLocation().getWorld(); player.getLocation().getWorld();
plot.unclaim(); plot.unclaim();
} }
} }
@ -430,99 +430,99 @@ public class Cluster extends SubCommand {
case "admin": case "admin":
case "helper": case "helper":
case "helpers": { case "helpers": {
if (!Permissions.hasPermission(plr, "plots.cluster.helpers")) { if (!Permissions.hasPermission(player, "plots.cluster.helpers")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.helpers"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.helpers");
return false; return false;
} }
if (args.length != 3) { if (args.length != 3) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers <add|remove> <player>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster helpers <add|remove> <player>");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
} }
PlotCluster cluster = area.getCluster(plr.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
UUID uuid = UUIDHandler.getUUID(args[2], null); UUID uuid = UUIDHandler.getUUID(args[2], null);
if (uuid == null) { if (uuid == null) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]); MainUtil.sendMessage(player, C.INVALID_PLAYER, args[2]);
return false; return false;
} }
if (args[1].equalsIgnoreCase("add")) { if (args[1].equalsIgnoreCase("add")) {
cluster.helpers.add(uuid); cluster.helpers.add(uuid);
DBFunc.setHelper(cluster, uuid); DBFunc.setHelper(cluster, uuid);
return MainUtil.sendMessage(plr, C.CLUSTER_ADDED_HELPER); return MainUtil.sendMessage(player, C.CLUSTER_ADDED_HELPER);
} }
if (args[1].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("remove")) {
cluster.helpers.remove(uuid); cluster.helpers.remove(uuid);
DBFunc.removeHelper(cluster, uuid); DBFunc.removeHelper(cluster, uuid);
return MainUtil.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); return MainUtil.sendMessage(player, C.CLUSTER_REMOVED_HELPER);
} }
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers <add|remove> <player>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster helpers <add|remove> <player>");
return false; return false;
} }
case "spawn": case "spawn":
case "home": case "home":
case "tp": { case "tp": {
if (!Permissions.hasPermission(plr, "plots.cluster.tp")) { if (!Permissions.hasPermission(player, "plots.cluster.tp")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.tp");
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp <name>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster tp <name>");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
return false; return false;
} }
PlotCluster cluster = area.getCluster(args[1]); PlotCluster cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
return false; return false;
} }
UUID uuid = plr.getUUID(); UUID uuid = player.getUUID();
if (!cluster.isAdded(uuid)) { if (!cluster.isAdded(uuid)) {
if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) { if (!Permissions.hasPermission(player, "plots.cluster.tp.other")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.tp.other");
return false; return false;
} }
} }
plr.teleport(cluster.getHome()); player.teleport(cluster.getHome());
return MainUtil.sendMessage(plr, C.CLUSTER_TELEPORTING); return MainUtil.sendMessage(player, C.CLUSTER_TELEPORTING);
} }
case "i": case "i":
case "info": case "info":
case "show": case "show":
case "information": { case "information": {
if (!Permissions.hasPermission(plr, "plots.cluster.info")) { if (!Permissions.hasPermission(player, "plots.cluster.info")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.info");
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster info [name]");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
} }
PlotCluster cluster; PlotCluster cluster;
if (args.length == 2) { if (args.length == 2) {
cluster = area.getCluster(args[1]); cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
return false; return false;
} }
} else { } else {
cluster = area.getCluster(plr.getLocation()); cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
} }
@ -533,50 +533,50 @@ public class Cluster extends SubCommand {
} }
String name = cluster.getName(); String name = cluster.getName();
String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1); String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1);
String rights = cluster.isAdded(plr.getUUID()) + ""; String rights = cluster.isAdded(player.getUUID()) + "";
String message = C.CLUSTER_INFO.s(); String message = C.CLUSTER_INFO.s();
message = message.replaceAll("%id%", id); message = message.replaceAll("%id%", id);
message = message.replaceAll("%owner%", owner); message = message.replaceAll("%owner%", owner);
message = message.replaceAll("%name%", name); message = message.replaceAll("%name%", name);
message = message.replaceAll("%size%", size); message = message.replaceAll("%size%", size);
message = message.replaceAll("%rights%", rights); message = message.replaceAll("%rights%", rights);
MainUtil.sendMessage(plr, message); MainUtil.sendMessage(player, message);
return true; return true;
} }
case "sh": case "sh":
case "setspawn": case "setspawn":
case "sethome": case "sethome":
if (!Permissions.hasPermission(plr, "plots.cluster.sethome")) { if (!Permissions.hasPermission(player, "plots.cluster.sethome")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.sethome");
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster sethome");
return false; return false;
} }
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr); C.NOT_IN_PLOT_WORLD.send(player);
} }
PlotCluster cluster = area.getCluster(plr.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
return false; return false;
} }
if (!cluster.hasHelperRights(plr.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions.hasPermission(plr, "plots.cluster.sethome.other")) { if (!Permissions.hasPermission(player, "plots.cluster.sethome.other")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.sethome.other");
return false; return false;
} }
} }
Location base = cluster.getClusterBottom(); Location base = cluster.getClusterBottom();
Location relative = plr.getLocation().subtract(base.getX(), 0, base.getZ()); Location relative = player.getLocation().subtract(base.getX(), 0, base.getZ());
BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ()); BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ());
cluster.settings.setPosition(blockloc); cluster.settings.setPosition(blockloc);
DBFunc.setPosition(cluster, relative.getX() + "," + relative.getY() + "," + relative.getZ()); DBFunc.setPosition(cluster, relative.getX() + "," + relative.getY() + "," + relative.getZ());
return MainUtil.sendMessage(plr, C.POSITION_SET); return MainUtil.sendMessage(player, C.POSITION_SET);
} }
MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); MainUtil.sendMessage(player, C.CLUSTER_AVAILABLE_ARGS);
return false; return false;
} }
} }

View File

@ -29,28 +29,28 @@ public class Condense extends SubCommand {
public static boolean TASK = false; public static boolean TASK = false;
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length != 2 && args.length != 3) { if (args.length != 2 && args.length != 3) {
MainUtil.sendMessage(plr, "/plot condense <area> <start|stop|info> [radius]"); MainUtil.sendMessage(player, "/plot condense <area> <start|stop|info> [radius]");
return false; return false;
} }
PlotArea area = PS.get().getPlotAreaByString(args[0]); PlotArea area = PS.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) { if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
MainUtil.sendMessage(plr, "INVALID AREA"); MainUtil.sendMessage(player, "INVALID AREA");
return false; return false;
} }
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "start": { case "start": {
if (args.length == 2) { if (args.length == 2) {
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " start <radius>"); MainUtil.sendMessage(player, "/plot condense " + area.toString() + " start <radius>");
return false; return false;
} }
if (Condense.TASK) { if (Condense.TASK) {
MainUtil.sendMessage(plr, "TASK ALREADY STARTED"); MainUtil.sendMessage(player, "TASK ALREADY STARTED");
return false; return false;
} }
if (!MathMan.isInteger(args[2])) { if (!MathMan.isInteger(args[2])) {
MainUtil.sendMessage(plr, "INVALID RADIUS"); MainUtil.sendMessage(player, "INVALID RADIUS");
return false; return false;
} }
int radius = Integer.parseInt(args[2]); int radius = Integer.parseInt(args[2]);
@ -93,7 +93,7 @@ public class Condense extends SubCommand {
int size = allPlots.size(); int size = allPlots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1); int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) { if (radius < minimumRadius) {
MainUtil.sendMessage(plr, "RADIUS TOO SMALL"); MainUtil.sendMessage(player, "RADIUS TOO SMALL");
return false; return false;
} }
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius)); List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
@ -107,19 +107,19 @@ public class Condense extends SubCommand {
start = Auto.getNextPlotId(start, 1); start = Auto.getNextPlotId(start, 1);
} }
if (free.isEmpty() || toMove.isEmpty()) { if (free.isEmpty() || toMove.isEmpty()) {
MainUtil.sendMessage(plr, "NO FREE PLOTS FOUND"); MainUtil.sendMessage(player, "NO FREE PLOTS FOUND");
return false; return false;
} }
MainUtil.sendMessage(plr, "TASK STARTED..."); MainUtil.sendMessage(player, "TASK STARTED...");
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
if (!Condense.TASK) { if (!Condense.TASK) {
MainUtil.sendMessage(plr, "TASK CANCELLED."); MainUtil.sendMessage(player, "TASK CANCELLED.");
} }
if (allPlots.isEmpty()) { if (allPlots.isEmpty()) {
Condense.TASK = false; Condense.TASK = false;
MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK."); MainUtil.sendMessage(player, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
return; return;
} }
final Runnable task = this; final Runnable task = this;
@ -137,7 +137,7 @@ public class Condense extends SubCommand {
@Override @Override
public void run() { public void run() {
if (result.get()) { if (result.get()) {
MainUtil.sendMessage(plr, "Moving: " + origin + " -> " + possible); MainUtil.sendMessage(player, "Moving: " + origin + " -> " + possible);
TaskManager.runTaskLater(task, 1); TaskManager.runTaskLater(task, 1);
} }
} }
@ -148,11 +148,11 @@ public class Condense extends SubCommand {
} }
if (free.isEmpty()) { if (free.isEmpty()) {
Condense.TASK = false; Condense.TASK = false;
MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!"); MainUtil.sendMessage(player, "TASK FAILED. NO FREE PLOTS FOUND!");
return; return;
} }
if (i >= free.size()) { if (i >= free.size()) {
MainUtil.sendMessage(plr, "SKIPPING COMPLEX PLOT: " + origin); MainUtil.sendMessage(player, "SKIPPING COMPLEX PLOT: " + origin);
} }
} }
}; };
@ -162,19 +162,19 @@ public class Condense extends SubCommand {
} }
case "stop": case "stop":
if (!Condense.TASK) { if (!Condense.TASK) {
MainUtil.sendMessage(plr, "TASK ALREADY STOPPED"); MainUtil.sendMessage(player, "TASK ALREADY STOPPED");
return false; return false;
} }
Condense.TASK = false; Condense.TASK = false;
MainUtil.sendMessage(plr, "TASK STOPPED"); MainUtil.sendMessage(player, "TASK STOPPED");
return true; return true;
case "info": case "info":
if (args.length == 2) { if (args.length == 2) {
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " info <radius>"); MainUtil.sendMessage(player, "/plot condense " + area.toString() + " info <radius>");
return false; return false;
} }
if (!MathMan.isInteger(args[2])) { if (!MathMan.isInteger(args[2])) {
MainUtil.sendMessage(plr, "INVALID RADIUS"); MainUtil.sendMessage(player, "INVALID RADIUS");
return false; return false;
} }
int radius = Integer.parseInt(args[2]); int radius = Integer.parseInt(args[2]);
@ -182,22 +182,22 @@ public class Condense extends SubCommand {
int size = plots.size(); int size = plots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1); int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) { if (radius < minimumRadius) {
MainUtil.sendMessage(plr, "RADIUS TOO SMALL"); MainUtil.sendMessage(player, "RADIUS TOO SMALL");
return false; return false;
} }
int maxMove = getPlots(plots, minimumRadius).size(); int maxMove = getPlots(plots, minimumRadius).size();
int userMove = getPlots(plots, radius).size(); int userMove = getPlots(plots, radius).size();
MainUtil.sendMessage(plr, "=== DEFAULT EVAL ==="); MainUtil.sendMessage(player, "=== DEFAULT EVAL ===");
MainUtil.sendMessage(plr, "MINIMUM RADIUS: " + minimumRadius); MainUtil.sendMessage(player, "MINIMUM RADIUS: " + minimumRadius);
MainUtil.sendMessage(plr, "MAXIMUM MOVES: " + maxMove); MainUtil.sendMessage(player, "MAXIMUM MOVES: " + maxMove);
MainUtil.sendMessage(plr, "=== INPUT EVAL ==="); MainUtil.sendMessage(player, "=== INPUT EVAL ===");
MainUtil.sendMessage(plr, "INPUT RADIUS: " + radius); MainUtil.sendMessage(player, "INPUT RADIUS: " + radius);
MainUtil.sendMessage(plr, "ESTIMATED MOVES: " + userMove); MainUtil.sendMessage(player, "ESTIMATED MOVES: " + userMove);
MainUtil.sendMessage(plr, "ESTIMATED TIME: No idea, times will drastically change based on the system performance and load"); MainUtil.sendMessage(player, "ESTIMATED TIME: No idea, times will drastically change based on the system performance and load");
MainUtil.sendMessage(plr, "&e - Radius is measured in plot width"); MainUtil.sendMessage(player, "&e - Radius is measured in plot width");
return true; return true;
} }
MainUtil.sendMessage(plr, "/plot condense " + area.worldname + " <start|stop|info> [radius]"); MainUtil.sendMessage(player, "/plot condense " + area.worldname + " <start|stop|info> [radius]");
return false; return false;
} }

View File

@ -15,15 +15,15 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Confirm extends SubCommand { public class Confirm extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
CmdInstance command = CmdConfirm.getPending(plr); CmdInstance command = CmdConfirm.getPending(player);
if (command == null) { if (command == null) {
MainUtil.sendMessage(plr, C.FAILED_CONFIRM); MainUtil.sendMessage(player, C.FAILED_CONFIRM);
return false; return false;
} }
CmdConfirm.removePending(plr); CmdConfirm.removePending(player);
if ((System.currentTimeMillis() - command.timestamp) > 20000) { if ((System.currentTimeMillis() - command.timestamp) > 20000) {
MainUtil.sendMessage(plr, C.FAILED_CONFIRM); MainUtil.sendMessage(player, C.FAILED_CONFIRM);
return false; return false;
} }
TaskManager.runTask(command.command); TaskManager.runTask(command.command);

View File

@ -18,30 +18,30 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Continue extends SubCommand { public class Continue extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Plot plot = plr.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.continue")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.continue")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (!plot.hasFlag(Flags.DONE)) { if (!plot.hasFlag(Flags.DONE)) {
MainUtil.sendMessage(plr, C.DONE_NOT_DONE); MainUtil.sendMessage(player, C.DONE_NOT_DONE);
return false; return false;
} }
int size = plot.getConnectedPlots().size(); int size = plot.getConnectedPlots().size();
if (Settings.DONE_COUNTS_TOWARDS_LIMIT && (plr.getAllowedPlots() < plr.getPlotCount() + size)) { if (Settings.DONE_COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots() < player.getPlotCount() + size)) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.continue"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command.continue");
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return false; return false;
} }
plot.removeFlag(Flags.DONE); plot.removeFlag(Flags.DONE);
MainUtil.sendMessage(plr, C.DONE_REMOVED); MainUtil.sendMessage(player, C.DONE_REMOVED);
return true; return true;
} }
} }

View File

@ -19,42 +19,42 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Copy extends SubCommand { public class Copy extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
Plot plot1 = loc.getPlotAbs(); Plot plot1 = loc.getPlotAbs();
if (plot1 == null) { if (plot1 == null) {
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return !MainUtil.sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) { if (!plot1.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN.s())) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (args.length != 1) { if (args.length != 1) {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true); Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
if (plot2 == null) { if (plot2 == null) {
return false; return false;
} }
if (plot1.equals(plot2)) { if (plot1.equals(plot2)) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
if (!plot1.getArea().isCompatible(plot2.getArea())) { if (!plot1.getArea().isCompatible(plot2.getArea())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr); C.PLOTWORLD_INCOMPATIBLE.send(player);
return false; return false;
} }
if (plot1.copy(plot2, new Runnable() { if (plot1.copy(plot2, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, C.COPY_SUCCESS); MainUtil.sendMessage(player, C.COPY_SUCCESS);
} }
})) { })) {
return true; return true;
} else { } else {
MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED); MainUtil.sendMessage(player, C.REQUIRES_UNOWNED);
return false; return false;
} }
} }

View File

@ -15,13 +15,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Debug extends SubCommand { public class Debug extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
for (C c : C.values()) { for (C caption : C.values()) {
msg.append(c.s()).append("\n"); msg.append(caption.s()).append("\n");
} }
MainUtil.sendMessage(plr, msg.toString()); MainUtil.sendMessage(player, msg.toString());
return true; return true;
} }
StringBuilder information = new StringBuilder(); StringBuilder information = new StringBuilder();
@ -35,7 +35,7 @@ public class Debug extends SubCommand {
information.append(getSection(section, "Messages")); information.append(getSection(section, "Messages"));
information.append(getLine(line, "Total Messages", C.values().length)); information.append(getLine(line, "Total Messages", C.values().length));
information.append(getLine(line, "View all captions", "/plot debug msg")); information.append(getLine(line, "View all captions", "/plot debug msg"));
MainUtil.sendMessage(plr, information.toString()); MainUtil.sendMessage(player, information.toString());
return true; return true;
} }

View File

@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -19,14 +20,14 @@ public class DebugAllowUnsafe extends SubCommand {
public static final List<UUID> unsafeAllowed = new ArrayList<>(); public static final List<UUID> unsafeAllowed = new ArrayList<>();
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
if (unsafeAllowed.contains(plr.getUUID())) { if (unsafeAllowed.contains(player.getUUID())) {
unsafeAllowed.remove(plr.getUUID()); unsafeAllowed.remove(player.getUUID());
sendMessage(plr, C.DEBUGALLOWUNSAFE_OFF); sendMessage(player, C.DEBUGALLOWUNSAFE_OFF);
} else { } else {
unsafeAllowed.add(plr.getUUID()); unsafeAllowed.add(player.getUUID());
sendMessage(plr, C.DEBUGALLOWUNSAFE_ON); sendMessage(player, C.DEBUGALLOWUNSAFE_ON);
} }
return true; return true;
} }

View File

@ -32,7 +32,7 @@ import java.util.UUID;
public class DebugClaimTest extends SubCommand { public class DebugClaimTest extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length < 3) { if (args.length < 3) {
return !MainUtil return !MainUtil
.sendMessage( .sendMessage(
@ -42,7 +42,7 @@ public class DebugClaimTest extends SubCommand {
} }
PlotArea area = PS.get().getPlotAreaByString(args[0]); PlotArea area = PS.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) { if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
C.NOT_VALID_PLOT_WORLD.send(plr, args[0]); C.NOT_VALID_PLOT_WORLD.send(player, args[0]);
return false; return false;
} }
PlotId min, max; PlotId min, max;
@ -52,18 +52,18 @@ public class DebugClaimTest extends SubCommand {
min = PlotId.fromString(args[1]); min = PlotId.fromString(args[1]);
max = PlotId.fromString(args[2]); max = PlotId.fromString(args[2]);
} catch (Exception ignored) { } catch (Exception ignored) {
return !MainUtil.sendMessage(plr, return !MainUtil.sendMessage(player,
"&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion " "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion "
+ "will only check the plots in the selected area."); + "will only check the plots in the selected area.");
} }
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while..."); MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)"); MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
ArrayList<Plot> plots = new ArrayList<>(); ArrayList<Plot> plots = new ArrayList<>();
for (PlotId id : MainUtil.getPlotSelectionIds(min, max)) { for (PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
Plot plot = area.getPlotAbs(id); Plot plot = area.getPlotAbs(id);
if (plot.hasOwner()) { if (plot.hasOwner()) {
MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.getId()); MainUtil.sendMessage(player, " - &cDB Already contains: " + plot.getId());
continue; continue;
} }
Location loc = manager.getSignLoc(area, plot); Location loc = manager.getSignLoc(area, plot);
@ -91,29 +91,29 @@ public class DebugClaimTest extends SubCommand {
uuid = UUIDHandler.getUUID(line, null); uuid = UUIDHandler.getUUID(line, null);
} }
if (uuid != null) { if (uuid != null) {
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.getId() + " : " + line); MainUtil.sendMessage(player, " - &aFound plot: " + plot.getId() + " : " + line);
plot.setOwner(uuid); plot.setOwner(uuid);
plots.add(plot); plots.add(plot);
} else { } else {
MainUtil.sendMessage(plr, " - &cInvalid PlayerName: " + plot.getId() + " : " + line); MainUtil.sendMessage(player, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
} }
} }
} }
} }
if (!plots.isEmpty()) { if (!plots.isEmpty()) {
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!"); MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
DBFunc.createPlotsAndData(plots, new Runnable() { DBFunc.createPlotsAndData(plots, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, "&6Database update finished!"); MainUtil.sendMessage(player, "&6Database update finished!");
} }
}); });
for (Plot plot : plots) { for (Plot plot : plots) {
plot.create(); plot.create();
} }
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
} else { } else {
MainUtil.sendMessage(plr, "No plots were found for the given search."); MainUtil.sendMessage(player, "No plots were found for the given search.");
} }
return true; return true;
} }

View File

@ -30,13 +30,13 @@ public class DebugFixFlags extends SubCommand {
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
PlotArea area = PS.get().getPlotAreaByString(args[0]); PlotArea area = PS.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) { if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[0]);
return false; return false;
} }
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---"); MainUtil.sendMessage(player, "&8--- &6Starting task &8 ---");
for (Plot plot : area.getPlots()) { for (Plot plot : area.getPlots()) {
HashMap<Flag<?>, Object> flags = plot.getFlags(); HashMap<Flag<?>, Object> flags = plot.getFlags();
Iterator<Entry<Flag<?>, Object>> i = flags.entrySet().iterator(); Iterator<Entry<Flag<?>, Object>> i = flags.entrySet().iterator();
@ -51,7 +51,7 @@ public class DebugFixFlags extends SubCommand {
DBFunc.setFlags(plot, plot.getFlags()); DBFunc.setFlags(plot, plot.getFlags());
} }
} }
MainUtil.sendMessage(plr, "&aDone!"); MainUtil.sendMessage(player, "&aDone!");
return true; return true;
} }
} }

View File

@ -15,7 +15,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class DebugLoadTest extends SubCommand { public class DebugLoadTest extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
PS.get().plots_tmp = DBFunc.getPlots(); PS.get().plots_tmp = DBFunc.getPlots();
return true; return true;
} }

View File

@ -21,7 +21,7 @@ import java.io.IOException;
public class DebugPaste extends SubCommand { public class DebugPaste extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -31,7 +31,7 @@ public class DebugPaste extends SubCommand {
try { try {
latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log")); latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log"));
} catch (IOException ignored) { } catch (IOException ignored) {
MainUtil.sendMessage(plr, "&clatest.log is too big to be pasted, will ignore"); MainUtil.sendMessage(player, "&clatest.log is too big to be pasted, will ignore");
latestLOG = "too big :("; latestLOG = "too big :(";
} }
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
@ -68,7 +68,7 @@ public class DebugPaste extends SubCommand {
b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues"); b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
String link = HastebinUtility.upload(b.toString()); String link = HastebinUtility.upload(b.toString());
plr.sendMessage(C.DEBUG_REPORT_CREATED.s().replace("%url%", link)); player.sendMessage(C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -25,8 +25,8 @@ public class DebugRoadRegen extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer player, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Location loc = player.getLocation(); Location loc = player.getLocation();
PlotArea plotworld = loc.getPlotArea(); PlotArea plotArea = loc.getPlotArea();
if (!(plotworld instanceof HybridPlotWorld)) { if (!(plotArea instanceof HybridPlotWorld)) {
return sendMessage(player, C.NOT_IN_PLOT_WORLD); return sendMessage(player, C.NOT_IN_PLOT_WORLD);
} }
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
@ -43,15 +43,15 @@ public class DebugRoadRegen extends SubCommand {
} }
} }
} }
boolean result = HybridUtils.manager.regenerateRoad(plotworld, chunk, extend); boolean result = HybridUtils.manager.regenerateRoad(plotArea, chunk, extend);
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&6Regenerating chunk: " + chunk.x + ',' + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed")); "&6Regenerating chunk: " + chunk.x + ',' + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed"));
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads"); MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
} else { } else {
HybridPlotManager manager = (HybridPlotManager) plotworld.getPlotManager(); HybridPlotManager manager = (HybridPlotManager) plotArea.getPlotManager();
manager.createRoadEast(plotworld, plot); manager.createRoadEast(plotArea, plot);
manager.createRoadSouth(plotworld, plot); manager.createRoadSouth(plotArea, plot);
manager.createRoadSouthEast(plotworld, plot); manager.createRoadSouthEast(plotArea, plot);
MainUtil.sendMessage(player, "&6Regenerating plot south/east roads: " + plot.getId() + "\n&6 - Result: &aSuccess"); MainUtil.sendMessage(player, "&6Regenerating plot south/east roads: " + plot.getId() + "\n&6 - Result: &aSuccess");
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads"); MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
} }

View File

@ -19,14 +19,14 @@ import java.util.ArrayList;
public class DebugSaveTest extends SubCommand { public class DebugSaveTest extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
ArrayList<Plot> plots = new ArrayList<Plot>(); ArrayList<Plot> plots = new ArrayList<Plot>();
plots.addAll(PS.get().getPlots()); plots.addAll(PS.get().getPlots());
MainUtil.sendMessage(plr, "&6Starting `DEBUGSAVETEST`"); MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`");
DBFunc.createPlotsAndData(plots, new Runnable() { DBFunc.createPlotsAndData(plots, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, "&6Database sync finished!"); MainUtil.sendMessage(player, "&6Database sync finished!");
} }
}); });
return true; return true;

View File

@ -24,26 +24,26 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Delete extends SubCommand { public class Delete extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return !sendMessage(plr, C.PLOT_UNOWNED); return !sendMessage(player, C.PLOT_UNOWNED);
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.delete")) {
return !sendMessage(plr, C.NO_PLOT_PERMS); return !sendMessage(player, C.NO_PLOT_PERMS);
} }
final PlotArea plotworld = plot.getArea(); final PlotArea plotArea = plot.getArea();
final java.util.Set<Plot> plots = plot.getConnectedPlots(); final java.util.Set<Plot> plots = plot.getConnectedPlots();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return; return;
} }
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
@ -51,25 +51,25 @@ public class Delete extends SubCommand {
@Override @Override
public void run() { public void run() {
plot.removeRunning(); plot.removeRunning();
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) { if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
double value = plotworld.PRICES.get("sell") * plots.size(); double value = plotArea.PRICES.get("sell") * plots.size();
if (value > 0d) { if (value > 0d) {
EconHandler.manager.depositMoney(plr, value); EconHandler.manager.depositMoney(player, value);
sendMessage(plr, C.ADDED_BALANCE, String.valueOf(value)); sendMessage(player, C.ADDED_BALANCE, String.valueOf(value));
} }
} }
MainUtil.sendMessage(plr, C.CLEARING_DONE, System.currentTimeMillis() - start); MainUtil.sendMessage(player, C.CLEARING_DONE, System.currentTimeMillis() - start);
} }
}); });
if (result) { if (result) {
plot.addRunning(); plot.addRunning();
} else { } else {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
} }
} }
}; };
if (hasConfirmation(plr)) { if (hasConfirmation(player)) {
CmdConfirm.addPending(plr, getCommandString() + ' ' + plot.getId(), run); CmdConfirm.addPending(player, getCommandString() + ' ' + plot.getId(), run);
} else { } else {
TaskManager.runTask(run); TaskManager.runTask(run);
} }

View File

@ -14,8 +14,9 @@ import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.*; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.UUID;
@CommandDeclaration(command = "deny", @CommandDeclaration(command = "deny",
aliases = {"d", "ban"}, aliases = {"d", "ban"},
@ -30,74 +31,74 @@ public class Deny extends SubCommand {
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Location location = plr.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.deny")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.deny")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return true; return true;
} }
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]); Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
if (uuids == null || uuids.isEmpty()) { if (uuids.isEmpty()) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
return false; return false;
} }
Iterator<UUID> iter = uuids.iterator(); Iterator<UUID> iter = uuids.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
UUID uuid = iter.next(); UUID uuid = iter.next();
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(plr, "plots.deny.everyone") || Permissions.hasPermission(plr, "plots.admin.command.deny"))) { if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, "plots.deny.everyone") || Permissions.hasPermission(player, "plots.admin.command.deny"))) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, MainUtil.getName(uuid)); MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
continue; continue;
} }
if (plot.isOwner(uuid)) { if (plot.isOwner(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_OWNER, MainUtil.getName(uuid)); MainUtil.sendMessage(player, C.ALREADY_OWNER, MainUtil.getName(uuid));
return false; return false;
} }
if (plot.getDenied().contains(uuid)) { if (plot.getDenied().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED, MainUtil.getName(uuid)); MainUtil.sendMessage(player, C.ALREADY_ADDED, MainUtil.getName(uuid));
return false; return false;
} }
plot.removeMember(uuid); plot.removeMember(uuid);
plot.removeTrusted(uuid); plot.removeTrusted(uuid);
plot.addDenied(uuid); plot.addDenied(uuid);
EventUtil.manager.callDenied(plr, plot, uuid, true); EventUtil.manager.callDenied(player, plot, uuid, true);
if (!uuid.equals(DBFunc.everyone)) { if (!uuid.equals(DBFunc.everyone)) {
handleKick(UUIDHandler.getPlayer(uuid), plot); handleKick(UUIDHandler.getPlayer(uuid), plot);
} else { } else {
for (PlotPlayer pp : plot.getPlayersInPlot()) { for (PlotPlayer plotPlayer : plot.getPlayersInPlot()) {
handleKick(pp, plot); handleKick(plotPlayer, plot);
} }
} }
} }
if (!uuids.isEmpty()) { if (!uuids.isEmpty()) {
MainUtil.sendMessage(plr, C.DENIED_ADDED); MainUtil.sendMessage(player, C.DENIED_ADDED);
} }
return true; return true;
} }
private void handleKick(PlotPlayer pp, Plot plot) { private void handleKick(PlotPlayer player, Plot plot) {
if (pp == null) { if (player == null) {
return; return;
} }
if (!plot.equals(pp.getCurrentPlot())) { if (!plot.equals(player.getCurrentPlot())) {
return; return;
} }
if (pp.hasPermission("plots.admin.entry.denied")) { if (player.hasPermission("plots.admin.entry.denied")) {
return; return;
} }
if (pp.getGameMode() == PlotGameMode.SPECTATOR) { if (player.getGameMode() == PlotGameMode.SPECTATOR) {
pp.stopSpectating(); player.stopSpectating();
} }
pp.teleport(WorldUtil.IMP.getSpawn(pp.getLocation().getWorld())); player.teleport(WorldUtil.IMP.getSpawn(player.getLocation().getWorld()));
MainUtil.sendMessage(pp, C.YOU_GOT_DENIED); MainUtil.sendMessage(player, C.YOU_GOT_DENIED);
} }
} }

View File

@ -19,18 +19,18 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Desc extends SetCommand { public class Desc extends SetCommand {
@Override @Override
public boolean set(PlotPlayer plr, Plot plot, String desc) { public boolean set(PlotPlayer player, Plot plot, String desc) {
if (desc.isEmpty()) { if (desc.isEmpty()) {
plot.removeFlag(Flags.DESCRIPTION); plot.removeFlag(Flags.DESCRIPTION);
MainUtil.sendMessage(plr, C.DESC_UNSET); MainUtil.sendMessage(player, C.DESC_UNSET);
return true; return true;
} }
boolean result = FlagManager.addPlotFlag(plot, Flags.DESCRIPTION, desc); boolean result = FlagManager.addPlotFlag(plot, Flags.DESCRIPTION, desc);
if (!result) { if (!result) {
MainUtil.sendMessage(plr, C.FLAG_NOT_ADDED); MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
return false; return false;
} }
MainUtil.sendMessage(plr, C.DESC_SET); MainUtil.sendMessage(player, C.DESC_SET);
return true; return true;
} }
} }

View File

@ -22,26 +22,26 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Done extends SubCommand { public class Done extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.done")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.done")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (plot.hasFlag(Flags.DONE)) { if (plot.hasFlag(Flags.DONE)) {
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE); MainUtil.sendMessage(player, C.DONE_ALREADY_DONE);
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return false; return false;
} }
plot.addRunning(); plot.addRunning();
MainUtil.sendMessage(plr, C.GENERATING_LINK); MainUtil.sendMessage(player, C.GENERATING_LINK);
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() { HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
@Override @Override
public void run(PlotAnalysis value) { public void run(PlotAnalysis value) {
@ -49,9 +49,9 @@ public class Done extends SubCommand {
if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) { if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) {
long flagValue = System.currentTimeMillis() / 1000; long flagValue = System.currentTimeMillis() / 1000;
plot.setFlag(Flags.DONE,flagValue); plot.setFlag(Flags.DONE,flagValue);
MainUtil.sendMessage(plr, C.DONE_SUCCESS); MainUtil.sendMessage(player, C.DONE_SUCCESS);
} else { } else {
MainUtil.sendMessage(plr, C.DONE_INSUFFICIENT_COMPLEXITY); MainUtil.sendMessage(player, C.DONE_INSUFFICIENT_COMPLEXITY);
} }
} }
}); });

View File

@ -28,30 +28,30 @@ import java.net.URL;
public class Download extends SubCommand { public class Download extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
String world = plr.getLocation().getWorld(); String world = player.getLocation().getWorld();
if (!PS.get().hasPlotArea(world)) { if (!PS.get().hasPlotArea(world)) {
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD); return !sendMessage(player, C.NOT_IN_PLOT_WORLD);
} }
final Plot plot = plr.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if ((Settings.DOWNLOAD_REQUIRES_DONE && (!plot.getFlag(Flags.DONE).isPresent())) && !Permissions if ((Settings.DOWNLOAD_REQUIRES_DONE && (!plot.getFlag(Flags.DONE).isPresent())) && !Permissions
.hasPermission(plr, "plots.admin.command.download")) { .hasPermission(player, "plots.admin.command.download")) {
MainUtil.sendMessage(plr, C.DONE_NOT_DONE); MainUtil.sendMessage(player, C.DONE_NOT_DONE);
return false; return false;
} }
if ((!plot.isOwner(plr.getUUID()))) { if ((!plot.isOwner(player.getUUID()))) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return false; return false;
} }
if (args.length == 0 || (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) { if (args.length == 0 || (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
@ -64,20 +64,20 @@ public class Download extends SubCommand {
@Override @Override
public void run(URL url) { public void run(URL url) {
if (url == null) { if (url == null) {
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED); MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
return; return;
} }
MainUtil.sendMessage(plr, url.toString()); MainUtil.sendMessage(player, url.toString());
} }
}); });
} }
}); });
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "bo3", "bo2", "b03", "b02")) { } else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "bo3", "bo2", "b03", "b02")) {
if (!Permissions.hasPermission(plr, "plots.download.bo3")) { if (!Permissions.hasPermission(player, "plots.download.bo3")) {
C.NO_PERMISSION.send(plr, "plots.download.bo3"); C.NO_PERMISSION.send(player, "plots.download.bo3");
} }
if (plot.getVolume() > 128d * 128d * 256) { if (plot.getVolume() > 128d * 128d * 256) {
C.SCHEMATIC_TOO_LARGE.send(plr); C.SCHEMATIC_TOO_LARGE.send(player);
return false; return false;
} }
plot.addRunning(); plot.addRunning();
@ -86,34 +86,34 @@ public class Download extends SubCommand {
public void run(URL url) { public void run(URL url) {
plot.removeRunning(); plot.removeRunning();
if (url == null) { if (url == null) {
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED); MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
return; return;
} }
MainUtil.sendMessage(plr, url.toString()); MainUtil.sendMessage(player, url.toString());
} }
}); });
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) { } else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
if (!Permissions.hasPermission(plr, "plots.download.world")) { if (!Permissions.hasPermission(player, "plots.download.world")) {
C.NO_PERMISSION.send(plr, "plots.download.world"); C.NO_PERMISSION.send(player, "plots.download.world");
} }
MainUtil.sendMessage(plr, "&cNote: The `.mca` files are 512x512"); MainUtil.sendMessage(player, "&cNote: The `.mca` files are 512x512");
plot.addRunning(); plot.addRunning();
WorldUtil.IMP.upload(plot, null, null, new RunnableVal<URL>() { WorldUtil.IMP.upload(plot, null, null, new RunnableVal<URL>() {
@Override @Override
public void run(URL url) { public void run(URL url) {
plot.removeRunning(); plot.removeRunning();
if (url == null) { if (url == null) {
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED); MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
return; return;
} }
MainUtil.sendMessage(plr, url.toString()); MainUtil.sendMessage(player, url.toString());
} }
}); });
} else { } else {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
MainUtil.sendMessage(plr, C.GENERATING_LINK); MainUtil.sendMessage(player, C.GENERATING_LINK);
return true; return true;
} }
} }

View File

@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(
@ -20,21 +21,21 @@ import java.util.UUID;
public class Grant extends SubCommand { public class Grant extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
final String arg0 = args[0].toLowerCase(); final String arg0 = args[0].toLowerCase();
switch (arg0) { switch (arg0) {
case "add": case "add":
case "check": case "check":
if (Permissions.hasPermission(plr, "plots.grant." + arg0)) { if (Permissions.hasPermission(player, "plots.grant." + arg0)) {
C.NO_PERMISSION.send(plr, "plots.grant." + arg0); C.NO_PERMISSION.send(player, "plots.grant." + arg0);
return false; return false;
} }
if (args.length > 2) { if (args.length > 2) {
break; break;
} }
final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : plr.getUUID(); final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID();
if (uuid == null) { if (uuid == null) {
C.INVALID_PLAYER.send(plr, args[1]); C.INVALID_PLAYER.send(player, args[1]);
return false; return false;
} }
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() { MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
@ -42,7 +43,7 @@ public class Grant extends SubCommand {
public void run(byte[] array) { public void run(byte[] array) {
if (arg0.equals("check")) { // check if (arg0.equals("check")) { // check
int granted = array == null ? 0 : ByteArrayUtilities.bytesToInteger(array); int granted = array == null ? 0 : ByteArrayUtilities.bytesToInteger(array);
C.GRANTED_PLOTS.send(plr, granted); C.GRANTED_PLOTS.send(player, granted);
} else { // add } else { // add
int amount = 1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array)); int amount = 1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array));
boolean replace = array != null; boolean replace = array != null;
@ -52,7 +53,7 @@ public class Grant extends SubCommand {
}); });
return true; return true;
} }
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }

View File

@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -29,19 +30,19 @@ public class Kick extends SubCommand {
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Location location = plr.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlot(); Plot plot = location.getPlot();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions.hasPermission(player, "plots.admin.command.kick")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]); Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
if (uuids == null) { if (uuids.isEmpty()) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
return false; return false;
} }
Set<PlotPlayer> players = new HashSet<>(); Set<PlotPlayer> players = new HashSet<>();
@ -55,33 +56,33 @@ public class Kick extends SubCommand {
players.add(pp); players.add(pp);
} }
} }
players.remove(plr); // Don't ever kick the calling player players.remove(player); // Don't ever kick the calling player
if (players.isEmpty()) { if (players.isEmpty()) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
return false; return false;
} }
for (PlotPlayer player : players) { for (PlotPlayer player2 : players) {
Location location2 = player.getLocation(); Location location2 = player2.getLocation();
if (!plr.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) { if (!player2.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); MainUtil.sendMessage(player2, C.INVALID_PLAYER, args[0]);
return false; return false;
} }
if (player.hasPermission("plots.admin.entry.denied")) { if (player2.hasPermission("plots.admin.entry.denied")) {
C.CANNOT_KICK_PLAYER.send(plr, player.getName()); C.CANNOT_KICK_PLAYER.send(player2, player2.getName());
return false; return false;
} }
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld()); Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
C.YOU_GOT_KICKED.send(player); C.YOU_GOT_KICKED.send(player2);
if (plot.equals(spawn.getPlot())) { if (plot.equals(spawn.getPlot())) {
Location newSpawn = WorldUtil.IMP.getSpawn(player); Location newSpawn = WorldUtil.IMP.getSpawn(player2);
if (plot.equals(newSpawn.getPlot())) { if (plot.equals(newSpawn.getPlot())) {
// Kick from server if you can't be teleported to spawn // Kick from server if you can't be teleported to spawn
player.kick(C.YOU_GOT_KICKED.s()); player2.kick(C.YOU_GOT_KICKED.s());
} else { } else {
player.teleport(newSpawn); player2.teleport(newSpawn);
} }
} else { } else {
player.teleport(spawn); player2.teleport(spawn);
} }
} }
return true; return true;

View File

@ -83,14 +83,14 @@ public class ListCmd extends SubCommand {
return args.toArray(new String[args.size()]); return args.toArray(new String[args.size()]);
} }
public void noArgs(PlotPlayer plr) { public void noArgs(PlotPlayer player) {
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr))); MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(player)));
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
if (args.length < 1) { if (args.length < 1) {
noArgs(plr); noArgs(player);
return false; return false;
} }
int page = 0; int page = 0;
@ -108,70 +108,70 @@ public class ListCmd extends SubCommand {
List<Plot> plots = null; List<Plot> plots = null;
String world = plr.getLocation().getWorld(); String world = player.getLocation().getWorld();
PlotArea area = plr.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
String arg = args[0].toLowerCase(); String arg = args[0].toLowerCase();
boolean sort = true; boolean sort = true;
switch (arg) { switch (arg) {
case "mine": case "mine":
if (!Permissions.hasPermission(plr, "plots.list.mine")) { if (!Permissions.hasPermission(player, "plots.list.mine")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.mine");
return false; return false;
} }
sort = false; sort = false;
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(plr)); plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(player));
break; break;
case "shared": case "shared":
if (!Permissions.hasPermission(plr, "plots.list.shared")) { if (!Permissions.hasPermission(player, "plots.list.shared")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.shared");
return false; return false;
} }
plots = new ArrayList<>(); plots = new ArrayList<>();
for (Plot plot : PS.get().getPlots()) { for (Plot plot : PS.get().getPlots()) {
if (plot.getTrusted().contains(plr.getUUID()) || plot.getMembers().contains(plr.getUUID())) { if (plot.getTrusted().contains(player.getUUID()) || plot.getMembers().contains(player.getUUID())) {
plots.add(plot); plots.add(plot);
} }
} }
break; break;
case "world": case "world":
if (!Permissions.hasPermission(plr, "plots.list.world")) { if (!Permissions.hasPermission(player, "plots.list.world")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world");
return false; return false;
} }
if (!Permissions.hasPermission(plr, "plots.list.world." + world)) { if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + world);
return false; return false;
} }
plots = new ArrayList<>(PS.get().getPlots(world)); plots = new ArrayList<>(PS.get().getPlots(world));
break; break;
case "expired": case "expired":
if (!Permissions.hasPermission(plr, "plots.list.expired")) { if (!Permissions.hasPermission(player, "plots.list.expired")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.expired"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.expired");
return false; return false;
} }
plots = ExpireManager.IMP == null ? new ArrayList<Plot>() : new ArrayList<>(ExpireManager.IMP.getPendingExpired()); plots = ExpireManager.IMP == null ? new ArrayList<Plot>() : new ArrayList<>(ExpireManager.IMP.getPendingExpired());
break; break;
case "area": case "area":
if (!Permissions.hasPermission(plr, "plots.list.area")) { if (!Permissions.hasPermission(player, "plots.list.area")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.area"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.area");
return false; return false;
} }
if (!Permissions.hasPermission(plr, "plots.list.world." + world)) { if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.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());
break; break;
case "all": case "all":
if (!Permissions.hasPermission(plr, "plots.list.all")) { if (!Permissions.hasPermission(player, "plots.list.all")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.all");
return false; return false;
} }
plots = new ArrayList<>(PS.get().getPlots()); plots = new ArrayList<>(PS.get().getPlots());
break; break;
case "done": case "done":
if (!Permissions.hasPermission(plr, "plots.list.done")) { if (!Permissions.hasPermission(player, "plots.list.done")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.done"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.done");
return false; return false;
} }
plots = new ArrayList<>(); plots = new ArrayList<>();
@ -199,8 +199,8 @@ public class ListCmd extends SubCommand {
sort = false; sort = false;
break; break;
case "top": case "top":
if (!Permissions.hasPermission(plr, "plots.list.top")) { if (!Permissions.hasPermission(player, "plots.list.top")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.top");
return false; return false;
} }
plots = new ArrayList<>(PS.get().getPlots()); plots = new ArrayList<>(PS.get().getPlots());
@ -236,8 +236,8 @@ public class ListCmd extends SubCommand {
sort = false; sort = false;
break; break;
case "forsale": case "forsale":
if (!Permissions.hasPermission(plr, "plots.list.forsale")) { if (!Permissions.hasPermission(player, "plots.list.forsale")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.forsale");
return false; return false;
} }
if (EconHandler.manager == null) { if (EconHandler.manager == null) {
@ -252,8 +252,8 @@ public class ListCmd extends SubCommand {
} }
break; break;
case "unowned": case "unowned":
if (!Permissions.hasPermission(plr, "plots.list.unowned")) { if (!Permissions.hasPermission(player, "plots.list.unowned")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.unowned");
return false; return false;
} }
plots = new ArrayList<>(); plots = new ArrayList<>();
@ -264,8 +264,8 @@ public class ListCmd extends SubCommand {
} }
break; break;
case "unknown": case "unknown":
if (!Permissions.hasPermission(plr, "plots.list.unknown")) { if (!Permissions.hasPermission(player, "plots.list.unknown")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.unknown");
return false; return false;
} }
plots = new ArrayList<>(); plots = new ArrayList<>();
@ -279,12 +279,12 @@ public class ListCmd extends SubCommand {
} }
break; break;
case "fuzzy": case "fuzzy":
if (!Permissions.hasPermission(plr, "plots.list.fuzzy")) { if (!Permissions.hasPermission(player, "plots.list.fuzzy")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.fuzzy"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.fuzzy");
return false; return false;
} }
if (args.length < (page == -1 ? 2 : 3)) { if (args.length < (page == -1 ? 2 : 3)) {
C.COMMAND_SYNTAX.send(plr, "/plot list fuzzy <search...> [#]"); C.COMMAND_SYNTAX.send(player, "/plot list fuzzy <search...> [#]");
return false; return false;
} }
String term; String term;
@ -298,12 +298,12 @@ public class ListCmd extends SubCommand {
break; break;
default: default:
if (PS.get().hasPlotArea(args[0])) { if (PS.get().hasPlotArea(args[0])) {
if (!Permissions.hasPermission(plr, "plots.list.world")) { if (!Permissions.hasPermission(player, "plots.list.world")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world");
return false; return false;
} }
if (!Permissions.hasPermission(plr, "plots.list.world." + args[0])) { if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + args[0]);
return false; return false;
} }
plots = new ArrayList<>(PS.get().getPlots(args[0])); plots = new ArrayList<>(PS.get().getPlots(args[0]));
@ -316,8 +316,8 @@ public class ListCmd extends SubCommand {
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
if (uuid != null) { if (uuid != null) {
if (!Permissions.hasPermission(plr, "plots.list.player")) { if (!Permissions.hasPermission(player, "plots.list.player")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.player");
return false; return false;
} }
sort = false; sort = false;
@ -327,15 +327,15 @@ public class ListCmd extends SubCommand {
} }
if (plots == null) { if (plots == null) {
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch()); sendMessage(player, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
return false; return false;
} }
if (plots.isEmpty()) { if (plots.isEmpty()) {
MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS); MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
return false; return false;
} }
displayPlots(plr, plots, 12, page, area, args, sort); displayPlots(player, plots, 12, page, area, args, sort);
return true; return true;
} }

View File

@ -29,40 +29,40 @@ import java.util.List;
public class Load extends SubCommand { public class Load extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (!Settings.METRICS) { if (!Settings.METRICS) {
MainUtil.sendMessage(plr, MainUtil.sendMessage(player,
"&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
return false; return false;
} }
String world = plr.getLocation().getWorld(); String world = player.getLocation().getWorld();
if (!PS.get().hasPlotArea(world)) { if (!PS.get().hasPlotArea(world)) {
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD); return !sendMessage(player, C.NOT_IN_PLOT_WORLD);
} }
final Plot plot = plr.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.load")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.load")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return false; return false;
} }
if (args.length != 0) { if (args.length != 0) {
if (args.length == 1) { if (args.length == 1) {
List<String> schematics = plr.getMeta("plot_schematics"); List<String> schematics = player.getMeta("plot_schematics");
if (schematics == null) { if (schematics == null) {
// No schematics found: // No schematics found:
MainUtil.sendMessage(plr, C.LOAD_NULL); MainUtil.sendMessage(player, C.LOAD_NULL);
return false; return false;
} }
String schematic; String schematic;
@ -70,26 +70,26 @@ public class Load extends SubCommand {
schematic = schematics.get(Integer.parseInt(args[0]) - 1); schematic = schematics.get(Integer.parseInt(args[0]) - 1);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
// use /plot load <index> // use /plot load <index>
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ')'); MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ')');
return false; return false;
} }
final URL url; final URL url;
try { try {
url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + '/' + schematic + ".schematic"); url = new URL(Settings.WEB_URL + "saves/" + player.getUUID() + '/' + schematic + ".schematic");
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
MainUtil.sendMessage(plr, C.LOAD_FAILED); MainUtil.sendMessage(player, C.LOAD_FAILED);
return false; return false;
} }
plot.addRunning(); plot.addRunning();
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT); MainUtil.sendMessage(player, C.GENERATING_COMPONENT);
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
Schematic schematic = SchematicHandler.manager.getSchematic(url); Schematic schematic = SchematicHandler.manager.getSchematic(url);
if (schematic == null) { if (schematic == null) {
plot.removeRunning(); plot.removeRunning();
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format"); sendMessage(player, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
return; return;
} }
SchematicHandler.manager.paste(schematic, plot, 0, 0, 0, true, new RunnableVal<Boolean>() { SchematicHandler.manager.paste(schematic, plot, 0, 0, 0, true, new RunnableVal<Boolean>() {
@ -97,9 +97,9 @@ public class Load extends SubCommand {
public void run(Boolean value) { public void run(Boolean value) {
plot.removeRunning(); plot.removeRunning();
if (value) { if (value) {
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
} else { } else {
sendMessage(plr, C.SCHEMATIC_PASTE_FAILED); sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
} }
} }
}); });
@ -108,30 +108,30 @@ public class Load extends SubCommand {
return true; return true;
} }
plot.removeRunning(); plot.removeRunning();
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot load <index>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot load <index>");
return false; return false;
} }
// list schematics // list schematics
List<String> schematics = plr.getMeta("plot_schematics"); List<String> schematics = player.getMeta("plot_schematics");
if (schematics == null) { if (schematics == null) {
plot.addRunning(); plot.addRunning();
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
List<String> schematics = SchematicHandler.manager.getSaves(plr.getUUID()); List<String> schematics = SchematicHandler.manager.getSaves(player.getUUID());
plot.removeRunning(); plot.removeRunning();
if ((schematics == null) || schematics.isEmpty()) { if ((schematics == null) || schematics.isEmpty()) {
MainUtil.sendMessage(plr, C.LOAD_FAILED); MainUtil.sendMessage(player, C.LOAD_FAILED);
return; return;
} }
plr.setMeta("plot_schematics", schematics); player.setMeta("plot_schematics", schematics);
displaySaves(plr); displaySaves(player);
} }
}); });
} else { } else {
displaySaves(plr); displaySaves(player);
} }
return true; return true;
} }

View File

@ -51,40 +51,40 @@ public class Merge extends SubCommand {
} }
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = plr.getLocationFull(); Location loc = player.getLocationFull();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
UUID uuid = plr.getUUID(); UUID uuid = player.getUUID();
if (!plot.isOwner(uuid)) { if (!plot.isOwner(uuid)) {
if (!Permissions.hasPermission(plr, "plots.admin.command.merge")) { if (!Permissions.hasPermission(player, "plots.admin.command.merge")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} else { } else {
uuid = plot.owner; uuid = plot.owner;
} }
} }
final PlotArea plotworld = plot.getArea(); final PlotArea plotArea = plot.getArea();
final double price = plotworld.PRICES.containsKey("merge") ? plotworld.PRICES.get("merge") : 0; final double price = plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : 0;
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(plr) < price) { if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(player) < price) {
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price)); sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
return false; return false;
} }
final int size = plot.getConnectedPlots().size(); final int size = plot.getConnectedPlots().size();
final int maxSize = Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS); final int maxSize = Permissions.hasPermissionRange(player, "plots.merge", Settings.MAX_PLOTS);
if (size - 1 > maxSize) { if (size - 1 > maxSize) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + (size + 1)); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.merge." + (size + 1));
return false; return false;
} }
int direction = -1; int direction = -1;
if (args.length == 0) { if (args.length == 0) {
switch (direction(plr.getLocationFull().getYaw())) { switch (direction(player.getLocationFull().getYaw())) {
case "NORTH": case "NORTH":
direction = 0; direction = 0;
break; break;
@ -105,14 +105,14 @@ public class Merge extends SubCommand {
terrain = "true".equalsIgnoreCase(args[1]); terrain = "true".equalsIgnoreCase(args[1]);
} }
if (plot.autoMerge(-1, maxSize, uuid, terrain)) { if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) { if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
EconHandler.manager.withdrawMoney(plr, price); EconHandler.manager.withdrawMoney(player, price);
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
} }
MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.sendMessage(player, C.SUCCESS_MERGE);
return true; return true;
} }
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE); MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
return false; return false;
} }
@ -124,8 +124,8 @@ public class Merge extends SubCommand {
} }
} }
if (direction == -1) { if (direction == -1) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + "> [removeroads]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + "> [removeroads]");
MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw()))); MainUtil.sendMessage(player, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
return false; return false;
} }
final boolean terrain; final boolean terrain;
@ -135,20 +135,20 @@ public class Merge extends SubCommand {
terrain = Settings.MERGE_REMOVES_ROADS; terrain = Settings.MERGE_REMOVES_ROADS;
} }
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) { if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) { if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
EconHandler.manager.withdrawMoney(plr, price); EconHandler.manager.withdrawMoney(player, price);
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
} }
MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.sendMessage(player, C.SUCCESS_MERGE);
return true; return true;
} }
Plot adjacent = plot.getRelative(direction); Plot adjacent = plot.getRelative(direction);
if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4) || adjacent.isOwner(uuid)) { if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4) || adjacent.isOwner(uuid)) {
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE); MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
return false; return false;
} }
if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) { if (!Permissions.hasPermission(player, C.PERMISSION_MERGE_OTHER)) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER); MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
return false; return false;
} }
java.util.Set<UUID> uuids = adjacent.getOwners(); java.util.Set<UUID> uuids = adjacent.getOwners();
@ -165,33 +165,33 @@ public class Merge extends SubCommand {
public void run() { public void run() {
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
plot.autoMerge(dir, maxSize - size, owner, terrain); plot.autoMerge(dir, maxSize - size, owner, terrain);
PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID()); PlotPlayer pp = UUIDHandler.getPlayer(player.getUUID());
if (pp == null) { if (pp == null) {
sendMessage(accepter, C.MERGE_NOT_VALID); sendMessage(accepter, C.MERGE_NOT_VALID);
return; return;
} }
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) { if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
if (EconHandler.manager.getMoney(plr) < price) { if (EconHandler.manager.getMoney(player) < price) {
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price)); sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
return; return;
} }
EconHandler.manager.withdrawMoney(plr, price); EconHandler.manager.withdrawMoney(player, price);
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
} }
MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.sendMessage(player, C.SUCCESS_MERGE);
} }
}; };
if (hasConfirmation(plr)) { if (hasConfirmation(player)) {
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), run); CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", player.getName()), run);
} else { } else {
run.run(); run.run();
} }
} }
if (!isOnline) { if (!isOnline) {
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE); MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
return false; return false;
} }
MainUtil.sendMessage(plr, C.MERGE_REQUESTED); MainUtil.sendMessage(player, C.MERGE_REQUESTED);
return true; return true;
} }
} }

View File

@ -19,42 +19,42 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Move extends SubCommand { public class Move extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
Plot plot1 = loc.getPlotAbs(); Plot plot1 = loc.getPlotAbs();
if (plot1 == null) { if (plot1 == null) {
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return !MainUtil.sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) { if (!plot1.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN.s())) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (args.length != 1) { if (args.length != 1) {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true); Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
if (plot2 == null) { if (plot2 == null) {
return false; return false;
} }
if (plot1.equals(plot2)) { if (plot1.equals(plot2)) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
return false; return false;
} }
if (!plot1.getArea().isCompatible(plot2.getArea())) { if (!plot1.getArea().isCompatible(plot2.getArea())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr); C.PLOTWORLD_INCOMPATIBLE.send(player);
return false; return false;
} }
if (plot1.move(plot2, new Runnable() { if (plot1.move(plot2, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, C.MOVE_SUCCESS); MainUtil.sendMessage(player, C.MOVE_SUCCESS);
} }
}, false)) { }, false)) {
return true; return true;
} else { } else {
MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED); MainUtil.sendMessage(player, C.REQUIRES_UNOWNED);
return false; return false;
} }
} }

View File

@ -26,7 +26,7 @@ import java.util.UUID;
public class Owner extends SetCommand { public class Owner extends SetCommand {
@Override @Override
public boolean set(final PlotPlayer plr, final Plot plot, String value) { public boolean set(final PlotPlayer player, final Plot plot, String value) {
Set<Plot> plots = plot.getConnectedPlots(); Set<Plot> plots = plot.getConnectedPlots();
UUID uuid = null; UUID uuid = null;
String name = null; String name = null;
@ -48,26 +48,26 @@ public class Owner extends SetCommand {
current.unclaim(); current.unclaim();
current.removeSign(); current.removeSign();
} }
MainUtil.sendMessage(plr, C.SET_OWNER); MainUtil.sendMessage(player, C.SET_OWNER);
return true; return true;
} }
C.INVALID_PLAYER.send(plr, value); C.INVALID_PLAYER.send(player, value);
return false; return false;
} }
if (plot.isOwner(uuid)) { if (plot.isOwner(uuid)) {
C.ALREADY_OWNER.send(plr); C.ALREADY_OWNER.send(player);
return false; return false;
} }
final PlotPlayer other = UUIDHandler.getPlayer(uuid); final PlotPlayer other = UUIDHandler.getPlayer(uuid);
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { if (!Permissions.hasPermission(player, "plots.admin.command.setowner")) {
if (other == null) { if (other == null) {
C.INVALID_PLAYER_OFFLINE.send(plr, value); C.INVALID_PLAYER_OFFLINE.send(player, value);
return false; return false;
} }
int size = plots.size(); int size = plots.size();
int currentPlots = (Settings.GLOBAL_LIMIT ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size; int currentPlots = (Settings.GLOBAL_LIMIT ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
if (currentPlots > other.getAllowedPlots()) { if (currentPlots > other.getAllowedPlots()) {
sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS); sendMessage(player, C.CANT_TRANSFER_MORE_PLOTS);
return false; return false;
} }
} }
@ -78,14 +78,14 @@ public class Owner extends SetCommand {
public void run() { public void run() {
plot.setOwner(finalUUID); plot.setOwner(finalUUID);
plot.setSign(finalName); plot.setSign(finalName);
MainUtil.sendMessage(plr, C.SET_OWNER); MainUtil.sendMessage(player, C.SET_OWNER);
if (other != null) { if (other != null) {
MainUtil.sendMessage(other, C.NOW_OWNER, plot.getArea() + ";" + plot.getId()); MainUtil.sendMessage(other, C.NOW_OWNER, plot.getArea() + ";" + plot.getId());
} }
} }
}; };
if (hasConfirmation(plr)) { if (hasConfirmation(player)) {
CmdConfirm.addPending(plr, "/plot set owner " + value, run); CmdConfirm.addPending(player, "/plot set owner " + value, run);
} else { } else {
TaskManager.runTask(run); TaskManager.runTask(run);
} }

View File

@ -16,11 +16,11 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class PluginCmd extends SubCommand { public class PluginCmd extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().getVersion(), "."))); MainUtil.sendMessage(player, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().getVersion(), ".")));
MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev"); MainUtil.sendMessage(player, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev");
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"); MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
MainUtil.sendMessage(plr, "$2>> $1&lNewest Version$2: $1" + getNewestVersionString()); MainUtil.sendMessage(player, "$2>> $1&lNewest Version$2: $1" + getNewestVersionString());
return true; return true;
} }

View File

@ -29,7 +29,7 @@ import java.util.UUID;
public class Purge extends SubCommand { public class Purge extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
return false; return false;
} }
@ -43,7 +43,7 @@ public class Purge extends SubCommand {
for (String arg : args) { for (String arg : args) {
String[] split = arg.split(":"); String[] split = arg.split(":");
if (split.length != 2) { if (split.length != 2) {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
switch (split[0].toLowerCase()) { switch (split[0].toLowerCase()) {
@ -55,7 +55,7 @@ public class Purge extends SubCommand {
case "a": case "a":
area = PS.get().getPlotAreaByString(split[1]); area = PS.get().getPlotAreaByString(split[1]);
if (area == null) { if (area == null) {
C.NOT_VALID_PLOT_WORLD.send(plr, split[1]); C.NOT_VALID_PLOT_WORLD.send(player, split[1]);
return false; return false;
} }
break; break;
@ -63,7 +63,7 @@ public class Purge extends SubCommand {
case "id": case "id":
id = PlotId.fromString(split[1]); id = PlotId.fromString(split[1]);
if (id == null) { if (id == null) {
C.NOT_VALID_PLOT_ID.send(plr, split[1]); C.NOT_VALID_PLOT_ID.send(player, split[1]);
return false; return false;
} }
break; break;
@ -71,7 +71,7 @@ public class Purge extends SubCommand {
case "o": case "o":
owner = UUIDHandler.getUUID(split[1], null); owner = UUIDHandler.getUUID(split[1], null);
if (owner == null) { if (owner == null) {
C.INVALID_PLAYER.send(plr, split[1]); C.INVALID_PLAYER.send(player, split[1]);
return false; return false;
} }
break; break;
@ -79,7 +79,7 @@ public class Purge extends SubCommand {
case "s": case "s":
added = UUIDHandler.getUUID(split[1], null); added = UUIDHandler.getUUID(split[1], null);
if (added == null) { if (added == null) {
C.INVALID_PLAYER.send(plr, split[1]); C.INVALID_PLAYER.send(player, split[1]);
return false; return false;
} }
break; break;
@ -139,7 +139,7 @@ public class Purge extends SubCommand {
} }
} }
if (toDelete.isEmpty()) { if (toDelete.isEmpty()) {
C.FOUND_NO_PLOTS.send(plr); C.FOUND_NO_PLOTS.send(player);
return false; return false;
} }
String cmd = "/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)"; String cmd = "/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
@ -158,11 +158,11 @@ public class Purge extends SubCommand {
} }
} }
DBFunc.purgeIds(ids); DBFunc.purgeIds(ids);
C.PURGE_SUCCESS.send(plr, ids.size() + "/" + toDelete.size()); C.PURGE_SUCCESS.send(player, ids.size() + "/" + toDelete.size());
} }
}; };
if (hasConfirmation(plr)) { if (hasConfirmation(player)) {
CmdConfirm.addPending(plr, cmd, run); CmdConfirm.addPending(player, cmd, run);
} else { } else {
run.run(); run.run();
} }

View File

@ -26,39 +26,39 @@ import java.util.Set;
public class RegenAllRoads extends SubCommand { public class RegenAllRoads extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
int height = 0; int height = 0;
if (args.length == 2) { if (args.length == 2) {
try { try {
height = Integer.parseInt(args[1]); height = Integer.parseInt(args[1]);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)"); MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0, 256)");
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false; return false;
} }
} else if (args.length != 1) { } else if (args.length != 1) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false; return false;
} }
PlotArea area = PS.get().getPlotAreaByString(args[0]); PlotArea area = PS.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) { if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
C.NOT_VALID_PLOT_WORLD.send(plr, args[0]); C.NOT_VALID_PLOT_WORLD.send(player, args[0]);
return false; return false;
} }
String name = args[0]; String name = args[0];
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
if (!(manager instanceof HybridPlotManager)) { if (!(manager instanceof HybridPlotManager)) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
return false; return false;
} }
Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name); Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
MainUtil.sendMessage(plr, "&cIf no schematic is set, the following will not do anything"); MainUtil.sendMessage(player, "&cIf no schematic is set, the following will not do anything");
MainUtil.sendMessage(plr, "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); MainUtil.sendMessage(player, "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
MainUtil.sendMessage(plr, "&6Potential chunks to update: &7" + (chunks.size() * 1024)); MainUtil.sendMessage(player, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
MainUtil.sendMessage(plr, "&6Estimated time: &7" + chunks.size() + " seconds"); MainUtil.sendMessage(player, "&6Estimated time: &7" + chunks.size() + " seconds");
boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height); boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height);
if (!result) { if (!result) {
MainUtil.sendMessage(plr, "&cCannot schedule mass schematic update! (Is one already in progress?)"); MainUtil.sendMessage(player, "&cCannot schedule mass schematic update! (Is one already in progress?)");
return false; return false;
} }
return true; return true;

View File

@ -23,7 +23,7 @@ import java.util.Objects;
public class Reload extends SubCommand { public class Reload extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
try { try {
// The following won't affect world generation, as that has to be // The following won't affect world generation, as that has to be
// loaded during startup unfortunately. // loaded during startup unfortunately.
@ -78,10 +78,10 @@ public class Reload extends SubCommand {
} }
}); });
PS.get().config.save(PS.get().configFile); PS.get().config.save(PS.get().configFile);
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); MainUtil.sendMessage(player, C.RELOADED_CONFIGS);
} catch (InvalidConfigurationException | IOException e) { } catch (InvalidConfigurationException | IOException e) {
e.printStackTrace(); e.printStackTrace();
MainUtil.sendMessage(plr, C.RELOAD_FAILED); MainUtil.sendMessage(player, C.RELOAD_FAILED);
} }
return true; return true;
} }

View File

@ -10,8 +10,10 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(
command = "remove", command = "remove",
@ -28,18 +30,18 @@ public class Remove extends SubCommand {
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location location = player.getLocation();
Plot plot = loc.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.remove")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.remove")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return true; return true;
} }
int count = 0; int count = 0;
@ -65,7 +67,7 @@ public class Remove extends SubCommand {
} }
default: default:
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]); Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
if (uuids != null) { if (uuids.isEmpty()) {
for (UUID uuid : uuids) { for (UUID uuid : uuids) {
if (plot.getTrusted().contains(uuid)) { if (plot.getTrusted().contains(uuid)) {
if (plot.removeTrusted(uuid)) { if (plot.removeTrusted(uuid)) {
@ -85,10 +87,10 @@ public class Remove extends SubCommand {
break; break;
} }
if (count == 0) { if (count == 0) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
return false; return false;
} else { } else {
MainUtil.sendMessage(plr, C.REMOVED_PLAYERS, count + ""); MainUtil.sendMessage(player, C.REMOVED_PLAYERS, count + "");
} }
return true; return true;
} }

View File

@ -28,31 +28,31 @@ import java.util.UUID;
public class Save extends SubCommand { public class Save extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (!Settings.METRICS) { if (!Settings.METRICS) {
MainUtil.sendMessage(plr, MainUtil.sendMessage(player,
"&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
return false; return false;
} }
String world = plr.getLocation().getWorld(); String world = player.getLocation().getWorld();
if (!PS.get().hasPlotArea(world)) { if (!PS.get().hasPlotArea(world)) {
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD); return !sendMessage(player, C.NOT_IN_PLOT_WORLD);
} }
final Plot plot = plr.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.save")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.save")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return false; return false;
} }
plot.addRunning(); plot.addRunning();
@ -69,17 +69,17 @@ public class Save extends SubCommand {
PlotId id = plot.getId(); PlotId id = plot.getId();
String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", ""); String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size + '_' + name; final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size + '_' + name;
UUID uuid = plr.getUUID(); UUID uuid = player.getUUID();
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() { SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() {
@Override @Override
public void run(URL url) { public void run(URL url) {
plot.removeRunning(); plot.removeRunning();
if (url == null) { if (url == null) {
MainUtil.sendMessage(plr, C.SAVE_FAILED); MainUtil.sendMessage(player, C.SAVE_FAILED);
return; return;
} }
MainUtil.sendMessage(plr, C.SAVE_SUCCESS); MainUtil.sendMessage(player, C.SAVE_SUCCESS);
List<String> schematics = plr.getMeta("plot_schematics"); List<String> schematics = player.getMeta("plot_schematics");
if (schematics != null) { if (schematics != null) {
schematics.add(file); schematics.add(file);
} }

View File

@ -33,37 +33,37 @@ public class SchematicCmd extends SubCommand {
private boolean running = false; private boolean running = false;
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length < 1) { if (args.length < 1) {
sendMessage(plr, C.SCHEMATIC_MISSING_ARG); sendMessage(player, C.SCHEMATIC_MISSING_ARG);
return true; return true;
} }
String arg = args[0].toLowerCase(); String arg = args[0].toLowerCase();
switch (arg) { switch (arg) {
case "paste": { case "paste": {
if (!Permissions.hasPermission(plr, "plots.schematic.paste")) { if (!Permissions.hasPermission(player, "plots.schematic.paste")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.schematic.paste");
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {
sendMessage(plr, C.SCHEMATIC_MISSING_ARG); sendMessage(player, C.SCHEMATIC_MISSING_ARG);
break; break;
} }
Location loc = plr.getLocation(); Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.schematic.paste")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.schematic.paste")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (this.running) { if (this.running) {
MainUtil.sendMessage(plr, "&cTask is already running."); MainUtil.sendMessage(player, "&cTask is already running.");
return false; return false;
} }
final String location = args[1]; final String location = args[1];
@ -80,7 +80,7 @@ public class SchematicCmd extends SubCommand {
schematic = SchematicHandler.manager.getSchematic(url); schematic = SchematicHandler.manager.getSchematic(url);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent url: " + location); sendMessage(player, C.SCHEMATIC_INVALID, "non-existent url: " + location);
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
return; return;
} }
@ -89,7 +89,7 @@ public class SchematicCmd extends SubCommand {
} }
if (schematic == null) { if (schematic == null) {
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format"); sendMessage(player, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
return; return;
} }
SchematicHandler.manager.paste(schematic, plot, 0, 0, 0, true, new RunnableVal<Boolean>() { SchematicHandler.manager.paste(schematic, plot, 0, 0, 0, true, new RunnableVal<Boolean>() {
@ -97,9 +97,9 @@ public class SchematicCmd extends SubCommand {
public void run(Boolean value) { public void run(Boolean value) {
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
if (value) { if (value) {
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
} else { } else {
sendMessage(plr, C.SCHEMATIC_PASTE_FAILED); sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
} }
} }
}); });
@ -141,81 +141,81 @@ public class SchematicCmd extends SubCommand {
// } // }
case "saveall": case "saveall":
case "exportall": { case "exportall": {
if (!(plr instanceof ConsolePlayer)) { if (!(player instanceof ConsolePlayer)) {
MainUtil.sendMessage(plr, C.NOT_CONSOLE); MainUtil.sendMessage(player, C.NOT_CONSOLE);
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
MainUtil.sendMessage(plr, "&cNeed world argument. Use &7/plots sch exportall <area>"); MainUtil.sendMessage(player, "&cNeed world argument. Use &7/plots sch exportall <area>");
return false; return false;
} }
PlotArea area = PS.get().getPlotAreaByString(args[1]); PlotArea area = PS.get().getPlotAreaByString(args[1]);
if (area == null) { if (area == null) {
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]); C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
return false; return false;
} }
Collection<Plot> plots = area.getPlots(); Collection<Plot> plots = area.getPlots();
if (plots.isEmpty()) { if (plots.isEmpty()) {
MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <area>"); MainUtil.sendMessage(player, "&cInvalid world. Use &7/plots sch exportall <area>");
return false; return false;
} }
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() { boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, "&aFinished mass export"); MainUtil.sendMessage(player, "&aFinished mass export");
} }
}); });
if (!result) { if (!result) {
MainUtil.sendMessage(plr, "&cTask is already running."); MainUtil.sendMessage(player, "&cTask is already running.");
return false; return false;
} else { } else {
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schematic&8: &7Mass export has started. This may take a while."); MainUtil.sendMessage(player, "&3PlotSquared&8->&3Schematic&8: &7Mass export has started. This may take a while.");
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots..."); MainUtil.sendMessage(player, "&3PlotSquared&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots...");
} }
break; break;
} }
case "export": case "export":
case "save": case "save":
if (!Permissions.hasPermission(plr, "plots.schematic.save")) { if (!Permissions.hasPermission(player, "plots.schematic.save")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.schematic.save");
return false; return false;
} }
if (this.running) { if (this.running) {
MainUtil.sendMessage(plr, "&cTask is already running."); MainUtil.sendMessage(player, "&cTask is already running.");
return false; return false;
} }
Location loc = plr.getLocation(); Location location = player.getLocation();
Plot plot = loc.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.schematic.save")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.schematic.save")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
loc.getWorld(); location.getWorld();
Collection<Plot> plots = new ArrayList<Plot>(); Collection<Plot> plots = new ArrayList<>();
plots.add(plot); plots.add(plot);
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() { boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, "&aFinished export"); MainUtil.sendMessage(player, "&aFinished export");
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
} }
}); });
if (!result) { if (!result) {
MainUtil.sendMessage(plr, "&cTask is already running."); MainUtil.sendMessage(player, "&cTask is already running.");
return false; return false;
} else { } else {
MainUtil.sendMessage(plr, "&7Starting export..."); MainUtil.sendMessage(player, "&7Starting export...");
} }
break; break;
default: default:
sendMessage(plr, C.SCHEMATIC_MISSING_ARG); sendMessage(player, C.SCHEMATIC_MISSING_ARG);
break; break;
} }
return true; return true;

View File

@ -47,25 +47,25 @@ public class Set extends SubCommand {
} }
@Override @Override
public boolean set(PlotPlayer plr, final Plot plot, String value) { public boolean set(PlotPlayer player, final Plot plot, String value) {
PlotArea plotworld = plr.getLocation().getPlotArea(); PlotArea plotArea = player.getLocation().getPlotArea();
PlotManager manager = plr.getLocation().getPlotManager(); PlotManager manager = player.getLocation().getPlotManager();
String[] components = manager.getPlotComponents(plotworld, plot.getId()); String[] components = manager.getPlotComponents(plotArea, plot.getId());
boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID()); boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(player.getUUID());
String[] args = value.split(" "); String[] args = value.split(" ");
String material = StringMan.join(Arrays.copyOfRange(args, 1, args.length), ",").trim(); String material = StringMan.join(Arrays.copyOfRange(args, 1, args.length), ",").trim();
for (String component : components) { for (String component : components) {
if (component.equalsIgnoreCase(args[0])) { if (component.equalsIgnoreCase(args[0])) {
if (!Permissions.hasPermission(plr, "plots.set." + component)) { if (!Permissions.hasPermission(player, "plots.set." + component)) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + component); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set." + component);
return false; return false;
} }
PlotBlock[] blocks; PlotBlock[] blocks;
try { try {
if (args.length < 2) { if (args.length < 2) {
MainUtil.sendMessage(plr, C.NEED_BLOCK); MainUtil.sendMessage(player, C.NEED_BLOCK);
return true; return true;
} }
String[] split = material.split(","); String[] split = material.split(",");
@ -73,7 +73,7 @@ public class Set extends SubCommand {
for (int i = 0; i < blocks.length; i++) { for (int i = 0; i < blocks.length; i++) {
PlotBlock block = blocks[i]; PlotBlock block = blocks[i];
if (block == null) { if (block == null) {
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, split[i]); MainUtil.sendMessage(player, C.NOT_VALID_BLOCK, split[i]);
String name; String name;
if (split[i].contains("%")) { if (split[i].contains("%")) {
name = split[i].split("%")[1]; name = split[i].split("%")[1];
@ -84,36 +84,36 @@ public class Set extends SubCommand {
if (match != null) { if (match != null) {
name = WorldUtil.IMP.getClosestMatchingName(match.best); name = WorldUtil.IMP.getClosestMatchingName(match.best);
if (name != null) { if (name != null) {
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, name.toLowerCase()); MainUtil.sendMessage(player, C.DID_YOU_MEAN, name.toLowerCase());
} }
} }
return false; return false;
} else if (!allowUnsafe && !WorldUtil.IMP.isBlockSolid(block)) { } else if (!allowUnsafe && !WorldUtil.IMP.isBlockSolid(block)) {
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString()); MainUtil.sendMessage(player, C.NOT_ALLOWED_BLOCK, block.toString());
return false; return false;
} }
} }
if (!allowUnsafe) { if (!allowUnsafe) {
for (PlotBlock block : blocks) { for (PlotBlock block : blocks) {
if (!WorldUtil.IMP.isBlockSolid(block)) { if (!WorldUtil.IMP.isBlockSolid(block)) {
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString()); MainUtil.sendMessage(player, C.NOT_ALLOWED_BLOCK, block.toString());
return false; return false;
} }
} }
} }
} catch (Exception ignored) { } catch (Exception ignored) {
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, material); MainUtil.sendMessage(player, C.NOT_VALID_BLOCK, material);
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
return false; return false;
} }
plot.addRunning(); plot.addRunning();
for (Plot current : plot.getConnectedPlots()) { for (Plot current : plot.getConnectedPlots()) {
current.setComponent(component, blocks); current.setComponent(component, blocks);
} }
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT); MainUtil.sendMessage(player, C.GENERATING_COMPONENT);
SetQueue.IMP.addTask(new Runnable() { SetQueue.IMP.addTask(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -128,37 +128,37 @@ public class Set extends SubCommand {
}; };
} }
public boolean noArgs(PlotPlayer plr) { public boolean noArgs(PlotPlayer player) {
ArrayList<String> newValues = new ArrayList<>(); ArrayList<String> newValues = new ArrayList<>();
newValues.addAll(Arrays.asList("biome", "alias", "home", "flag")); newValues.addAll(Arrays.asList("biome", "alias", "home", "flag"));
Plot plot = plr.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if (plot != null) { if (plot != null) {
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId()))); newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId())));
} }
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(newValues, C.BLOCK_LIST_SEPARATER.formatted())); MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(newValues, C.BLOCK_LIST_SEPARATER.formatted()));
return false; return false;
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
return noArgs(plr); return noArgs(player);
} }
Command cmd = MainCommand.getInstance().getCommand("set" + args[0]); Command cmd = MainCommand.getInstance().getCommand("set" + args[0]);
if (cmd != null) { if (cmd != null) {
cmd.execute(plr, Arrays.copyOfRange(args, 1, args.length), null, null); cmd.execute(player, Arrays.copyOfRange(args, 1, args.length), null, null);
return true; return true;
} }
// Additional checks // Additional checks
Plot plot = plr.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
MainUtil.sendMessage(plr, C.NOT_IN_PLOT); MainUtil.sendMessage(player, C.NOT_IN_PLOT);
return false; return false;
} }
// components // components
HashSet<String> components = new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId()))); HashSet<String> components = new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId())));
if (components.contains(args[0].toLowerCase())) { if (components.contains(args[0].toLowerCase())) {
return this.component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length)); return this.component.onCommand(player, Arrays.copyOfRange(args, 0, args.length));
} }
// flag // flag
Flag<?> flag = FlagManager.getFlag(args[0].toLowerCase()); Flag<?> flag = FlagManager.getFlag(args[0].toLowerCase());
@ -169,9 +169,9 @@ public class Set extends SubCommand {
a.append(" ").append(args[x]); a.append(" ").append(args[x]);
} }
} }
MainCommand.onCommand(plr, ("flag set " + args[0] + a.toString()).split(" ")); MainCommand.onCommand(player, ("flag set " + args[0] + a.toString()).split(" "));
return true; return true;
} }
return noArgs(plr); return noArgs(player);
} }
} }

View File

@ -11,32 +11,32 @@ import com.intellectualcrafters.plot.util.StringMan;
public abstract class SetCommand extends SubCommand { public abstract class SetCommand extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
Plot plot = loc.getPlotAbs(); Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plr, "plots.admin.command." + getFullId())) { if (!Permissions.hasPermission(player, "plots.admin.command." + getFullId())) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getFullId()); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command." + getFullId());
MainUtil.sendMessage(plr, C.PLOT_NOT_CLAIMED); MainUtil.sendMessage(player, C.PLOT_NOT_CLAIMED);
return false; return false;
} }
} }
if (!plot.isOwner(plr.getUUID())) { if (!plot.isOwner(player.getUUID())) {
if (!Permissions.hasPermission(plr, "plots.admin.command." + getFullId())) { if (!Permissions.hasPermission(player, "plots.admin.command." + getFullId())) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getFullId()); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command." + getFullId());
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
} }
if (args.length == 0) { if (args.length == 0) {
return set(plr, plot, ""); return set(player, plot, "");
} }
return set(plr, plot, StringMan.join(args, " ")); return set(player, plot, StringMan.join(args, " "));
} }
public abstract boolean set(PlotPlayer plr, Plot plot, String value); public abstract boolean set(PlotPlayer player, Plot plot, String value);
} }

View File

@ -19,24 +19,24 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class SetHome extends SetCommand { public class SetHome extends SetCommand {
@Override @Override
public boolean set(PlotPlayer plr, Plot plot, String value) { public boolean set(PlotPlayer player, Plot plot, String value) {
switch (value.toLowerCase()) { switch (value.toLowerCase()) {
case "unset": case "unset":
case "remove": case "remove":
case "none": { case "none": {
Plot base = plot.getBasePlot(false); Plot base = plot.getBasePlot(false);
base.setHome(null); base.setHome(null);
return MainUtil.sendMessage(plr, C.POSITION_UNSET); return MainUtil.sendMessage(player, C.POSITION_UNSET);
} }
case "": case "":
Plot base = plot.getBasePlot(false); Plot base = plot.getBasePlot(false);
Location bot = base.getBottomAbs(); Location bot = base.getBottomAbs();
Location loc = plr.getLocationFull(); Location loc = player.getLocationFull();
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch()); BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());
base.setHome(rel); base.setHome(rel);
return MainUtil.sendMessage(plr, C.POSITION_SET); return MainUtil.sendMessage(player, C.POSITION_SET);
default: default:
MainUtil.sendMessage(plr, C.HOME_ARGUMENT); MainUtil.sendMessage(player, C.HOME_ARGUMENT);
return false; return false;
} }
} }

View File

@ -28,7 +28,7 @@ import java.util.Map.Entry;
category = CommandCategory.ADMINISTRATION) category = CommandCategory.ADMINISTRATION)
public class Setup extends SubCommand { public class Setup extends SubCommand {
public void displayGenerators(PlotPlayer plr) { public void displayGenerators(PlotPlayer player) {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
message.append("&6What generator do you want?"); message.append("&6What generator do you want?");
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) { for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
@ -40,32 +40,32 @@ public class Setup extends SubCommand {
message.append("\n&8 - &7").append(entry.getKey()).append(" (Unknown structure)"); message.append("\n&8 - &7").append(entry.getKey()).append(" (Unknown structure)");
} }
} }
MainUtil.sendMessage(plr, message.toString()); MainUtil.sendMessage(player, message.toString());
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
// going through setup // going through setup
SetupObject object = plr.getMeta("setup"); SetupObject object = player.getMeta("setup");
if (object == null) { if (object == null) {
object = new SetupObject(); object = new SetupObject();
plr.setMeta("setup", object); player.setMeta("setup", object);
SetupUtils.manager.updateGenerators(); SetupUtils.manager.updateGenerators();
sendMessage(plr, C.SETUP_INIT); sendMessage(player, C.SETUP_INIT);
displayGenerators(plr); displayGenerators(player);
return false; return false;
} }
if (args.length == 1) { if (args.length == 1) {
if (args[0].equalsIgnoreCase("cancel")) { if (args[0].equalsIgnoreCase("cancel")) {
plr.deleteMeta("setup"); player.deleteMeta("setup");
MainUtil.sendMessage(plr, "&aCancelled setup"); MainUtil.sendMessage(player, "&aCancelled setup");
return false; return false;
} }
if (args[0].equalsIgnoreCase("back")) { if (args[0].equalsIgnoreCase("back")) {
if (object.setup_index > 0) { if (object.setup_index > 0) {
object.setup_index--; object.setup_index--;
ConfigurationNode node = object.step[object.setup_index]; ConfigurationNode node = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, node.getDescription(), node.getType().getType(), sendMessage(player, C.SETUP_STEP, object.setup_index + 1, node.getDescription(), node.getType().getType(),
String.valueOf(node.getDefaultValue())); String.valueOf(node.getDefaultValue()));
return false; return false;
} else if (object.current > 0) { } else if (object.current > 0) {
@ -78,15 +78,15 @@ public class Setup extends SubCommand {
case 0: // choose generator case 0: // choose generator
if (args.length != 1 || !SetupUtils.generators.containsKey(args[0])) { if (args.length != 1 || !SetupUtils.generators.containsKey(args[0])) {
String prefix = "\n&8 - &7"; String prefix = "\n&8 - &7";
MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix) MainUtil.sendMessage(player, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix)
.replaceAll("PlotSquared", "&2PlotSquared")); .replaceAll("PlotSquared", "&2PlotSquared"));
sendMessage(plr, C.SETUP_INIT); sendMessage(player, C.SETUP_INIT);
return false; return false;
} }
object.setupGenerator = args[0]; object.setupGenerator = args[0];
object.current++; object.current++;
String partial = "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"; String partial = "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots";
MainUtil.sendMessage(plr, "&6What world type do you want?\n&8 - &2DEFAULT&8 - &7Standard plot generation" MainUtil.sendMessage(player, "&6What world type do you want?\n&8 - &2DEFAULT&8 - &7Standard plot generation"
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
break; break;
case 1: // choose world type case 1: // choose world type
@ -100,13 +100,13 @@ public class Setup extends SubCommand {
types.add("augmented"); types.add("augmented");
types.add("partial"); types.add("partial");
if (args.length != 1 || !types.contains(args[0].toLowerCase())) { if (args.length != 1 || !types.contains(args[0].toLowerCase())) {
MainUtil.sendMessage(plr, "&cYou must choose a world type!"); MainUtil.sendMessage(player, "&cYou must choose a world type!");
for (String type : types) { for (String type : types) {
int i = allTypes.indexOf(type); int i = allTypes.indexOf(type);
if (type.equals("default")) { if (type.equals("default")) {
MainUtil.sendMessage(plr, "&8 - &2" + type + " &8-&7 " + allDesc.get(i)); MainUtil.sendMessage(player, "&8 - &2" + type + " &8-&7 " + allDesc.get(i));
} else { } else {
MainUtil.sendMessage(plr, "&8 - &7" + type + " &8-&7 " + allDesc.get(i)); MainUtil.sendMessage(player, "&8 - &7" + type + " &8-&7 " + allDesc.get(i));
} }
} }
return false; return false;
@ -122,12 +122,12 @@ public class Setup extends SubCommand {
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object); SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
} }
if (object.step.length == 0) { if (object.step.length == 0) {
MainUtil.sendMessage(plr, "&6What do you want your world to be called?"); MainUtil.sendMessage(player, "&6What do you want your world to be called?");
object.setup_index = 0; object.setup_index = 0;
return true; return true;
} }
ConfigurationNode step = object.step[object.setup_index]; ConfigurationNode step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(), sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue())); String.valueOf(step.getDefaultValue()));
} else { } else {
if (gen.isFull()) { if (gen.isFull()) {
@ -138,16 +138,16 @@ public class Setup extends SubCommand {
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object); SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
} else { } else {
object.plotManager = "PlotSquared"; object.plotManager = "PlotSquared";
MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator"); MainUtil.sendMessage(player, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin"); MainUtil.sendMessage(player, "&7 - You may need to manually configure the other plugin");
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator() object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes(); .getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
} }
if (object.type == 2) { if (object.type == 2) {
MainUtil.sendMessage(plr, "What would you like this area called?"); MainUtil.sendMessage(player, "What would you like this area called?");
object.current++; object.current++;
} else { } else {
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" MainUtil.sendMessage(player, "&6What terrain would you like in plots?"
+ "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &2NONE&8 - &7No terrain at all"
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads" + "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
@ -158,42 +158,42 @@ public class Setup extends SubCommand {
break; break;
case 2: // area id case 2: // area id
if (!StringMan.isAlphanumericUnd(args[0])) { if (!StringMan.isAlphanumericUnd(args[0])) {
MainUtil.sendMessage(plr, "&cThe area id must be alphanumerical!"); MainUtil.sendMessage(player, "&cThe area id must be alphanumerical!");
return false; return false;
} }
for (PlotArea area : PS.get().getPlotAreas()) { for (PlotArea area : PS.get().getPlotAreas()) {
if (area.id != null && area.id.equalsIgnoreCase(args[0])) { if (area.id != null && area.id.equalsIgnoreCase(args[0])) {
MainUtil.sendMessage(plr, "&cYou must choose an area id that is not in use!"); MainUtil.sendMessage(player, "&cYou must choose an area id that is not in use!");
return false; return false;
} }
} }
object.id = args[0]; object.id = args[0];
object.current++; object.current++;
MainUtil.sendMessage(plr, "&6What should be the minimum Plot Id?"); MainUtil.sendMessage(player, "&6What should be the minimum Plot Id?");
break; break;
case 3: // min case 3: // min
object.min = PlotId.fromString(args[0]); object.min = PlotId.fromString(args[0]);
if (object.min == null) { if (object.min == null) {
MainUtil.sendMessage(plr, "&cYou must choose a valid minimum PlotId!"); MainUtil.sendMessage(player, "&cYou must choose a valid minimum PlotId!");
return false; return false;
} }
object.current++; object.current++;
MainUtil.sendMessage(plr, "&6What should be the maximum Plot Id?"); MainUtil.sendMessage(player, "&6What should be the maximum Plot Id?");
break; break;
case 4: case 4:
// max // max
PlotId id = PlotId.fromString(args[0]); PlotId id = PlotId.fromString(args[0]);
if (id == null) { if (id == null) {
MainUtil.sendMessage(plr, "&cYou must choose a valid maximum PlotId!"); MainUtil.sendMessage(player, "&cYou must choose a valid maximum PlotId!");
return false; return false;
} }
if (id.x <= object.min.x || id.y <= object.min.y) { if (id.x <= object.min.x || id.y <= object.min.y) {
MainUtil.sendMessage(plr, "&cThe max PlotId must be greater than the minimum!"); MainUtil.sendMessage(player, "&cThe max PlotId must be greater than the minimum!");
return false; return false;
} }
object.max = id; object.max = id;
object.current++; object.current++;
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" MainUtil.sendMessage(player, "&6What terrain would you like in plots?"
+ "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &2NONE&8 - &7No terrain at all"
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads" + "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
@ -202,7 +202,7 @@ public class Setup extends SubCommand {
case 5: { // Choose terrain case 5: { // Choose terrain
List<String> terrain = Arrays.asList("none", "ore", "road", "all"); List<String> terrain = Arrays.asList("none", "ore", "road", "all");
if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) { if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) {
MainUtil.sendMessage(plr, "&cYou must choose the terrain!" MainUtil.sendMessage(player, "&cYou must choose the terrain!"
+ "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &2NONE&8 - &7No terrain at all"
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads" + "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
@ -216,58 +216,58 @@ public class Setup extends SubCommand {
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes(); .getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
} }
ConfigurationNode step = object.step[object.setup_index]; ConfigurationNode step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(), sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue())); String.valueOf(step.getDefaultValue()));
break; break;
} }
case 6: // world setup case 6: // world setup
if (object.setup_index == object.step.length) { if (object.setup_index == object.step.length) {
MainUtil.sendMessage(plr, "&6What do you want your world to be called?"); MainUtil.sendMessage(player, "&6What do you want your world to be called?");
object.setup_index = 0; object.setup_index = 0;
object.current++; object.current++;
return true; return true;
} }
ConfigurationNode step = object.step[object.setup_index]; ConfigurationNode step = object.step[object.setup_index];
if (args.length < 1) { if (args.length < 1) {
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(), sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue())); String.valueOf(step.getDefaultValue()));
return false; return false;
} }
boolean valid = step.isValid(args[0]); boolean valid = step.isValid(args[0]);
if (valid) { if (valid) {
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]); sendMessage(player, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
step.setValue(args[0]); step.setValue(args[0]);
object.setup_index++; object.setup_index++;
if (object.setup_index == object.step.length) { if (object.setup_index == object.step.length) {
onCommand(plr, args); onCommand(player, args);
return false; return false;
} }
step = object.step[object.setup_index]; step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(), sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue())); String.valueOf(step.getDefaultValue()));
return false; return false;
} else { } else {
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant()); sendMessage(player, C.SETUP_INVALID_ARG, args[0], step.getConstant());
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(), sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue())); String.valueOf(step.getDefaultValue()));
return false; return false;
} }
case 7: case 7:
if (args.length != 1) { if (args.length != 1) {
MainUtil.sendMessage(plr, "&cYou need to choose a world name!"); MainUtil.sendMessage(player, "&cYou need to choose a world name!");
return false; return false;
} }
if (WorldUtil.IMP.isWorld(args[0])) { if (WorldUtil.IMP.isWorld(args[0])) {
if (PS.get().hasPlotArea(args[0])) { if (PS.get().hasPlotArea(args[0])) {
MainUtil.sendMessage(plr, "&cThat world name is already taken!"); MainUtil.sendMessage(player, "&cThat world name is already taken!");
return false; return false;
} }
MainUtil.sendMessage(plr, MainUtil.sendMessage(player,
"&cThe world you specified already exists. After restarting, new terrain will use PlotSquared, however you may need to " "&cThe world you specified already exists. After restarting, new terrain will use PlotSquared, however you may need to "
+ "reset the world for it to generate correctly!"); + "reset the world for it to generate correctly!");
} }
object.world = args[0]; object.world = args[0];
plr.deleteMeta("setup"); player.deleteMeta("setup");
String world; String world;
if (object.setupManager == null) { if (object.setupManager == null) {
world = SetupUtils.manager.setupWorld(object); world = SetupUtils.manager.setupWorld(object);
@ -275,12 +275,12 @@ public class Setup extends SubCommand {
world = object.setupManager.setupWorld(object); world = object.setupManager.setupWorld(object);
} }
try { try {
plr.teleport(WorldUtil.IMP.getSpawn(world)); player.teleport(WorldUtil.IMP.getSpawn(world));
} catch (Exception e) { } catch (Exception e) {
plr.sendMessage("&cAn error occurred. See console for more information"); player.sendMessage("&cAn error occurred. See console for more information");
e.printStackTrace(); e.printStackTrace();
} }
sendMessage(plr, C.SETUP_FINISHED, object.world); sendMessage(player, C.SETUP_FINISHED, object.world);
} }
return false; return false;
} }

View File

@ -28,7 +28,7 @@ public abstract class SubCommand extends Command {
} }
public abstract boolean onCommand(PlotPlayer plr, String[] args); public abstract boolean onCommand(PlotPlayer player, String[] args);
public boolean sendMessage(PlotPlayer player, C message, Object... args) { public boolean sendMessage(PlotPlayer player, C message, Object... args) {
message.send(player, args); message.send(player, args);

View File

@ -17,42 +17,42 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Swap extends SubCommand { public class Swap extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
Plot plot1 = loc.getPlotAbs(); Plot plot1 = loc.getPlotAbs();
if (plot1 == null) { if (plot1 == null) {
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return !MainUtil.sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) { if (!plot1.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN.s())) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false; return false;
} }
if (args.length != 1) { if (args.length != 1) {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true); Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
if (plot2 == null) { if (plot2 == null) {
return false; return false;
} }
if (plot1.equals(plot2)) { if (plot1.equals(plot2)) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
return false; return false;
} }
if (!plot1.getArea().isCompatible(plot2.getArea())) { if (!plot1.getArea().isCompatible(plot2.getArea())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr); C.PLOTWORLD_INCOMPATIBLE.send(player);
return false; return false;
} }
if (plot1.move(plot2, new Runnable() { if (plot1.move(plot2, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, C.SWAP_SUCCESS); MainUtil.sendMessage(player, C.SWAP_SUCCESS);
} }
}, true)) { }, true)) {
return true; return true;
} else { } else {
MainUtil.sendMessage(plr, C.SWAP_OVERLAP); MainUtil.sendMessage(player, C.SWAP_OVERLAP);
return false; return false;
} }
} }

View File

@ -24,31 +24,31 @@ public class Target extends SubCommand {
} }
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
Location plrLocation = plr.getLocation(); Location location = player.getLocation();
if (!plrLocation.isPlotArea()) { if (!location.isPlotArea()) {
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
return false; return false;
} }
Plot target = null; Plot target = null;
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) { if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
int distance = Integer.MAX_VALUE; int distance = Integer.MAX_VALUE;
for (Plot plot : PS.get().getPlots(plrLocation.getWorld())) { for (Plot plot : PS.get().getPlots(location.getWorld())) {
double current = plot.getCenter().getEuclideanDistanceSquared(plrLocation); double current = plot.getCenter().getEuclideanDistanceSquared(location);
if (current < distance) { if (current < distance) {
distance = (int) current; distance = (int) current;
target = plot; target = plot;
} }
} }
if (target == null) { if (target == null) {
MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS); MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
return false; return false;
} }
} else if ((target = MainUtil.getPlotFromString(plr, args[0], true)) == null) { } else if ((target = MainUtil.getPlotFromString(player, args[0], true)) == null) {
return false; return false;
} }
plr.setCompassTarget(target.getCenter()); player.setCompassTarget(target.getCenter());
MainUtil.sendMessage(plr, C.COMPASS_TARGET); MainUtil.sendMessage(player, C.COMPASS_TARGET);
return true; return true;
} }
} }

View File

@ -74,10 +74,10 @@ public class Template extends SubCommand {
} }
} }
public static byte[] getBytes(PlotArea plotworld) { public static byte[] getBytes(PlotArea plotArea) {
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds." + plotworld.worldname); ConfigurationSection section = PS.get().config.getConfigurationSection("worlds." + plotArea.worldname);
YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
String generator = SetupUtils.manager.getGenerator(plotworld); String generator = SetupUtils.manager.getGenerator(plotArea);
if (generator != null) { if (generator != null) {
config.set("generator.plugin", generator); config.set("generator.plugin", generator);
} }
@ -103,34 +103,34 @@ public class Template extends SubCommand {
} }
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length != 2 && args.length != 3) { if (args.length != 2 && args.length != 3) {
if (args.length == 1) { if (args.length == 1) {
if (args[0].equalsIgnoreCase("export")) { if (args[0].equalsIgnoreCase("export")) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export <world>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot template export <world>");
return true; return true;
} else if (args[0].equalsIgnoreCase("import")) { } else if (args[0].equalsIgnoreCase("import")) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import <world> <template>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot template import <world> <template>");
return true; return true;
} }
} }
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template <import|export> <world> [template]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot template <import|export> <world> [template]");
return true; return true;
} }
final String world = args[1]; final String world = args[1];
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "import": { case "import": {
if (args.length != 3) { if (args.length != 3) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import <world> <template>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot template import <world> <template>");
return false; return false;
} }
if (PS.get().hasPlotArea(world)) { if (PS.get().hasPlotArea(world)) {
MainUtil.sendMessage(plr, C.SETUP_WORLD_TAKEN, world); MainUtil.sendMessage(player, C.SETUP_WORLD_TAKEN, world);
return false; return false;
} }
boolean result = extractAllFiles(world, args[2]); boolean result = extractAllFiles(world, args[2]);
if (!result) { if (!result) {
MainUtil.sendMessage(plr, "&cInvalid template file: " + args[2] + ".template"); MainUtil.sendMessage(player, "&cInvalid template file: " + args[2] + ".template");
return false; return false;
} }
File worldFile = new File(PS.get().IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml"); File worldFile = new File(PS.get().IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml");
@ -158,20 +158,20 @@ public class Template extends SubCommand {
SetQueue.IMP.addTask(new Runnable() { SetQueue.IMP.addTask(new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, "Done!"); MainUtil.sendMessage(player, "Done!");
plr.teleport(WorldUtil.IMP.getSpawn(world)); player.teleport(WorldUtil.IMP.getSpawn(world));
} }
}); });
return true; return true;
} }
case "export": case "export":
if (args.length != 2) { if (args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export <world>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot template export <world>");
return false; return false;
} }
final PlotArea area = PS.get().getPlotAreaByString(world); final PlotArea area = PS.get().getPlotAreaByString(world);
if (area == null) { if (area == null) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
return false; return false;
} }
final PlotManager manager = area.getPlotManager(); final PlotManager manager = area.getPlotManager();
@ -182,15 +182,15 @@ public class Template extends SubCommand {
manager.exportTemplate(area); manager.exportTemplate(area);
} catch (Exception e) { // Must recover from any exception thrown a third party template manager } catch (Exception e) { // Must recover from any exception thrown a third party template manager
e.printStackTrace(); e.printStackTrace();
MainUtil.sendMessage(plr, "Failed: " + e.getMessage()); MainUtil.sendMessage(player, "Failed: " + e.getMessage());
return; return;
} }
MainUtil.sendMessage(plr, "Done!"); MainUtil.sendMessage(player, "Done!");
} }
}); });
return true; return true;
default: default:
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
} }
return false; return false;
} }

View File

@ -127,18 +127,18 @@ public class Trim extends SubCommand {
} }
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
final String world = args[0]; final String world = args[0];
if (!WorldUtil.IMP.isWorld(world) || !PS.get().hasPlotArea(world)) { if (!WorldUtil.IMP.isWorld(world) || !PS.get().hasPlotArea(world)) {
MainUtil.sendMessage(plr, C.NOT_VALID_WORLD); MainUtil.sendMessage(player, C.NOT_VALID_WORLD);
return false; return false;
} }
if (Trim.TASK) { if (Trim.TASK) {
C.TRIM_IN_PROGRESS.send(plr); C.TRIM_IN_PROGRESS.send(player);
return false; return false;
} }
Trim.TASK = true; Trim.TASK = true;
@ -156,7 +156,7 @@ public class Trim extends SubCommand {
public void run() { public void run() {
if (nonViable.isEmpty()) { if (nonViable.isEmpty()) {
Trim.TASK = false; Trim.TASK = false;
plr.sendMessage("Trim done!"); player.sendMessage("Trim done!");
return; return;
} }
Iterator<ChunkLoc> iterator = nonViable.iterator(); Iterator<ChunkLoc> iterator = nonViable.iterator();

View File

@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -35,7 +36,7 @@ public class Trust extends Command {
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.trust"), C.NO_PLOT_PERMS); checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.trust"), C.NO_PLOT_PERMS);
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage()); checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]); final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
checkTrue(uuids != null && !uuids.isEmpty(), C.INVALID_PLAYER, args[0]); checkTrue(!uuids.isEmpty(), C.INVALID_PLAYER, args[0]);
Iterator<UUID> iter = uuids.iterator(); Iterator<UUID> iter = uuids.iterator();
int size = plot.getTrusted().size() + plot.getMembers().size(); int size = plot.getTrusted().size() + plot.getMembers().size();
while (iter.hasNext()) { while (iter.hasNext()) {

View File

@ -21,26 +21,26 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Unlink extends SubCommand { public class Unlink extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = plr.getLocation(); Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(player, C.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return !sendMessage(plr, C.PLOT_UNOWNED); return !sendMessage(player, C.PLOT_UNOWNED);
} }
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.unlink")) {
return sendMessage(plr, C.NO_PLOT_PERMS); return sendMessage(player, C.NO_PLOT_PERMS);
} }
if (!plot.isMerged()) { if (!plot.isMerged()) {
return sendMessage(plr, C.UNLINK_IMPOSSIBLE); return sendMessage(player, C.UNLINK_IMPOSSIBLE);
} }
final boolean createRoad; final boolean createRoad;
if (args.length != 0) { if (args.length != 0) {
if (args.length != 1 || !StringMan.isEqualIgnoreCaseToAny(args[0], "true", "false")) { if (args.length != 1 || !StringMan.isEqualIgnoreCaseToAny(args[0], "true", "false")) {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;
} }
createRoad = Boolean.parseBoolean(args[0]); createRoad = Boolean.parseBoolean(args[0]);
@ -51,14 +51,14 @@ public class Unlink extends SubCommand {
@Override @Override
public void run() { public void run() {
if (!plot.unlinkPlot(createRoad, createRoad)) { if (!plot.unlinkPlot(createRoad, createRoad)) {
MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); MainUtil.sendMessage(player, "&cUnlink has been cancelled");
return; return;
} }
MainUtil.sendMessage(plr, C.UNLINK_SUCCESS); MainUtil.sendMessage(player, C.UNLINK_SUCCESS);
} }
}; };
if (hasConfirmation(plr)) { if (hasConfirmation(player)) {
CmdConfirm.addPending(plr, "/plot unlink " + plot.getId(), runnable); CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable);
} else { } else {
TaskManager.runTask(runnable); TaskManager.runTask(runnable);
} }

View File

@ -21,7 +21,7 @@ import java.net.URL;
public class Update extends SubCommand { public class Update extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer plr, String[] args) { public boolean onCommand(PlotPlayer player, String[] args) {
URL url; URL url;
if (args.length == 0) { if (args.length == 0) {
url = Updater.getUpdate(); url = Updater.getUpdate();
@ -29,20 +29,20 @@ public class Update extends SubCommand {
try { try {
url = new URL(args[0]); url = new URL(args[0]);
} catch (MalformedURLException ignored) { } catch (MalformedURLException ignored) {
MainUtil.sendMessage(plr, "&cInvalid URL: " + args[0]); MainUtil.sendMessage(player, "&cInvalid URL: " + args[0]);
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot update [url]");
return false; return false;
} }
} else { } else {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, getUsage().replaceAll("\\{label\\}", "plot")); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, getUsage().replaceAll("\\{label\\}", "plot"));
return false; return false;
} }
if (url == null) { if (url == null) {
MainUtil.sendMessage(plr, "&cNo update found!"); MainUtil.sendMessage(player, "&cNo update found!");
MainUtil.sendMessage(plr, "&cTo manually specify an update URL: /plot update <url>"); MainUtil.sendMessage(player, "&cTo manually specify an update URL: /plot update <url>");
return false; return false;
} }
if (PS.get().update(plr, url) && (url == PS.get().update)) { if (PS.get().update(player, url) && (url == PS.get().update)) {
PS.get().update = null; PS.get().update = null;
} }
return true; return true;

View File

@ -676,11 +676,11 @@ public enum C {
return m; return m;
} }
public static String format(C c, Object... args) { public static String format(C caption, Object... args) {
if (c.usePrefix()) { if (caption.usePrefix()) {
return C.PREFIX.s() + format(c.s, args); return C.PREFIX.s() + format(caption.s, args);
} else { } else {
return format(c.s, args); return format(caption.s, args);
} }
} }
@ -700,9 +700,9 @@ public enum C {
HashSet<String> allNames = new HashSet<>(); HashSet<String> allNames = new HashSet<>();
HashSet<String> categories = new HashSet<>(); HashSet<String> categories = new HashSet<>();
HashSet<String> toRemove = new HashSet<>(); HashSet<String> toRemove = new HashSet<>();
for (C c : allEnums) { for (C caption : allEnums) {
allNames.add(c.name()); allNames.add(caption.name());
categories.add(c.category.toLowerCase()); categories.add(caption.category.toLowerCase());
} }
HashSet<C> captions = new HashSet<>(); HashSet<C> captions = new HashSet<>();
boolean changed = false; boolean changed = false;
@ -797,16 +797,16 @@ public enum C {
return this.category; return this.category;
} }
public void send(CommandCaller plr, String... args) { public void send(CommandCaller caller, String... args) {
send(plr, (Object[]) args); send(caller, (Object[]) args);
} }
public void send(CommandCaller plr, Object... args) { public void send(CommandCaller caller, Object... args) {
String msg = format(this, args); String msg = format(this, args);
if (plr == null) { if (caller == null) {
PS.log(msg); PS.log(msg);
} else { } else {
plr.sendMessage(msg); caller.sendMessage(msg);
} }
} }
} }

View File

@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -17,39 +18,39 @@ import java.util.ArrayList;
public class ClassicPlotManager extends SquarePlotManager { public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean setComponent(PlotArea plotworld, PlotId plotid, String component, PlotBlock[] blocks) { public boolean setComponent(PlotArea plotArea, PlotId plotId, String component, PlotBlock[] blocks) {
switch (component) { switch (component) {
case "floor": case "floor":
setFloor(plotworld, plotid, blocks); setFloor(plotArea, plotId, blocks);
return true; return true;
case "wall": case "wall":
setWallFilling(plotworld, plotid, blocks); setWallFilling(plotArea, plotId, blocks);
return true; return true;
case "all": case "all":
setAll(plotworld, plotid, blocks); setAll(plotArea, plotId, blocks);
return true; return true;
case "air": case "air":
setAir(plotworld, plotid, blocks); setAir(plotArea, plotId, blocks);
return true; return true;
case "main": case "main":
setMain(plotworld, plotid, blocks); setMain(plotArea, plotId, blocks);
return true; return true;
case "middle": case "middle":
setMiddle(plotworld, plotid, blocks); setMiddle(plotArea, plotId, blocks);
return true; return true;
case "outline": case "outline":
setOutline(plotworld, plotid, blocks); setOutline(plotArea, plotId, blocks);
return true; return true;
case "border": case "border":
setWall(plotworld, plotid, blocks); setWall(plotArea, plotId, blocks);
return true; return true;
} }
return false; return false;
} }
@Override @Override
public boolean unclaimPlot(PlotArea plotworld, Plot plot, Runnable whenDone) { public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
setWallFilling(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_FILLING}); setWallFilling(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_FILLING});
if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) { if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
setWall(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_BLOCK}); setWall(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_BLOCK});
@ -58,78 +59,78 @@ public class ClassicPlotManager extends SquarePlotManager {
return true; return true;
} }
public boolean setFloor(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setFloor(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
for (RegionWrapper region : plot.getRegions()) { for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotworld.worldname, region.minX, dpw.PLOT_HEIGHT, region.minZ); Location pos1 = new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT, region.minZ);
Location pos2 = new Location(plotworld.worldname, region.maxX, dpw.PLOT_HEIGHT, region.maxZ); Location pos2 = new Location(plotArea.worldname, region.maxX, dpw.PLOT_HEIGHT, region.maxZ);
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks); MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
} }
} }
return true; return true;
} }
public boolean setAll(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setAll(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
if (!plot.isBasePlot()) { if (!plot.isBasePlot()) {
return false; return false;
} }
for (RegionWrapper region : plot.getRegions()) { for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotworld.worldname, region.minX, 1, region.minZ); Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
Location pos2 = new Location(plotworld.worldname, region.maxX, 255, region.maxZ); Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks); MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
} }
return true; return true;
} }
public boolean setAir(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setAir(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
if (!plot.isBasePlot()) { if (!plot.isBasePlot()) {
return false; return false;
} }
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
for (RegionWrapper region : plot.getRegions()) { for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotworld.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ); Location pos1 = new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
Location pos2 = new Location(plotworld.worldname, region.maxX, 255, region.maxZ); Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks); MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
} }
return true; return true;
} }
public boolean setMain(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setMain(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
if (!plot.isBasePlot()) { if (!plot.isBasePlot()) {
return false; return false;
} }
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
for (RegionWrapper region : plot.getRegions()) { for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotworld.worldname, region.minX, 1, region.minZ); Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
Location pos2 = new Location(plotworld.worldname, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ); Location pos2 = new Location(plotArea.worldname, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ);
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks); MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
} }
return true; return true;
} }
public boolean setMiddle(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setMiddle(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
if (!plot.isBasePlot()) { if (!plot.isBasePlot()) {
return false; return false;
} }
Location[] corners = plot.getCorners(); Location[] corners = plot.getCorners();
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
SetQueue.IMP.setBlock(plotworld.worldname, (corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT, SetQueue.IMP.setBlock(plotArea.worldname, (corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT,
(corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]); (corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]);
return true; return true;
} }
public boolean setOutline(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setOutline(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
if (dpw.ROAD_WIDTH == 0) { if (dpw.ROAD_WIDTH == 0) {
return false; return false;
} }
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
Location bottom = plot.getBottomAbs(); Location bottom = plot.getBottomAbs();
Location top = plot.getExtendedTopAbs(); Location top = plot.getExtendedTopAbs();
PseudoRandom random = new PseudoRandom(); PseudoRandom random = new PseudoRandom();
@ -137,7 +138,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int z = bottom.getZ(); int z = bottom.getZ();
for (int x = bottom.getX(); x <= top.getX(); x++) { for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
@ -145,7 +146,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int x = bottom.getX(); int x = bottom.getX();
for (int z = bottom.getZ(); z <= top.getZ(); z++) { for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
@ -154,7 +155,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int z = top.getZ(); int z = top.getZ();
for (int x = bottom.getX(); x <= top.getX(); x++) { for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
@ -162,26 +163,26 @@ public class ClassicPlotManager extends SquarePlotManager {
int x = top.getX(); int x = top.getX();
for (int z = bottom.getZ(); z <= top.getZ(); z++) { for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (RegionWrapper region : plot.getRegions()) { for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotworld.worldname, region.minX, 255, region.minZ); Location pos1 = new Location(plotArea.worldname, region.minX, 255, region.minZ);
Location pos2 = new Location(plotworld.worldname, region.maxX, 255, region.maxZ); Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks); MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
} }
} }
return true; return true;
} }
public boolean setWallFilling(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setWallFilling(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
if (dpw.ROAD_WIDTH == 0) { if (dpw.ROAD_WIDTH == 0) {
return false; return false;
} }
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1); Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
Location top = plot.getExtendedTopAbs().add(1, 0, 1); Location top = plot.getExtendedTopAbs().add(1, 0, 1);
PseudoRandom random = new PseudoRandom(); PseudoRandom random = new PseudoRandom();
@ -189,7 +190,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int z = bot.getZ(); int z = bot.getZ();
for (int x = bot.getX(); x < top.getX(); x++) { for (int x = bot.getX(); x < top.getX(); x++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
@ -197,7 +198,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int x = bot.getX(); int x = bot.getX();
for (int z = bot.getZ(); z < top.getZ(); z++) { for (int z = bot.getZ(); z < top.getZ(); z++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
@ -205,7 +206,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int z = top.getZ(); int z = top.getZ();
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) { for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
@ -213,19 +214,19 @@ public class ClassicPlotManager extends SquarePlotManager {
int x = top.getX(); int x = top.getX();
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) { for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
} }
return true; return true;
} }
public boolean setWall(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) { public boolean setWall(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
if (dpw.ROAD_WIDTH == 0) { if (dpw.ROAD_WIDTH == 0) {
return false; return false;
} }
Plot plot = plotworld.getPlotAbs(plotid); Plot plot = plotArea.getPlotAbs(plotId);
Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1); Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
Location top = plot.getExtendedTopAbs().add(1, 0, 1); Location top = plot.getExtendedTopAbs().add(1, 0, 1);
PseudoRandom random = new PseudoRandom(); PseudoRandom random = new PseudoRandom();
@ -233,25 +234,25 @@ public class ClassicPlotManager extends SquarePlotManager {
if (!plot.getMerged(0)) { if (!plot.getMerged(0)) {
int z = bot.getZ(); int z = bot.getZ();
for (int x = bot.getX(); x < top.getX(); x++) { for (int x = bot.getX(); x < top.getX(); x++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
if (!plot.getMerged(3)) { if (!plot.getMerged(3)) {
int x = bot.getX(); int x = bot.getX();
for (int z = bot.getZ(); z < top.getZ(); z++) { for (int z = bot.getZ(); z < top.getZ(); z++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
if (!plot.getMerged(2)) { if (!plot.getMerged(2)) {
int z = top.getZ(); int z = top.getZ();
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) { for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
if (!plot.getMerged(1)) { if (!plot.getMerged(1)) {
int x = top.getX(); int x = top.getX();
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) { for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); SetQueue.IMP.setBlock(plotArea.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
return true; return true;
@ -291,102 +292,102 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
@Override @Override
public boolean createRoadSouth(PlotArea plotworld, Plot plot) { public boolean createRoadSouth(PlotArea plotArea, Plot plot) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId()); Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
int sz = pos2.getZ() + 1; int sz = pos2.getZ() + 1;
int ez = sz + dpw.ROAD_WIDTH - 1; int ez = sz + dpw.ROAD_WIDTH - 1;
int sx = pos1.getX() - 2; int sx = pos1.getX() - 2;
int ex = pos2.getX() + 2; int ex = pos2.getX() + 2;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, MainUtil.setSimpleCuboidAsync(plotArea.worldname,
new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotworld.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz),
new Location(plotworld.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0)); new Location(plotArea.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz),
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING); new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING);
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz),
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz),
dpw.WALL_BLOCK); dpw.WALL_BLOCK);
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, ez), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, ez),
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, ez), dpw.WALL_FILLING); new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, ez), dpw.WALL_FILLING);
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez),
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez), new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez),
dpw.WALL_BLOCK); dpw.WALL_BLOCK);
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz + 1),
new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK); new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
return true; return true;
} }
@Override @Override
public boolean createRoadSouthEast(PlotArea plotworld, Plot plot) { public boolean createRoadSouthEast(PlotArea plotArea, Plot plot) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
int sx = pos2.getX() + 1; int sx = pos2.getX() + 1;
int ex = sx + dpw.ROAD_WIDTH - 1; int ex = sx + dpw.ROAD_WIDTH - 1;
int sz = pos2.getZ() + 1; int sz = pos2.getZ() + 1;
int ez = sz + dpw.ROAD_WIDTH - 1; int ez = sz + dpw.ROAD_WIDTH - 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1),
new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock( new Location(plotArea.worldname, ex - 1, 255, ez - 1), new PlotBlock(
(short) 0, (byte) 0)); (short) 0, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz + 1),
new Location(plotworld.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0)); new Location(plotArea.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz + 1),
new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK); new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
return true; return true;
} }
@Override @Override
public boolean removeRoadEast(PlotArea plotworld, Plot plot) { public boolean removeRoadEast(PlotArea plotArea, Plot plot) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId()); Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
int sx = pos2.getX() + 1; int sx = pos2.getX() + 1;
int ex = sx + dpw.ROAD_WIDTH - 1; int ex = sx + dpw.ROAD_WIDTH - 1;
int sz = pos1.getZ() - 1; int sz = pos1.getZ() - 1;
int ez = pos2.getZ() + 1; int ez = pos2.getZ() + 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz + 1),
new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK); new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz + 1), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1),
new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK); new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK);
return true; return true;
} }
@Override @Override
public boolean removeRoadSouth(PlotArea plotworld, Plot plot) { public boolean removeRoadSouth(PlotArea plotArea, Plot plot) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId()); Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
int sz = pos2.getZ() + 1; int sz = pos2.getZ() + 1;
int ez = sz + dpw.ROAD_WIDTH - 1; int ez = sz + dpw.ROAD_WIDTH - 1;
int sx = pos1.getX() - 1; int sx = pos1.getX() - 1;
int ex = pos2.getX() + 1; int ex = pos2.getX() + 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz),
new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK); new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.PLOT_HEIGHT, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz),
new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK); new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK);
return true; return true;
} }
@Override @Override
public boolean removeRoadSouthEast(PlotArea plotworld, Plot plot) { public boolean removeRoadSouthEast(PlotArea plotArea, Plot plot) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
Location loc = getPlotTopLocAbs(dpw, plot.getId()); Location location = getPlotTopLocAbs(dpw, plot.getId());
int sx = loc.getX() + 1; int sx = location.getX() + 1;
int ex = sx + dpw.ROAD_WIDTH - 1; int ex = sx + dpw.ROAD_WIDTH - 1;
int sz = loc.getZ() + 1; int sz = location.getZ() + 1;
int ez = sz + dpw.ROAD_WIDTH - 1; int ez = sz + dpw.ROAD_WIDTH - 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT + 1, sz),
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz),
new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK); new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT, sz),
new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK); new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
return true; return true;
} }
@ -394,51 +395,51 @@ public class ClassicPlotManager extends SquarePlotManager {
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED). * Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED).
*/ */
@Override @Override
public boolean finishPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds) { public boolean finishPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) {
PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
if (block.id != 0 || !block.equals(unclaim)) { if (block.id != 0 || !block.equals(unclaim)) {
for (PlotId id : plotIds) { for (PlotId id : plotIds) {
setWall(plotworld, id, new PlotBlock[]{block}); setWall(plotArea, id, new PlotBlock[]{block});
} }
} }
return true; return true;
} }
@Override @Override
public boolean finishPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds) { public boolean finishPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds) {
PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
for (PlotId id : plotIds) { for (PlotId id : plotIds) {
if (block.id != 0 || !block.equals(unclaim)) { if (block.id != 0 || !block.equals(unclaim)) {
setWall(plotworld, id, new PlotBlock[]{block}); setWall(plotArea, id, new PlotBlock[]{block});
} }
} }
return true; return true;
} }
@Override @Override
public boolean startPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds) { public boolean startPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) {
return true; return true;
} }
@Override @Override
public boolean startPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds) { public boolean startPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds) {
return true; return true;
} }
@Override @Override
public boolean claimPlot(PlotArea plotworld, Plot plot) { public boolean claimPlot(PlotArea plotArea, Plot plot) {
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; PlotBlock claim = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
if (claim.id != 0 || !claim.equals(unclaim)) { if (claim.id != 0 || !claim.equals(unclaim)) {
setWall(plotworld, plot.getId(), new PlotBlock[]{claim}); setWall(plotArea, plot.getId(), new PlotBlock[]{claim});
} }
return true; return true;
} }
@Override @Override
public String[] getPlotComponents(PlotArea plotworld, PlotId plotid) { public String[] getPlotComponents(PlotArea plotArea, PlotId plotId) {
return new String[]{"main", "floor", "air", "all", "border", "wall", "outline", "middle"}; return new String[]{"main", "floor", "air", "all", "border", "wall", "outline", "middle"};
} }
@ -446,10 +447,10 @@ public class ClassicPlotManager extends SquarePlotManager {
* Remove sign for a plot. * Remove sign for a plot.
*/ */
@Override @Override
public Location getSignLoc(PlotArea plotworld, Plot plot) { public Location getSignLoc(PlotArea plotArea, Plot plot) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
plot = plot.getBasePlot(false); plot = plot.getBasePlot(false);
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
return new Location(plotworld.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2); return new Location(plotArea.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2);
} }
} }

View File

@ -5,9 +5,9 @@ import com.intellectualcrafters.plot.object.PlotId;
public abstract class GridPlotWorld extends PlotArea { public abstract class GridPlotWorld extends PlotArea {
public GridPlotWorld(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
super(worldname, id, generator, min, max);
}
public short SIZE; public short SIZE;
public GridPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
super(worldName, id, generator, min, max);
}
} }

View File

@ -27,10 +27,10 @@ import java.util.Map.Entry;
public class HybridPlotManager extends ClassicPlotManager { public class HybridPlotManager extends ClassicPlotManager {
@Override @Override
public void exportTemplate(PlotArea plotworld) throws IOException { public void exportTemplate(PlotArea plotArea) throws IOException {
HashSet<FileBytes> files = new HashSet<>( HashSet<FileBytes> files = new HashSet<>(
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotworld)))); Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotArea))));
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator; String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotArea.worldname + File.separator;
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator; String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
try { try {
File sideroad = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "sideroad.schematic"); File sideroad = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "sideroad.schematic");
@ -48,7 +48,7 @@ public class HybridPlotManager extends ClassicPlotManager {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
Template.zipAll(plotworld.worldname, files); Template.zipAll(plotArea.worldname, files);
} }
@Override @Override
@ -97,16 +97,16 @@ public class HybridPlotManager extends ClassicPlotManager {
} }
@Override @Override
public boolean createRoadSouth(PlotArea plotworld, Plot plot) { public boolean createRoadSouth(PlotArea plotArea, Plot plot) {
super.createRoadSouth(plotworld, plot); super.createRoadSouth(plotArea, plot);
HybridPlotWorld hpw = (HybridPlotWorld) plotworld; HybridPlotWorld hpw = (HybridPlotWorld) plotArea;
PlotId id = plot.getId(); PlotId id = plot.getId();
PlotId id2 = new PlotId(id.x, id.y + 1); PlotId id2 = new PlotId(id.x, id.y + 1);
Location bot = getPlotBottomLocAbs(hpw, id2); Location bot = getPlotBottomLocAbs(hpw, id2);
Location top = getPlotTopLocAbs(hpw, id); Location top = getPlotTopLocAbs(hpw, id);
Location pos1 = new Location(plotworld.worldname, bot.getX() - 1, 0, top.getZ() + 1); Location pos1 = new Location(plotArea.worldname, bot.getX() - 1, 0, top.getZ() + 1);
Location pos2 = new Location(plotworld.worldname, top.getX() + 1, 255, bot.getZ()); Location pos2 = new Location(plotArea.worldname, top.getX() + 1, 255, bot.getZ());
MainUtil.resetBiome(plotworld, pos1, pos2); MainUtil.resetBiome(plotArea, pos1, pos2);
if (!hpw.ROAD_SCHEMATIC_ENABLED) { if (!hpw.ROAD_SCHEMATIC_ENABLED) {
return true; return true;
} }
@ -115,9 +115,9 @@ public class HybridPlotManager extends ClassicPlotManager {
} }
@Override @Override
public boolean createRoadSouthEast(PlotArea plotworld, Plot plot) { public boolean createRoadSouthEast(PlotArea plotArea, Plot plot) {
super.createRoadSouthEast(plotworld, plot); super.createRoadSouthEast(plotArea, plot);
HybridPlotWorld hpw = (HybridPlotWorld) plotworld; HybridPlotWorld hpw = (HybridPlotWorld) plotArea;
PlotId id = plot.getId(); PlotId id = plot.getId();
PlotId id2 = new PlotId(id.x + 1, id.y + 1); PlotId id2 = new PlotId(id.x + 1, id.y + 1);
Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1); Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
@ -139,13 +139,13 @@ public class HybridPlotManager extends ClassicPlotManager {
* to have 512x512 sized plots. </p> * to have 512x512 sized plots. </p>
*/ */
@Override @Override
public boolean clearPlot(PlotArea plotworld, Plot plot, final Runnable whenDone) { public boolean clearPlot(PlotArea plotArea, Plot plot, final Runnable whenDone) {
final String world = plotworld.worldname; final String world = plotArea.worldname;
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld; final HybridPlotWorld dpw = (HybridPlotWorld) plotArea;
Location pos1 = plot.getBottomAbs(); Location pos1 = plot.getBottomAbs();
Location pos2 = plot.getExtendedTopAbs(); Location pos2 = plot.getExtendedTopAbs();
// If augmented // If augmented
final boolean canRegen = (plotworld.TYPE == 0) && (plotworld.TERRAIN == 0); final boolean canRegen = (plotArea.TYPE == 0) && (plotArea.TERRAIN == 0);
// The component blocks // The component blocks
final PlotBlock[] plotfloor = dpw.TOP_BLOCK; final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
final PlotBlock[] filling = dpw.MAIN_BLOCK; final PlotBlock[] filling = dpw.MAIN_BLOCK;
@ -197,10 +197,10 @@ public class HybridPlotManager extends ClassicPlotManager {
return true; return true;
} }
public void pastePlotSchematic(HybridPlotWorld plotworld, Location l1, Location l2) { public void pastePlotSchematic(HybridPlotWorld plotWorld, Location l1, Location l2) {
if (!plotworld.PLOT_SCHEMATIC) { if (!plotWorld.PLOT_SCHEMATIC) {
return; return;
} }
createSchemAbs(plotworld, l1, l2, false); createSchemAbs(plotWorld, l1, l2, false);
} }
} }

View File

@ -130,14 +130,14 @@ public abstract class HybridUtils {
if (whenDone == null) { if (whenDone == null) {
return; return;
} }
PlotArea plotworld = plot.getArea(); PlotArea plotArea = plot.getArea();
if (!(plotworld instanceof ClassicPlotWorld)) { if (!(plotArea instanceof ClassicPlotWorld)) {
whenDone.value = -1; whenDone.value = -1;
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
whenDone.value = 0; whenDone.value = 0;
final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld; final ClassicPlotWorld cpw = (ClassicPlotWorld) plotArea;
final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(plot.getRegions()); final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(plot.getRegions());
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
@ -339,13 +339,13 @@ public abstract class HybridUtils {
int z = chunk.z << 4; int z = chunk.z << 4;
int ex = x + 15; int ex = x + 15;
int ez = z + 15; int ez = z + 15;
HybridPlotWorld plotworld = (HybridPlotWorld) area; HybridPlotWorld plotWorld = (HybridPlotWorld) area;
extend = Math.min(extend, 255 - plotworld.ROAD_HEIGHT - plotworld.SCHEMATIC_HEIGHT); extend = Math.min(extend, 255 - plotWorld.ROAD_HEIGHT - plotWorld.SCHEMATIC_HEIGHT);
if (!plotworld.ROAD_SCHEMATIC_ENABLED) { if (!plotWorld.ROAD_SCHEMATIC_ENABLED) {
return false; return false;
} }
boolean toCheck = false; boolean toCheck = false;
if (plotworld.TYPE == 2) { if (plotWorld.TYPE == 2) {
boolean c1 = area.contains(x, z); boolean c1 = area.contains(x, z);
boolean c2 = area.contains(ex, ez); boolean c2 = area.contains(ex, ez);
if (!c1 && !c2) { if (!c1 && !c2) {
@ -355,10 +355,10 @@ public abstract class HybridUtils {
} }
} }
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
PlotId id1 = manager.getPlotId(plotworld, x, 0, z); PlotId id1 = manager.getPlotId(plotWorld, x, 0, z);
PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez); PlotId id2 = manager.getPlotId(plotWorld, ex, 0, ez);
x -= plotworld.ROAD_OFFSET_X; x -= plotWorld.ROAD_OFFSET_X;
z -= plotworld.ROAD_OFFSET_Z; z -= plotWorld.ROAD_OFFSET_Z;
if (id1 == null || id2 == null || id1 != id2) { if (id1 == null || id2 == null || id1 != id2) {
boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false); boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
if (result) { if (result) {
@ -374,7 +374,7 @@ public abstract class HybridUtils {
toCheck = true; toCheck = true;
} }
} }
int size = plotworld.SIZE; int size = plotWorld.SIZE;
for (int X = 0; X < 16; X++) { for (int X = 0; X < 16; X++) {
short absX = (short) ((x + X) % size); short absX = (short) ((x + X) % size);
for (int Z = 0; Z < 16; Z++) { for (int Z = 0; Z < 16; Z++) {
@ -387,24 +387,24 @@ public abstract class HybridUtils {
} }
boolean condition; boolean condition;
if (toCheck) { if (toCheck) {
condition = manager.getPlotId(plotworld, x + X + plotworld.ROAD_OFFSET_X, 1, z + Z + plotworld.ROAD_OFFSET_Z) == null; condition = manager.getPlotId(plotWorld, x + X + plotWorld.ROAD_OFFSET_X, 1, z + Z + plotWorld.ROAD_OFFSET_Z) == null;
// condition = MainUtil.isPlotRoad(new Location(plotworld.worldname, x + X, 1, z + Z)); // condition = MainUtil.isPlotRoad(new Location(plotworld.worldname, x + X, 1, z + Z));
} else { } else {
boolean gx = absX > plotworld.PATH_WIDTH_LOWER; boolean gx = absX > plotWorld.PATH_WIDTH_LOWER;
boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; boolean gz = absZ > plotWorld.PATH_WIDTH_LOWER;
boolean lx = absX < plotworld.PATH_WIDTH_UPPER; boolean lx = absX < plotWorld.PATH_WIDTH_UPPER;
boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; boolean lz = absZ < plotWorld.PATH_WIDTH_UPPER;
condition = !gx || !gz || !lx || !lz; condition = !gx || !gz || !lx || !lz;
} }
if (condition) { if (condition) {
HashMap<Integer, PlotBlock> blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ)); HashMap<Integer, PlotBlock> blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
for (short y = (short) plotworld.ROAD_HEIGHT; y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend; y++) { for (short y = (short) plotWorld.ROAD_HEIGHT; y <= plotWorld.ROAD_HEIGHT + plotWorld.SCHEMATIC_HEIGHT + extend; y++) {
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0); SetQueue.IMP.setBlock(area.worldname, x + X + plotWorld.ROAD_OFFSET_X, y, z + Z + plotWorld.ROAD_OFFSET_Z, 0);
} }
if (blocks != null) { if (blocks != null) {
for (Entry<Integer, PlotBlock> entry : blocks.entrySet()) { for (Entry<Integer, PlotBlock> entry : blocks.entrySet()) {
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, entry.getKey(), SetQueue.IMP.setBlock(area.worldname, x + X + plotWorld.ROAD_OFFSET_X, entry.getKey(),
z + Z + plotworld.ROAD_OFFSET_Z, entry.getValue()); z + Z + plotWorld.ROAD_OFFSET_Z, entry.getValue());
} }
} }
} }

View File

@ -13,7 +13,7 @@ public abstract class PlotGenerator<T> {
this.generator = generator; this.generator = generator;
} }
public abstract void initialize(PlotArea plotworld); public abstract void initialize(PlotArea plotArea);
/** /**
* TYPE = 2; * TYPE = 2;

View File

@ -19,7 +19,7 @@ import java.util.Iterator;
public abstract class SquarePlotManager extends GridPlotManager { public abstract class SquarePlotManager extends GridPlotManager {
@Override @Override
public boolean clearPlot(PlotArea plotworld, final Plot plot, final Runnable whenDone) { public boolean clearPlot(PlotArea plotArea, final Plot plot, final Runnable whenDone) {
final HashSet<RegionWrapper> regions = plot.getRegions(); final HashSet<RegionWrapper> regions = plot.getRegions();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
@ -41,18 +41,18 @@ public abstract class SquarePlotManager extends GridPlotManager {
} }
@Override @Override
public Location getPlotTopLocAbs(PlotArea plotworld, PlotId plotid) { public Location getPlotTopLocAbs(PlotArea plotArea, PlotId plotId) {
SquarePlotWorld dpw = (SquarePlotWorld) plotworld; SquarePlotWorld dpw = (SquarePlotWorld) plotArea;
int px = plotid.x; int px = plotId.x;
int pz = plotid.y; int pz = plotId.y;
int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1; int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1; int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
return new Location(plotworld.worldname, x, Math.min(plotworld.MAX_BUILD_HEIGHT, 255), z); return new Location(plotArea.worldname, x, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), z);
} }
@Override @Override
public PlotId getPlotIdAbs(PlotArea plotworld, int x, int y, int z) { public PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z) {
SquarePlotWorld dpw = (SquarePlotWorld) plotworld; SquarePlotWorld dpw = (SquarePlotWorld) plotArea;
if (dpw.ROAD_OFFSET_X != 0) { if (dpw.ROAD_OFFSET_X != 0) {
x -= dpw.ROAD_OFFSET_X; x -= dpw.ROAD_OFFSET_X;
} }
@ -97,10 +97,10 @@ public abstract class SquarePlotManager extends GridPlotManager {
} }
@Override @Override
public PlotId getPlotId(PlotArea plotworld, int x, int y, int z) { public PlotId getPlotId(PlotArea plotArea, int x, int y, int z) {
try { try {
SquarePlotWorld dpw = (SquarePlotWorld) plotworld; SquarePlotWorld dpw = (SquarePlotWorld) plotArea;
if (plotworld == null) { if (plotArea == null) {
return null; return null;
} }
x -= dpw.ROAD_OFFSET_X; x -= dpw.ROAD_OFFSET_X;
@ -144,7 +144,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
if (hash == 0) { if (hash == 0) {
return id; return id;
} }
Plot plot = plotworld.getOwnedPlotAbs(id); Plot plot = plotArea.getOwnedPlotAbs(id);
// Not merged, and standing on road // Not merged, and standing on road
if (plot == null) { if (plot == null) {
return null; return null;
@ -177,7 +177,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
} }
PS.debug("invalid location: " + Arrays.toString(merged)); PS.debug("invalid location: " + Arrays.toString(merged));
} catch (Exception ignored) { } catch (Exception ignored) {
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname); PS.debug("Invalid plot / road width in settings.yml for world: " + plotArea.worldname);
} }
return null; return null;
} }

View File

@ -85,12 +85,12 @@ public class PlotCluster {
return (1 + this.pos2.x - this.pos1.x) * (1 + this.pos2.y - this.pos1.y); return (1 + this.pos2.x - this.pos1.x) * (1 + this.pos2.y - this.pos1.y);
} }
public void setArea(PlotArea plotarea) { public void setArea(PlotArea plotArea) {
if (this.area != null) { if (this.area != null) {
this.area.removeCluster(this); this.area.removeCluster(this);
} }
this.area = plotarea; this.area = plotArea;
plotarea.addCluster(this); plotArea.addCluster(this);
} }
@Override @Override

View File

@ -13,63 +13,63 @@ public abstract class PlotManager {
* Plot locations (methods with Abs in them will not need to consider mega * Plot locations (methods with Abs in them will not need to consider mega
* plots). * plots).
*/ */
public abstract PlotId getPlotIdAbs(PlotArea plotworld, int x, int y, int z); public abstract PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z);
public abstract PlotId getPlotId(PlotArea plotworld, int x, int y, int z); public abstract PlotId getPlotId(PlotArea plotArea, int x, int y, int z);
// If you have a circular plot, just return the corner if it were a square // If you have a circular plot, just return the corner if it were a square
public abstract Location getPlotBottomLocAbs(PlotArea plotworld, PlotId plotid); public abstract Location getPlotBottomLocAbs(PlotArea plotArea, PlotId plotId);
// the same applies here // the same applies here
public abstract Location getPlotTopLocAbs(PlotArea plotworld, PlotId plotid); public abstract Location getPlotTopLocAbs(PlotArea plotArea, PlotId plotId);
/* /*
* Plot clearing (return false if you do not support some method) * Plot clearing (return false if you do not support some method)
*/ */
public abstract boolean clearPlot(PlotArea plotworld, Plot plot, Runnable whenDone); public abstract boolean clearPlot(PlotArea plotArea, Plot plot, Runnable whenDone);
public abstract boolean claimPlot(PlotArea plotworld, Plot plot); public abstract boolean claimPlot(PlotArea plotArea, Plot plot);
public abstract boolean unclaimPlot(PlotArea plotworld, Plot plot, Runnable whenDone); public abstract boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone);
public abstract Location getSignLoc(PlotArea plotworld, Plot plot); public abstract Location getSignLoc(PlotArea plotArea, Plot plot);
/* /*
* Plot set functions (return false if you do not support the specific set * Plot set functions (return false if you do not support the specific set
* method). * method).
*/ */
public abstract String[] getPlotComponents(PlotArea plotworld, PlotId plotid); public abstract String[] getPlotComponents(PlotArea plotArea, PlotId plotId);
public abstract boolean setComponent(PlotArea plotworld, PlotId plotid, String component, PlotBlock[] blocks); public abstract boolean setComponent(PlotArea plotArea, PlotId plotId, String component, PlotBlock[] blocks);
/* /*
* PLOT MERGING (return false if your generator does not support plot * PLOT MERGING (return false if your generator does not support plot
* merging). * merging).
*/ */
public abstract boolean createRoadEast(PlotArea plotworld, Plot plot); public abstract boolean createRoadEast(PlotArea plotArea, Plot plot);
public abstract boolean createRoadSouth(PlotArea plotworld, Plot plot); public abstract boolean createRoadSouth(PlotArea plotArea, Plot plot);
public abstract boolean createRoadSouthEast(PlotArea plotworld, Plot plot); public abstract boolean createRoadSouthEast(PlotArea plotArea, Plot plot);
public abstract boolean removeRoadEast(PlotArea plotworld, Plot plot); public abstract boolean removeRoadEast(PlotArea plotArea, Plot plot);
public abstract boolean removeRoadSouth(PlotArea plotworld, Plot plot); public abstract boolean removeRoadSouth(PlotArea plotArea, Plot plot);
public abstract boolean removeRoadSouthEast(PlotArea plotworld, Plot plot); public abstract boolean removeRoadSouthEast(PlotArea plotArea, Plot plot);
public abstract boolean startPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds); public abstract boolean startPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds);
public abstract boolean startPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds); public abstract boolean startPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds);
public abstract boolean finishPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds); public abstract boolean finishPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds);
public abstract boolean finishPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds); public abstract boolean finishPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds);
public void exportTemplate(PlotArea plotworld) throws IOException { public void exportTemplate(PlotArea plotArea) throws IOException {
HashSet<FileBytes> files = new HashSet<>( HashSet<FileBytes> files = new HashSet<>(
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotworld)))); Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotArea))));
Template.zipAll(plotworld.worldname, files); Template.zipAll(plotArea.worldname, files);
} }
} }

View File

@ -57,48 +57,48 @@ public abstract class EventUtil {
public abstract void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added); public abstract void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added);
public void doJoinTask(final PlotPlayer pp) { public void doJoinTask(final PlotPlayer player) {
if (ExpireManager.IMP != null) { if (ExpireManager.IMP != null) {
ExpireManager.IMP.handleJoin(pp); ExpireManager.IMP.handleJoin(player);
} }
if (PS.get().worldedit != null) { if (PS.get().worldedit != null) {
if (pp.getAttribute("worldedit")) { if (player.getAttribute("worldedit")) {
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED); MainUtil.sendMessage(player, C.WORLDEDIT_BYPASSED);
} }
} }
if (PS.get().update != null && Permissions.hasPermission(pp, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) { if (PS.get().update != null && Permissions.hasPermission(player, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
MainUtil.sendMessage(pp, "&6An update for PlotSquared is available: &7/plot update"); MainUtil.sendMessage(player, "&6An update for PlotSquared is available: &7/plot update");
} }
final Plot plot = pp.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (Settings.TELEPORT_ON_LOGIN && plot != null) { if (Settings.TELEPORT_ON_LOGIN && plot != null) {
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
plot.teleportPlayer(pp); plot.teleportPlayer(player);
} }
}); });
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD); MainUtil.sendMessage(player, C.TELEPORTED_TO_ROAD);
} }
} }
public void doRespawnTask(final PlotPlayer pp) { public void doRespawnTask(final PlotPlayer player) {
final Plot plot = pp.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (Settings.TELEPORT_ON_DEATH && plot != null) { if (Settings.TELEPORT_ON_DEATH && plot != null) {
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
plot.teleportPlayer(pp); plot.teleportPlayer(player);
} }
}); });
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD); MainUtil.sendMessage(player, C.TELEPORTED_TO_ROAD);
} }
} }
public boolean checkPlayerBlockEvent(PlotPlayer pp, PlayerBlockEventType type, Location loc, LazyBlock block, boolean notifyPerms) { public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type, Location location, LazyBlock block, boolean notifyPerms) {
PlotArea area = PS.get().getPlotAreaAbs(loc); PlotArea area = PS.get().getPlotAreaAbs(location);
Plot plot; Plot plot;
if (area != null) { if (area != null) {
plot = area.getPlot(loc); plot = area.getPlot(location);
} else { } else {
plot = null; plot = null;
} }
@ -106,7 +106,7 @@ public abstract class EventUtil {
if (area == null) { if (area == null) {
return true; return true;
} }
} else if (plot.isAdded(pp.getUUID())) { } else if (plot.isAdded(player.getUUID())) {
return true; return true;
} }
switch (type) { switch (type) {
@ -117,10 +117,10 @@ public abstract class EventUtil {
return true; return true;
case BREAK_BLOCK: case BREAK_BLOCK:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE); Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
if (use.isPresent()) { if (use.isPresent()) {
@ -136,54 +136,54 @@ public abstract class EventUtil {
return true; return true;
} }
} }
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_BREAK.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_BREAK.s()));
case BREAK_HANGING: case BREAK_HANGING:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (plot.getFlag(Flags.HANGING_BREAK).or(false)) { if (plot.getFlag(Flags.HANGING_BREAK).or(false)) {
return true; return true;
} }
if (plot.hasOwner()) { if (plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_HANGING_BREAK.s())); .sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_HANGING_BREAK.s()));
} }
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
case BREAK_MISC: case BREAK_MISC:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (plot.getFlag(Flags.MISC_BREAK).or(false)) { if (plot.getFlag(Flags.MISC_BREAK).or(false)) {
return true; return true;
} }
if (plot.hasOwner()) { if (plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_BREAK.s())); .sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_BREAK.s()));
} }
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
case BREAK_VEHICLE: case BREAK_VEHICLE:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (plot.getFlag(Flags.VEHICLE_BREAK).or(false)) { if (plot.getFlag(Flags.VEHICLE_BREAK).or(false)) {
return true; return true;
} }
if (plot.hasOwner()) { if (plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_BREAK.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_BREAK.s()));
} }
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
case INTERACT_BLOCK: { case INTERACT_BLOCK: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
Optional<HashSet<PlotBlock>> flagValue = plot.getFlag(Flags.USE); Optional<HashSet<PlotBlock>> flagValue = plot.getFlag(Flags.USE);
HashSet<PlotBlock> value; HashSet<PlotBlock> value;
@ -193,17 +193,17 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s())); .sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s()));
} }
return true; return true;
} }
case PLACE_BLOCK: { case PLACE_BLOCK: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
} }
Optional<HashSet<PlotBlock>> flagValue = plot.getFlag(Flags.PLACE); Optional<HashSet<PlotBlock>> flagValue = plot.getFlag(Flags.PLACE);
HashSet<PlotBlock> value; HashSet<PlotBlock> value;
@ -213,19 +213,19 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_PLACE.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_PLACE.s()));
} }
return true; return true;
} }
case TRIGGER_PHYSICAL: { case TRIGGER_PHYSICAL: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), false); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), false);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), false); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), false);
} }
if (plot.getFlag(Flags.DEVICE_INTERACT).or(false)) { if (plot.getFlag(Flags.DEVICE_INTERACT).or(false)) {
return true; return true;
@ -238,7 +238,7 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), false)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), false)) {
return true; return true;
} }
return false; return false;
@ -247,10 +247,10 @@ public abstract class EventUtil {
} }
case INTERACT_HANGING: { case INTERACT_HANGING: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (plot.getFlag(Flags.HOSTILE_INTERACT).or(false)) { if (plot.getFlag(Flags.HOSTILE_INTERACT).or(false)) {
return true; return true;
@ -263,19 +263,19 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_HANGING_INTERACT.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_HANGING_INTERACT.s()));
} }
return true; return true;
} }
case INTERACT_MISC: { case INTERACT_MISC: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (plot.getFlag(Flags.MISC_INTERACT).or(false)) { if (plot.getFlag(Flags.MISC_INTERACT).or(false)) {
return true; return true;
@ -288,19 +288,19 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_MISC_INTERACT.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_MISC_INTERACT.s()));
} }
return true; return true;
} }
case INTERACT_VEHICLE: { case INTERACT_VEHICLE: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (plot.getFlag(Flags.VEHICLE_USE).or(false)) { if (plot.getFlag(Flags.VEHICLE_USE).or(false)) {
return true; return true;
@ -313,19 +313,19 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_VEHICLE_USE.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_VEHICLE_USE.s()));
} }
return true; return true;
} }
case SPAWN_MOB: { case SPAWN_MOB: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (plot.getFlag(Flags.MOB_PLACE).or(false)) { if (plot.getFlag(Flags.MOB_PLACE).or(false)) {
return true; return true;
@ -338,10 +338,10 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + '/' + C.FLAG_PLACE.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + '/' + C.FLAG_PLACE.s()));
} }
return true; return true;
} }
@ -349,10 +349,10 @@ public abstract class EventUtil {
return true; return true;
case PLACE_MISC: { case PLACE_MISC: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (plot.getFlag(Flags.MISC_PLACE).or(false)) { if (plot.getFlag(Flags.MISC_PLACE).or(false)) {
return true; return true;
@ -365,20 +365,20 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + '/' + C.FLAG_PLACE.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + '/' + C.FLAG_PLACE.s()));
} }
return true; return true;
} }
case PLACE_VEHICLE: case PLACE_VEHICLE:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (plot.getFlag(Flags.VEHICLE_PLACE).or(false)) { if (plot.getFlag(Flags.VEHICLE_PLACE).or(false)) {
return true; return true;
@ -391,10 +391,10 @@ public abstract class EventUtil {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + '/' + C.FLAG_PLACE.s())); return !(!notifyPerms || MainUtil.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + '/' + C.FLAG_PLACE.s()));
} }
return true; return true;
default: default:

View File

@ -619,35 +619,35 @@ public class MainUtil {
/** /**
* Send a message to the player. * Send a message to the player.
* *
* @param plr Player to receive message * @param player the recipient of the message
* @param c Caption to send * @param caption the message to send
* *
* @return boolean success * @return boolean success
*/ */
public static boolean sendMessage(PlotPlayer plr, C c, String... args) { public static boolean sendMessage(PlotPlayer player, C caption, String... args) {
return sendMessage(plr, c, (Object[]) args); return sendMessage(player, caption, (Object[]) args);
} }
/** /**
* Send a message to the player * Send a message to the player
* *
* @param plr Player to receive message * @param player the recipient of the message
* @param c Caption to send * @param caption the message to send
* *
* @return boolean success * @return boolean success
*/ */
public static boolean sendMessage(final PlotPlayer plr, final C c, final Object... args) { public static boolean sendMessage(final PlotPlayer player, final C caption, final Object... args) {
if (c.s().isEmpty()) { if (caption.s().isEmpty()) {
return true; return true;
} }
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
String m = C.format(c, args); String m = C.format(caption, args);
if (plr == null) { if (player == null) {
PS.log(m); PS.log(m);
} else { } else {
plr.sendMessage(m); player.sendMessage(m);
} }
} }
}); });
@ -696,11 +696,11 @@ public class MainUtil {
public static Set<UUID> getUUIDsFromString(String list) { public static Set<UUID> getUUIDsFromString(String list) {
String[] split = list.split(","); String[] split = list.split(",");
HashSet<UUID> result = new HashSet<UUID>(); HashSet<UUID> result = new HashSet<>();
for (String name : split) { for (String name : split) {
if (name.length() == 0) { if (name.isEmpty()) {
// Invalid // Invalid
return null; return Collections.emptySet();
} }
if (name.equals("*")) { if (name.equals("*")) {
result.add(DBFunc.everyone); result.add(DBFunc.everyone);
@ -711,12 +711,12 @@ public class MainUtil {
result.add(UUID.fromString(name)); result.add(UUID.fromString(name));
continue; continue;
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
return null; return Collections.emptySet();
} }
} }
UUID uuid = UUIDHandler.getUUID(name, null); UUID uuid = UUIDHandler.getUUID(name, null);
if (uuid == null) { if (uuid == null) {
return null; return Collections.emptySet();
} }
result.add(uuid); result.add(uuid);
} }
@ -856,9 +856,9 @@ public class MainUtil {
} }
public static void getPersistentMeta(UUID uuid, final String key, final RunnableVal<byte[]> result) { public static void getPersistentMeta(UUID uuid, final String key, final RunnableVal<byte[]> result) {
PlotPlayer pp = UUIDHandler.getPlayer(uuid); PlotPlayer player = UUIDHandler.getPlayer(uuid);
if (pp != null) { if (player != null) {
result.run(pp.getPersistentMeta(key)); result.run(player.getPersistentMeta(key));
} else { } else {
DBFunc.dbManager.getPersistentMeta(uuid, new RunnableVal<Map<String, byte[]>>() { DBFunc.dbManager.getPersistentMeta(uuid, new RunnableVal<Map<String, byte[]>>() {
@Override @Override

View File

@ -17,26 +17,26 @@ public class Permissions {
/** /**
* Check if a player has a permission (C class helps keep track of permissions). * Check if a player has a permission (C class helps keep track of permissions).
* @param player * @param player
* @param c * @param caption
* @return * @return
*/ */
public static boolean hasPermission(PlotPlayer player, C c) { public static boolean hasPermission(PlotPlayer player, C caption) {
return hasPermission(player, c.s()); return hasPermission(player, caption.s());
} }
/** /**
* Check if a PlotPlayer has a permission * Check if a {@link PlotPlayer} has a permission.
* @param player * @param player
* @param perm * @param permission
* @return * @return
*/ */
public static boolean hasPermission(PlotPlayer player, String perm) { public static boolean hasPermission(PlotPlayer player, String permission) {
if (!Settings.PERMISSION_CACHING) { if (!Settings.PERMISSION_CACHING) {
return hasPermission((CommandCaller) player, perm); return hasPermission((CommandCaller) player, permission);
} }
HashMap<String, Boolean> map = player.getMeta("perm"); HashMap<String, Boolean> map = player.getMeta("perm");
if (map != null) { if (map != null) {
Boolean result = map.get(perm); Boolean result = map.get(permission);
if (result != null) { if (result != null) {
return result; return result;
} }
@ -44,19 +44,19 @@ public class Permissions {
map = new HashMap<>(); map = new HashMap<>();
player.setMeta("perm", map); player.setMeta("perm", map);
} }
boolean result = hasPermission((CommandCaller) player, perm); boolean result = hasPermission((CommandCaller) player, permission);
map.put(perm, result); map.put(permission, result);
return result; return result;
} }
/** /**
* Check if a CommandCaller (PlotPlayer implements CommandCaller) has a permission. * Check if a {@code CommandCaller} has a permission.
* @param player * @param caller
* @param permission * @param permission
* @return * @return
*/ */
public static boolean hasPermission(CommandCaller player, String permission) { public static boolean hasPermission(CommandCaller caller, String permission) {
if (player.hasPermission(permission) || player.hasPermission(C.PERMISSION_ADMIN.s())) { if (caller.hasPermission(permission) || caller.hasPermission(C.PERMISSION_ADMIN.s())) {
return true; return true;
} }
permission = permission.toLowerCase().replaceAll("^[^a-z|0-9|\\.|_|-]", ""); permission = permission.toLowerCase().replaceAll("^[^a-z|0-9|\\.|_|-]", "");
@ -65,7 +65,7 @@ public class Permissions {
for (int i = 0; i <= (nodes.length - 1); i++) { for (int i = 0; i <= (nodes.length - 1); i++) {
n.append(nodes[i] + "."); n.append(nodes[i] + ".");
if (!permission.equals(n + C.PERMISSION_STAR.s())) { if (!permission.equals(n + C.PERMISSION_STAR.s())) {
if (player.hasPermission(n + C.PERMISSION_STAR.s())) { if (caller.hasPermission(n + C.PERMISSION_STAR.s())) {
return true; return true;
} }
} }

View File

@ -1,11 +1,11 @@
package com.intellectualcrafters.plot.util; package com.intellectualcrafters.plot.util;
import java.util.HashMap;
import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.object.SetupObject;
import java.util.HashMap;
public abstract class SetupUtils { public abstract class SetupUtils {
public static SetupUtils manager; public static SetupUtils manager;
@ -14,7 +14,7 @@ public abstract class SetupUtils {
public abstract void updateGenerators(); public abstract void updateGenerators();
public abstract String getGenerator(final PlotArea plotworld); public abstract String getGenerator(final PlotArea plotArea);
public abstract String setupWorld(final SetupObject object); public abstract String setupWorld(final SetupObject object);
} }

View File

@ -28,11 +28,11 @@ public class SpongeSetupUtils extends SetupUtils {
} }
@Override @Override
public String getGenerator(final PlotArea plotworld) { public String getGenerator(final PlotArea plotArea) {
if (SetupUtils.generators.isEmpty()) { if (SetupUtils.generators.isEmpty()) {
updateGenerators(); updateGenerators();
} }
final World world = SpongeUtil.getWorld(plotworld.worldname); final World world = SpongeUtil.getWorld(plotArea.worldname);
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -50,11 +50,11 @@ public class SpongeSetupUtils extends SetupUtils {
} }
@Override @Override
public String getGenerator(PlotArea plotworld) { public String getGenerator(PlotArea plotArea) {
if (SetupUtils.generators.isEmpty()) { if (SetupUtils.generators.isEmpty()) {
updateGenerators(); updateGenerators();
} }
World world = SpongeUtil.getWorld(plotworld.worldname); World world = SpongeUtil.getWorld(plotArea.worldname);
if (world == null) { if (world == null) {
return null; return null;
} }