mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Reformat
This commit is contained in:
parent
11c4a90cc9
commit
477e698f7e
@ -5,7 +5,10 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.Statistic.Type;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
|
@ -84,8 +84,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||
PlotSquared.debug("&aFast mode UUID caching enabled!");
|
||||
File playerDataFolder =
|
||||
new File(container, world + File.separator + "playerdata");
|
||||
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new DatFileFilter());
|
||||
boolean check = all.isEmpty();
|
||||
if (dat != null) {
|
||||
@ -127,8 +126,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
PlotSquared.debug("Failed to cache: " + all.size()
|
||||
+ " uuids - slowly processing all files");
|
||||
PlotSquared.debug(
|
||||
"Failed to cache: " + all.size() + " uuids - slowly processing all files");
|
||||
}
|
||||
}
|
||||
HashSet<String> worlds1 = Sets.newHashSet(world, "world");
|
||||
@ -137,8 +136,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
File playerDataFolder = null;
|
||||
for (String worldName : worlds1) {
|
||||
// Getting UUIDs
|
||||
playerDataFolder =
|
||||
new File(container, worldName + File.separator + "playerdata");
|
||||
playerDataFolder = new File(container, worldName + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new DatFileFilter());
|
||||
if ((dat != null) && (dat.length != 0)) {
|
||||
for (String current : dat) {
|
||||
@ -212,8 +210,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
|
||||
if (getUUIDMap().isEmpty()) {
|
||||
for (OfflinePlotPlayer op : FileUUIDHandler.this.uuidWrapper
|
||||
.getOfflinePlayers()) {
|
||||
for (OfflinePlotPlayer op : FileUUIDHandler.this.uuidWrapper.getOfflinePlayers()) {
|
||||
long last = op.getLastPlayed();
|
||||
if (last != 0) {
|
||||
String name = op.getName();
|
||||
|
@ -73,14 +73,12 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try {
|
||||
HashBiMap<StringWrapper, UUID> toAdd =
|
||||
HashBiMap.create(new HashMap<>());
|
||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<>());
|
||||
try (PreparedStatement statement = getConnection()
|
||||
.prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
|
||||
ResultSet resultSet = statement.executeQuery()) {
|
||||
while (resultSet.next()) {
|
||||
StringWrapper username =
|
||||
new StringWrapper(resultSet.getString("username"));
|
||||
StringWrapper username = new StringWrapper(resultSet.getString("username"));
|
||||
UUID uuid = UUID.fromString(resultSet.getString("uuid"));
|
||||
toAdd.put(new StringWrapper(username.value), uuid);
|
||||
}
|
||||
@ -99,8 +97,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
return;
|
||||
}
|
||||
FileUUIDHandler fileHandler =
|
||||
new FileUUIDHandler(SQLUUIDHandler.this.uuidWrapper);
|
||||
FileUUIDHandler fileHandler = new FileUUIDHandler(SQLUUIDHandler.this.uuidWrapper);
|
||||
fileHandler.startCaching(() -> {
|
||||
// If the file based UUID handler didn't cache it, then we can't cache offline mode
|
||||
// Also, trying to cache based on files again, is useless as that's what the file based uuid cacher does
|
||||
@ -203,13 +200,12 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
// Ignoring duplicates
|
||||
if (super.add(name, uuid)) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(
|
||||
"REPLACE INTO usercache (`uuid`, `username`) VALUES(?, ?)")) {
|
||||
try (PreparedStatement statement = getConnection()
|
||||
.prepareStatement("REPLACE INTO usercache (`uuid`, `username`) VALUES(?, ?)")) {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, name.toString());
|
||||
statement.execute();
|
||||
PlotSquared
|
||||
.debug(C.PREFIX + "&cAdded '&6" + uuid + "&c' - '&6" + name + "&c'");
|
||||
PlotSquared.debug(C.PREFIX + "&cAdded '&6" + uuid + "&c' - '&6" + name + "&c'");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -230,8 +226,8 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
statement.setString(1, name.value);
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.execute();
|
||||
PlotSquared.debug(
|
||||
C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + '\'');
|
||||
PlotSquared
|
||||
.debug(C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + '\'');
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
import org.ajoberstar.grgit.Grgit
|
||||
|
||||
dependencies {
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'org.yaml:snakeyaml:1.23'
|
||||
|
@ -49,8 +49,7 @@ import java.util.zip.ZipInputStream;
|
||||
* An implementation of the core, with a static getter for easy access.
|
||||
*/
|
||||
@SuppressWarnings({"unused", "WeakerAccess"}) public class PlotSquared {
|
||||
private static final Set<Plot> EMPTY_SET =
|
||||
Collections.unmodifiableSet(Collections.emptySet());
|
||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
||||
private static PlotSquared instance;
|
||||
// Implementation
|
||||
public final IPlotMain IMP;
|
||||
@ -1143,9 +1142,8 @@ import java.util.zip.ZipInputStream;
|
||||
PlotSquared.log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
|
||||
if (type == 2) {
|
||||
Set<PlotCluster> clusters = this.clusters_tmp != null ?
|
||||
this.clusters_tmp.get(world) :
|
||||
new HashSet<>();
|
||||
Set<PlotCluster> clusters =
|
||||
this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<>();
|
||||
if (clusters == null) {
|
||||
throw new IllegalArgumentException("No cluster exists for world: " + world);
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(command = "auto", permission = "plots.auto", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]")
|
||||
@CommandDeclaration(command = "auto", permission = "plots.auto",
|
||||
category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE,
|
||||
description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]")
|
||||
public class Auto extends SubCommand {
|
||||
|
||||
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
|
||||
|
@ -10,7 +10,9 @@ import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
|
||||
@CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim")
|
||||
@CommandDeclaration(command = "claim", aliases = "c",
|
||||
description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim")
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
|
@ -13,8 +13,10 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandDeclaration(command = "inbox", description = "Review the comments for a plot", usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox", category = CommandCategory.CHAT, requiredType = RequiredType.NONE)
|
||||
public class Inbox extends SubCommand {
|
||||
@CommandDeclaration(command = "inbox", description = "Review the comments for a plot",
|
||||
usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox",
|
||||
category = CommandCategory.CHAT, requiredType = RequiredType.NONE) public class Inbox
|
||||
extends SubCommand {
|
||||
|
||||
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
||||
if (oldComments == null || oldComments.isEmpty()) {
|
||||
|
@ -18,8 +18,11 @@ import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]", command = "purge", permission = "plots.admin", description = "Purge all plots for a world", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE, confirmation = true)
|
||||
public class Purge extends SubCommand {
|
||||
@CommandDeclaration(
|
||||
usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]",
|
||||
command = "purge", permission = "plots.admin", description = "Purge all plots for a world",
|
||||
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE,
|
||||
confirmation = true) public class Purge extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
|
@ -10,8 +10,10 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot",
|
||||
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO,
|
||||
|
@ -27,22 +27,19 @@ public class PlotSettings {
|
||||
* @deprecated Raw access
|
||||
*/
|
||||
@Deprecated public String alias = "";
|
||||
|
||||
private List<PlotComment> comments = null;
|
||||
|
||||
/**
|
||||
* The ratings for a plot.
|
||||
*
|
||||
* @deprecated Raw access
|
||||
*/
|
||||
@Deprecated public HashMap<UUID, Integer> ratings;
|
||||
|
||||
/**
|
||||
* Flags.
|
||||
*
|
||||
* @deprecated Raw access
|
||||
*/
|
||||
@Deprecated public HashMap<Flag<?>, Object> flags = new HashMap<>();
|
||||
private List<PlotComment> comments = null;
|
||||
/**
|
||||
* Home Position.
|
||||
*
|
||||
|
@ -240,8 +240,8 @@ public abstract class ChunkManager {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
for (ChunkLoc loc : chunks) {
|
||||
String directory =
|
||||
world + File.separator + "region" + File.separator + "r." + loc.x + "."
|
||||
+ loc.z + ".mca";
|
||||
world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z
|
||||
+ ".mca";
|
||||
File file = new File(PlotSquared.get().IMP.getWorldContainer(), directory);
|
||||
PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
|
||||
if (file.exists()) {
|
||||
|
@ -31,8 +31,7 @@ public class CommentManager {
|
||||
if (value != null) {
|
||||
int num = 0;
|
||||
for (PlotComment comment : value) {
|
||||
if (comment.timestamp > getTimestamp(player,
|
||||
inbox.toString())) {
|
||||
if (comment.timestamp > getTimestamp(player, inbox.toString())) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class UUIDHandlerImplementation {
|
||||
|
||||
private final ConcurrentHashMap<String, PlotPlayer> players;
|
||||
public final HashSet<UUID> unknown = new HashSet<>();
|
||||
private final ConcurrentHashMap<String, PlotPlayer> players;
|
||||
protected UUIDWrapper uuidWrapper;
|
||||
private boolean cached = false;
|
||||
private BiMap<StringWrapper, UUID> uuidMap =
|
||||
HashBiMap.create(new HashMap<>());
|
||||
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<>());
|
||||
// private BiMap<UUID, StringWrapper> nameMap = uuidMap.inverse();
|
||||
|
||||
public UUIDHandlerImplementation(UUIDWrapper wrapper) {
|
||||
@ -138,8 +137,8 @@ public abstract class UUIDHandlerImplementation {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
UUID offlineUpper = UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
|
||||
if (UUIDHandlerImplementation.this.unknown.contains(offlineUpper)
|
||||
&& !offlineUpper.equals(uuid)) {
|
||||
if (UUIDHandlerImplementation.this.unknown.contains(offlineUpper) && !offlineUpper
|
||||
.equals(uuid)) {
|
||||
UUIDHandlerImplementation.this.unknown.remove(offlineUpper);
|
||||
Set<Plot> plots = PlotSquared.get().getPlotsAbs(offlineUpper);
|
||||
if (!plots.isEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user