mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Tweaked some things
This commit is contained in:
parent
da58c7b411
commit
cee970e3d9
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.commands;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
@ -17,6 +18,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.DatFileFilter;
|
||||
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
@ -24,7 +26,6 @@ import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -102,19 +103,12 @@ public class DebugUUID extends SubCommand {
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Collecting playerdata");
|
||||
|
||||
HashSet<String> worlds = new HashSet<>();
|
||||
worlds.add(WorldUtil.IMP.getMainWorld());
|
||||
worlds.add("world");
|
||||
HashSet<String> worlds = Sets.newHashSet(WorldUtil.IMP.getMainWorld(), "world");
|
||||
HashSet<UUID> uuids = new HashSet<>();
|
||||
HashSet<String> names = new HashSet<>();
|
||||
for (String worldName : worlds) {
|
||||
File playerDataFolder = new File(worldName + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
}
|
||||
});
|
||||
String[] dat = playerDataFolder.list(new DatFileFilter());
|
||||
if (dat != null) {
|
||||
for (String current : dat) {
|
||||
String s = current.replaceAll(".dat$", "");
|
||||
@ -127,12 +121,7 @@ public class DebugUUID extends SubCommand {
|
||||
}
|
||||
}
|
||||
File playersFolder = new File(worldName + File.separator + "players");
|
||||
dat = playersFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
}
|
||||
});
|
||||
dat = playersFolder.list(new DatFileFilter());
|
||||
if (dat != null) {
|
||||
for (String current : dat) {
|
||||
names.add(current.replaceAll(".dat$", ""));
|
||||
|
@ -6,9 +6,9 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.io.ByteSink;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.common.primitives.Primitives;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -167,13 +167,13 @@ public class NbtFactory {
|
||||
* @return The decoded NBT compound.
|
||||
* @throws IOException If anything went wrong.
|
||||
*/
|
||||
public static NbtCompound fromStream(InputSupplier<? extends InputStream> stream, StreamOptions option) throws IOException {
|
||||
public static NbtCompound fromStream(ByteSource stream, StreamOptions option) throws IOException {
|
||||
InputStream input = null;
|
||||
DataInputStream data = null;
|
||||
boolean suppress = true;
|
||||
|
||||
try {
|
||||
input = stream.getInput();
|
||||
input = stream.openStream();
|
||||
if (option == StreamOptions.GZIP_COMPRESSION) {
|
||||
data = new DataInputStream(new BufferedInputStream(new GZIPInputStream(input)));
|
||||
} else {
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
public class DatFileFilter implements FilenameFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".dat");
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -21,8 +21,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -90,12 +88,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||
PS.debug("&aFast mode UUID caching enabled!");
|
||||
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
}
|
||||
});
|
||||
String[] dat = playerDataFolder.list(new DatFileFilter());
|
||||
boolean check = all.isEmpty();
|
||||
if (dat != null) {
|
||||
for (String current : dat) {
|
||||
@ -103,16 +96,20 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(s);
|
||||
if (check || all.remove(uuid)) {
|
||||
File file = new File(playerDataFolder + File.separator + current);
|
||||
InputSupplier<FileInputStream> is = com.google.common.io.Files.newInputStreamSupplier(file);
|
||||
File file = new File(playerDataFolder, current);
|
||||
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
long last = (long) bukkit.get("lastPlayed");
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.storeDate(uuid, last);
|
||||
if (!compound.containsKey("bukkit")) {
|
||||
PS.debug("ERROR: Player data does not contain the the key \"bukkit\"");
|
||||
} else {
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
long last = (long) bukkit.get("lastPlayed");
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.storeDate(uuid, last);
|
||||
}
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
}
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -132,21 +129,14 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
toAdd.put(new StringWrapper("*"), DBFunc.everyone);
|
||||
HashSet<String> worlds = new HashSet<>();
|
||||
worlds.add(world);
|
||||
worlds.add("world");
|
||||
HashSet<String> worlds = Sets.newHashSet(world, "world");
|
||||
HashSet<UUID> uuids = new HashSet<>();
|
||||
HashSet<String> names = new HashSet<>();
|
||||
File playerDataFolder = null;
|
||||
for (String worldName : worlds) {
|
||||
// Getting UUIDs
|
||||
playerDataFolder = new File(container, worldName + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
}
|
||||
});
|
||||
String[] dat = playerDataFolder.list(new DatFileFilter());
|
||||
if ((dat != null) && (dat.length != 0)) {
|
||||
for (String current : dat) {
|
||||
String s = current.replaceAll(".dat$", "");
|
||||
@ -161,12 +151,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
// Getting names
|
||||
File playersFolder = new File(worldName + File.separator + "players");
|
||||
dat = playersFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
}
|
||||
});
|
||||
dat = playersFolder.list(new DatFileFilter());
|
||||
if ((dat != null) && (dat.length != 0)) {
|
||||
for (String current : dat) {
|
||||
names.add(current.replaceAll(".dat$", ""));
|
||||
@ -182,22 +167,26 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
long last = (long) bukkit.get("lastPlayed");
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
if (Settings.UUID_LOWERCASE && !name.toLowerCase().equals(name)) {
|
||||
uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name);
|
||||
} else {
|
||||
long most = (long) compound.get("UUIDMost");
|
||||
long least = (long) compound.get("UUIDLeast");
|
||||
uuid = new UUID(most, least);
|
||||
if (!compound.containsKey("bukkit")) {
|
||||
PS.debug("ERROR: Player data does not contain the the key \"bukkit\"");
|
||||
} else {
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
long last = (long) bukkit.get("lastPlayed");
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
if (Settings.UUID_LOWERCASE && !name.toLowerCase().equals(name)) {
|
||||
uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name);
|
||||
} else {
|
||||
long most = (long) compound.get("UUIDMost");
|
||||
long least = (long) compound.get("UUIDLeast");
|
||||
uuid = new UUID(most, least);
|
||||
}
|
||||
}
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.storeDate(uuid, last);
|
||||
}
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
}
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.storeDate(uuid, last);
|
||||
}
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
} catch (Exception ignored) {
|
||||
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ 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(player.getUUID());
|
||||
if (pp == null) {
|
||||
PlotPlayer plotPlayer = UUIDHandler.getPlayer(player.getUUID());
|
||||
if (plotPlayer == null) {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public enum C {
|
||||
MERGE_ACCEPTED("$2The merge request has been accepted", "Merge"),
|
||||
SUCCESS_MERGE("$2Plots have been merged!", "Merge"),
|
||||
MERGE_REQUESTED("$2Successfully sent a merge request", "Merge"),
|
||||
MERGE_REQUEST_CONFIRM("merge request from %s", "Permission"),
|
||||
MERGE_REQUEST_CONFIRM("Merge request from %s", "Permission"),
|
||||
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%", "Merge"),
|
||||
NO_AVAILABLE_AUTOMERGE("$2You do not own any adjacent plots in the specified direction or are not allowed to merge to the required size.",
|
||||
"Merge"),
|
||||
|
@ -100,7 +100,7 @@ public class FlagManager {
|
||||
StringBuilder flag_string = new StringBuilder();
|
||||
int i = 0;
|
||||
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
|
||||
Flag<?> flag = entry.getKey();
|
||||
Flag flag = entry.getKey();
|
||||
if (i != 0) {
|
||||
flag_string.append(',');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user