mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13: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>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>3.0.14</version>
|
||||
<version>3.0.15</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
@ -11,8 +11,6 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -952,7 +950,7 @@ public class PS {
|
||||
@Deprecated
|
||||
public ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
||||
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);
|
||||
Collections.sort(worlds);
|
||||
for (String world : worlds) {
|
||||
@ -1034,7 +1032,7 @@ public class PS {
|
||||
* @return A String array of the plot world names
|
||||
*/
|
||||
public String[] getPlotWorldsString() {
|
||||
final Set<String> strings = plots.keySet();
|
||||
final Set<String> strings = plotworlds.keySet();
|
||||
return strings.toArray(new String[strings.size()]);
|
||||
}
|
||||
|
||||
@ -1103,9 +1101,10 @@ public class PS {
|
||||
*/
|
||||
public Set<Plot> getPlots(final UUID uuid) {
|
||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||
for (final String world : plots.keySet()) {
|
||||
if (isPlotWorld(world)) {
|
||||
for (final Plot plot : plots.get(world).values()) {
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
if (isPlotWorld(entry.getKey())) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
Plot plot = entry2.getValue();
|
||||
if (plot.hasOwner()) {
|
||||
if (PlotHandler.isOwner(plot, uuid)) {
|
||||
myplots.add(plot);
|
||||
|
@ -234,9 +234,9 @@ public class SQLManager implements AbstractDB {
|
||||
PreparedStatement stmt = null;
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
ArrayList<Plot> keys = new ArrayList<>(plotTasks.keySet());
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
Plot plot = keys.get(i);
|
||||
// ArrayList<Entry<Plot, Queue<UniqueStatement>>> keys = new ArrayList<>(plotTasks.entrySet());
|
||||
for (Entry<Plot, Queue<UniqueStatement>> entry : plotTasks.entrySet()) {
|
||||
Plot plot = entry.getKey();
|
||||
if (plotTasks.get(plot).size() == 0) {
|
||||
plotTasks.remove(plot);
|
||||
continue;
|
||||
@ -271,14 +271,13 @@ public class SQLManager implements AbstractDB {
|
||||
PreparedStatement stmt = null;
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
ArrayList<PlotCluster> keys = new ArrayList<>(clusterTasks.keySet());
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
PlotCluster plot = keys.get(i);
|
||||
if (clusterTasks.get(plot).size() == 0) {
|
||||
clusterTasks.remove(plot);
|
||||
for (Entry<PlotCluster, Queue<UniqueStatement>> entry : clusterTasks.entrySet()) {
|
||||
PlotCluster cluster = entry.getKey();
|
||||
if (clusterTasks.get(cluster).size() == 0) {
|
||||
clusterTasks.remove(cluster);
|
||||
continue;
|
||||
}
|
||||
task = clusterTasks.get(plot).remove();
|
||||
task = clusterTasks.get(cluster).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task._method == null || !task._method.equals(method)) {
|
||||
@ -1212,7 +1211,7 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
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<>();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
@ -1436,11 +1435,12 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
stmt.close();
|
||||
}
|
||||
if (plots.keySet().size() > 0) {
|
||||
if (plots.entrySet().size() > 0) {
|
||||
this.createEmptySettings(new ArrayList<Integer>(plots.keySet()), null);
|
||||
}
|
||||
boolean invalidPlot = false;
|
||||
for (final String worldname : noExist.keySet()) {
|
||||
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||
String worldname = entry.getKey();
|
||||
invalidPlot = true;
|
||||
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);
|
||||
}
|
||||
boolean invalidPlot = false;
|
||||
for (final String w : noExist.keySet()) {
|
||||
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||
String w = entry.getKey();
|
||||
invalidPlot = true;
|
||||
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() {
|
||||
blockMap = new BlockState[256][];
|
||||
blockMapReverse = new ConcurrentHashMap<BlockState, PlotBlock>();
|
||||
blockMapReverse = new HashMap<BlockState, PlotBlock>();
|
||||
HashMap<String, BlockState> states = new HashMap<>();
|
||||
|
||||
PS.get().copyFile("ids.txt", "config");
|
||||
|
Loading…
Reference in New Issue
Block a user