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