mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Beautify code
This commit is contained in:
parent
8e306a92e3
commit
da58c7b411
@ -28,6 +28,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -192,9 +193,9 @@ public class PlotAPI {
|
||||
@Deprecated
|
||||
public String[] getPermissions() {
|
||||
ArrayList<String> perms = new ArrayList<>();
|
||||
for (C c : C.values()) {
|
||||
if ("static.permissions".equals(c.getCategory())) {
|
||||
perms.add(c.s());
|
||||
for (C caption : C.values()) {
|
||||
if ("static.permissions".equals(caption.getCategory())) {
|
||||
perms.add(caption.s());
|
||||
}
|
||||
}
|
||||
return perms.toArray(new String[perms.size()]);
|
||||
@ -249,7 +250,7 @@ public class PlotAPI {
|
||||
*/
|
||||
public Set<PlotArea> getPlotAreas(World world) {
|
||||
if (world == null) {
|
||||
return new HashSet<>();
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return PS.get().getPlotAreas(world.getName());
|
||||
}
|
||||
@ -661,8 +662,8 @@ public class PlotAPI {
|
||||
*
|
||||
*/
|
||||
public int getAllowedPlots(Player player) {
|
||||
PlotPlayer pp = PlotPlayer.wrap(player);
|
||||
return pp.getAllowedPlots();
|
||||
PlotPlayer plotPlayer = PlotPlayer.wrap(player);
|
||||
return plotPlayer.getAllowedPlots();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,17 +42,17 @@ public abstract class APlotMeConnector {
|
||||
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
||||
}
|
||||
|
||||
public Location getPlotTopLocAbs(int path, int plot, PlotId plotid) {
|
||||
int px = plotid.x;
|
||||
int pz = plotid.y;
|
||||
public Location getPlotTopLocAbs(int path, int plot, PlotId plotId) {
|
||||
int px = plotId.x;
|
||||
int pz = plotId.y;
|
||||
int x = px * (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);
|
||||
}
|
||||
|
||||
public Location getPlotBottomLocAbs(int path, int plot, PlotId plotid) {
|
||||
int px = plotid.x;
|
||||
int pz = plotid.y;
|
||||
public Location getPlotBottomLocAbs(int path, int plot, PlotId plotId) {
|
||||
int px = plotId.x;
|
||||
int pz = plotId.y;
|
||||
int x = px * (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);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
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.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
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.ChunkUnloadEvent;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ChunkListener implements Listener {
|
||||
|
||||
@ -134,10 +134,7 @@ public class ChunkListener implements Listener {
|
||||
return true;
|
||||
}
|
||||
plot = new Location(world, x + 7, 1, z + 7).getOwnedPlotAbs();
|
||||
if (plot != null && plot.hasOwner()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return plot != null && plot.hasOwner();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -22,12 +23,12 @@ public class ForceFieldListener implements Listener {
|
||||
private Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
|
||||
Set<PlotPlayer> players = new HashSet<>();
|
||||
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
PlotPlayer pp;
|
||||
if (!(entity instanceof Player) || ((pp = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(pp.getCurrentPlot())) {
|
||||
PlotPlayer plotPlayer;
|
||||
if (!(entity instanceof Player) || ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
if (!plot.isAdded(pp.getUUID())) {
|
||||
players.add(pp);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
players.add(plotPlayer);
|
||||
}
|
||||
}
|
||||
return players;
|
||||
@ -38,22 +39,22 @@ public class ForceFieldListener implements Listener {
|
||||
if (!(entity instanceof Player)) {
|
||||
continue;
|
||||
}
|
||||
PlotPlayer pp;
|
||||
if ((pp = BukkitUtil.getPlayer((Player) entity)) == null) {
|
||||
PlotPlayer plotPlayer;
|
||||
if ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) {
|
||||
continue;
|
||||
}
|
||||
if (!plot.equals(pp.getCurrentPlot())) {
|
||||
if (!plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID())) {
|
||||
return pp;
|
||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
||||
return plotPlayer;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Vector calculateVelocity(PlotPlayer pp, PlotPlayer e) {
|
||||
Location playerLocation = pp.getLocationFull();
|
||||
private Vector calculateVelocity(PlotPlayer player, PlotPlayer e) {
|
||||
Location playerLocation = player.getLocationFull();
|
||||
Location oPlayerLocation = e.getLocation();
|
||||
double playerX = playerLocation.getX();
|
||||
double playerY = playerLocation.getY();
|
||||
@ -85,25 +86,25 @@ public class ForceFieldListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlotEntry(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
Plot plot = plotPlayer.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
Optional<Boolean> forcefield = plot.getFlag(Flags.FORCEFIELD);
|
||||
if (forcefield.isPresent() && forcefield.get()) {
|
||||
UUID uuid = pp.getUUID();
|
||||
UUID uuid = plotPlayer.getUUID();
|
||||
if (plot.isAdded(uuid)) {
|
||||
Set<PlotPlayer> players = getNearbyPlayers(player, plot);
|
||||
for (PlotPlayer oPlayer : players) {
|
||||
((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(pp, oPlayer));
|
||||
((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer));
|
||||
}
|
||||
} else {
|
||||
PlotPlayer oPlayer = hasNearbyPermitted(player, plot);
|
||||
if (oPlayer == null) {
|
||||
return;
|
||||
}
|
||||
player.setVelocity(calculateVelocity(oPlayer, pp));
|
||||
player.setVelocity(calculateVelocity(oPlayer, plotPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@ -609,44 +610,44 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void blockDestroy(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlotAbs(loc);
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
if (plot != null) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (event.getBlock().getY() == 0) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if (!plot.isAdded(pp.getUUID())) {
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
||||
Block block = event.getBlock();
|
||||
if (destroy.isPresent() && destroy.get()
|
||||
.contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
|
||||
return;
|
||||
}
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
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);
|
||||
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey(Flags.DONE)) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -822,19 +823,19 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(pp.getUUID())) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
||||
Block block = event.getBlock();
|
||||
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;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -842,8 +843,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -2169,70 +2170,70 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
player = null;
|
||||
}
|
||||
if (player != null) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
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;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
|
||||
return false;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
|
||||
return false;
|
||||
}
|
||||
} 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
|
||||
.isAdded(pp.getUUID()))) {
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
return false;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
return false;
|
||||
}
|
||||
} else if (victim instanceof Player) {
|
||||
if (plot != null) {
|
||||
if (Flags.PVP.isFalse(plot) && !Permissions.hasPermission(pp, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
|
||||
if (Flags.PVP.isFalse(plot) && !Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
|
||||
return false;
|
||||
}
|
||||
} else if (victim instanceof Creature) { // victim is animal
|
||||
if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot
|
||||
.isAdded(pp.getUUID()))) {
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
return false;
|
||||
}
|
||||
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
|
||||
return true;
|
||||
} 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;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2249,22 +2250,22 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlot(l);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
|
||||
event.setHatching(false);
|
||||
}
|
||||
} else if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned");
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned");
|
||||
event.setHatching(false);
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
|
||||
} else if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
|
||||
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
|
||||
event.setHatching(false);
|
||||
}
|
||||
}
|
||||
@ -2272,14 +2273,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void blockCreate(BlockPlaceEvent event) {
|
||||
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlotAbs(loc);
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
if (plot != null) {
|
||||
if (!plot.hasOwner()) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
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)) {
|
||||
event.setCancelled(true);
|
||||
MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
|
||||
|
@ -18,23 +18,23 @@ public class PlayerEvents183 implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBigBoom(BlockExplodeEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
String world = loc.getWorld();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
String world = location.getWorld();
|
||||
if (!PS.get().hasPlotArea(world)) {
|
||||
return;
|
||||
}
|
||||
PlotArea area = loc.getPlotArea();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
loc = BukkitUtil.getLocation(iterator.next().getLocation());
|
||||
if (loc.getPlotArea() != null) {
|
||||
location = BukkitUtil.getLocation(iterator.next().getLocation());
|
||||
if (location.getPlotArea() != null) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(loc);
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot == null || !plot.getFlag(Flags.EXPLOSION).or(false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -61,12 +61,12 @@ public class EntityWrapper {
|
||||
public EntityWrapper(Entity entity, short depth) {
|
||||
this.hash = entity.getEntityId();
|
||||
this.depth = depth;
|
||||
Location loc = entity.getLocation();
|
||||
this.yaw = loc.getYaw();
|
||||
this.pitch = loc.getPitch();
|
||||
this.x = loc.getX();
|
||||
this.y = loc.getY();
|
||||
this.z = loc.getZ();
|
||||
Location location = entity.getLocation();
|
||||
this.yaw = location.getYaw();
|
||||
this.pitch = location.getPitch();
|
||||
this.x = location.getX();
|
||||
this.y = location.getY();
|
||||
this.z = location.getZ();
|
||||
this.type = entity.getType();
|
||||
if (depth == 0) {
|
||||
return;
|
||||
@ -376,10 +376,10 @@ public class EntityWrapper {
|
||||
this.lived.persistent = lived.getRemoveWhenFarAway();
|
||||
this.lived.leashed = lived.isLeashed();
|
||||
if (this.lived.leashed) {
|
||||
Location loc = lived.getLeashHolder().getLocation();
|
||||
this.lived.leash_x = (short) (this.x - loc.getBlockX());
|
||||
this.lived.leash_y = (short) (this.y - loc.getBlockY());
|
||||
this.lived.leash_z = (short) (this.z - loc.getBlockZ());
|
||||
Location location = lived.getLeashHolder().getLocation();
|
||||
this.lived.leash_x = (short) (this.x - location.getBlockX());
|
||||
this.lived.leash_y = (short) (this.y - location.getBlockY());
|
||||
this.lived.leash_z = (short) (this.z - location.getBlockZ());
|
||||
}
|
||||
EntityEquipment equipment = lived.getEquipment();
|
||||
this.lived.equipped = equipment != null;
|
||||
@ -435,27 +435,27 @@ public class EntityWrapper {
|
||||
}
|
||||
|
||||
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);
|
||||
loc.setYaw(this.yaw);
|
||||
loc.setPitch(this.pitch);
|
||||
Location location = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
|
||||
location.setYaw(this.yaw);
|
||||
location.setPitch(this.pitch);
|
||||
if (!this.type.isSpawnable()) {
|
||||
return null;
|
||||
}
|
||||
Entity entity;
|
||||
switch (this.type) {
|
||||
case DROPPED_ITEM:
|
||||
return world.dropItem(loc, this.stack);
|
||||
return world.dropItem(location, this.stack);
|
||||
case PLAYER:
|
||||
case LEASH_HITCH:
|
||||
return null;
|
||||
case ITEM_FRAME:
|
||||
entity = world.spawn(loc, ItemFrame.class);
|
||||
entity = world.spawn(location, ItemFrame.class);
|
||||
break;
|
||||
case PAINTING:
|
||||
entity = world.spawn(loc, Painting.class);
|
||||
entity = world.spawn(location, Painting.class);
|
||||
break;
|
||||
default:
|
||||
entity = world.spawnEntity(loc, this.type);
|
||||
entity = world.spawnEntity(location, this.type);
|
||||
break;
|
||||
}
|
||||
if (this.depth == 0) {
|
||||
|
@ -376,8 +376,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
int tz = pos2.getZ();
|
||||
for (Entity entity : entities) {
|
||||
if (!(entity instanceof Player)) {
|
||||
org.bukkit.Location loc = entity.getLocation();
|
||||
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
|
||||
org.bukkit.Location location = entity.getLocation();
|
||||
if (location.getX() >= bx && location.getX() <= tx && location.getZ() >= bz && location.getZ() <= tz) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
@ -472,15 +472,15 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
int[] count = new int[6];
|
||||
if (doWhole) {
|
||||
for (Entity entity : entities) {
|
||||
org.bukkit.Location loc = entity.getLocation();
|
||||
Chunk chunk = loc.getChunk();
|
||||
org.bukkit.Location location = entity.getLocation();
|
||||
Chunk chunk = location.getChunk();
|
||||
if (chunks.contains(chunk)) {
|
||||
int X = chunk.getX();
|
||||
int Z = chunk.getZ();
|
||||
if (X > bx && X < tx && Z > bz && Z < tz) {
|
||||
count(count, entity);
|
||||
} else {
|
||||
Plot other = area.getPlot(BukkitUtil.getLocation(loc));
|
||||
Plot other = area.getPlot(BukkitUtil.getLocation(location));
|
||||
if (plot.equals(other)) {
|
||||
count(count, entity);
|
||||
}
|
||||
|
@ -179,11 +179,11 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(PlotArea plotworld) {
|
||||
public String getGenerator(PlotArea plotArea) {
|
||||
if (SetupUtils.generators.isEmpty()) {
|
||||
updateGenerators();
|
||||
}
|
||||
World world = Bukkit.getWorld(plotworld.worldname);
|
||||
World world = Bukkit.getWorld(plotArea.worldname);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
private static Player lastPlayer = null;
|
||||
private static PlotPlayer lastPlotPlayer = null;
|
||||
|
||||
public static void removePlayer(String plr) {
|
||||
public static void removePlayer(String player) {
|
||||
lastPlayer = null;
|
||||
lastPlotPlayer = null;
|
||||
}
|
||||
@ -62,9 +62,9 @@ public class BukkitUtil extends WorldUtil {
|
||||
return lastPlotPlayer;
|
||||
}
|
||||
String name = player.getName();
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(name);
|
||||
if (pp != null) {
|
||||
return pp;
|
||||
PlotPlayer plotPlayer = UUIDHandler.getPlayer(name);
|
||||
if (plotPlayer != null) {
|
||||
return plotPlayer;
|
||||
}
|
||||
lastPlotPlayer = new BukkitPlayer(player);
|
||||
UUIDHandler.getPlayers().put(name, lastPlotPlayer);
|
||||
@ -102,15 +102,15 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
public static Location getLocation(Entity entity) {
|
||||
org.bukkit.Location loc = entity.getLocation();
|
||||
String world = loc.getWorld().getName();
|
||||
return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
org.bukkit.Location location = entity.getLocation();
|
||||
String world = location.getWorld().getName();
|
||||
return new Location(world, location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
public static Location getLocationFull(Entity entity) {
|
||||
org.bukkit.Location loc = entity.getLocation();
|
||||
return new Location(loc.getWorld().getName(), MathMan.roundInt(loc.getX()), MathMan.roundInt(loc.getY()), MathMan.roundInt(loc.getZ()),
|
||||
loc.getYaw(), loc.getPitch());
|
||||
org.bukkit.Location location = entity.getLocation();
|
||||
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()),
|
||||
location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -158,8 +158,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSpawn(PlotPlayer pp) {
|
||||
return getLocation(((BukkitPlayer) pp).player.getBedSpawnLocation());
|
||||
public Location getSpawn(PlotPlayer player) {
|
||||
return getLocation(((BukkitPlayer) player).player.getBedSpawnLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,9 +190,9 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeFromString(String biomeStr) {
|
||||
public int getBiomeFromString(String biomeString) {
|
||||
try {
|
||||
Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
||||
Biome biome = Biome.valueOf(biomeString.toUpperCase());
|
||||
return Arrays.asList(Biome.values()).indexOf(biome);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return -1;
|
||||
@ -300,9 +300,9 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomes(String worldName, RegionWrapper region, String biomeStr) {
|
||||
public void setBiomes(String worldName, RegionWrapper region, String biomeString) {
|
||||
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 z = region.minZ; z <= region.maxZ; z++) {
|
||||
world.setBiome(x, z, biome);
|
||||
|
@ -86,23 +86,23 @@ public class SendChunk {
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer pp = entry.getValue();
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
Location loc = null;
|
||||
Location location = null;
|
||||
String world;
|
||||
if (plot != null) {
|
||||
world = plot.getArea().worldname;
|
||||
} else {
|
||||
loc = pp.getLocation();
|
||||
world = loc.getWorld();
|
||||
location = pp.getLocation();
|
||||
world = location.getWorld();
|
||||
}
|
||||
ArrayList<Chunk> list = map.get(world);
|
||||
if (list == null) {
|
||||
continue;
|
||||
}
|
||||
if (loc == null) {
|
||||
loc = pp.getLocation();
|
||||
if (location == null) {
|
||||
location = pp.getLocation();
|
||||
}
|
||||
int cx = loc.getX() >> 4;
|
||||
int cz = loc.getZ() >> 4;
|
||||
int cx = location.getX() >> 4;
|
||||
int cz = location.getZ() >> 4;
|
||||
Player player = ((BukkitPlayer) pp).player;
|
||||
Object entity = this.methodGetHandlePlayer.of(player).call();
|
||||
|
||||
|
@ -280,7 +280,6 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = bc.getChunkWrapper();
|
||||
String worldName = wrapper.world;
|
||||
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
|
||||
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
|
||||
if (x != 0 && z != 0) {
|
||||
@ -288,7 +287,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
while (!other.isLoaded()) {
|
||||
other.load(true);
|
||||
}
|
||||
ChunkManager.manager.loadChunk(worldName, new ChunkLoc(x, z), true);
|
||||
ChunkManager.manager.loadChunk(wrapper.world, new ChunkLoc(x, z), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
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(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
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();
|
||||
int size = plot.getTrusted().size() + plot.getMembers().size();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -21,31 +21,31 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Alias extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, Plot plot, String alias) {
|
||||
public boolean set(PlotPlayer player, Plot plot, String alias) {
|
||||
if (alias.isEmpty()) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
if (alias.length() >= 50) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG);
|
||||
MainUtil.sendMessage(player, C.ALIAS_TOO_LONG);
|
||||
return false;
|
||||
}
|
||||
if (alias.contains(" ") || !StringMan.isAsciiPrintable(alias)) {
|
||||
C.NOT_VALID_VALUE.send(plr);
|
||||
C.NOT_VALID_VALUE.send(player);
|
||||
return false;
|
||||
}
|
||||
for (Plot p : PS.get().getPlots(plot.getArea())) {
|
||||
if (p.getAlias().equalsIgnoreCase(alias)) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -51,23 +51,23 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
PlotArea plotarea = plr.getApplicablePlotArea();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
PlotArea plotarea = player.getApplicablePlotArea();
|
||||
if (plotarea == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
int size_x = 1;
|
||||
int size_z = 1;
|
||||
String schematic = null;
|
||||
if (args.length > 0) {
|
||||
if (Permissions.hasPermission(plr, "plots.auto.mega")) {
|
||||
if (Permissions.hasPermission(player, "plots.auto.mega")) {
|
||||
try {
|
||||
String[] split = args[0].split(",|;");
|
||||
size_x = Integer.parseInt(split[0]);
|
||||
size_z = Integer.parseInt(split[1]);
|
||||
if (size_x < 1 || size_z < 1) {
|
||||
MainUtil.sendMessage(plr, "&cError: size<=0");
|
||||
MainUtil.sendMessage(player, "&cError: size<=0");
|
||||
}
|
||||
if (args.length > 1) {
|
||||
schematic = args[1];
|
||||
@ -87,31 +87,31 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname);
|
||||
int diff = currentPlots - plr.getAllowedPlots();
|
||||
int currentPlots = Settings.GLOBAL_LIMIT ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
|
||||
int diff = currentPlots - player.getAllowedPlots();
|
||||
if (diff + size_x * size_z > 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;
|
||||
} else if (plr.hasPersistentMeta("grantedPlots")) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||
} else if (player.hasPersistentMeta("grantedPlots")) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||
if (grantedPlots - diff < size_x * size_z) {
|
||||
plr.removePersistentMeta("grantedPlots");
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
player.removePersistentMeta("grantedPlots");
|
||||
return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
} else {
|
||||
int left = grantedPlots - diff - size_x * size_z;
|
||||
if (left == 0) {
|
||||
plr.removePersistentMeta("grantedPlots");
|
||||
player.removePersistentMeta("grantedPlots");
|
||||
} 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 {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -119,21 +119,21 @@ public class Auto extends SubCommand {
|
||||
double cost = plotarea.PRICES.get("claim");
|
||||
cost = (size_x * size_z) * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
return true;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
EconHandler.manager.withdrawMoney(player, cost);
|
||||
sendMessage(player, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
if (schematic != null && !schematic.isEmpty()) {
|
||||
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) {
|
||||
MainUtil.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
if (!Permissions.hasPermission(player, "plots.claim." + schematic) && !Permissions.hasPermission(player, "plots.admin.command.schematic")) {
|
||||
MainUtil.sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -149,14 +149,14 @@ public class Auto extends SubCommand {
|
||||
for (int i = 0; i <= max; i++) {
|
||||
PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
Plot current = plotarea.getPlotAbs(currentId);
|
||||
if (current.canClaim(plr)) {
|
||||
current.claim(plr, true, null);
|
||||
if (current.canClaim(player)) {
|
||||
current.claim(player, true, null);
|
||||
return true;
|
||||
}
|
||||
id = getNextPlotId(id, 1);
|
||||
}
|
||||
// no free plots
|
||||
MainUtil.sendMessage(plr, C.NO_FREE_PLOTS);
|
||||
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
@ -164,12 +164,12 @@ public class Auto extends SubCommand {
|
||||
PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
||||
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 j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
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) {
|
||||
|
@ -17,40 +17,40 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
requiredType = RequiredType.NONE)
|
||||
public class BO3 extends SubCommand {
|
||||
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
|
||||
public void noArgs(PlotPlayer player) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
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")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.bo3")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
noArgs(plr);
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "output":
|
||||
case "save":
|
||||
case "export":
|
||||
return BO3Handler.saveBO3(plr, plot);
|
||||
return BO3Handler.saveBO3(player, plot);
|
||||
case "paste":
|
||||
case "load":
|
||||
case "import":
|
||||
case "input":
|
||||
// TODO NOT IMPLEMENTED YET
|
||||
MainUtil.sendMessage(plr, "NOT IMPLEMENTED YET!!!");
|
||||
MainUtil.sendMessage(player, "NOT IMPLEMENTED YET!!!");
|
||||
return false;
|
||||
default:
|
||||
noArgs(plr);
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,16 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Biome extends SetCommand {
|
||||
|
||||
@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);
|
||||
if (biome == -1) {
|
||||
String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), C.BLOCK_LIST_SEPARATER.s());
|
||||
C.NEED_BIOME.send(plr);
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes);
|
||||
C.NEED_BIOME.send(player);
|
||||
MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
@ -36,7 +36,7 @@ public class Biome extends SetCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + value.toLowerCase());
|
||||
MainUtil.sendMessage(player, C.BIOME_SET_TO.s() + value.toLowerCase());
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -20,61 +20,61 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
String schematic = "";
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
}
|
||||
Location loc = plr.getLocation();
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
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;
|
||||
if (currentPlots >= plr.getAllowedPlots()) {
|
||||
if (plr.hasPersistentMeta("grantedPlots")) {
|
||||
grants = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||
if (currentPlots >= player.getAllowedPlots()) {
|
||||
if (player.hasPersistentMeta("grantedPlots")) {
|
||||
grants = ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||
if (grants <= 0) {
|
||||
plr.removePersistentMeta("grantedPlots");
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
player.removePersistentMeta("grantedPlots");
|
||||
return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
} else {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
}
|
||||
if (!plot.canClaim(plr)) {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
if (!plot.canClaim(player)) {
|
||||
return sendMessage(player, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
PlotArea world = plot.getArea();
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
double cost = world.PRICES.get("claim");
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
EconHandler.manager.withdrawMoney(player, cost);
|
||||
sendMessage(player, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
if (grants > 0) {
|
||||
if (grants == 1) {
|
||||
plr.removePersistentMeta("grantedPlots");
|
||||
player.removePersistentMeta("grantedPlots");
|
||||
} 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 (world.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
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")) {
|
||||
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
if (!Permissions.hasPermission(player, "plots.claim." + schematic) && !Permissions.hasPermission(player, "plots.admin.command.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);
|
||||
}
|
||||
}
|
||||
|
@ -30,74 +30,74 @@ import java.util.UUID;
|
||||
public class Cluster extends SubCommand {
|
||||
|
||||
@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
|
||||
if (args.length == 0) {
|
||||
// return arguments
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_AVAILABLE_ARGS);
|
||||
return false;
|
||||
}
|
||||
String sub = args[0].toLowerCase();
|
||||
switch (sub) {
|
||||
case "l":
|
||||
case "list": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.list")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.list");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.list")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.list");
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list");
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster list");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
// Ignore unmanaged clusters
|
||||
String name = "'" + cluster.getName() + "' : " + cluster.toString();
|
||||
if (plr.getUUID().equals(cluster.owner)) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name);
|
||||
} else if (cluster.helpers.contains(plr.getUUID())) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name);
|
||||
} else if (cluster.invited.contains(plr.getUUID())) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name);
|
||||
if (player.getUUID().equals(cluster.owner)) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&a" + name);
|
||||
} else if (cluster.helpers.contains(player.getUUID())) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&3" + name);
|
||||
} else if (cluster.invited.contains(player.getUUID())) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&9" + name);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString());
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, cluster.toString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "c":
|
||||
case "create": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.create")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.create")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.create");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = PlotId.fromString(args[2]);
|
||||
PlotId pos2 = PlotId.fromString(args[3]);
|
||||
if (pos1 == null || pos2 == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
// check if name is taken
|
||||
String name = args[1];
|
||||
if (area.getCluster(name) != null) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
if (pos2.x < pos1.x || pos2.y < pos1.y) {
|
||||
@ -108,33 +108,33 @@ public class Cluster extends SubCommand {
|
||||
//check if overlap
|
||||
PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2);
|
||||
if (cluster != null) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, cluster.getName());
|
||||
MainUtil.sendMessage(player, C.CLUSTER_INTERSECTION, cluster.getName());
|
||||
return false;
|
||||
}
|
||||
// Check if it occupies existing plots
|
||||
Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
if (!plots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.create.other")) {
|
||||
UUID uuid = plr.getUUID();
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.create.other")) {
|
||||
UUID uuid = player.getUUID();
|
||||
for (Plot plot : plots) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check allowed cluster size
|
||||
cluster = new PlotCluster(area, pos1, pos2, plr.getUUID());
|
||||
cluster = new PlotCluster(area, pos1, pos2, player.getUUID());
|
||||
int current;
|
||||
if (Settings.GLOBAL_LIMIT) {
|
||||
current = plr.getPlayerClusterCount();
|
||||
current = player.getPlayerClusterCount();
|
||||
} 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) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
case "disband":
|
||||
case "del":
|
||||
case "delete": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.delete")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.delete")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.delete");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
PlotCluster cluster;
|
||||
if (args.length == 2) {
|
||||
cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
cluster = area.getCluster(plr.getLocation());
|
||||
cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!cluster.owner.equals(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.delete.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other");
|
||||
if (!cluster.owner.equals(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.delete.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.delete.other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DBFunc.delete(cluster);
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_DELETED);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_DELETED);
|
||||
return true;
|
||||
}
|
||||
case "res":
|
||||
case "resize": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = PlotId.fromString(args[1]);
|
||||
PlotId pos2 = PlotId.fromString(args[2]);
|
||||
if (pos1 == null || pos2 == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
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));
|
||||
}
|
||||
// check if in cluster
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
PlotCluster cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other");
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//check if overlap
|
||||
PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2);
|
||||
if (intersect != null) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, intersect.getName());
|
||||
MainUtil.sendMessage(player, C.CLUSTER_INTERSECTION, intersect.getName());
|
||||
return false;
|
||||
}
|
||||
HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||
@ -243,116 +243,116 @@ public class Cluster extends SubCommand {
|
||||
removed.removeAll(newPlots);
|
||||
// Check expand / shrink
|
||||
if (!removed.isEmpty()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize.shrink")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.shrink");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize.shrink")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.shrink");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
newPlots.removeAll(existing);
|
||||
if (!newPlots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize.expand")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.expand");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize.expand")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.expand");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check allowed cluster size
|
||||
int current;
|
||||
if (Settings.GLOBAL_LIMIT) {
|
||||
current = plr.getPlayerClusterCount();
|
||||
current = player.getPlayerClusterCount();
|
||||
} 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);
|
||||
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) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
// resize cluster
|
||||
DBFunc.resizeCluster(cluster, pos1, pos2);
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_RESIZED);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_RESIZED);
|
||||
return true;
|
||||
}
|
||||
case "add":
|
||||
case "inv":
|
||||
case "invite": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.invite")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.invite")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.invite");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// check if in cluster
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
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) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.invite.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other");
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.invite.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.invite.other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// check uuid
|
||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]);
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[2]);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
// add the user if not added
|
||||
cluster.invited.add(uuid);
|
||||
DBFunc.setInvited(cluster, uuid);
|
||||
PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_INVITED, cluster.getName());
|
||||
PlotPlayer player2 = UUIDHandler.getPlayer(uuid);
|
||||
if (player2 != null) {
|
||||
MainUtil.sendMessage(player2, C.CLUSTER_INVITED, cluster.getName());
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_ADDED_USER);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_ADDED_USER);
|
||||
return true;
|
||||
}
|
||||
case "k":
|
||||
case "remove":
|
||||
case "kick": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.kick")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.kick")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.kick");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
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) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.kick.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other");
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.kick.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.kick.other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// check uuid
|
||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[1]);
|
||||
return false;
|
||||
}
|
||||
// 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)) {
|
||||
MainUtil.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName());
|
||||
if (uuid.equals(player.getUUID()) || uuid.equals(cluster.owner) || !cluster.isAdded(uuid)) {
|
||||
MainUtil.sendMessage(player, C.CANNOT_KICK_PLAYER, cluster.getName());
|
||||
return false;
|
||||
}
|
||||
if (cluster.helpers.contains(uuid)) {
|
||||
@ -361,54 +361,54 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
cluster.invited.remove(uuid);
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
|
||||
PlotPlayer player2 = UUIDHandler.getPlayer(uuid);
|
||||
if (player2 != null) {
|
||||
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();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
plot.unclaim();
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_KICKED_USER);
|
||||
MainUtil.sendMessage(player2, C.CLUSTER_KICKED_USER);
|
||||
return true;
|
||||
}
|
||||
case "quit":
|
||||
case "leave": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.leave")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.leave")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.leave");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster;
|
||||
if (args.length == 2) {
|
||||
cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
cluster = area.getCluster(plr.getLocation());
|
||||
cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
UUID uuid = plr.getUUID();
|
||||
UUID uuid = player.getUUID();
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
if (uuid.equals(cluster.owner)) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_CANNOT_LEAVE);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_CANNOT_LEAVE);
|
||||
return false;
|
||||
}
|
||||
if (cluster.helpers.contains(uuid)) {
|
||||
@ -417,11 +417,11 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
cluster.invited.remove(uuid);
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
||||
for (Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
|
||||
for (Plot plot : new ArrayList<>(PS.get().getPlots(player.getLocation().getWorld(), uuid))) {
|
||||
PlotCluster current = plot.getCluster();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
plr.getLocation().getWorld();
|
||||
player.getLocation().getWorld();
|
||||
plot.unclaim();
|
||||
}
|
||||
}
|
||||
@ -430,99 +430,99 @@ public class Cluster extends SubCommand {
|
||||
case "admin":
|
||||
case "helper":
|
||||
case "helpers": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.helpers")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.helpers");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.helpers")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.helpers");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
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) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
UUID uuid = UUIDHandler.getUUID(args[2], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]);
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[2]);
|
||||
return false;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("add")) {
|
||||
cluster.helpers.add(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")) {
|
||||
cluster.helpers.remove(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;
|
||||
}
|
||||
case "spawn":
|
||||
case "home":
|
||||
case "tp": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.tp")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.tp")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.tp");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
UUID uuid = plr.getUUID();
|
||||
UUID uuid = player.getUUID();
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.tp.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.tp.other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
plr.teleport(cluster.getHome());
|
||||
return MainUtil.sendMessage(plr, C.CLUSTER_TELEPORTING);
|
||||
player.teleport(cluster.getHome());
|
||||
return MainUtil.sendMessage(player, C.CLUSTER_TELEPORTING);
|
||||
}
|
||||
case "i":
|
||||
case "info":
|
||||
case "show":
|
||||
case "information": {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.info")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.info")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.info");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster;
|
||||
if (args.length == 2) {
|
||||
cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
cluster = area.getCluster(plr.getLocation());
|
||||
cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -533,50 +533,50 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
String name = cluster.getName();
|
||||
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();
|
||||
message = message.replaceAll("%id%", id);
|
||||
message = message.replaceAll("%owner%", owner);
|
||||
message = message.replaceAll("%name%", name);
|
||||
message = message.replaceAll("%size%", size);
|
||||
message = message.replaceAll("%rights%", rights);
|
||||
MainUtil.sendMessage(plr, message);
|
||||
MainUtil.sendMessage(player, message);
|
||||
return true;
|
||||
}
|
||||
case "sh":
|
||||
case "setspawn":
|
||||
case "sethome":
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.sethome")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.sethome")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
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) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.sethome.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other");
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.sethome.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.sethome.other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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());
|
||||
cluster.settings.setPosition(blockloc);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -29,28 +29,28 @@ public class Condense extends SubCommand {
|
||||
public static boolean TASK = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
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;
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
|
||||
MainUtil.sendMessage(plr, "INVALID AREA");
|
||||
MainUtil.sendMessage(player, "INVALID AREA");
|
||||
return false;
|
||||
}
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "start": {
|
||||
if (args.length == 2) {
|
||||
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " start <radius>");
|
||||
MainUtil.sendMessage(player, "/plot condense " + area.toString() + " start <radius>");
|
||||
return false;
|
||||
}
|
||||
if (Condense.TASK) {
|
||||
MainUtil.sendMessage(plr, "TASK ALREADY STARTED");
|
||||
MainUtil.sendMessage(player, "TASK ALREADY STARTED");
|
||||
return false;
|
||||
}
|
||||
if (!MathMan.isInteger(args[2])) {
|
||||
MainUtil.sendMessage(plr, "INVALID RADIUS");
|
||||
MainUtil.sendMessage(player, "INVALID RADIUS");
|
||||
return false;
|
||||
}
|
||||
int radius = Integer.parseInt(args[2]);
|
||||
@ -93,7 +93,7 @@ public class Condense extends SubCommand {
|
||||
int size = allPlots.size();
|
||||
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
|
||||
if (radius < minimumRadius) {
|
||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||
MainUtil.sendMessage(player, "RADIUS TOO SMALL");
|
||||
return false;
|
||||
}
|
||||
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
|
||||
@ -107,19 +107,19 @@ public class Condense extends SubCommand {
|
||||
start = Auto.getNextPlotId(start, 1);
|
||||
}
|
||||
if (free.isEmpty() || toMove.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, "NO FREE PLOTS FOUND");
|
||||
MainUtil.sendMessage(player, "NO FREE PLOTS FOUND");
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "TASK STARTED...");
|
||||
MainUtil.sendMessage(player, "TASK STARTED...");
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Condense.TASK) {
|
||||
MainUtil.sendMessage(plr, "TASK CANCELLED.");
|
||||
MainUtil.sendMessage(player, "TASK CANCELLED.");
|
||||
}
|
||||
if (allPlots.isEmpty()) {
|
||||
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;
|
||||
}
|
||||
final Runnable task = this;
|
||||
@ -137,7 +137,7 @@ public class Condense extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
if (result.get()) {
|
||||
MainUtil.sendMessage(plr, "Moving: " + origin + " -> " + possible);
|
||||
MainUtil.sendMessage(player, "Moving: " + origin + " -> " + possible);
|
||||
TaskManager.runTaskLater(task, 1);
|
||||
}
|
||||
}
|
||||
@ -148,11 +148,11 @@ public class Condense extends SubCommand {
|
||||
}
|
||||
if (free.isEmpty()) {
|
||||
Condense.TASK = false;
|
||||
MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
|
||||
MainUtil.sendMessage(player, "TASK FAILED. NO FREE PLOTS FOUND!");
|
||||
return;
|
||||
}
|
||||
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":
|
||||
if (!Condense.TASK) {
|
||||
MainUtil.sendMessage(plr, "TASK ALREADY STOPPED");
|
||||
MainUtil.sendMessage(player, "TASK ALREADY STOPPED");
|
||||
return false;
|
||||
}
|
||||
Condense.TASK = false;
|
||||
MainUtil.sendMessage(plr, "TASK STOPPED");
|
||||
MainUtil.sendMessage(player, "TASK STOPPED");
|
||||
return true;
|
||||
case "info":
|
||||
if (args.length == 2) {
|
||||
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " info <radius>");
|
||||
MainUtil.sendMessage(player, "/plot condense " + area.toString() + " info <radius>");
|
||||
return false;
|
||||
}
|
||||
if (!MathMan.isInteger(args[2])) {
|
||||
MainUtil.sendMessage(plr, "INVALID RADIUS");
|
||||
MainUtil.sendMessage(player, "INVALID RADIUS");
|
||||
return false;
|
||||
}
|
||||
int radius = Integer.parseInt(args[2]);
|
||||
@ -182,22 +182,22 @@ public class Condense extends SubCommand {
|
||||
int size = plots.size();
|
||||
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
|
||||
if (radius < minimumRadius) {
|
||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||
MainUtil.sendMessage(player, "RADIUS TOO SMALL");
|
||||
return false;
|
||||
}
|
||||
int maxMove = getPlots(plots, minimumRadius).size();
|
||||
int userMove = getPlots(plots, radius).size();
|
||||
MainUtil.sendMessage(plr, "=== DEFAULT EVAL ===");
|
||||
MainUtil.sendMessage(plr, "MINIMUM RADIUS: " + minimumRadius);
|
||||
MainUtil.sendMessage(plr, "MAXIMUM MOVES: " + maxMove);
|
||||
MainUtil.sendMessage(plr, "=== INPUT EVAL ===");
|
||||
MainUtil.sendMessage(plr, "INPUT RADIUS: " + radius);
|
||||
MainUtil.sendMessage(plr, "ESTIMATED MOVES: " + userMove);
|
||||
MainUtil.sendMessage(plr, "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, "=== DEFAULT EVAL ===");
|
||||
MainUtil.sendMessage(player, "MINIMUM RADIUS: " + minimumRadius);
|
||||
MainUtil.sendMessage(player, "MAXIMUM MOVES: " + maxMove);
|
||||
MainUtil.sendMessage(player, "=== INPUT EVAL ===");
|
||||
MainUtil.sendMessage(player, "INPUT RADIUS: " + radius);
|
||||
MainUtil.sendMessage(player, "ESTIMATED MOVES: " + userMove);
|
||||
MainUtil.sendMessage(player, "ESTIMATED TIME: No idea, times will drastically change based on the system performance and load");
|
||||
MainUtil.sendMessage(player, "&e - Radius is measured in plot width");
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -15,15 +15,15 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Confirm extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
CmdInstance command = CmdConfirm.getPending(plr);
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
CmdInstance command = CmdConfirm.getPending(player);
|
||||
if (command == null) {
|
||||
MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
|
||||
MainUtil.sendMessage(player, C.FAILED_CONFIRM);
|
||||
return false;
|
||||
}
|
||||
CmdConfirm.removePending(plr);
|
||||
CmdConfirm.removePending(player);
|
||||
if ((System.currentTimeMillis() - command.timestamp) > 20000) {
|
||||
MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
|
||||
MainUtil.sendMessage(player, C.FAILED_CONFIRM);
|
||||
return false;
|
||||
}
|
||||
TaskManager.runTask(command.command);
|
||||
|
@ -18,30 +18,30 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Continue extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Plot plot = player.getCurrentPlot();
|
||||
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")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.continue")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (!plot.hasFlag(Flags.DONE)) {
|
||||
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
||||
MainUtil.sendMessage(player, C.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
int size = plot.getConnectedPlots().size();
|
||||
if (Settings.DONE_COUNTS_TOWARDS_LIMIT && (plr.getAllowedPlots() < plr.getPlotCount() + size)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.continue");
|
||||
if (Settings.DONE_COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots() < player.getPlotCount() + size)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command.continue");
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.removeFlag(Flags.DONE);
|
||||
MainUtil.sendMessage(plr, C.DONE_REMOVED);
|
||||
MainUtil.sendMessage(player, C.DONE_REMOVED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,42 +19,42 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Copy extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
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())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot1.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
|
||||
if (plot2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getArea().isCompatible(plot2.getArea())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
return false;
|
||||
}
|
||||
if (plot1.copy(plot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.COPY_SUCCESS);
|
||||
MainUtil.sendMessage(player, C.COPY_SUCCESS);
|
||||
}
|
||||
})) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.REQUIRES_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Debug extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (C c : C.values()) {
|
||||
msg.append(c.s()).append("\n");
|
||||
for (C caption : C.values()) {
|
||||
msg.append(caption.s()).append("\n");
|
||||
}
|
||||
MainUtil.sendMessage(plr, msg.toString());
|
||||
MainUtil.sendMessage(player, msg.toString());
|
||||
return true;
|
||||
}
|
||||
StringBuilder information = new StringBuilder();
|
||||
@ -35,7 +35,7 @@ public class Debug extends SubCommand {
|
||||
information.append(getSection(section, "Messages"));
|
||||
information.append(getLine(line, "Total Messages", C.values().length));
|
||||
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
||||
MainUtil.sendMessage(plr, information.toString());
|
||||
MainUtil.sendMessage(player, information.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -19,14 +20,14 @@ public class DebugAllowUnsafe extends SubCommand {
|
||||
public static final List<UUID> unsafeAllowed = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
|
||||
if (unsafeAllowed.contains(plr.getUUID())) {
|
||||
unsafeAllowed.remove(plr.getUUID());
|
||||
sendMessage(plr, C.DEBUGALLOWUNSAFE_OFF);
|
||||
if (unsafeAllowed.contains(player.getUUID())) {
|
||||
unsafeAllowed.remove(player.getUUID());
|
||||
sendMessage(player, C.DEBUGALLOWUNSAFE_OFF);
|
||||
} else {
|
||||
unsafeAllowed.add(plr.getUUID());
|
||||
sendMessage(plr, C.DEBUGALLOWUNSAFE_ON);
|
||||
unsafeAllowed.add(player.getUUID());
|
||||
sendMessage(player, C.DEBUGALLOWUNSAFE_ON);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
||||
public class DebugClaimTest extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length < 3) {
|
||||
return !MainUtil
|
||||
.sendMessage(
|
||||
@ -42,7 +42,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
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;
|
||||
}
|
||||
PlotId min, max;
|
||||
@ -52,18 +52,18 @@ public class DebugClaimTest extends SubCommand {
|
||||
min = PlotId.fromString(args[1]);
|
||||
max = PlotId.fromString(args[2]);
|
||||
} 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 "
|
||||
+ "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(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: &7Beginning sign to plot conversion. This may take a while...");
|
||||
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();
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
Plot plot = area.getPlotAbs(id);
|
||||
if (plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.getId());
|
||||
MainUtil.sendMessage(player, " - &cDB Already contains: " + plot.getId());
|
||||
continue;
|
||||
}
|
||||
Location loc = manager.getSignLoc(area, plot);
|
||||
@ -91,29 +91,29 @@ public class DebugClaimTest extends SubCommand {
|
||||
uuid = UUIDHandler.getUUID(line, null);
|
||||
}
|
||||
if (uuid != null) {
|
||||
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.getId() + " : " + line);
|
||||
MainUtil.sendMessage(player, " - &aFound plot: " + plot.getId() + " : " + line);
|
||||
plot.setOwner(uuid);
|
||||
plots.add(plot);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
||||
MainUtil.sendMessage(player, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, "&6Database update finished!");
|
||||
MainUtil.sendMessage(player, "&6Database update finished!");
|
||||
}
|
||||
});
|
||||
for (Plot plot : plots) {
|
||||
plot.create();
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||
} 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;
|
||||
}
|
||||
|
@ -30,13 +30,13 @@ public class DebugFixFlags extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
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;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
||||
MainUtil.sendMessage(player, "&8--- &6Starting task &8 ---");
|
||||
for (Plot plot : area.getPlots()) {
|
||||
HashMap<Flag<?>, Object> flags = plot.getFlags();
|
||||
Iterator<Entry<Flag<?>, Object>> i = flags.entrySet().iterator();
|
||||
@ -51,7 +51,7 @@ public class DebugFixFlags extends SubCommand {
|
||||
DBFunc.setFlags(plot, plot.getFlags());
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&aDone!");
|
||||
MainUtil.sendMessage(player, "&aDone!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class DebugLoadTest extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
PS.get().plots_tmp = DBFunc.getPlots();
|
||||
return true;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
||||
public class DebugPaste extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -31,7 +31,7 @@ public class DebugPaste extends SubCommand {
|
||||
try {
|
||||
latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log"));
|
||||
} 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 :(";
|
||||
}
|
||||
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");
|
||||
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ public class DebugRoadRegen extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
PlotArea plotworld = loc.getPlotArea();
|
||||
if (!(plotworld instanceof HybridPlotWorld)) {
|
||||
PlotArea plotArea = loc.getPlotArea();
|
||||
if (!(plotArea instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
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,
|
||||
"&6Regenerating chunk: " + chunk.x + ',' + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed"));
|
||||
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
|
||||
} else {
|
||||
HybridPlotManager manager = (HybridPlotManager) plotworld.getPlotManager();
|
||||
manager.createRoadEast(plotworld, plot);
|
||||
manager.createRoadSouth(plotworld, plot);
|
||||
manager.createRoadSouthEast(plotworld, plot);
|
||||
HybridPlotManager manager = (HybridPlotManager) plotArea.getPlotManager();
|
||||
manager.createRoadEast(plotArea, plot);
|
||||
manager.createRoadSouth(plotArea, plot);
|
||||
manager.createRoadSouthEast(plotArea, plot);
|
||||
MainUtil.sendMessage(player, "&6Regenerating plot south/east roads: " + plot.getId() + "\n&6 - Result: &aSuccess");
|
||||
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
|
||||
}
|
||||
|
@ -19,14 +19,14 @@ import java.util.ArrayList;
|
||||
public class DebugSaveTest extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||
plots.addAll(PS.get().getPlots());
|
||||
MainUtil.sendMessage(plr, "&6Starting `DEBUGSAVETEST`");
|
||||
MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`");
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, "&6Database sync finished!");
|
||||
MainUtil.sendMessage(player, "&6Database sync finished!");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -24,26 +24,26 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Delete extends SubCommand {
|
||||
|
||||
@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();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
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")) {
|
||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.delete")) {
|
||||
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();
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return;
|
||||
}
|
||||
final long start = System.currentTimeMillis();
|
||||
@ -51,25 +51,25 @@ public class Delete extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
|
||||
double value = plotworld.PRICES.get("sell") * plots.size();
|
||||
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
|
||||
double value = plotArea.PRICES.get("sell") * plots.size();
|
||||
if (value > 0d) {
|
||||
EconHandler.manager.depositMoney(plr, value);
|
||||
sendMessage(plr, C.ADDED_BALANCE, String.valueOf(value));
|
||||
EconHandler.manager.depositMoney(player, 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) {
|
||||
plot.addRunning();
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, getCommandString() + ' ' + plot.getId(), run);
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, getCommandString() + ' ' + plot.getId(), run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "deny",
|
||||
aliases = {"d", "ban"},
|
||||
@ -30,74 +31,74 @@ public class Deny extends SubCommand {
|
||||
}
|
||||
|
||||
@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();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.deny")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.deny")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
if (uuids == null || uuids.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
if (uuids.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
Iterator<UUID> iter = uuids.iterator();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(plr, "plots.deny.everyone") || Permissions.hasPermission(plr, "plots.admin.command.deny"))) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, "plots.deny.everyone") || Permissions.hasPermission(player, "plots.admin.command.deny"))) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
continue;
|
||||
}
|
||||
if (plot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
MainUtil.sendMessage(player, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
plot.removeMember(uuid);
|
||||
plot.removeTrusted(uuid);
|
||||
plot.addDenied(uuid);
|
||||
EventUtil.manager.callDenied(plr, plot, uuid, true);
|
||||
EventUtil.manager.callDenied(player, plot, uuid, true);
|
||||
if (!uuid.equals(DBFunc.everyone)) {
|
||||
handleKick(UUIDHandler.getPlayer(uuid), plot);
|
||||
} else {
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
handleKick(pp, plot);
|
||||
for (PlotPlayer plotPlayer : plot.getPlayersInPlot()) {
|
||||
handleKick(plotPlayer, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!uuids.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.DENIED_ADDED);
|
||||
MainUtil.sendMessage(player, C.DENIED_ADDED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleKick(PlotPlayer pp, Plot plot) {
|
||||
if (pp == null) {
|
||||
private void handleKick(PlotPlayer player, Plot plot) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if (!plot.equals(pp.getCurrentPlot())) {
|
||||
if (!plot.equals(player.getCurrentPlot())) {
|
||||
return;
|
||||
}
|
||||
if (pp.hasPermission("plots.admin.entry.denied")) {
|
||||
if (player.hasPermission("plots.admin.entry.denied")) {
|
||||
return;
|
||||
}
|
||||
if (pp.getGameMode() == PlotGameMode.SPECTATOR) {
|
||||
pp.stopSpectating();
|
||||
if (player.getGameMode() == PlotGameMode.SPECTATOR) {
|
||||
player.stopSpectating();
|
||||
}
|
||||
pp.teleport(WorldUtil.IMP.getSpawn(pp.getLocation().getWorld()));
|
||||
MainUtil.sendMessage(pp, C.YOU_GOT_DENIED);
|
||||
player.teleport(WorldUtil.IMP.getSpawn(player.getLocation().getWorld()));
|
||||
MainUtil.sendMessage(player, C.YOU_GOT_DENIED);
|
||||
}
|
||||
}
|
||||
|
@ -19,18 +19,18 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Desc extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, Plot plot, String desc) {
|
||||
public boolean set(PlotPlayer player, Plot plot, String desc) {
|
||||
if (desc.isEmpty()) {
|
||||
plot.removeFlag(Flags.DESCRIPTION);
|
||||
MainUtil.sendMessage(plr, C.DESC_UNSET);
|
||||
MainUtil.sendMessage(player, C.DESC_UNSET);
|
||||
return true;
|
||||
}
|
||||
boolean result = FlagManager.addPlotFlag(plot, Flags.DESCRIPTION, desc);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.DESC_SET);
|
||||
MainUtil.sendMessage(player, C.DESC_SET);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -22,26 +22,26 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Done extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
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")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.done")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.hasFlag(Flags.DONE)) {
|
||||
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
||||
MainUtil.sendMessage(player, C.DONE_ALREADY_DONE);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK);
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK);
|
||||
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
|
||||
@Override
|
||||
public void run(PlotAnalysis value) {
|
||||
@ -49,9 +49,9 @@ public class Done extends SubCommand {
|
||||
if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) {
|
||||
long flagValue = System.currentTimeMillis() / 1000;
|
||||
plot.setFlag(Flags.DONE,flagValue);
|
||||
MainUtil.sendMessage(plr, C.DONE_SUCCESS);
|
||||
MainUtil.sendMessage(player, C.DONE_SUCCESS);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.DONE_INSUFFICIENT_COMPLEXITY);
|
||||
MainUtil.sendMessage(player, C.DONE_INSUFFICIENT_COMPLEXITY);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -28,30 +28,30 @@ import java.net.URL;
|
||||
public class Download extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
String world = plr.getLocation().getWorld();
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
String world = player.getLocation().getWorld();
|
||||
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) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if ((Settings.DOWNLOAD_REQUIRES_DONE && (!plot.getFlag(Flags.DONE).isPresent())) && !Permissions
|
||||
.hasPermission(plr, "plots.admin.command.download")) {
|
||||
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
||||
.hasPermission(player, "plots.admin.command.download")) {
|
||||
MainUtil.sendMessage(player, C.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID()))) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if ((!plot.isOwner(player.getUUID()))) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0 || (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
|
||||
@ -64,20 +64,20 @@ public class Download extends SubCommand {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
MainUtil.sendMessage(player, url.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "bo3", "bo2", "b03", "b02")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.download.bo3")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.download.bo3");
|
||||
if (!Permissions.hasPermission(player, "plots.download.bo3")) {
|
||||
C.NO_PERMISSION.send(player, "plots.download.bo3");
|
||||
}
|
||||
if (plot.getVolume() > 128d * 128d * 256) {
|
||||
C.SCHEMATIC_TOO_LARGE.send(plr);
|
||||
C.SCHEMATIC_TOO_LARGE.send(player);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
@ -86,34 +86,34 @@ public class Download extends SubCommand {
|
||||
public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
MainUtil.sendMessage(player, url.toString());
|
||||
}
|
||||
});
|
||||
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.download.world")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.download.world");
|
||||
if (!Permissions.hasPermission(player, "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();
|
||||
WorldUtil.IMP.upload(plot, null, null, new RunnableVal<URL>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
MainUtil.sendMessage(player, url.toString());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK);
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -20,21 +21,21 @@ import java.util.UUID;
|
||||
public class Grant extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
final String arg0 = args[0].toLowerCase();
|
||||
switch (arg0) {
|
||||
case "add":
|
||||
case "check":
|
||||
if (Permissions.hasPermission(plr, "plots.grant." + arg0)) {
|
||||
C.NO_PERMISSION.send(plr, "plots.grant." + arg0);
|
||||
if (Permissions.hasPermission(player, "plots.grant." + arg0)) {
|
||||
C.NO_PERMISSION.send(player, "plots.grant." + arg0);
|
||||
return false;
|
||||
}
|
||||
if (args.length > 2) {
|
||||
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) {
|
||||
C.INVALID_PLAYER.send(plr, args[1]);
|
||||
C.INVALID_PLAYER.send(player, args[1]);
|
||||
return false;
|
||||
}
|
||||
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
|
||||
@ -42,7 +43,7 @@ public class Grant extends SubCommand {
|
||||
public void run(byte[] array) {
|
||||
if (arg0.equals("check")) { // check
|
||||
int granted = array == null ? 0 : ByteArrayUtilities.bytesToInteger(array);
|
||||
C.GRANTED_PLOTS.send(plr, granted);
|
||||
C.GRANTED_PLOTS.send(player, granted);
|
||||
} else { // add
|
||||
int amount = 1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array));
|
||||
boolean replace = array != null;
|
||||
@ -52,7 +53,7 @@ public class Grant extends SubCommand {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -29,19 +30,19 @@ public class Kick extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location location = plr.getLocation();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlot();
|
||||
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")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions.hasPermission(player, "plots.admin.command.kick")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
if (uuids == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
if (uuids.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
Set<PlotPlayer> players = new HashSet<>();
|
||||
@ -55,33 +56,33 @@ public class Kick extends SubCommand {
|
||||
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()) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
for (PlotPlayer player : players) {
|
||||
Location location2 = player.getLocation();
|
||||
if (!plr.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
for (PlotPlayer player2 : players) {
|
||||
Location location2 = player2.getLocation();
|
||||
if (!player2.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
||||
MainUtil.sendMessage(player2, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
if (player.hasPermission("plots.admin.entry.denied")) {
|
||||
C.CANNOT_KICK_PLAYER.send(plr, player.getName());
|
||||
if (player2.hasPermission("plots.admin.entry.denied")) {
|
||||
C.CANNOT_KICK_PLAYER.send(player2, player2.getName());
|
||||
return false;
|
||||
}
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||
C.YOU_GOT_KICKED.send(player);
|
||||
C.YOU_GOT_KICKED.send(player2);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(player);
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(player2);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// 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 {
|
||||
player.teleport(newSpawn);
|
||||
player2.teleport(newSpawn);
|
||||
}
|
||||
} else {
|
||||
player.teleport(spawn);
|
||||
player2.teleport(spawn);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -83,14 +83,14 @@ public class ListCmd extends SubCommand {
|
||||
return args.toArray(new String[args.size()]);
|
||||
}
|
||||
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr)));
|
||||
public void noArgs(PlotPlayer player) {
|
||||
MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(player)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
noArgs(plr);
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
int page = 0;
|
||||
@ -108,70 +108,70 @@ public class ListCmd extends SubCommand {
|
||||
|
||||
List<Plot> plots = null;
|
||||
|
||||
String world = plr.getLocation().getWorld();
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
String world = player.getLocation().getWorld();
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
String arg = args[0].toLowerCase();
|
||||
boolean sort = true;
|
||||
switch (arg) {
|
||||
case "mine":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.mine")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
|
||||
if (!Permissions.hasPermission(player, "plots.list.mine")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.mine");
|
||||
return false;
|
||||
}
|
||||
sort = false;
|
||||
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(plr));
|
||||
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(player));
|
||||
break;
|
||||
case "shared":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.shared")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared");
|
||||
if (!Permissions.hasPermission(player, "plots.list.shared")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.shared");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "world":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||
if (!Permissions.hasPermission(player, "plots.list.world")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world");
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world." + world)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world);
|
||||
if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + world);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots(world));
|
||||
break;
|
||||
case "expired":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.expired")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.expired");
|
||||
if (!Permissions.hasPermission(player, "plots.list.expired")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.expired");
|
||||
return false;
|
||||
}
|
||||
plots = ExpireManager.IMP == null ? new ArrayList<Plot>() : new ArrayList<>(ExpireManager.IMP.getPendingExpired());
|
||||
break;
|
||||
case "area":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.area")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.area");
|
||||
if (!Permissions.hasPermission(player, "plots.list.area")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.area");
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world." + world)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world);
|
||||
if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + world);
|
||||
return false;
|
||||
}
|
||||
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
|
||||
break;
|
||||
case "all":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.all")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all");
|
||||
if (!Permissions.hasPermission(player, "plots.list.all")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.all");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots());
|
||||
break;
|
||||
case "done":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.done")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.done");
|
||||
if (!Permissions.hasPermission(player, "plots.list.done")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.done");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -199,8 +199,8 @@ public class ListCmd extends SubCommand {
|
||||
sort = false;
|
||||
break;
|
||||
case "top":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.top")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top");
|
||||
if (!Permissions.hasPermission(player, "plots.list.top")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.top");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots());
|
||||
@ -236,8 +236,8 @@ public class ListCmd extends SubCommand {
|
||||
sort = false;
|
||||
break;
|
||||
case "forsale":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.forsale")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
||||
if (!Permissions.hasPermission(player, "plots.list.forsale")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.forsale");
|
||||
return false;
|
||||
}
|
||||
if (EconHandler.manager == null) {
|
||||
@ -252,8 +252,8 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "unowned":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.unowned")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned");
|
||||
if (!Permissions.hasPermission(player, "plots.list.unowned")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.unowned");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -264,8 +264,8 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "unknown":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.unknown")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown");
|
||||
if (!Permissions.hasPermission(player, "plots.list.unknown")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.unknown");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -279,12 +279,12 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "fuzzy":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.fuzzy")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.fuzzy");
|
||||
if (!Permissions.hasPermission(player, "plots.list.fuzzy")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.fuzzy");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
String term;
|
||||
@ -298,12 +298,12 @@ public class ListCmd extends SubCommand {
|
||||
break;
|
||||
default:
|
||||
if (PS.get().hasPlotArea(args[0])) {
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||
if (!Permissions.hasPermission(player, "plots.list.world")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world");
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world." + args[0])) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]);
|
||||
if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + args[0]);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots(args[0]));
|
||||
@ -316,8 +316,8 @@ public class ListCmd extends SubCommand {
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
if (uuid != null) {
|
||||
if (!Permissions.hasPermission(plr, "plots.list.player")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player");
|
||||
if (!Permissions.hasPermission(player, "plots.list.player")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.player");
|
||||
return false;
|
||||
}
|
||||
sort = false;
|
||||
@ -327,15 +327,15 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (plots.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
displayPlots(plr, plots, 12, page, area, args, sort);
|
||||
displayPlots(player, plots, 12, page, area, args, sort);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,40 +29,40 @@ import java.util.List;
|
||||
public class Load extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
String world = plr.getLocation().getWorld();
|
||||
String world = player.getLocation().getWorld();
|
||||
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) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.load")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.load")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length != 0) {
|
||||
if (args.length == 1) {
|
||||
List<String> schematics = plr.getMeta("plot_schematics");
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
if (schematics == null) {
|
||||
// No schematics found:
|
||||
MainUtil.sendMessage(plr, C.LOAD_NULL);
|
||||
MainUtil.sendMessage(player, C.LOAD_NULL);
|
||||
return false;
|
||||
}
|
||||
String schematic;
|
||||
@ -70,26 +70,26 @@ public class Load extends SubCommand {
|
||||
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
} catch (NumberFormatException ignored) {
|
||||
// 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;
|
||||
}
|
||||
final URL url;
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||
MainUtil.sendMessage(player, C.LOAD_FAILED);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
MainUtil.sendMessage(player, C.GENERATING_COMPONENT);
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Schematic schematic = SchematicHandler.manager.getSchematic(url);
|
||||
if (schematic == null) {
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
plot.removeRunning();
|
||||
if (value) {
|
||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
sendMessage(plr, C.SCHEMATIC_PASTE_FAILED);
|
||||
sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -108,30 +108,30 @@ public class Load extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot load <index>");
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot load <index>");
|
||||
return false;
|
||||
}
|
||||
|
||||
// list schematics
|
||||
|
||||
List<String> schematics = plr.getMeta("plot_schematics");
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
if (schematics == null) {
|
||||
plot.addRunning();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> schematics = SchematicHandler.manager.getSaves(plr.getUUID());
|
||||
List<String> schematics = SchematicHandler.manager.getSaves(player.getUUID());
|
||||
plot.removeRunning();
|
||||
if ((schematics == null) || schematics.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||
MainUtil.sendMessage(player, C.LOAD_FAILED);
|
||||
return;
|
||||
}
|
||||
plr.setMeta("plot_schematics", schematics);
|
||||
displaySaves(plr);
|
||||
player.setMeta("plot_schematics", schematics);
|
||||
displaySaves(player);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
displaySaves(plr);
|
||||
displaySaves(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -51,40 +51,40 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocationFull();
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocationFull();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
UUID uuid = plr.getUUID();
|
||||
UUID uuid = player.getUUID();
|
||||
if (!plot.isOwner(uuid)) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.merge")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!Permissions.hasPermission(player, "plots.admin.command.merge")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
} else {
|
||||
uuid = plot.owner;
|
||||
}
|
||||
}
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
final double price = plotworld.PRICES.containsKey("merge") ? plotworld.PRICES.get("merge") : 0;
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(plr) < price) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
final PlotArea plotArea = plot.getArea();
|
||||
final double price = plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : 0;
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(player) < price) {
|
||||
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + (size + 1));
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.merge." + (size + 1));
|
||||
return false;
|
||||
}
|
||||
int direction = -1;
|
||||
if (args.length == 0) {
|
||||
switch (direction(plr.getLocationFull().getYaw())) {
|
||||
switch (direction(player.getLocationFull().getYaw())) {
|
||||
case "NORTH":
|
||||
direction = 0;
|
||||
break;
|
||||
@ -105,14 +105,14 @@ public class Merge extends SubCommand {
|
||||
terrain = "true".equalsIgnoreCase(args[1]);
|
||||
}
|
||||
if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(player, price);
|
||||
sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
MainUtil.sendMessage(player, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
|
||||
}
|
||||
@ -124,8 +124,8 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (direction == -1) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + "> [removeroads]");
|
||||
MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + "> [removeroads]");
|
||||
MainUtil.sendMessage(player, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
|
||||
return false;
|
||||
}
|
||||
final boolean terrain;
|
||||
@ -135,20 +135,20 @@ public class Merge extends SubCommand {
|
||||
terrain = Settings.MERGE_REMOVES_ROADS;
|
||||
}
|
||||
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(player, price);
|
||||
sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
MainUtil.sendMessage(player, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
}
|
||||
Plot adjacent = plot.getRelative(direction);
|
||||
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;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
|
||||
return false;
|
||||
}
|
||||
java.util.Set<UUID> uuids = adjacent.getOwners();
|
||||
@ -165,33 +165,33 @@ public class Merge extends SubCommand {
|
||||
public void run() {
|
||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||
plot.autoMerge(dir, maxSize - size, owner, terrain);
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(player.getUUID());
|
||||
if (pp == null) {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < price) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < price) {
|
||||
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
return;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
EconHandler.manager.withdrawMoney(player, price);
|
||||
sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
MainUtil.sendMessage(player, C.SUCCESS_MERGE);
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), run);
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", player.getName()), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
}
|
||||
if (!isOnline) {
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.MERGE_REQUESTED);
|
||||
MainUtil.sendMessage(player, C.MERGE_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,42 +19,42 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Move extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
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())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot1.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
|
||||
if (plot2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getArea().isCompatible(plot2.getArea())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
return false;
|
||||
}
|
||||
if (plot1.move(plot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.MOVE_SUCCESS);
|
||||
MainUtil.sendMessage(player, C.MOVE_SUCCESS);
|
||||
}
|
||||
}, false)) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.REQUIRES_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import java.util.UUID;
|
||||
public class Owner extends SetCommand {
|
||||
|
||||
@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();
|
||||
UUID uuid = null;
|
||||
String name = null;
|
||||
@ -48,26 +48,26 @@ public class Owner extends SetCommand {
|
||||
current.unclaim();
|
||||
current.removeSign();
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SET_OWNER);
|
||||
MainUtil.sendMessage(player, C.SET_OWNER);
|
||||
return true;
|
||||
}
|
||||
C.INVALID_PLAYER.send(plr, value);
|
||||
C.INVALID_PLAYER.send(player, value);
|
||||
return false;
|
||||
}
|
||||
if (plot.isOwner(uuid)) {
|
||||
C.ALREADY_OWNER.send(plr);
|
||||
C.ALREADY_OWNER.send(player);
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
C.INVALID_PLAYER_OFFLINE.send(plr, value);
|
||||
C.INVALID_PLAYER_OFFLINE.send(player, value);
|
||||
return false;
|
||||
}
|
||||
int size = plots.size();
|
||||
int currentPlots = (Settings.GLOBAL_LIMIT ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
|
||||
if (currentPlots > other.getAllowedPlots()) {
|
||||
sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
sendMessage(player, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -78,14 +78,14 @@ public class Owner extends SetCommand {
|
||||
public void run() {
|
||||
plot.setOwner(finalUUID);
|
||||
plot.setSign(finalName);
|
||||
MainUtil.sendMessage(plr, C.SET_OWNER);
|
||||
MainUtil.sendMessage(player, C.SET_OWNER);
|
||||
if (other != null) {
|
||||
MainUtil.sendMessage(other, C.NOW_OWNER, plot.getArea() + ";" + plot.getId());
|
||||
}
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot set owner " + value, run);
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, "/plot set owner " + value, run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class PluginCmd extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
MainUtil.sendMessage(plr, 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(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lNewest Version$2: $1" + getNewestVersionString());
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
MainUtil.sendMessage(player, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().getVersion(), ".")));
|
||||
MainUtil.sendMessage(player, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lNewest Version$2: $1" + getNewestVersionString());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ import java.util.UUID;
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class Purge extends SubCommand {
|
||||
for (String arg : args) {
|
||||
String[] split = arg.split(":");
|
||||
if (split.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
switch (split[0].toLowerCase()) {
|
||||
@ -55,7 +55,7 @@ public class Purge extends SubCommand {
|
||||
case "a":
|
||||
area = PS.get().getPlotAreaByString(split[1]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, split[1]);
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -63,7 +63,7 @@ public class Purge extends SubCommand {
|
||||
case "id":
|
||||
id = PlotId.fromString(split[1]);
|
||||
if (id == null) {
|
||||
C.NOT_VALID_PLOT_ID.send(plr, split[1]);
|
||||
C.NOT_VALID_PLOT_ID.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -71,7 +71,7 @@ public class Purge extends SubCommand {
|
||||
case "o":
|
||||
owner = UUIDHandler.getUUID(split[1], null);
|
||||
if (owner == null) {
|
||||
C.INVALID_PLAYER.send(plr, split[1]);
|
||||
C.INVALID_PLAYER.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -79,7 +79,7 @@ public class Purge extends SubCommand {
|
||||
case "s":
|
||||
added = UUIDHandler.getUUID(split[1], null);
|
||||
if (added == null) {
|
||||
C.INVALID_PLAYER.send(plr, split[1]);
|
||||
C.INVALID_PLAYER.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -139,7 +139,7 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (toDelete.isEmpty()) {
|
||||
C.FOUND_NO_PLOTS.send(plr);
|
||||
C.FOUND_NO_PLOTS.send(player);
|
||||
return false;
|
||||
}
|
||||
String cmd = "/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
|
||||
@ -158,11 +158,11 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
}
|
||||
DBFunc.purgeIds(ids);
|
||||
C.PURGE_SUCCESS.send(plr, ids.size() + "/" + toDelete.size());
|
||||
C.PURGE_SUCCESS.send(player, ids.size() + "/" + toDelete.size());
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, cmd, run);
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, cmd, run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
|
@ -26,39 +26,39 @@ import java.util.Set;
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
int height = 0;
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
height = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0, 256)");
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
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;
|
||||
}
|
||||
String name = args[0];
|
||||
PlotManager manager = area.getPlotManager();
|
||||
if (!(manager instanceof HybridPlotManager)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
|
||||
MainUtil.sendMessage(plr, "&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(plr, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
|
||||
MainUtil.sendMessage(plr, "&6Estimated time: &7" + chunks.size() + " seconds");
|
||||
MainUtil.sendMessage(player, "&cIf no schematic is set, the following will not do anything");
|
||||
MainUtil.sendMessage(player, "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
|
||||
MainUtil.sendMessage(player, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
|
||||
MainUtil.sendMessage(player, "&6Estimated time: &7" + chunks.size() + " seconds");
|
||||
boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height);
|
||||
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 true;
|
||||
|
@ -23,7 +23,7 @@ import java.util.Objects;
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
try {
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
@ -78,10 +78,10 @@ public class Reload extends SubCommand {
|
||||
}
|
||||
});
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS);
|
||||
MainUtil.sendMessage(player, C.RELOADED_CONFIGS);
|
||||
} catch (InvalidConfigurationException | IOException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, C.RELOAD_FAILED);
|
||||
MainUtil.sendMessage(player, C.RELOAD_FAILED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -10,8 +10,10 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "remove",
|
||||
@ -28,18 +30,18 @@ public class Remove extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.remove")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.remove")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
int count = 0;
|
||||
@ -65,7 +67,7 @@ public class Remove extends SubCommand {
|
||||
}
|
||||
default:
|
||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
if (uuids != null) {
|
||||
if (uuids.isEmpty()) {
|
||||
for (UUID uuid : uuids) {
|
||||
if (plot.getTrusted().contains(uuid)) {
|
||||
if (plot.removeTrusted(uuid)) {
|
||||
@ -85,10 +87,10 @@ public class Remove extends SubCommand {
|
||||
break;
|
||||
}
|
||||
if (count == 0) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.REMOVED_PLAYERS, count + "");
|
||||
MainUtil.sendMessage(player, C.REMOVED_PLAYERS, count + "");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -28,31 +28,31 @@ import java.util.UUID;
|
||||
public class Save extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
String world = plr.getLocation().getWorld();
|
||||
String world = player.getLocation().getWorld();
|
||||
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) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.save")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.save")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
@ -69,17 +69,17 @@ public class Save extends SubCommand {
|
||||
PlotId id = plot.getId();
|
||||
String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
|
||||
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>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.SAVE_FAILED);
|
||||
MainUtil.sendMessage(player, C.SAVE_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SAVE_SUCCESS);
|
||||
List<String> schematics = plr.getMeta("plot_schematics");
|
||||
MainUtil.sendMessage(player, C.SAVE_SUCCESS);
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
if (schematics != null) {
|
||||
schematics.add(file);
|
||||
}
|
||||
|
@ -33,37 +33,37 @@ public class SchematicCmd extends SubCommand {
|
||||
private boolean running = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
sendMessage(player, C.SCHEMATIC_MISSING_ARG);
|
||||
return true;
|
||||
}
|
||||
String arg = args[0].toLowerCase();
|
||||
switch (arg) {
|
||||
case "paste": {
|
||||
if (!Permissions.hasPermission(plr, "plots.schematic.paste")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste");
|
||||
if (!Permissions.hasPermission(player, "plots.schematic.paste")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.schematic.paste");
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
sendMessage(player, C.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
Location loc = plr.getLocation();
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.schematic.paste")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.schematic.paste")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (this.running) {
|
||||
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||
MainUtil.sendMessage(player, "&cTask is already running.");
|
||||
return false;
|
||||
}
|
||||
final String location = args[1];
|
||||
@ -80,7 +80,7 @@ public class SchematicCmd extends SubCommand {
|
||||
schematic = SchematicHandler.manager.getSchematic(url);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent url: " + location);
|
||||
sendMessage(player, C.SCHEMATIC_INVALID, "non-existent url: " + location);
|
||||
SchematicCmd.this.running = false;
|
||||
return;
|
||||
}
|
||||
@ -89,7 +89,7 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
if (schematic == null) {
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
SchematicCmd.this.running = false;
|
||||
if (value) {
|
||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
} 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 "exportall": {
|
||||
if (!(plr instanceof ConsolePlayer)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
|
||||
if (!(player instanceof ConsolePlayer)) {
|
||||
MainUtil.sendMessage(player, C.NOT_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
return false;
|
||||
}
|
||||
Collection<Plot> plots = area.getPlots();
|
||||
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;
|
||||
}
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, "&aFinished mass export");
|
||||
MainUtil.sendMessage(player, "&aFinished mass export");
|
||||
}
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||
MainUtil.sendMessage(player, "&cTask is already running.");
|
||||
return false;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, "&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: &7Mass export has started. This may take a while.");
|
||||
MainUtil.sendMessage(player, "&3PlotSquared&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots...");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "export":
|
||||
case "save":
|
||||
if (!Permissions.hasPermission(plr, "plots.schematic.save")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
|
||||
if (!Permissions.hasPermission(player, "plots.schematic.save")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.schematic.save");
|
||||
return false;
|
||||
}
|
||||
if (this.running) {
|
||||
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||
MainUtil.sendMessage(player, "&cTask is already running.");
|
||||
return false;
|
||||
}
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.schematic.save")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.schematic.save")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
loc.getWorld();
|
||||
Collection<Plot> plots = new ArrayList<Plot>();
|
||||
location.getWorld();
|
||||
Collection<Plot> plots = new ArrayList<>();
|
||||
plots.add(plot);
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, "&aFinished export");
|
||||
MainUtil.sendMessage(player, "&aFinished export");
|
||||
SchematicCmd.this.running = false;
|
||||
}
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||
MainUtil.sendMessage(player, "&cTask is already running.");
|
||||
return false;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, "&7Starting export...");
|
||||
MainUtil.sendMessage(player, "&7Starting export...");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
sendMessage(player, C.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
@ -47,25 +47,25 @@ public class Set extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, final Plot plot, String value) {
|
||||
PlotArea plotworld = plr.getLocation().getPlotArea();
|
||||
PlotManager manager = plr.getLocation().getPlotManager();
|
||||
String[] components = manager.getPlotComponents(plotworld, plot.getId());
|
||||
boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
|
||||
public boolean set(PlotPlayer player, final Plot plot, String value) {
|
||||
PlotArea plotArea = player.getLocation().getPlotArea();
|
||||
PlotManager manager = player.getLocation().getPlotManager();
|
||||
String[] components = manager.getPlotComponents(plotArea, plot.getId());
|
||||
boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(player.getUUID());
|
||||
|
||||
String[] args = value.split(" ");
|
||||
String material = StringMan.join(Arrays.copyOfRange(args, 1, args.length), ",").trim();
|
||||
|
||||
for (String component : components) {
|
||||
if (component.equalsIgnoreCase(args[0])) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set." + component)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + component);
|
||||
if (!Permissions.hasPermission(player, "plots.set." + component)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set." + component);
|
||||
return false;
|
||||
}
|
||||
PlotBlock[] blocks;
|
||||
try {
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(plr, C.NEED_BLOCK);
|
||||
MainUtil.sendMessage(player, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
String[] split = material.split(",");
|
||||
@ -73,7 +73,7 @@ public class Set extends SubCommand {
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
PlotBlock block = blocks[i];
|
||||
if (block == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, split[i]);
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_BLOCK, split[i]);
|
||||
String name;
|
||||
if (split[i].contains("%")) {
|
||||
name = split[i].split("%")[1];
|
||||
@ -84,36 +84,36 @@ public class Set extends SubCommand {
|
||||
if (match != null) {
|
||||
name = WorldUtil.IMP.getClosestMatchingName(match.best);
|
||||
if (name != null) {
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, name.toLowerCase());
|
||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, name.toLowerCase());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
if (!allowUnsafe) {
|
||||
for (PlotBlock block : blocks) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, material);
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_BLOCK, material);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
current.setComponent(component, blocks);
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
MainUtil.sendMessage(player, C.GENERATING_COMPONENT);
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
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<>();
|
||||
newValues.addAll(Arrays.asList("biome", "alias", "home", "flag"));
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
return noArgs(plr);
|
||||
return noArgs(player);
|
||||
}
|
||||
Command cmd = MainCommand.getInstance().getCommand("set" + args[0]);
|
||||
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;
|
||||
}
|
||||
// Additional checks
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
// components
|
||||
HashSet<String> components = new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId())));
|
||||
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 = FlagManager.getFlag(args[0].toLowerCase());
|
||||
@ -169,9 +169,9 @@ public class Set extends SubCommand {
|
||||
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 noArgs(plr);
|
||||
return noArgs(player);
|
||||
}
|
||||
}
|
||||
|
@ -11,32 +11,32 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
public abstract class SetCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
MainUtil.sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
if (!Permissions.hasPermission(player, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
MainUtil.sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -19,24 +19,24 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class SetHome extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, Plot plot, String value) {
|
||||
public boolean set(PlotPlayer player, Plot plot, String value) {
|
||||
switch (value.toLowerCase()) {
|
||||
case "unset":
|
||||
case "remove":
|
||||
case "none": {
|
||||
Plot base = plot.getBasePlot(false);
|
||||
base.setHome(null);
|
||||
return MainUtil.sendMessage(plr, C.POSITION_UNSET);
|
||||
return MainUtil.sendMessage(player, C.POSITION_UNSET);
|
||||
}
|
||||
case "":
|
||||
Plot base = plot.getBasePlot(false);
|
||||
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());
|
||||
base.setHome(rel);
|
||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||
return MainUtil.sendMessage(player, C.POSITION_SET);
|
||||
default:
|
||||
MainUtil.sendMessage(plr, C.HOME_ARGUMENT);
|
||||
MainUtil.sendMessage(player, C.HOME_ARGUMENT);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import java.util.Map.Entry;
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Setup extends SubCommand {
|
||||
|
||||
public void displayGenerators(PlotPlayer plr) {
|
||||
public void displayGenerators(PlotPlayer player) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("&6What generator do you want?");
|
||||
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)");
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, message.toString());
|
||||
MainUtil.sendMessage(player, message.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
// going through setup
|
||||
SetupObject object = plr.getMeta("setup");
|
||||
SetupObject object = player.getMeta("setup");
|
||||
if (object == null) {
|
||||
object = new SetupObject();
|
||||
plr.setMeta("setup", object);
|
||||
player.setMeta("setup", object);
|
||||
SetupUtils.manager.updateGenerators();
|
||||
sendMessage(plr, C.SETUP_INIT);
|
||||
displayGenerators(plr);
|
||||
sendMessage(player, C.SETUP_INIT);
|
||||
displayGenerators(player);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("cancel")) {
|
||||
plr.deleteMeta("setup");
|
||||
MainUtil.sendMessage(plr, "&aCancelled setup");
|
||||
player.deleteMeta("setup");
|
||||
MainUtil.sendMessage(player, "&aCancelled setup");
|
||||
return false;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("back")) {
|
||||
if (object.setup_index > 0) {
|
||||
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()));
|
||||
return false;
|
||||
} else if (object.current > 0) {
|
||||
@ -78,15 +78,15 @@ public class Setup extends SubCommand {
|
||||
case 0: // choose generator
|
||||
if (args.length != 1 || !SetupUtils.generators.containsKey(args[0])) {
|
||||
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"));
|
||||
sendMessage(plr, C.SETUP_INIT);
|
||||
sendMessage(player, C.SETUP_INIT);
|
||||
return false;
|
||||
}
|
||||
object.setupGenerator = args[0];
|
||||
object.current++;
|
||||
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);
|
||||
break;
|
||||
case 1: // choose world type
|
||||
@ -100,13 +100,13 @@ public class Setup extends SubCommand {
|
||||
types.add("augmented");
|
||||
types.add("partial");
|
||||
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) {
|
||||
int i = allTypes.indexOf(type);
|
||||
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 {
|
||||
MainUtil.sendMessage(plr, "&8 - &7" + type + " &8-&7 " + allDesc.get(i));
|
||||
MainUtil.sendMessage(player, "&8 - &7" + type + " &8-&7 " + allDesc.get(i));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -122,12 +122,12 @@ public class Setup extends SubCommand {
|
||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
|
||||
}
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
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()));
|
||||
} else {
|
||||
if (gen.isFull()) {
|
||||
@ -138,16 +138,16 @@ public class Setup extends SubCommand {
|
||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
|
||||
} else {
|
||||
object.plotManager = "PlotSquared";
|
||||
MainUtil.sendMessage(plr, "&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, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
|
||||
MainUtil.sendMessage(player, "&7 - You may need to manually configure the other plugin");
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
}
|
||||
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++;
|
||||
} 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 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
@ -158,42 +158,42 @@ public class Setup extends SubCommand {
|
||||
break;
|
||||
case 2: // area id
|
||||
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;
|
||||
}
|
||||
for (PlotArea area : PS.get().getPlotAreas()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
object.id = args[0];
|
||||
object.current++;
|
||||
MainUtil.sendMessage(plr, "&6What should be the minimum Plot Id?");
|
||||
MainUtil.sendMessage(player, "&6What should be the minimum Plot Id?");
|
||||
break;
|
||||
case 3: // min
|
||||
object.min = PlotId.fromString(args[0]);
|
||||
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;
|
||||
}
|
||||
object.current++;
|
||||
MainUtil.sendMessage(plr, "&6What should be the maximum Plot Id?");
|
||||
MainUtil.sendMessage(player, "&6What should be the maximum Plot Id?");
|
||||
break;
|
||||
case 4:
|
||||
// max
|
||||
PlotId id = PlotId.fromString(args[0]);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
object.max = id;
|
||||
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 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
@ -202,7 +202,7 @@ public class Setup extends SubCommand {
|
||||
case 5: { // Choose terrain
|
||||
List<String> terrain = Arrays.asList("none", "ore", "road", "all");
|
||||
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 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
@ -216,58 +216,58 @@ public class Setup extends SubCommand {
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
}
|
||||
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()));
|
||||
break;
|
||||
}
|
||||
case 6: // world setup
|
||||
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.current++;
|
||||
return true;
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
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()));
|
||||
return false;
|
||||
}
|
||||
boolean valid = step.isValid(args[0]);
|
||||
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]);
|
||||
object.setup_index++;
|
||||
if (object.setup_index == object.step.length) {
|
||||
onCommand(plr, args);
|
||||
onCommand(player, args);
|
||||
return false;
|
||||
}
|
||||
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()));
|
||||
return false;
|
||||
} else {
|
||||
sendMessage(plr, 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_INVALID_ARG, args[0], step.getConstant());
|
||||
sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
return false;
|
||||
}
|
||||
case 7:
|
||||
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;
|
||||
}
|
||||
if (WorldUtil.IMP.isWorld(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;
|
||||
}
|
||||
MainUtil.sendMessage(plr,
|
||||
MainUtil.sendMessage(player,
|
||||
"&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!");
|
||||
}
|
||||
object.world = args[0];
|
||||
plr.deleteMeta("setup");
|
||||
player.deleteMeta("setup");
|
||||
String world;
|
||||
if (object.setupManager == null) {
|
||||
world = SetupUtils.manager.setupWorld(object);
|
||||
@ -275,12 +275,12 @@ public class Setup extends SubCommand {
|
||||
world = object.setupManager.setupWorld(object);
|
||||
}
|
||||
try {
|
||||
plr.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
} 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();
|
||||
}
|
||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||
sendMessage(player, C.SETUP_FINISHED, object.world);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -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) {
|
||||
message.send(player, args);
|
||||
|
@ -17,42 +17,42 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Swap extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
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())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot1.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
|
||||
if (plot2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getArea().isCompatible(plot2.getArea())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
return false;
|
||||
}
|
||||
if (plot1.move(plot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.SWAP_SUCCESS);
|
||||
MainUtil.sendMessage(player, C.SWAP_SUCCESS);
|
||||
}
|
||||
}, true)) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.SWAP_OVERLAP);
|
||||
MainUtil.sendMessage(player, C.SWAP_OVERLAP);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -24,31 +24,31 @@ public class Target extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location plrLocation = plr.getLocation();
|
||||
if (!plrLocation.isPlotArea()) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
if (!location.isPlotArea()) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
Plot target = null;
|
||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||
int distance = Integer.MAX_VALUE;
|
||||
for (Plot plot : PS.get().getPlots(plrLocation.getWorld())) {
|
||||
double current = plot.getCenter().getEuclideanDistanceSquared(plrLocation);
|
||||
for (Plot plot : PS.get().getPlots(location.getWorld())) {
|
||||
double current = plot.getCenter().getEuclideanDistanceSquared(location);
|
||||
if (current < distance) {
|
||||
distance = (int) current;
|
||||
target = plot;
|
||||
}
|
||||
}
|
||||
if (target == null) {
|
||||
MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
} else if ((target = MainUtil.getPlotFromString(plr, args[0], true)) == null) {
|
||||
} else if ((target = MainUtil.getPlotFromString(player, args[0], true)) == null) {
|
||||
return false;
|
||||
}
|
||||
plr.setCompassTarget(target.getCenter());
|
||||
MainUtil.sendMessage(plr, C.COMPASS_TARGET);
|
||||
player.setCompassTarget(target.getCenter());
|
||||
MainUtil.sendMessage(player, C.COMPASS_TARGET);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ public class Template extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] getBytes(PlotArea plotworld) {
|
||||
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds." + plotworld.worldname);
|
||||
public static byte[] getBytes(PlotArea plotArea) {
|
||||
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds." + plotArea.worldname);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
String generator = SetupUtils.manager.getGenerator(plotworld);
|
||||
String generator = SetupUtils.manager.getGenerator(plotArea);
|
||||
if (generator != null) {
|
||||
config.set("generator.plugin", generator);
|
||||
}
|
||||
@ -103,34 +103,34 @@ public class Template extends SubCommand {
|
||||
}
|
||||
|
||||
@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 == 1) {
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
final String world = args[1];
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "import": {
|
||||
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;
|
||||
}
|
||||
if (PS.get().hasPlotArea(world)) {
|
||||
MainUtil.sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||
MainUtil.sendMessage(player, C.SETUP_WORLD_TAKEN, world);
|
||||
return false;
|
||||
}
|
||||
boolean result = extractAllFiles(world, args[2]);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid template file: " + args[2] + ".template");
|
||||
MainUtil.sendMessage(player, "&cInvalid template file: " + args[2] + ".template");
|
||||
return false;
|
||||
}
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, "Done!");
|
||||
plr.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
MainUtil.sendMessage(player, "Done!");
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case "export":
|
||||
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;
|
||||
}
|
||||
final PlotArea area = PS.get().getPlotAreaByString(world);
|
||||
if (area == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final PlotManager manager = area.getPlotManager();
|
||||
@ -182,15 +182,15 @@ public class Template extends SubCommand {
|
||||
manager.exportTemplate(area);
|
||||
} catch (Exception e) { // Must recover from any exception thrown a third party template manager
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, "Failed: " + e.getMessage());
|
||||
MainUtil.sendMessage(player, "Failed: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "Done!");
|
||||
MainUtil.sendMessage(player, "Done!");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -127,18 +127,18 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
final String world = args[0];
|
||||
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;
|
||||
}
|
||||
if (Trim.TASK) {
|
||||
C.TRIM_IN_PROGRESS.send(plr);
|
||||
C.TRIM_IN_PROGRESS.send(player);
|
||||
return false;
|
||||
}
|
||||
Trim.TASK = true;
|
||||
@ -156,7 +156,7 @@ public class Trim extends SubCommand {
|
||||
public void run() {
|
||||
if (nonViable.isEmpty()) {
|
||||
Trim.TASK = false;
|
||||
plr.sendMessage("Trim done!");
|
||||
player.sendMessage("Trim done!");
|
||||
return;
|
||||
}
|
||||
Iterator<ChunkLoc> iterator = nonViable.iterator();
|
||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
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(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
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();
|
||||
int size = plot.getTrusted().size() + plot.getMembers().size();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -21,26 +21,26 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Unlink extends SubCommand {
|
||||
|
||||
@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();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
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")) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.unlink")) {
|
||||
return sendMessage(player, C.NO_PLOT_PERMS);
|
||||
}
|
||||
if (!plot.isMerged()) {
|
||||
return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
||||
return sendMessage(player, C.UNLINK_IMPOSSIBLE);
|
||||
}
|
||||
final boolean createRoad;
|
||||
if (args.length != 0) {
|
||||
if (args.length != 1 || !StringMan.isEqualIgnoreCaseToAny(args[0], "true", "false")) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
createRoad = Boolean.parseBoolean(args[0]);
|
||||
@ -51,14 +51,14 @@ public class Unlink extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!plot.unlinkPlot(createRoad, createRoad)) {
|
||||
MainUtil.sendMessage(plr, "&cUnlink has been cancelled");
|
||||
MainUtil.sendMessage(player, "&cUnlink has been cancelled");
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.UNLINK_SUCCESS);
|
||||
MainUtil.sendMessage(player, C.UNLINK_SUCCESS);
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot unlink " + plot.getId(), runnable);
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import java.net.URL;
|
||||
public class Update extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
URL url;
|
||||
if (args.length == 0) {
|
||||
url = Updater.getUpdate();
|
||||
@ -29,20 +29,20 @@ public class Update extends SubCommand {
|
||||
try {
|
||||
url = new URL(args[0]);
|
||||
} catch (MalformedURLException ignored) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid URL: " + args[0]);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]");
|
||||
MainUtil.sendMessage(player, "&cInvalid URL: " + args[0]);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot update [url]");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, getUsage().replaceAll("\\{label\\}", "plot"));
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, getUsage().replaceAll("\\{label\\}", "plot"));
|
||||
return false;
|
||||
}
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, "&cNo update found!");
|
||||
MainUtil.sendMessage(plr, "&cTo manually specify an update URL: /plot update <url>");
|
||||
MainUtil.sendMessage(player, "&cNo update found!");
|
||||
MainUtil.sendMessage(player, "&cTo manually specify an update URL: /plot update <url>");
|
||||
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;
|
||||
}
|
||||
return true;
|
||||
|
@ -676,11 +676,11 @@ public enum C {
|
||||
return m;
|
||||
}
|
||||
|
||||
public static String format(C c, Object... args) {
|
||||
if (c.usePrefix()) {
|
||||
return C.PREFIX.s() + format(c.s, args);
|
||||
public static String format(C caption, Object... args) {
|
||||
if (caption.usePrefix()) {
|
||||
return C.PREFIX.s() + format(caption.s, args);
|
||||
} 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> categories = new HashSet<>();
|
||||
HashSet<String> toRemove = new HashSet<>();
|
||||
for (C c : allEnums) {
|
||||
allNames.add(c.name());
|
||||
categories.add(c.category.toLowerCase());
|
||||
for (C caption : allEnums) {
|
||||
allNames.add(caption.name());
|
||||
categories.add(caption.category.toLowerCase());
|
||||
}
|
||||
HashSet<C> captions = new HashSet<>();
|
||||
boolean changed = false;
|
||||
@ -797,16 +797,16 @@ public enum C {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void send(CommandCaller plr, String... args) {
|
||||
send(plr, (Object[]) args);
|
||||
public void send(CommandCaller caller, String... args) {
|
||||
send(caller, (Object[]) args);
|
||||
}
|
||||
|
||||
public void send(CommandCaller plr, Object... args) {
|
||||
public void send(CommandCaller caller, Object... args) {
|
||||
String msg = format(this, args);
|
||||
if (plr == null) {
|
||||
if (caller == null) {
|
||||
PS.log(msg);
|
||||
} else {
|
||||
plr.sendMessage(msg);
|
||||
caller.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@ -17,39 +18,39 @@ import java.util.ArrayList;
|
||||
public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@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) {
|
||||
case "floor":
|
||||
setFloor(plotworld, plotid, blocks);
|
||||
setFloor(plotArea, plotId, blocks);
|
||||
return true;
|
||||
case "wall":
|
||||
setWallFilling(plotworld, plotid, blocks);
|
||||
setWallFilling(plotArea, plotId, blocks);
|
||||
return true;
|
||||
case "all":
|
||||
setAll(plotworld, plotid, blocks);
|
||||
setAll(plotArea, plotId, blocks);
|
||||
return true;
|
||||
case "air":
|
||||
setAir(plotworld, plotid, blocks);
|
||||
setAir(plotArea, plotId, blocks);
|
||||
return true;
|
||||
case "main":
|
||||
setMain(plotworld, plotid, blocks);
|
||||
setMain(plotArea, plotId, blocks);
|
||||
return true;
|
||||
case "middle":
|
||||
setMiddle(plotworld, plotid, blocks);
|
||||
setMiddle(plotArea, plotId, blocks);
|
||||
return true;
|
||||
case "outline":
|
||||
setOutline(plotworld, plotid, blocks);
|
||||
setOutline(plotArea, plotId, blocks);
|
||||
return true;
|
||||
case "border":
|
||||
setWall(plotworld, plotid, blocks);
|
||||
setWall(plotArea, plotId, blocks);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unclaimPlot(PlotArea plotworld, Plot plot, Runnable whenDone) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
setWallFilling(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_FILLING});
|
||||
if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
|
||||
setWall(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_BLOCK});
|
||||
@ -58,78 +59,78 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setFloor(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
public boolean setFloor(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
if (plot.isBasePlot()) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, dpw.PLOT_HEIGHT, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, dpw.PLOT_HEIGHT, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, dpw.PLOT_HEIGHT, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAll(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
public boolean setAll(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, 255, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAir(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
public boolean setAir(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, 255, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMain(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
public boolean setMain(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMiddle(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
public boolean setMiddle(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
Location[] corners = plot.getCorners();
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, (corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT,
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
SetQueue.IMP.setBlock(plotArea.worldname, (corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT,
|
||||
(corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setOutline(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
public boolean setOutline(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
Location bottom = plot.getBottomAbs();
|
||||
Location top = plot.getExtendedTopAbs();
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
@ -137,7 +138,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int z = bottom.getZ();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
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();
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
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();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
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();
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
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()) {
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, 255, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, 255, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, 255, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, pos1, pos2, blocks);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWallFilling(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
public boolean setWallFilling(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
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 top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
@ -189,7 +190,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
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();
|
||||
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
||||
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();
|
||||
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
|
||||
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();
|
||||
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean setWall(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
public boolean setWall(PlotArea plotArea, PlotId plotId, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
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 top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
@ -233,25 +234,25 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bot.getZ();
|
||||
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)) {
|
||||
int x = bot.getX();
|
||||
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)) {
|
||||
int z = top.getZ();
|
||||
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)) {
|
||||
int x = top.getX();
|
||||
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;
|
||||
@ -291,102 +292,102 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouth(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
public boolean createRoadSouth(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
int sx = pos1.getX() - 2;
|
||||
int ex = pos2.getX() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname,
|
||||
new Location(plotworld.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));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz),
|
||||
new Location(plotworld.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz),
|
||||
new Location(plotworld.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),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz),
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname,
|
||||
new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz),
|
||||
new Location(plotArea.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, ez),
|
||||
new Location(plotworld.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),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez),
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, ez),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, ez), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouthEast(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
public boolean createRoadSouthEast(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock(
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, 255, ez - 1), new PlotBlock(
|
||||
(short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1),
|
||||
new Location(plotworld.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),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRoadEast(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
public boolean removeRoadEast(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int sz = pos1.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),
|
||||
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1),
|
||||
new Location(plotworld.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),
|
||||
new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1),
|
||||
new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRoadSouth(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
public boolean removeRoadSouth(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
int sx = pos1.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),
|
||||
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz),
|
||||
new Location(plotworld.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),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRoadSouthEast(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location loc = getPlotTopLocAbs(dpw, plot.getId());
|
||||
int sx = loc.getX() + 1;
|
||||
public boolean removeRoadSouthEast(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location location = getPlotTopLocAbs(dpw, plot.getId());
|
||||
int sx = location.getX() + 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;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz),
|
||||
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz),
|
||||
new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz),
|
||||
new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT + 1, sz),
|
||||
new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz),
|
||||
new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT, sz),
|
||||
new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
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).
|
||||
*/
|
||||
@Override
|
||||
public boolean finishPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
public boolean finishPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
|
||||
if (block.id != 0 || !block.equals(unclaim)) {
|
||||
for (PlotId id : plotIds) {
|
||||
setWall(plotworld, id, new PlotBlock[]{block});
|
||||
setWall(plotArea, id, new PlotBlock[]{block});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finishPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
public boolean finishPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
|
||||
for (PlotId id : plotIds) {
|
||||
if (block.id != 0 || !block.equals(unclaim)) {
|
||||
setWall(plotworld, id, new PlotBlock[]{block});
|
||||
setWall(plotArea, id, new PlotBlock[]{block});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
public boolean startPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
public boolean startPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean claimPlot(PlotArea plotworld, Plot plot) {
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
public boolean claimPlot(PlotArea plotArea, Plot plot) {
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
|
||||
PlotBlock claim = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
|
||||
if (claim.id != 0 || !claim.equals(unclaim)) {
|
||||
setWall(plotworld, plot.getId(), new PlotBlock[]{claim});
|
||||
setWall(plotArea, plot.getId(), new PlotBlock[]{claim});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@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"};
|
||||
}
|
||||
|
||||
@ -446,10 +447,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
* Remove sign for a plot.
|
||||
*/
|
||||
@Override
|
||||
public Location getSignLoc(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
public Location getSignLoc(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
plot = plot.getBasePlot(false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
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 GridPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldName, id, generator, min, max);
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ import java.util.Map.Entry;
|
||||
public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
@Override
|
||||
public void exportTemplate(PlotArea plotworld) throws IOException {
|
||||
public void exportTemplate(PlotArea plotArea) throws IOException {
|
||||
HashSet<FileBytes> files = new HashSet<>(
|
||||
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotworld))));
|
||||
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
|
||||
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotArea))));
|
||||
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;
|
||||
try {
|
||||
File sideroad = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "sideroad.schematic");
|
||||
@ -48,7 +48,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Template.zipAll(plotworld.worldname, files);
|
||||
Template.zipAll(plotArea.worldname, files);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,16 +97,16 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouth(PlotArea plotworld, Plot plot) {
|
||||
super.createRoadSouth(plotworld, plot);
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
public boolean createRoadSouth(PlotArea plotArea, Plot plot) {
|
||||
super.createRoadSouth(plotArea, plot);
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotArea;
|
||||
PlotId id = plot.getId();
|
||||
PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||
Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
Location top = getPlotTopLocAbs(hpw, id);
|
||||
Location pos1 = new Location(plotworld.worldname, bot.getX() - 1, 0, top.getZ() + 1);
|
||||
Location pos2 = new Location(plotworld.worldname, top.getX() + 1, 255, bot.getZ());
|
||||
MainUtil.resetBiome(plotworld, pos1, pos2);
|
||||
Location pos1 = new Location(plotArea.worldname, bot.getX() - 1, 0, top.getZ() + 1);
|
||||
Location pos2 = new Location(plotArea.worldname, top.getX() + 1, 255, bot.getZ());
|
||||
MainUtil.resetBiome(plotArea, pos1, pos2);
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
@ -115,9 +115,9 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouthEast(PlotArea plotworld, Plot plot) {
|
||||
super.createRoadSouthEast(plotworld, plot);
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
public boolean createRoadSouthEast(PlotArea plotArea, Plot plot) {
|
||||
super.createRoadSouthEast(plotArea, plot);
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotArea;
|
||||
PlotId id = plot.getId();
|
||||
PlotId id2 = new PlotId(id.x + 1, id.y + 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>
|
||||
*/
|
||||
@Override
|
||||
public boolean clearPlot(PlotArea plotworld, Plot plot, final Runnable whenDone) {
|
||||
final String world = plotworld.worldname;
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
public boolean clearPlot(PlotArea plotArea, Plot plot, final Runnable whenDone) {
|
||||
final String world = plotArea.worldname;
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotArea;
|
||||
Location pos1 = plot.getBottomAbs();
|
||||
Location pos2 = plot.getExtendedTopAbs();
|
||||
// If augmented
|
||||
final boolean canRegen = (plotworld.TYPE == 0) && (plotworld.TERRAIN == 0);
|
||||
final boolean canRegen = (plotArea.TYPE == 0) && (plotArea.TERRAIN == 0);
|
||||
// The component blocks
|
||||
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
|
||||
final PlotBlock[] filling = dpw.MAIN_BLOCK;
|
||||
@ -197,10 +197,10 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void pastePlotSchematic(HybridPlotWorld plotworld, Location l1, Location l2) {
|
||||
if (!plotworld.PLOT_SCHEMATIC) {
|
||||
public void pastePlotSchematic(HybridPlotWorld plotWorld, Location l1, Location l2) {
|
||||
if (!plotWorld.PLOT_SCHEMATIC) {
|
||||
return;
|
||||
}
|
||||
createSchemAbs(plotworld, l1, l2, false);
|
||||
createSchemAbs(plotWorld, l1, l2, false);
|
||||
}
|
||||
}
|
||||
|
@ -130,14 +130,14 @@ public abstract class HybridUtils {
|
||||
if (whenDone == null) {
|
||||
return;
|
||||
}
|
||||
PlotArea plotworld = plot.getArea();
|
||||
if (!(plotworld instanceof ClassicPlotWorld)) {
|
||||
PlotArea plotArea = plot.getArea();
|
||||
if (!(plotArea instanceof ClassicPlotWorld)) {
|
||||
whenDone.value = -1;
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
whenDone.value = 0;
|
||||
final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
|
||||
final ClassicPlotWorld cpw = (ClassicPlotWorld) plotArea;
|
||||
final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(plot.getRegions());
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
@ -339,13 +339,13 @@ public abstract class HybridUtils {
|
||||
int z = chunk.z << 4;
|
||||
int ex = x + 15;
|
||||
int ez = z + 15;
|
||||
HybridPlotWorld plotworld = (HybridPlotWorld) area;
|
||||
extend = Math.min(extend, 255 - plotworld.ROAD_HEIGHT - plotworld.SCHEMATIC_HEIGHT);
|
||||
if (!plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||
HybridPlotWorld plotWorld = (HybridPlotWorld) area;
|
||||
extend = Math.min(extend, 255 - plotWorld.ROAD_HEIGHT - plotWorld.SCHEMATIC_HEIGHT);
|
||||
if (!plotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
return false;
|
||||
}
|
||||
boolean toCheck = false;
|
||||
if (plotworld.TYPE == 2) {
|
||||
if (plotWorld.TYPE == 2) {
|
||||
boolean c1 = area.contains(x, z);
|
||||
boolean c2 = area.contains(ex, ez);
|
||||
if (!c1 && !c2) {
|
||||
@ -355,10 +355,10 @@ public abstract class HybridUtils {
|
||||
}
|
||||
}
|
||||
PlotManager manager = area.getPlotManager();
|
||||
PlotId id1 = manager.getPlotId(plotworld, x, 0, z);
|
||||
PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||
x -= plotworld.ROAD_OFFSET_X;
|
||||
z -= plotworld.ROAD_OFFSET_Z;
|
||||
PlotId id1 = manager.getPlotId(plotWorld, x, 0, z);
|
||||
PlotId id2 = manager.getPlotId(plotWorld, ex, 0, ez);
|
||||
x -= plotWorld.ROAD_OFFSET_X;
|
||||
z -= plotWorld.ROAD_OFFSET_Z;
|
||||
if (id1 == null || id2 == null || id1 != id2) {
|
||||
boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||
if (result) {
|
||||
@ -374,7 +374,7 @@ public abstract class HybridUtils {
|
||||
toCheck = true;
|
||||
}
|
||||
}
|
||||
int size = plotworld.SIZE;
|
||||
int size = plotWorld.SIZE;
|
||||
for (int X = 0; X < 16; X++) {
|
||||
short absX = (short) ((x + X) % size);
|
||||
for (int Z = 0; Z < 16; Z++) {
|
||||
@ -387,24 +387,24 @@ public abstract class HybridUtils {
|
||||
}
|
||||
boolean condition;
|
||||
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));
|
||||
} else {
|
||||
boolean gx = absX > plotworld.PATH_WIDTH_LOWER;
|
||||
boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
|
||||
boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
|
||||
boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
|
||||
boolean gx = absX > plotWorld.PATH_WIDTH_LOWER;
|
||||
boolean gz = absZ > plotWorld.PATH_WIDTH_LOWER;
|
||||
boolean lx = absX < plotWorld.PATH_WIDTH_UPPER;
|
||||
boolean lz = absZ < plotWorld.PATH_WIDTH_UPPER;
|
||||
condition = !gx || !gz || !lx || !lz;
|
||||
}
|
||||
if (condition) {
|
||||
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++) {
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0);
|
||||
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++) {
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotWorld.ROAD_OFFSET_X, y, z + Z + plotWorld.ROAD_OFFSET_Z, 0);
|
||||
}
|
||||
if (blocks != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : blocks.entrySet()) {
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, entry.getKey(),
|
||||
z + Z + plotworld.ROAD_OFFSET_Z, entry.getValue());
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotWorld.ROAD_OFFSET_X, entry.getKey(),
|
||||
z + Z + plotWorld.ROAD_OFFSET_Z, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public abstract class PlotGenerator<T> {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
public abstract void initialize(PlotArea plotworld);
|
||||
public abstract void initialize(PlotArea plotArea);
|
||||
|
||||
/**
|
||||
* TYPE = 2;
|
||||
|
@ -19,7 +19,7 @@ import java.util.Iterator;
|
||||
public abstract class SquarePlotManager extends GridPlotManager {
|
||||
|
||||
@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();
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
@ -41,18 +41,18 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getPlotTopLocAbs(PlotArea plotworld, PlotId plotid) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
int px = plotid.x;
|
||||
int pz = plotid.y;
|
||||
public Location getPlotTopLocAbs(PlotArea plotArea, PlotId plotId) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotArea;
|
||||
int px = plotId.x;
|
||||
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 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
|
||||
public PlotId getPlotIdAbs(PlotArea plotworld, int x, int y, int z) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
public PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotArea;
|
||||
if (dpw.ROAD_OFFSET_X != 0) {
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
}
|
||||
@ -97,10 +97,10 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotId getPlotId(PlotArea plotworld, int x, int y, int z) {
|
||||
public PlotId getPlotId(PlotArea plotArea, int x, int y, int z) {
|
||||
try {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
if (plotworld == null) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotArea;
|
||||
if (plotArea == null) {
|
||||
return null;
|
||||
}
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
@ -144,7 +144,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
if (hash == 0) {
|
||||
return id;
|
||||
}
|
||||
Plot plot = plotworld.getOwnedPlotAbs(id);
|
||||
Plot plot = plotArea.getOwnedPlotAbs(id);
|
||||
// Not merged, and standing on road
|
||||
if (plot == null) {
|
||||
return null;
|
||||
@ -177,7 +177,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
}
|
||||
PS.debug("invalid location: " + Arrays.toString(merged));
|
||||
} 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;
|
||||
}
|
||||
|
@ -85,12 +85,12 @@ public class PlotCluster {
|
||||
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) {
|
||||
this.area.removeCluster(this);
|
||||
}
|
||||
this.area = plotarea;
|
||||
plotarea.addCluster(this);
|
||||
this.area = plotArea;
|
||||
plotArea.addCluster(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,63 +13,63 @@ public abstract class PlotManager {
|
||||
* Plot locations (methods with Abs in them will not need to consider mega
|
||||
* 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
|
||||
public abstract Location getPlotBottomLocAbs(PlotArea plotworld, PlotId plotid);
|
||||
public abstract Location getPlotBottomLocAbs(PlotArea plotArea, PlotId plotId);
|
||||
|
||||
// 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)
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* 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<>(
|
||||
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotworld))));
|
||||
Template.zipAll(plotworld.worldname, files);
|
||||
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotArea))));
|
||||
Template.zipAll(plotArea.worldname, files);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -57,48 +57,48 @@ public abstract class EventUtil {
|
||||
|
||||
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) {
|
||||
ExpireManager.IMP.handleJoin(pp);
|
||||
ExpireManager.IMP.handleJoin(player);
|
||||
}
|
||||
if (PS.get().worldedit != null) {
|
||||
if (pp.getAttribute("worldedit")) {
|
||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
|
||||
if (player.getAttribute("worldedit")) {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_BYPASSED);
|
||||
}
|
||||
}
|
||||
if (PS.get().update != null && Permissions.hasPermission(pp, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
|
||||
MainUtil.sendMessage(pp, "&6An update for PlotSquared is available: &7/plot update");
|
||||
if (PS.get().update != null && Permissions.hasPermission(player, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
|
||||
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) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
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) {
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
public void doRespawnTask(final PlotPlayer player) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (Settings.TELEPORT_ON_DEATH && plot != null) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
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) {
|
||||
PlotArea area = PS.get().getPlotAreaAbs(loc);
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type, Location location, LazyBlock block, boolean notifyPerms) {
|
||||
PlotArea area = PS.get().getPlotAreaAbs(location);
|
||||
Plot plot;
|
||||
if (area != null) {
|
||||
plot = area.getPlot(loc);
|
||||
plot = area.getPlot(location);
|
||||
} else {
|
||||
plot = null;
|
||||
}
|
||||
@ -106,7 +106,7 @@ public abstract class EventUtil {
|
||||
if (area == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (plot.isAdded(pp.getUUID())) {
|
||||
} else if (plot.isAdded(player.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
switch (type) {
|
||||
@ -117,10 +117,10 @@ public abstract class EventUtil {
|
||||
return true;
|
||||
case BREAK_BLOCK:
|
||||
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()) {
|
||||
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);
|
||||
if (use.isPresent()) {
|
||||
@ -136,54 +136,54 @@ public abstract class EventUtil {
|
||||
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 !(!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:
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
if (plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
|
||||
.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_HANGING_BREAK.s()));
|
||||
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
|
||||
.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:
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
if (plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
|
||||
.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_BREAK.s()));
|
||||
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
|
||||
.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:
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
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 !(!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: {
|
||||
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()) {
|
||||
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);
|
||||
HashSet<PlotBlock> value;
|
||||
@ -193,17 +193,17 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
|
||||
.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s()));
|
||||
return Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms) || !(!notifyPerms || MainUtil
|
||||
.sendMessage(player, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case PLACE_BLOCK: {
|
||||
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()) {
|
||||
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);
|
||||
HashSet<PlotBlock> value;
|
||||
@ -213,19 +213,19 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 !(!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;
|
||||
}
|
||||
case TRIGGER_PHYSICAL: {
|
||||
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()) {
|
||||
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)) {
|
||||
return true;
|
||||
@ -238,7 +238,7 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 false;
|
||||
@ -247,10 +247,10 @@ public abstract class EventUtil {
|
||||
}
|
||||
case INTERACT_HANGING: {
|
||||
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()) {
|
||||
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)) {
|
||||
return true;
|
||||
@ -263,19 +263,19 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 !(!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;
|
||||
}
|
||||
case INTERACT_MISC: {
|
||||
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()) {
|
||||
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)) {
|
||||
return true;
|
||||
@ -288,19 +288,19 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 !(!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;
|
||||
}
|
||||
case INTERACT_VEHICLE: {
|
||||
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()) {
|
||||
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)) {
|
||||
return true;
|
||||
@ -313,19 +313,19 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 !(!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;
|
||||
}
|
||||
case SPAWN_MOB: {
|
||||
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()) {
|
||||
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)) {
|
||||
return true;
|
||||
@ -338,10 +338,10 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 !(!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;
|
||||
}
|
||||
@ -349,10 +349,10 @@ public abstract class EventUtil {
|
||||
return true;
|
||||
case PLACE_MISC: {
|
||||
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()) {
|
||||
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)) {
|
||||
return true;
|
||||
@ -365,20 +365,20 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 !(!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;
|
||||
}
|
||||
case PLACE_VEHICLE:
|
||||
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()) {
|
||||
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)) {
|
||||
return true;
|
||||
@ -391,10 +391,10 @@ public abstract class EventUtil {
|
||||
value = null;
|
||||
}
|
||||
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 !(!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;
|
||||
default:
|
||||
|
@ -619,35 +619,35 @@ public class MainUtil {
|
||||
/**
|
||||
* Send a message to the player.
|
||||
*
|
||||
* @param plr Player to receive message
|
||||
* @param c Caption to send
|
||||
* @param player the recipient of the message
|
||||
* @param caption the message to send
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
public static boolean sendMessage(PlotPlayer plr, C c, String... args) {
|
||||
return sendMessage(plr, c, (Object[]) args);
|
||||
public static boolean sendMessage(PlotPlayer player, C caption, String... args) {
|
||||
return sendMessage(player, caption, (Object[]) args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
*
|
||||
* @param plr Player to receive message
|
||||
* @param c Caption to send
|
||||
* @param player the recipient of the message
|
||||
* @param caption the message to send
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
public static boolean sendMessage(final PlotPlayer plr, final C c, final Object... args) {
|
||||
if (c.s().isEmpty()) {
|
||||
public static boolean sendMessage(final PlotPlayer player, final C caption, final Object... args) {
|
||||
if (caption.s().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String m = C.format(c, args);
|
||||
if (plr == null) {
|
||||
String m = C.format(caption, args);
|
||||
if (player == null) {
|
||||
PS.log(m);
|
||||
} else {
|
||||
plr.sendMessage(m);
|
||||
player.sendMessage(m);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -696,11 +696,11 @@ public class MainUtil {
|
||||
|
||||
public static Set<UUID> getUUIDsFromString(String list) {
|
||||
String[] split = list.split(",");
|
||||
HashSet<UUID> result = new HashSet<UUID>();
|
||||
HashSet<UUID> result = new HashSet<>();
|
||||
for (String name : split) {
|
||||
if (name.length() == 0) {
|
||||
if (name.isEmpty()) {
|
||||
// Invalid
|
||||
return null;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
if (name.equals("*")) {
|
||||
result.add(DBFunc.everyone);
|
||||
@ -711,12 +711,12 @@ public class MainUtil {
|
||||
result.add(UUID.fromString(name));
|
||||
continue;
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
UUID uuid = UUIDHandler.getUUID(name, null);
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
result.add(uuid);
|
||||
}
|
||||
@ -856,9 +856,9 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static void getPersistentMeta(UUID uuid, final String key, final RunnableVal<byte[]> result) {
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||
if (pp != null) {
|
||||
result.run(pp.getPersistentMeta(key));
|
||||
PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
result.run(player.getPersistentMeta(key));
|
||||
} else {
|
||||
DBFunc.dbManager.getPersistentMeta(uuid, new RunnableVal<Map<String, byte[]>>() {
|
||||
@Override
|
||||
|
@ -17,26 +17,26 @@ public class Permissions {
|
||||
/**
|
||||
* Check if a player has a permission (C class helps keep track of permissions).
|
||||
* @param player
|
||||
* @param c
|
||||
* @param caption
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermission(PlotPlayer player, C c) {
|
||||
return hasPermission(player, c.s());
|
||||
public static boolean hasPermission(PlotPlayer player, C caption) {
|
||||
return hasPermission(player, caption.s());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a PlotPlayer has a permission
|
||||
* Check if a {@link PlotPlayer} has a permission.
|
||||
* @param player
|
||||
* @param perm
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermission(PlotPlayer player, String perm) {
|
||||
public static boolean hasPermission(PlotPlayer player, String permission) {
|
||||
if (!Settings.PERMISSION_CACHING) {
|
||||
return hasPermission((CommandCaller) player, perm);
|
||||
return hasPermission((CommandCaller) player, permission);
|
||||
}
|
||||
HashMap<String, Boolean> map = player.getMeta("perm");
|
||||
if (map != null) {
|
||||
Boolean result = map.get(perm);
|
||||
Boolean result = map.get(permission);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
@ -44,19 +44,19 @@ public class Permissions {
|
||||
map = new HashMap<>();
|
||||
player.setMeta("perm", map);
|
||||
}
|
||||
boolean result = hasPermission((CommandCaller) player, perm);
|
||||
map.put(perm, result);
|
||||
boolean result = hasPermission((CommandCaller) player, permission);
|
||||
map.put(permission, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a CommandCaller (PlotPlayer implements CommandCaller) has a permission.
|
||||
* @param player
|
||||
* Check if a {@code CommandCaller} has a permission.
|
||||
* @param caller
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermission(CommandCaller player, String permission) {
|
||||
if (player.hasPermission(permission) || player.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
public static boolean hasPermission(CommandCaller caller, String permission) {
|
||||
if (caller.hasPermission(permission) || caller.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
return true;
|
||||
}
|
||||
permission = permission.toLowerCase().replaceAll("^[^a-z|0-9|\\.|_|-]", "");
|
||||
@ -65,7 +65,7 @@ public class Permissions {
|
||||
for (int i = 0; i <= (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ".");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class SetupUtils {
|
||||
|
||||
public static SetupUtils manager;
|
||||
@ -14,7 +14,7 @@ public abstract class SetupUtils {
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(final PlotArea plotworld) {
|
||||
public String getGenerator(final PlotArea plotArea) {
|
||||
if (SetupUtils.generators.isEmpty()) {
|
||||
updateGenerators();
|
||||
}
|
||||
final World world = SpongeUtil.getWorld(plotworld.worldname);
|
||||
final World world = SpongeUtil.getWorld(plotArea.worldname);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(PlotArea plotworld) {
|
||||
public String getGenerator(PlotArea plotArea) {
|
||||
if (SetupUtils.generators.isEmpty()) {
|
||||
updateGenerators();
|
||||
}
|
||||
World world = SpongeUtil.getWorld(plotworld.worldname);
|
||||
World world = SpongeUtil.getWorld(plotArea.worldname);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user