mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Cleaning and API clarifications
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
3d8179a4e6
commit
b39ea1b68b
File diff suppressed because one or more lines are too long
@ -34,10 +34,12 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
public final String CREATE_PLOT;
|
public final String CREATE_PLOT;
|
||||||
public final String CREATE_PLOT_SAFE;
|
public final String CREATE_PLOT_SAFE;
|
||||||
public final String CREATE_CLUSTER;
|
public final String CREATE_CLUSTER;
|
||||||
private final String prefix;
|
|
||||||
// Private Final
|
// Private Final
|
||||||
|
private final String prefix;
|
||||||
private final Database database;
|
private final Database database;
|
||||||
private final boolean mySQL;
|
private final boolean mySQL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* important tasks
|
* important tasks
|
||||||
*/
|
*/
|
||||||
@ -67,6 +69,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
* cluster_settings
|
* cluster_settings
|
||||||
*/
|
*/
|
||||||
public volatile ConcurrentHashMap<PlotCluster, Queue<UniqueStatement>> clusterTasks;
|
public volatile ConcurrentHashMap<PlotCluster, Queue<UniqueStatement>> clusterTasks;
|
||||||
|
|
||||||
// Private
|
// Private
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
private boolean closed = false;
|
private boolean closed = false;
|
||||||
@ -75,11 +78,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param database
|
* @param database
|
||||||
* @param p prefix
|
* @param prefix prefix
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public SQLManager(final Database database, String p, boolean debug)
|
public SQLManager(final Database database, String prefix, boolean debug)
|
||||||
throws SQLException, ClassNotFoundException {
|
throws SQLException, ClassNotFoundException {
|
||||||
// Private final
|
// Private final
|
||||||
this.database = database;
|
this.database = database;
|
||||||
@ -90,7 +93,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
this.plotTasks = new ConcurrentHashMap<>();
|
this.plotTasks = new ConcurrentHashMap<>();
|
||||||
this.playerTasks = new ConcurrentHashMap<>();
|
this.playerTasks = new ConcurrentHashMap<>();
|
||||||
this.clusterTasks = new ConcurrentHashMap<>();
|
this.clusterTasks = new ConcurrentHashMap<>();
|
||||||
this.prefix = p;
|
this.prefix = prefix;
|
||||||
this.SET_OWNER = "UPDATE `" + this.prefix
|
this.SET_OWNER = "UPDATE `" + this.prefix
|
||||||
+ "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND `world` = ?";
|
+ "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND `world` = ?";
|
||||||
this.GET_ALL_PLOTS =
|
this.GET_ALL_PLOTS =
|
||||||
@ -551,30 +554,18 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createSettings(settings, new Runnable() {
|
createSettings(settings, () -> createTiers(helpers, "helpers",
|
||||||
@Override public void run() {
|
() -> createTiers(trusted, "trusted",
|
||||||
createTiers(helpers, "helpers", new Runnable() {
|
() -> createTiers(denied, "denied", () -> {
|
||||||
@Override public void run() {
|
try {
|
||||||
createTiers(trusted, "trusted", new Runnable() {
|
SQLManager.this.connection.commit();
|
||||||
@Override public void run() {
|
} catch (SQLException e) {
|
||||||
createTiers(denied, "denied", new Runnable() {
|
e.printStackTrace();
|
||||||
@Override public void run() {
|
|
||||||
try {
|
|
||||||
SQLManager.this.connection.commit();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (whenDone != null) {
|
|
||||||
whenDone.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
if (whenDone != null) {
|
||||||
}
|
whenDone.run();
|
||||||
});
|
}
|
||||||
|
}))));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("&7[WARN] Failed to set all helpers for plots");
|
PlotSquared.debug("&7[WARN] Failed to set all helpers for plots");
|
||||||
@ -1354,7 +1345,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create plot settings
|
* Creates plot settings
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param plot
|
* @param plot
|
||||||
|
@ -14,6 +14,8 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -525,17 +527,8 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull public Set<Plot> getPlots(@Nonnull final UUID uuid) {
|
@Nonnull public Set<Plot> getPlots(@Nonnull final UUID uuid) {
|
||||||
final Set<Plot> myplots = new HashSet<>();
|
return getPlots().stream().filter(plot -> plot.isBasePlot() && plot.isOwner(uuid))
|
||||||
for (final Plot plot : getPlots()) {
|
.collect(ImmutableSet.toImmutableSet());
|
||||||
if (plot.isBasePlot() && plot.isOwner(uuid)) {
|
|
||||||
myplots.add(plot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return myplots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Plot> getPlots(@Nonnull final PlotPlayer player) {
|
|
||||||
return getPlots(player.getUUID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -560,6 +553,15 @@ public abstract class PlotArea {
|
|||||||
return getPlotsAbs(uuid).size();
|
return getPlotsAbs(uuid).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the plots for the player in this PlotArea.
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link #getPlots(UUID)}
|
||||||
|
*/
|
||||||
|
@Deprecated public Set<Plot> getPlots(@Nonnull final PlotPlayer player) {
|
||||||
|
return getPlots(player.getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasPlot(@Nonnull final UUID uuid) {
|
public boolean hasPlot(@Nonnull final UUID uuid) {
|
||||||
for (Entry<PlotId, Plot> entry : this.plots.entrySet()) {
|
for (Entry<PlotId, Plot> entry : this.plots.entrySet()) {
|
||||||
if (entry.getValue().isOwner(uuid))
|
if (entry.getValue().isOwner(uuid))
|
||||||
@ -685,8 +687,20 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull public Map<PlotId, Plot> getPlotsRaw() {
|
/**
|
||||||
return this.plots;
|
* Returns an ImmutableMap of PlotId's and Plots in this PlotArea.
|
||||||
|
*/
|
||||||
|
public Map<PlotId, Plot> getPlotsMap() {
|
||||||
|
return ImmutableMap.copyOf(plots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an ImmutableMap of PlotId's and Plots in this PlotArea.
|
||||||
|
* @deprecated Use {@link #getPlotsMap()}
|
||||||
|
*/
|
||||||
|
//todo eventually remove
|
||||||
|
@Deprecated @Nonnull public Map<PlotId, Plot> getPlotsRaw() {
|
||||||
|
return ImmutableMap.copyOf(plots);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull public Set<Entry<PlotId, Plot>> getPlotEntries() {
|
@Nonnull public Set<Entry<PlotId, Plot>> getPlotEntries() {
|
||||||
@ -714,14 +728,13 @@ public abstract class PlotArea {
|
|||||||
center = new PlotId(0, 0);
|
center = new PlotId(0, 0);
|
||||||
plots = Integer.MAX_VALUE;
|
plots = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
PlotId currentId;
|
|
||||||
for (int i = 0; i < plots; i++) {
|
for (int i = 0; i < plots; i++) {
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
start = getMeta("lastPlot", new PlotId(0, 0));
|
start = getMeta("lastPlot", new PlotId(0, 0));
|
||||||
} else {
|
} else {
|
||||||
start = start.getNextId(1);
|
start = start.getNextId(1);
|
||||||
}
|
}
|
||||||
currentId = new PlotId(center.x + start.x, center.y + start.y);
|
PlotId currentId = new PlotId(center.x + start.x, center.y + start.y);
|
||||||
Plot plot = getPlotAbs(currentId);
|
Plot plot = getPlotAbs(currentId);
|
||||||
if (plot != null && plot.canClaim(player)) {
|
if (plot != null && plot.canClaim(player)) {
|
||||||
setMeta("lastPlot", currentId);
|
setMeta("lastPlot", currentId);
|
||||||
|
Loading…
Reference in New Issue
Block a user