mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Don't use keyset on ConcurrentHashMap
This commit is contained in:
parent
160ac794e1
commit
8040e13919
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>3.0.14</version>
|
<version>3.0.15</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -11,8 +11,6 @@ import java.net.URL;
|
|||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DatabaseMetaData;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -952,7 +950,7 @@ public class PS {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
public ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
||||||
ArrayList<Plot> newPlots = new ArrayList<>();
|
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||||
ArrayList<String> worlds = new ArrayList<>(this.plots.keySet());
|
ArrayList<String> worlds = new ArrayList<>(this.plotworlds.keySet());
|
||||||
HashSet<Plot> set = new HashSet<>(plots);
|
HashSet<Plot> set = new HashSet<>(plots);
|
||||||
Collections.sort(worlds);
|
Collections.sort(worlds);
|
||||||
for (String world : worlds) {
|
for (String world : worlds) {
|
||||||
@ -1034,7 +1032,7 @@ public class PS {
|
|||||||
* @return A String array of the plot world names
|
* @return A String array of the plot world names
|
||||||
*/
|
*/
|
||||||
public String[] getPlotWorldsString() {
|
public String[] getPlotWorldsString() {
|
||||||
final Set<String> strings = plots.keySet();
|
final Set<String> strings = plotworlds.keySet();
|
||||||
return strings.toArray(new String[strings.size()]);
|
return strings.toArray(new String[strings.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1103,9 +1101,10 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(final UUID uuid) {
|
public Set<Plot> getPlots(final UUID uuid) {
|
||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (final String world : plots.keySet()) {
|
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
if (isPlotWorld(world)) {
|
if (isPlotWorld(entry.getKey())) {
|
||||||
for (final Plot plot : plots.get(world).values()) {
|
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||||
|
Plot plot = entry2.getValue();
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (PlotHandler.isOwner(plot, uuid)) {
|
if (PlotHandler.isOwner(plot, uuid)) {
|
||||||
myplots.add(plot);
|
myplots.add(plot);
|
||||||
|
@ -234,9 +234,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
UniqueStatement task = null;
|
UniqueStatement task = null;
|
||||||
UniqueStatement lastTask = null;
|
UniqueStatement lastTask = null;
|
||||||
ArrayList<Plot> keys = new ArrayList<>(plotTasks.keySet());
|
// ArrayList<Entry<Plot, Queue<UniqueStatement>>> keys = new ArrayList<>(plotTasks.entrySet());
|
||||||
for (int i = 0; i < keys.size(); i++) {
|
for (Entry<Plot, Queue<UniqueStatement>> entry : plotTasks.entrySet()) {
|
||||||
Plot plot = keys.get(i);
|
Plot plot = entry.getKey();
|
||||||
if (plotTasks.get(plot).size() == 0) {
|
if (plotTasks.get(plot).size() == 0) {
|
||||||
plotTasks.remove(plot);
|
plotTasks.remove(plot);
|
||||||
continue;
|
continue;
|
||||||
@ -271,14 +271,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
UniqueStatement task = null;
|
UniqueStatement task = null;
|
||||||
UniqueStatement lastTask = null;
|
UniqueStatement lastTask = null;
|
||||||
ArrayList<PlotCluster> keys = new ArrayList<>(clusterTasks.keySet());
|
for (Entry<PlotCluster, Queue<UniqueStatement>> entry : clusterTasks.entrySet()) {
|
||||||
for (int i = 0; i < keys.size(); i++) {
|
PlotCluster cluster = entry.getKey();
|
||||||
PlotCluster plot = keys.get(i);
|
if (clusterTasks.get(cluster).size() == 0) {
|
||||||
if (clusterTasks.get(plot).size() == 0) {
|
clusterTasks.remove(cluster);
|
||||||
clusterTasks.remove(plot);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
task = clusterTasks.get(plot).remove();
|
task = clusterTasks.get(cluster).remove();
|
||||||
count++;
|
count++;
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
if (task._method == null || !task._method.equals(method)) {
|
if (task._method == null || !task._method.equals(method)) {
|
||||||
@ -1212,7 +1211,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getPlots() {
|
public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getPlots() {
|
||||||
final ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> newplots = new ConcurrentHashMap();
|
final ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> newplots = new ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>>();
|
||||||
final HashMap<Integer, Plot> plots = new HashMap<>();
|
final HashMap<Integer, Plot> plots = new HashMap<>();
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
@ -1436,11 +1435,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}
|
}
|
||||||
if (plots.keySet().size() > 0) {
|
if (plots.entrySet().size() > 0) {
|
||||||
this.createEmptySettings(new ArrayList<Integer>(plots.keySet()), null);
|
this.createEmptySettings(new ArrayList<Integer>(plots.keySet()), null);
|
||||||
}
|
}
|
||||||
boolean invalidPlot = false;
|
boolean invalidPlot = false;
|
||||||
for (final String worldname : noExist.keySet()) {
|
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||||
|
String worldname = entry.getKey();
|
||||||
invalidPlot = true;
|
invalidPlot = true;
|
||||||
PS.debug("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'.");
|
PS.debug("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'.");
|
||||||
}
|
}
|
||||||
@ -2167,7 +2167,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
newClusters.get(world).add(c);
|
newClusters.get(world).add(c);
|
||||||
}
|
}
|
||||||
boolean invalidPlot = false;
|
boolean invalidPlot = false;
|
||||||
for (final String w : noExist.keySet()) {
|
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||||
|
String w = entry.getKey();
|
||||||
invalidPlot = true;
|
invalidPlot = true;
|
||||||
PS.debug("&c[WARNING] Found " + noExist.get(w) + " clusters in DB for non existant world; '" + w + "'.");
|
PS.debug("&c[WARNING] Found " + noExist.get(w) + " clusters in DB for non existant world; '" + w + "'.");
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
public void registerBlocks() {
|
public void registerBlocks() {
|
||||||
blockMap = new BlockState[256][];
|
blockMap = new BlockState[256][];
|
||||||
blockMapReverse = new ConcurrentHashMap<BlockState, PlotBlock>();
|
blockMapReverse = new HashMap<BlockState, PlotBlock>();
|
||||||
HashMap<String, BlockState> states = new HashMap<>();
|
HashMap<String, BlockState> states = new HashMap<>();
|
||||||
|
|
||||||
PS.get().copyFile("ids.txt", "config");
|
PS.get().copyFile("ids.txt", "config");
|
||||||
|
Loading…
Reference in New Issue
Block a user