mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Misc. code changes
A lot of renaming Some formatting Narrowed scope of variables Added annotations
This commit is contained in:
parent
84911c1a8c
commit
b66734a472
@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.bukkit.object;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -19,7 +20,7 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override public UUID getUUID() {
|
||||
@NotNull @Override public UUID getUUID() {
|
||||
return this.player.getUniqueId();
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,12 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -18,8 +23,8 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -55,7 +60,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
||||
}
|
||||
|
||||
@Nonnull @Override public UUID getUUID() {
|
||||
@NotNull @Override public UUID getUUID() {
|
||||
if (this.uuid == null) {
|
||||
this.uuid = UUIDHandler.getUUID(this);
|
||||
}
|
||||
|
@ -13,14 +13,6 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
||||
|
||||
public class OfflinePlayerUtil {
|
||||
|
||||
public static Player loadPlayer(String name) {
|
||||
return loadPlayer(Bukkit.getOfflinePlayer(name));
|
||||
}
|
||||
|
||||
public static Player loadPlayer(UUID id) {
|
||||
return loadPlayer(Bukkit.getOfflinePlayer(id));
|
||||
}
|
||||
|
||||
public static Player loadPlayer(OfflinePlayer player) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
|
@ -26,8 +26,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
public BiomeGrid biomeGrid;
|
||||
public Chunk chunk;
|
||||
public String world;
|
||||
public int cx;
|
||||
public int cz;
|
||||
public int chunkX;
|
||||
public int chunkZ;
|
||||
@Getter @Setter private ChunkData cd = null;
|
||||
|
||||
public GenChunk() {
|
||||
@ -39,7 +39,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
if (chunk == null) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
if (worldObj != null) {
|
||||
this.chunk = worldObj.getChunkAt(cx, cz);
|
||||
this.chunk = worldObj.getChunkAt(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
@ -52,8 +52,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
public void setChunk(ChunkWrapper wrap) {
|
||||
chunk = null;
|
||||
world = wrap.world;
|
||||
cx = wrap.x;
|
||||
cz = wrap.z;
|
||||
chunkX = wrap.x;
|
||||
chunkZ = wrap.z;
|
||||
}
|
||||
|
||||
@Override public void fillBiome(String biomeName) {
|
||||
@ -82,13 +82,13 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
Arrays.fill(data, start, end, block);
|
||||
}
|
||||
}
|
||||
int minx = Math.min(pos1.getX(), pos2.getX());
|
||||
int miny = Math.min(pos1.getY(), pos2.getY());
|
||||
int minz = Math.min(pos1.getZ(), pos2.getZ());
|
||||
int maxx = Math.max(pos1.getX(), pos2.getX());
|
||||
int maxy = Math.max(pos1.getY(), pos2.getY());
|
||||
int maxz = Math.max(pos1.getZ(), pos2.getZ());
|
||||
cd.setRegion(minx, miny, minz, maxx + 1, maxy + 1, maxz + 1, block.to(Material.class));
|
||||
int minX = Math.min(pos1.getX(), pos2.getX());
|
||||
int minY = Math.min(pos1.getY(), pos2.getY());
|
||||
int minZ = Math.min(pos1.getZ(), pos2.getZ());
|
||||
int maxX = Math.max(pos1.getX(), pos2.getX());
|
||||
int maxY = Math.max(pos1.getY(), pos2.getY());
|
||||
int maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
||||
cd.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, block.to(Material.class));
|
||||
}
|
||||
|
||||
@Override public boolean setBiome(int x, int z, String biome) {
|
||||
@ -147,11 +147,11 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return chunk == null ? cx : chunk.getX();
|
||||
return chunk == null ? chunkX : chunk.getX();
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return chunk == null ? cz : chunk.getZ();
|
||||
return chunk == null ? chunkZ : chunk.getZ();
|
||||
}
|
||||
|
||||
@Override public String getWorld() {
|
||||
|
@ -7,13 +7,14 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DefaultUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@Override public UUID getUUID(PlotPlayer player) {
|
||||
@NotNull @Override public UUID getUUID(PlotPlayer player) {
|
||||
return ((BukkitPlayer) player).player.getUniqueId();
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,14 @@ import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
|
||||
@Override public UUID getUUID(PlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
@NotNull @Override public UUID getUUID(PlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override public UUID getUUID(OfflinePlotPlayer player) {
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -33,9 +34,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public UUID getUUID(PlotPlayer player) {
|
||||
return UUID
|
||||
.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
@NotNull @Override public UUID getUUID(PlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override public UUID getUUID(OfflinePlotPlayer player) {
|
||||
|
@ -10,7 +10,11 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -150,10 +154,10 @@ public abstract class Command {
|
||||
this.perm = declaration.permission();
|
||||
this.required = declaration.requiredType();
|
||||
this.category = declaration.category();
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
List<String> aliasOptions = new ArrayList<>();
|
||||
aliasOptions.add(this.id);
|
||||
aliasOptions.addAll(Arrays.asList(declaration.aliases()));
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
options.put("aliases", aliasOptions);
|
||||
options.put("description", declaration.description());
|
||||
options.put("usage", declaration.usage());
|
||||
|
@ -212,10 +212,15 @@ public class ConfigurationSerialization {
|
||||
return result;
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ex) {
|
||||
if (ex instanceof InvocationTargetException) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call method '" + method.toString() + "' of " + this.clazz
|
||||
+ " for deserialization",
|
||||
ex instanceof InvocationTargetException ? ex.getCause() : ex);
|
||||
+ " for deserialization", ex.getCause());
|
||||
} else {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call method '" + method.toString() + "' of " + this.clazz
|
||||
+ " for deserialization", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -226,10 +231,15 @@ public class ConfigurationSerialization {
|
||||
try {
|
||||
return ctor.newInstance(args);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException ex) {
|
||||
if (ex instanceof InvocationTargetException) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
||||
+ " for deserialization",
|
||||
ex instanceof InvocationTargetException ? ex.getCause() : ex);
|
||||
+ " for deserialization", ex.getCause());
|
||||
} else {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
||||
+ " for deserialization", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -5,8 +5,17 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
@ -68,15 +77,15 @@ public class Auto extends SubCommand {
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
* @param schematic
|
||||
*/
|
||||
public static void homeOrAuto(final PlotPlayer player, final PlotArea area, PlotId start,
|
||||
final String schem) {
|
||||
final String schematic) {
|
||||
Set<Plot> plots = player.getPlots();
|
||||
if (!plots.isEmpty()) {
|
||||
plots.iterator().next().teleportPlayer(player);
|
||||
} else {
|
||||
autoClaimSafe(player, area, start, schem);
|
||||
autoClaimSafe(player, area, start, schematic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,11 +95,11 @@ public class Auto extends SubCommand {
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
* @param schematic
|
||||
*/
|
||||
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start,
|
||||
final String schem) {
|
||||
autoClaimSafe(player, area, start, schem, null);
|
||||
final String schematic) {
|
||||
autoClaimSafe(player, area, start, schematic, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,10 +108,10 @@ public class Auto extends SubCommand {
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
* @param schematic
|
||||
*/
|
||||
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start,
|
||||
final String schem, @Nullable final Integer allowedPlots) {
|
||||
final String schematic, @Nullable final Integer allowedPlots) {
|
||||
player.setMeta(Auto.class.getName(), true);
|
||||
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
|
||||
@Override public void run(final Plot plot) {
|
||||
@ -112,7 +121,7 @@ public class Auto extends SubCommand {
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
|
||||
} else if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) {
|
||||
plot.claim(player, true, schem, false);
|
||||
plot.claim(player, true, schematic, false);
|
||||
if (area.AUTO_MERGE) {
|
||||
plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true);
|
||||
}
|
||||
|
@ -36,14 +36,11 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
|
||||
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
|
||||
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE);
|
||||
confirm.run(this, new Runnable() {
|
||||
@Override public void run() {
|
||||
confirm.run(this, () -> {
|
||||
final long start = System.currentTimeMillis();
|
||||
boolean result = plot.clear(true, false, new Runnable() {
|
||||
@Override public void run() {
|
||||
boolean result = plot.clear(true, false, () -> {
|
||||
plot.unlink();
|
||||
GlobalBlockQueue.IMP.addTask(new Runnable() {
|
||||
@Override public void run() {
|
||||
GlobalBlockQueue.IMP.addTask(() -> {
|
||||
plot.removeRunning();
|
||||
// If the state changes, then mark it as no longer done
|
||||
if (plot.getFlag(Flags.DONE).isPresent()) {
|
||||
@ -54,16 +51,13 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
|
||||
}
|
||||
MainUtil.sendMessage(player, Captions.CLEARING_DONE,
|
||||
"" + (System.currentTimeMillis() - start));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
} else {
|
||||
plot.addRunning();
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
@ -466,7 +466,6 @@ import java.util.UUID;
|
||||
PlotSquared.get().getPlots(player.getLocation().getWorld(), uuid))) {
|
||||
PlotCluster current = plot.getCluster();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
player.getLocation().getWorld();
|
||||
plot.unclaim();
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,12 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@CommandDeclaration(command = "condense", permission = "plots.admin",
|
||||
@ -104,6 +108,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, "TASK STARTED...");
|
||||
Condense.TASK = true;
|
||||
Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (!Condense.TASK) {
|
||||
@ -147,7 +152,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
}
|
||||
}
|
||||
};
|
||||
Condense.TASK = true;
|
||||
TaskManager.runTaskAsync(run);
|
||||
return true;
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ import java.util.Map.Entry;
|
||||
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||
plots = new ArrayList<>();
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
String areaname = entry.getKey();
|
||||
PlotArea pa = PlotSquared.get().getPlotAreaByString(areaname);
|
||||
String areaName = entry.getKey();
|
||||
PlotArea pa = PlotSquared.get().getPlotAreaByString(areaName);
|
||||
if (pa != null) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
Plot plot = entry2.getValue();
|
||||
@ -123,9 +123,9 @@ import java.util.Map.Entry;
|
||||
plots.add(plot);
|
||||
}
|
||||
} else {
|
||||
HashMap<PlotId, Plot> plotmap = PlotSquared.get().plots_tmp
|
||||
.computeIfAbsent(areaname, k -> new HashMap<>());
|
||||
plotmap.putAll(entry.getValue());
|
||||
HashMap<PlotId, Plot> plotMap = PlotSquared.get().plots_tmp
|
||||
.computeIfAbsent(areaName, k -> new HashMap<>());
|
||||
plotMap.putAll(entry.getValue());
|
||||
}
|
||||
}
|
||||
DBFunc.createPlotsAndData(plots,
|
||||
|
@ -27,11 +27,11 @@ import java.util.stream.Collectors;
|
||||
extends SubCommand {
|
||||
|
||||
private static String readFile(@NonNull final File file) throws IOException {
|
||||
final StringBuilder content = new StringBuilder();
|
||||
final List<String> lines;
|
||||
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
lines = reader.lines().collect(Collectors.toList());
|
||||
}
|
||||
final StringBuilder content = new StringBuilder();
|
||||
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
|
||||
content.append(lines.get(i)).append("\n");
|
||||
}
|
||||
@ -41,7 +41,6 @@ import java.util.stream.Collectors;
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try {
|
||||
final IncendoPaster incendoPaster = new IncendoPaster("plotsquared");
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(
|
||||
@ -79,6 +78,7 @@ import java.util.stream.Collectors;
|
||||
"\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
|
||||
b.append("\n# or via our Discord at https://discord.gg/ngZCzbU");
|
||||
|
||||
final IncendoPaster incendoPaster = new IncendoPaster("plotsquared");
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("information", b.toString()));
|
||||
|
||||
try {
|
||||
|
@ -8,9 +8,13 @@ import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -44,9 +48,7 @@ import java.util.UUID;
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
Iterator<UUID> iter = uuids.iterator();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
for (UUID uuid : uuids) {
|
||||
if (uuid == DBFunc.EVERYONE && !(
|
||||
Permissions.hasPermission(player, Captions.PERMISSION_DENY_EVERYONE) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DENY))) {
|
||||
|
@ -5,12 +5,22 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared.SortType;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "list", aliases = {"l", "find", "search"}, description = "List plots",
|
||||
permission = "plots.list", category = CommandCategory.INFO,
|
||||
@ -20,7 +30,7 @@ public class ListCmd extends SubCommand {
|
||||
private String[] getArgumentList(PlotPlayer player) {
|
||||
List<String> args = new ArrayList<>();
|
||||
if (EconHandler.manager != null && Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_LIST_FORSALE)) {
|
||||
.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
|
||||
args.add("forsale");
|
||||
}
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_MINE)) {
|
||||
@ -222,9 +232,9 @@ public class ListCmd extends SubCommand {
|
||||
sort = false;
|
||||
break;
|
||||
case "forsale":
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_FORSALE)) {
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_FORSALE);
|
||||
Captions.PERMISSION_LIST_FOR_SALE);
|
||||
return false;
|
||||
}
|
||||
if (EconHandler.manager == null) {
|
||||
|
@ -4,7 +4,11 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
@ -50,9 +54,9 @@ import java.util.List;
|
||||
MainUtil.sendMessage(player, Captions.LOAD_NULL);
|
||||
return false;
|
||||
}
|
||||
String schem;
|
||||
String schematic;
|
||||
try {
|
||||
schem = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
} catch (Exception ignored) {
|
||||
// use /plot load <index>
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER,
|
||||
@ -61,7 +65,7 @@ import java.util.List;
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schem);
|
||||
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, Captions.LOAD_FAILED);
|
||||
@ -70,8 +74,8 @@ import java.util.List;
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
Schematic schematic = SchematicHandler.manager.getSchematic(url);
|
||||
if (schematic == null) {
|
||||
Schematic taskSchematic = SchematicHandler.manager.getSchematic(url);
|
||||
if (taskSchematic == null) {
|
||||
plot.removeRunning();
|
||||
sendMessage(player, Captions.SCHEMATIC_INVALID,
|
||||
"non-existent or not in gzip format");
|
||||
@ -79,7 +83,7 @@ import java.util.List;
|
||||
}
|
||||
PlotArea area = plot.getArea();
|
||||
SchematicHandler.manager
|
||||
.paste(schematic, plot, 0, area.MIN_BUILD_HEIGHT, 0, false,
|
||||
.paste(taskSchematic, plot, 0, area.MIN_BUILD_HEIGHT, 0, false,
|
||||
new RunnableVal<Boolean>() {
|
||||
@Override public void run(Boolean value) {
|
||||
plot.removeRunning();
|
||||
|
@ -44,11 +44,11 @@ import java.util.UUID;
|
||||
int count = 0;
|
||||
switch (args[0]) {
|
||||
case "unknown": {
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
HashSet<UUID> all = new HashSet<>();
|
||||
all.addAll(plot.getMembers());
|
||||
all.addAll(plot.getTrusted());
|
||||
all.addAll(plot.getDenied());
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
for (UUID uuid : all) {
|
||||
if (UUIDHandler.getName(uuid) == null) {
|
||||
toRemove.add(uuid);
|
||||
|
@ -4,9 +4,19 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@ -191,9 +201,7 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
location.getWorld();
|
||||
Collection<Plot> plots = new ArrayList<>();
|
||||
plots.add(plot);
|
||||
ArrayList<Plot> plots = Lists.newArrayList(plot);
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, () -> {
|
||||
MainUtil.sendMessage(player, "&aFinished export");
|
||||
SchematicCmd.this.running = false;
|
||||
@ -212,7 +220,7 @@ public class SchematicCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String string =
|
||||
StringMan.join(SchematicHandler.manager.getShematicNames(), "$2, $1");
|
||||
StringMan.join(SchematicHandler.manager.getSchematicNames(), "$2, $1");
|
||||
Captions.SCHEMATIC_LIST.send(player, string);
|
||||
}
|
||||
break;
|
||||
|
@ -6,7 +6,11 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
@ -345,7 +349,7 @@ import java.util.Map.Entry;
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override public boolean parseInut(String input) {
|
||||
@Override public boolean parseInput(String input) {
|
||||
this.generator = input.toLowerCase();
|
||||
return true;
|
||||
}
|
||||
@ -385,7 +389,7 @@ import java.util.Map.Entry;
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override public boolean parseInut(String input) {
|
||||
@Override public boolean parseInput(String input) {
|
||||
if (!WORLD_TYPES.keySet().contains(input.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
@ -416,7 +420,7 @@ import java.util.Map.Entry;
|
||||
|
||||
public abstract Collection<PlotMessage> showDescriptionMessage();
|
||||
|
||||
public abstract boolean parseInut(String input);
|
||||
public abstract boolean parseInput(String input);
|
||||
|
||||
public final PlotMessage getUsage() {
|
||||
return new PlotMessage("Usage: ").color("$1")
|
||||
|
@ -39,25 +39,25 @@ import java.util.UUID;
|
||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]);
|
||||
Iterator<UUID> iter = uuids.iterator();
|
||||
Iterator<UUID> iterator = uuids.iterator();
|
||||
int size = currentPlot.getTrusted().size() + currentPlot.getMembers().size();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
while (iterator.hasNext()) {
|
||||
UUID uuid = iterator.next();
|
||||
if (uuid == DBFunc.EVERYONE && !(
|
||||
Permissions.hasPermission(player, Captions.PERMISSION_TRUST_EVERYONE) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST))) {
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (currentPlot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (currentPlot.getTrusted().contains(uuid)) {
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
size += currentPlot.getMembers().contains(uuid) ? 0 : 1;
|
||||
|
@ -125,8 +125,8 @@ public enum Captions {
|
||||
PERMISSION_FLAG_ADD("plots.flag.add", "static.permissions"),
|
||||
PERMISSION_FLAG_LIST("plots.flag.list", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_KICK("plots.admin.command.kick", "static.permissions"),
|
||||
PERMISSION_GRANT("plots.grant.%s0", "static.permissions"),
|
||||
PERMISSION_LIST_FORSALE("plots.list.forsale", "static.permissions"),
|
||||
PERMISSION_GRANT("plots.grant.%s0", "static.permissions"), PERMISSION_LIST_FOR_SALE(
|
||||
"plots.list.forsale", "static.permissions"),
|
||||
PERMISSION_LIST_MINE("plots.list.mine", "static.permissions"),
|
||||
PERMISSION_LIST_SHARED("plots.list.shared", "static.permissions"),
|
||||
PERMISSION_LIST_WORLD("plots.list.world", "static.permissions"),
|
||||
@ -211,37 +211,25 @@ public enum Captions {
|
||||
CLUSTER_AVAILABLE_ARGS(
|
||||
"$1The following sub commands are available: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, "
|
||||
+ "$4members$2, $4info$2, $4tp$2, $4sethome", "Cluster"), CLUSTER_LIST_HEADING(
|
||||
"$2There are $1%s$2 clusters in this world", "Cluster"),
|
||||
|
||||
CLUSTER_LIST_ELEMENT("$2 - $1%s&-", "Cluster"), CLUSTER_INTERSECTION(
|
||||
"$2The proposed area overlaps with: %s0", "Cluster"),
|
||||
|
||||
CLUSTER_OUTSIDE("$2The proposed area is outside the plot area: %s0", "Cluster"), CLUSTER_ADDED(
|
||||
"$4Successfully created the cluster.", "Cluster"),
|
||||
|
||||
CLUSTER_DELETED("$4Successfully deleted the cluster.", "Cluster"), CLUSTER_RESIZED(
|
||||
"$4Successfully resized the cluster.", "Cluster"),
|
||||
|
||||
CLUSTER_ADDED_USER("$4Successfully added user to the cluster.", "Cluster"), CANNOT_KICK_PLAYER(
|
||||
"$2You cannot kick that player", "Cluster"),
|
||||
|
||||
CLUSTER_INVITED("$1You have been invited to the following cluster: $2%s",
|
||||
"Cluster"), CLUSTER_REMOVED("$1You have been removed from cluster: $2%s", "Cluster"),
|
||||
|
||||
CLUSTER_KICKED_USER("$4Successfully kicked the user", "Cluster"), INVALID_CLUSTER(
|
||||
"$1Invalid cluster name: $2%s", "Cluster"),
|
||||
|
||||
CLUSTER_NOT_ADDED("$2That player was not added to the plot cluster",
|
||||
"Cluster"), CLUSTER_CANNOT_LEAVE("$1You must delete or transfer ownership before leaving",
|
||||
"Cluster"),
|
||||
|
||||
CLUSTER_ADDED_HELPER("$4Successfully added a helper to the cluster",
|
||||
"$2There are $1%s$2 clusters in this world", "Cluster"), CLUSTER_LIST_ELEMENT("$2 - $1%s&-",
|
||||
"Cluster"), CLUSTER_INTERSECTION(
|
||||
"$2The proposed area overlaps with: %s0", "Cluster"), CLUSTER_OUTSIDE(
|
||||
"$2The proposed area is outside the plot area: %s0", "Cluster"), CLUSTER_ADDED(
|
||||
"$4Successfully created the cluster.", "Cluster"), CLUSTER_DELETED(
|
||||
"$4Successfully deleted the cluster.", "Cluster"), CLUSTER_RESIZED(
|
||||
"$4Successfully resized the cluster.", "Cluster"), CLUSTER_ADDED_USER(
|
||||
"$4Successfully added user to the cluster.", "Cluster"), CANNOT_KICK_PLAYER(
|
||||
"$2You cannot kick that player", "Cluster"), CLUSTER_INVITED(
|
||||
"$1You have been invited to the following cluster: $2%s", "Cluster"), CLUSTER_REMOVED(
|
||||
"$1You have been removed from cluster: $2%s", "Cluster"), CLUSTER_KICKED_USER(
|
||||
"$4Successfully kicked the user", "Cluster"), INVALID_CLUSTER(
|
||||
"$1Invalid cluster name: $2%s", "Cluster"), CLUSTER_NOT_ADDED(
|
||||
"$2That player was not added to the plot cluster", "Cluster"), CLUSTER_CANNOT_LEAVE(
|
||||
"$1You must delete or transfer ownership before leaving",
|
||||
"Cluster"), CLUSTER_ADDED_HELPER("$4Successfully added a helper to the cluster",
|
||||
"Cluster"), CLUSTER_REMOVED_HELPER("$4Successfully removed a helper from the cluster",
|
||||
"Cluster"),
|
||||
|
||||
CLUSTER_REGENERATED("$4Successfully started cluster regeneration",
|
||||
"Cluster"), CLUSTER_REGENERATED("$4Successfully started cluster regeneration",
|
||||
"Cluster"), CLUSTER_TELEPORTING("$4Teleporting...", "Cluster"),
|
||||
|
||||
CLUSTER_INFO(
|
||||
"$1Current cluster: $2%id%&-$1Name: $2%name%&-$1Owner: $2%owner%&-$1Size: $2%size%&-$1Rights: $2%rights%",
|
||||
"Cluster"),
|
||||
|
@ -308,7 +308,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
PlotSquared.debug("============ DATABASE ERROR ============");
|
||||
PlotSquared.debug("There was an error updating the database.");
|
||||
PlotSquared.debug(" - It will be corrected on shutdown");
|
||||
PlotSquared.debug("========================================");
|
||||
e.printStackTrace();
|
||||
PlotSquared.debug("========================================");
|
||||
}
|
||||
@ -326,15 +325,15 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
PreparedStatement statement = null;
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
Iterator<Entry<Plot, Queue<UniqueStatement>>> iter =
|
||||
Iterator<Entry<Plot, Queue<UniqueStatement>>> iterator =
|
||||
this.plotTasks.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
Entry<Plot, Queue<UniqueStatement>> entry = iter.next();
|
||||
Entry<Plot, Queue<UniqueStatement>> entry = iterator.next();
|
||||
Plot plot = entry.getKey();
|
||||
Queue<UniqueStatement> tasks = entry.getValue();
|
||||
if (tasks.isEmpty()) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
task = tasks.remove();
|
||||
@ -352,7 +351,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
try {
|
||||
if (statement != null && statement.isClosed()) {
|
||||
if (statement.isClosed()) {
|
||||
statement = null;
|
||||
}
|
||||
} catch (AbstractMethodError ignore) {
|
||||
@ -1615,17 +1614,17 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
PlotId plot_id = new PlotId(resultSet.getInt("plot_id_x"),
|
||||
resultSet.getInt("plot_id_z"));
|
||||
id = resultSet.getInt("id");
|
||||
String areaid = resultSet.getString("world");
|
||||
if (!areas.contains(areaid)) {
|
||||
String areaID = resultSet.getString("world");
|
||||
if (!areas.contains(areaID)) {
|
||||
if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||
toDelete.add(id);
|
||||
continue;
|
||||
} else {
|
||||
AtomicInteger value = noExist.get(areaid);
|
||||
AtomicInteger value = noExist.get(areaID);
|
||||
if (value != null) {
|
||||
value.incrementAndGet();
|
||||
} else {
|
||||
noExist.put(areaid, new AtomicInteger(1));
|
||||
noExist.put(areaID, new AtomicInteger(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1657,7 +1656,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
.getTime();
|
||||
} catch (ParseException e) {
|
||||
PlotSquared.debug(
|
||||
"Could not parse date for plot: #" + id + "(" + areaid + ";"
|
||||
"Could not parse date for plot: #" + id + "(" + areaID + ";"
|
||||
+ plot_id + ") (" + parsable + ")");
|
||||
time = System.currentTimeMillis() + id;
|
||||
}
|
||||
@ -1665,7 +1664,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
Plot p = new Plot(plot_id, user, new HashSet<>(), new HashSet<>(),
|
||||
new HashSet<>(), "", null, null, null,
|
||||
new boolean[] {false, false, false, false}, time, id);
|
||||
HashMap<PlotId, Plot> map = newPlots.get(areaid);
|
||||
HashMap<PlotId, Plot> map = newPlots.get(areaID);
|
||||
if (map != null) {
|
||||
Plot last = map.put(p.getId(), p);
|
||||
if (last != null) {
|
||||
@ -1679,7 +1678,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
}
|
||||
} else {
|
||||
map = new HashMap<>();
|
||||
newPlots.put(areaid, map);
|
||||
newPlots.put(areaID, map);
|
||||
map.put(p.getId(), p);
|
||||
}
|
||||
plots.put(id, p);
|
||||
|
@ -1,7 +1,12 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.generator;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
@ -49,7 +54,7 @@ public class AugmentedUtils {
|
||||
queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
}
|
||||
LocalBlockQueue primaryMask;
|
||||
// coords
|
||||
// coordinates
|
||||
int bxx;
|
||||
int bzz;
|
||||
int txx;
|
||||
|
@ -3,14 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.Template;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
@ -18,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -32,12 +26,11 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
new FileBytes(Settings.Paths.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(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem");
|
||||
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator
|
||||
+ "__TEMP_DIR__" + File.separator;
|
||||
if (sideroad.exists()) {
|
||||
files.add(new FileBytes(newDir + "sideroad.schem",
|
||||
Files.readAllBytes(sideroad.toPath())));
|
||||
|
@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.plot.listener;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
@ -68,7 +72,6 @@ public class WEManager {
|
||||
}
|
||||
boolean allowMember = player.hasPermission("plots.worldedit.member");
|
||||
Plot plot = player.getCurrentPlot();
|
||||
HashSet<RegionWrapper> allowed = new HashSet<>();
|
||||
if (plot == null) {
|
||||
plot = player.getMeta("WorldEditRegionPlot");
|
||||
}
|
||||
|
@ -166,16 +166,16 @@ import java.util.Map.Entry;
|
||||
compile();
|
||||
}
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
Iterator<Entry<PlotBlock, Double>> iter = blocks.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entry<PlotBlock, Double> entry = iter.next();
|
||||
Iterator<Entry<PlotBlock, Double>> iterator = blocks.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<PlotBlock, Double> entry = iterator.next();
|
||||
PlotBlock block = entry.getKey();
|
||||
builder.append(block.getRawId());
|
||||
Double weight = entry.getValue();
|
||||
if (weight != 1) {
|
||||
builder.append(":").append(weight.intValue());
|
||||
}
|
||||
if (iter.hasNext()) {
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(",");
|
||||
}
|
||||
}
|
||||
|
@ -2220,13 +2220,13 @@ public class Plot {
|
||||
if (!EventUtil.manager.callMerge(this, dir, max)) {
|
||||
return false;
|
||||
}
|
||||
HashSet<Plot> visited = new HashSet<>();
|
||||
HashSet<PlotId> merged;
|
||||
Set<Plot> connected = this.getConnectedPlots();
|
||||
merged = connected.stream().map(Plot::getId).collect(Collectors.toCollection(HashSet::new));
|
||||
HashSet<PlotId> merged =
|
||||
connected.stream().map(Plot::getId).collect(Collectors.toCollection(HashSet::new));
|
||||
ArrayDeque<Plot> frontier = new ArrayDeque<>(connected);
|
||||
Plot current;
|
||||
boolean toReturn = false;
|
||||
HashSet<Plot> visited = new HashSet<>();
|
||||
while ((current = frontier.poll()) != null && max >= 0) {
|
||||
if (visited.contains(current)) {
|
||||
continue;
|
||||
@ -2421,10 +2421,10 @@ public class Plot {
|
||||
regions_cache = null;
|
||||
|
||||
HashSet<Plot> tmpSet = new HashSet<>();
|
||||
ArrayDeque<Plot> frontier = new ArrayDeque<>();
|
||||
HashSet<Object> queuecache = new HashSet<>();
|
||||
tmpSet.add(this);
|
||||
Plot tmp;
|
||||
HashSet<Object> queuecache = new HashSet<>();
|
||||
ArrayDeque<Plot> frontier = new ArrayDeque<>();
|
||||
if (merged[0]) {
|
||||
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH));
|
||||
if (!tmp.getMerged(Direction.SOUTH)) {
|
||||
@ -2923,6 +2923,26 @@ public class Plot {
|
||||
plot.swapData(other, null);
|
||||
}
|
||||
// copy terrain
|
||||
if (occupied) {
|
||||
Runnable swap = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (regions.isEmpty()) {
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
Location pos3 = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
Location pos4 = pos2.clone().add(offsetX, 0, offsetZ);
|
||||
pos3.setWorld(destination.getWorldName());
|
||||
pos4.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.swap(pos1, pos2, pos3, pos4, this);
|
||||
}
|
||||
};
|
||||
swap.run();
|
||||
} else {
|
||||
Runnable move = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (regions.isEmpty()) {
|
||||
@ -2948,26 +2968,6 @@ public class Plot {
|
||||
() -> ChunkManager.manager.regenerateRegion(pos1, pos2, false, task));
|
||||
}
|
||||
};
|
||||
Runnable swap = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (regions.isEmpty()) {
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
Location pos3 = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
Location pos4 = pos2.clone().add(offsetX, 0, offsetZ);
|
||||
pos3.setWorld(destination.getWorldName());
|
||||
pos4.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.swap(pos1, pos2, pos3, pos4, this);
|
||||
}
|
||||
};
|
||||
if (occupied) {
|
||||
swap.run();
|
||||
} else {
|
||||
move.run();
|
||||
}
|
||||
return true;
|
||||
|
@ -10,7 +10,12 @@ import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
@ -844,11 +849,10 @@ public abstract class PlotArea {
|
||||
return false;
|
||||
}
|
||||
|
||||
manager.startPlotMerge(this, plotIds);
|
||||
final Set<UUID> trusted = new HashSet<>();
|
||||
final Set<UUID> members = new HashSet<>();
|
||||
final Set<UUID> denied = new HashSet<>();
|
||||
|
||||
manager.startPlotMerge(this, plotIds);
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
PlotId id = new PlotId(x, y);
|
||||
|
@ -50,21 +50,21 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
// Duplicate 0;0
|
||||
if (setup.type != 0) {
|
||||
File container = PlotSquared.imp().getWorldContainer();
|
||||
File dest = new File(container, worldName);
|
||||
if (!dest.exists()) {
|
||||
File destination = new File(container, worldName);
|
||||
if (!destination.exists()) {
|
||||
File src = new File(container, "0,0");
|
||||
if (src.exists()) {
|
||||
if (!dest.exists()) {
|
||||
dest.mkdirs();
|
||||
if (!destination.exists()) {
|
||||
destination.mkdirs();
|
||||
}
|
||||
File levelDat = new File(src, "level.dat");
|
||||
if (levelDat.exists()) {
|
||||
try {
|
||||
Files.copy(levelDat.toPath(),
|
||||
new File(dest, levelDat.getName()).toPath());
|
||||
new File(destination, levelDat.getName()).toPath());
|
||||
File data = new File(src, "data");
|
||||
if (data.exists()) {
|
||||
File dataDest = new File(dest, "data");
|
||||
File dataDest = new File(destination, "data");
|
||||
dataDest.mkdirs();
|
||||
for (File file : data.listFiles()) {
|
||||
Files.copy(file.toPath(),
|
||||
|
@ -35,8 +35,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
return true;
|
||||
}
|
||||
int mode = 0;
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char c = chars[i];
|
||||
for (char c : chars) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
mode = 1;
|
||||
|
@ -1,6 +1,11 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@ -47,7 +52,6 @@ public class HastebinUtility {
|
||||
}
|
||||
|
||||
public static String upload(final File file) throws IOException {
|
||||
final StringBuilder content = new StringBuilder();
|
||||
List<String> lines = new ArrayList<>();
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
@ -56,6 +60,7 @@ public class HastebinUtility {
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
final StringBuilder content = new StringBuilder();
|
||||
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
|
||||
content.append(lines.get(i)).append("\n");
|
||||
}
|
||||
|
@ -399,8 +399,6 @@ public class MainUtil {
|
||||
|
||||
List<UUID> uuids = new ArrayList<>();
|
||||
PlotId id = null;
|
||||
PlotArea area = null;
|
||||
String alias = null;
|
||||
|
||||
for (String term : split) {
|
||||
try {
|
||||
@ -418,6 +416,8 @@ public class MainUtil {
|
||||
IntStream.range(0, size).mapToObj(i -> new ArrayList<Plot>())
|
||||
.collect(Collectors.toCollection(() -> new ArrayList<>(size)));
|
||||
|
||||
PlotArea area = null;
|
||||
String alias = null;
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
int count = 0;
|
||||
if (!uuids.isEmpty()) {
|
||||
|
@ -1,7 +1,15 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.util;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author DPOH-VAR
|
||||
@ -137,21 +145,22 @@ public class ReflectionUtils {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) {
|
||||
public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... parameterTypes) {
|
||||
try {
|
||||
return (Constructor<T>) clazz.getConstructor(paramaterTypes);
|
||||
return (Constructor<T>) clazz.getConstructor(parameterTypes);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
//todo print a constructor not found method
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T callConstructor(Constructor<T> constructor, Object... paramaters) {
|
||||
public static <T> T callConstructor(Constructor<T> constructor, Object... parameters) {
|
||||
if (constructor == null) {
|
||||
throw new RuntimeException("No such constructor");
|
||||
}
|
||||
constructor.setAccessible(true);
|
||||
try {
|
||||
return constructor.newInstance(paramaters);
|
||||
return constructor.newInstance(parameters);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex.getCause());
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException ex) {
|
||||
|
@ -7,12 +7,25 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.ClassicPlotWorld;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.*;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
@ -267,7 +280,7 @@ public abstract class SchematicHandler {
|
||||
*
|
||||
* @return Immutable collection with schematic names
|
||||
*/
|
||||
public Collection<String> getShematicNames() {
|
||||
public Collection<String> getSchematicNames() {
|
||||
final File parent =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.SCHEMATICS);
|
||||
final List<String> names = new ArrayList<>();
|
||||
|
@ -9,8 +9,9 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||
import com.google.common.collect.BiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -85,7 +86,7 @@ public class UUIDHandler {
|
||||
implementation.add(toAdd);
|
||||
}
|
||||
|
||||
@Nonnull public static UUID getUUID(PlotPlayer player) {
|
||||
@NotNull public static UUID getUUID(PlotPlayer player) {
|
||||
return implementation.getUUID(player);
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ public class UUIDHandler {
|
||||
return implementation.getUUID(player);
|
||||
}
|
||||
|
||||
public static String getName(UUID uuid) {
|
||||
@Nullable public static String getName(UUID uuid) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
@ -120,13 +121,13 @@ public class UUIDHandler {
|
||||
return check(implementation.getPlayer(name));
|
||||
}
|
||||
|
||||
private static PlotPlayer check(PlotPlayer plr) {
|
||||
if (plr != null && !plr.isOnline()) {
|
||||
UUIDHandler.getPlayers().remove(plr.getName());
|
||||
PlotSquared.get().IMP.unregister(plr);
|
||||
plr = null;
|
||||
private static PlotPlayer check(@Nullable PlotPlayer player) {
|
||||
if (player != null && !player.isOnline()) {
|
||||
UUIDHandler.getPlayers().remove(player.getName());
|
||||
PlotSquared.get().IMP.unregister(player);
|
||||
player = null;
|
||||
}
|
||||
return plr;
|
||||
return player;
|
||||
}
|
||||
|
||||
public static UUID getUUIDFromString(String nameOrUUIDString) {
|
||||
|
@ -4,13 +4,23 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class UUIDHandlerImplementation {
|
||||
@ -216,7 +226,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
this.uuidMap.clear();
|
||||
}
|
||||
|
||||
public String getName(UUID uuid) {
|
||||
@Nullable public String getName(UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
@ -227,7 +237,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
@Nullable public UUID getUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
if (name.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@ -255,7 +265,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getUUID(PlotPlayer player) {
|
||||
@NotNull public UUID getUUID(PlotPlayer player) {
|
||||
return this.uuidWrapper.getUUID(player);
|
||||
}
|
||||
|
||||
@ -263,7 +273,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
return this.uuidWrapper.getUUID(player);
|
||||
}
|
||||
|
||||
public PlotPlayer getPlayer(UUID uuid) {
|
||||
@Nullable public PlotPlayer getPlayer(UUID uuid) {
|
||||
String name = getName(uuid);
|
||||
if (name != null) {
|
||||
return getPlayer(name);
|
||||
|
@ -3,9 +3,17 @@ package com.github.intellectualsites.plotsquared.plot.util;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -66,7 +74,6 @@ public abstract class WorldUtil {
|
||||
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
||||
File dat = getDat(plot.getWorldName());
|
||||
Location spawn = getSpawn(plot.getWorldName());
|
||||
byte[] buffer = new byte[1024];
|
||||
if (dat != null) {
|
||||
ZipEntry ze = new ZipEntry("world" + File.separator + dat.getName());
|
||||
zos.putNextEntry(ze);
|
||||
@ -89,6 +96,7 @@ public abstract class WorldUtil {
|
||||
}
|
||||
}
|
||||
setSpawn(spawn);
|
||||
byte[] buffer = new byte[1024];
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
Location bot = current.getBottomAbs();
|
||||
Location top = current.getTopAbs();
|
||||
@ -107,12 +115,12 @@ public abstract class WorldUtil {
|
||||
"world" + File.separator + "region" + File.separator
|
||||
+ name);
|
||||
zos.putNextEntry(ze);
|
||||
final FileInputStream in = new FileInputStream(file);
|
||||
try (FileInputStream in = new FileInputStream(file)) {
|
||||
int len;
|
||||
while ((len = in.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
|
@ -81,8 +81,7 @@ public class GlobalBlockQueue {
|
||||
return false;
|
||||
}
|
||||
running.set(true);
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override public void run() {
|
||||
TaskManager.runTaskRepeat(() -> {
|
||||
if (inactiveQueues.isEmpty() && activeQueues.isEmpty()) {
|
||||
lastSuccess = System.currentTimeMillis();
|
||||
tasks();
|
||||
@ -127,7 +126,6 @@ public class GlobalBlockQueue {
|
||||
// Enable it again (note that we are still on the main thread)
|
||||
SET_TASK.value2.endSet(true);
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -169,13 +169,12 @@ public class ExpireManager {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
boolean shouldCheckAccountAge = false;
|
||||
|
||||
long diff = getAge(plot);
|
||||
if (diff == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// Filter out non old plots
|
||||
boolean shouldCheckAccountAge = false;
|
||||
for (int i = 0; i < applicable.size(); i++) {
|
||||
ExpiryTask et = applicable.poll();
|
||||
if (et.applies(diff)) {
|
||||
|
@ -2,12 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.uuid;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class UUIDWrapper {
|
||||
|
||||
public abstract UUID getUUID(PlotPlayer player);
|
||||
@NotNull public abstract UUID getUUID(PlotPlayer player);
|
||||
|
||||
public abstract UUID getUUID(OfflinePlotPlayer player);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user