mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Modified internal configuration classes, Updated Mojang UUID fetcher, other various method and documentation tweaks
This commit is contained in:
parent
a0d666ae14
commit
5e8909883d
@ -31,13 +31,13 @@ import java.util.ArrayDeque;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||||
|
|
||||||
final int MAX_REQUESTS = 500;
|
final int MAX_REQUESTS = 500;
|
||||||
private final String PROFILE_URL =
|
private final String PROFILE_URL =
|
||||||
"https://sessionserver.mojang.com/session/minecraft/profile/";
|
"https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||||
private final int INTERVAL = 12000;
|
|
||||||
private final JSONParser jsonParser = new JSONParser();
|
private final JSONParser jsonParser = new JSONParser();
|
||||||
private final SQLite sqlite;
|
private final SQLite sqlite;
|
||||||
|
|
||||||
@ -133,7 +133,10 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
"Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)");
|
"Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(INTERVAL * 50);
|
//Mojang allows requests every 10 minutes according to https://wiki.vg/Mojang_API
|
||||||
|
//15 Minutes is chosen here since system timers are not always precise
|
||||||
|
//and it should provide enough time where Mojang won't block requests.
|
||||||
|
TimeUnit.MINUTES.sleep(15);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
break;
|
break;
|
||||||
@ -142,7 +145,6 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -6,7 +6,6 @@ package com.github.intellectualsites.plotsquared.configuration;
|
|||||||
*/
|
*/
|
||||||
class ConfigurationOptions {
|
class ConfigurationOptions {
|
||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
private char pathSeparator = '.';
|
|
||||||
private boolean copyDefaults = false;
|
private boolean copyDefaults = false;
|
||||||
|
|
||||||
protected ConfigurationOptions(Configuration configuration) {
|
protected ConfigurationOptions(Configuration configuration) {
|
||||||
@ -26,28 +25,12 @@ class ConfigurationOptions {
|
|||||||
* Gets the char that will be used to separate {@link
|
* Gets the char that will be used to separate {@link
|
||||||
* ConfigurationSection}s.
|
* ConfigurationSection}s.
|
||||||
*
|
*
|
||||||
* <p>This value does not affect how the {@link Configuration} is stored,
|
* <p> This value is always '.'.
|
||||||
* only in how you access the data. The default value is '.'.
|
|
||||||
*
|
*
|
||||||
* @return Path separator
|
* @return Path separator
|
||||||
*/
|
*/
|
||||||
public char pathSeparator() {
|
char pathSeparator() {
|
||||||
return pathSeparator;
|
return '.';
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the char that will be used to separate {@link
|
|
||||||
* ConfigurationSection}s.
|
|
||||||
*
|
|
||||||
* <p>This value does not affect how the {@link Configuration} is stored,
|
|
||||||
* only in how you access the data. The default value is '.'.
|
|
||||||
*
|
|
||||||
* @param value Path separator
|
|
||||||
* @return This object, for chaining
|
|
||||||
*/
|
|
||||||
public ConfigurationOptions pathSeparator(char value) {
|
|
||||||
pathSeparator = value;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,8 +18,4 @@ public class MemoryConfigurationOptions extends ConfigurationOptions {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public MemoryConfigurationOptions pathSeparator(char value) {
|
|
||||||
super.pathSeparator(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,6 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public FileConfigurationOptions pathSeparator(char value) {
|
|
||||||
super.pathSeparator(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the header that will be applied to the top of the saved output.
|
* Gets the header that will be applied to the top of the saved output.
|
||||||
*
|
*
|
||||||
|
@ -5,7 +5,6 @@ package com.github.intellectualsites.plotsquared.configuration.file;
|
|||||||
* YamlConfiguration}.
|
* YamlConfiguration}.
|
||||||
*/
|
*/
|
||||||
public class YamlConfigurationOptions extends FileConfigurationOptions {
|
public class YamlConfigurationOptions extends FileConfigurationOptions {
|
||||||
private int indent = 2;
|
|
||||||
|
|
||||||
YamlConfigurationOptions(YamlConfiguration configuration) {
|
YamlConfigurationOptions(YamlConfiguration configuration) {
|
||||||
super(configuration);
|
super(configuration);
|
||||||
@ -20,11 +19,6 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public YamlConfigurationOptions pathSeparator(char value) {
|
|
||||||
super.pathSeparator(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public YamlConfigurationOptions header(String value) {
|
@Override public YamlConfigurationOptions header(String value) {
|
||||||
super.header(value);
|
super.header(value);
|
||||||
return this;
|
return this;
|
||||||
@ -42,27 +36,8 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
|
|||||||
*
|
*
|
||||||
* @return How much to indent by
|
* @return How much to indent by
|
||||||
*/
|
*/
|
||||||
public int indent() {
|
int indent() {
|
||||||
return indent;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets how much spaces should be used to indent each line.
|
|
||||||
*
|
|
||||||
* <p>The minimum value this may be is 2, and the maximum is 9.
|
|
||||||
*
|
|
||||||
* @param value New indent
|
|
||||||
* @return This object, for chaining
|
|
||||||
*/
|
|
||||||
public YamlConfigurationOptions indent(int value) {
|
|
||||||
if (value < 2) {
|
|
||||||
throw new IllegalArgumentException("Indent must be at least 2 characters");
|
|
||||||
}
|
|
||||||
if (value > 9) {
|
|
||||||
throw new IllegalArgumentException("Indent cannot be greater than 9 characters");
|
|
||||||
}
|
|
||||||
|
|
||||||
indent = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@CommandDeclaration(command = "setflag", aliases = {"f", "flag", "setf", "setflag"},
|
@CommandDeclaration(command = "setflag", aliases = {"f", "flag",
|
||||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>", description = "Set plot flags",
|
"setflag"}, usage = "/plot flag <set|remove|add|list|info> <flag> <value>", description = "Set plot flags", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.flag")
|
||||||
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE,
|
public class FlagCmd extends SubCommand {
|
||||||
permission = "plots.flag") public class FlagCmd extends SubCommand {
|
|
||||||
|
|
||||||
private boolean checkPermValue(PlotPlayer player, Flag flag, String key, String value) {
|
private boolean checkPermValue(PlotPlayer player, Flag flag, String key, String value) {
|
||||||
key = key.toLowerCase();
|
key = key.toLowerCase();
|
||||||
|
@ -149,8 +149,14 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
PlotComment comment = value.get(index - 1);
|
PlotComment comment = value.get(index - 1);
|
||||||
inbox.removeComment(plot, comment);
|
inbox.removeComment(plot, comment);
|
||||||
plot.removeComment(comment);
|
boolean success = plot.removeComment(comment);
|
||||||
MainUtil.sendMessage(player, Captions.COMMENT_REMOVED, comment.comment);
|
//noinspection StatementWithEmptyBody
|
||||||
|
if (success) {
|
||||||
|
MainUtil
|
||||||
|
.sendMessage(player, Captions.COMMENT_REMOVED, comment.comment);
|
||||||
|
} else {
|
||||||
|
//TODO Comment removal failure message
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})) {
|
})) {
|
||||||
sendMessage(player, Captions.NOT_IN_PLOT);
|
sendMessage(player, Captions.NOT_IN_PLOT);
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.database;
|
package com.github.intellectualsites.plotsquared.plot.database;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.HashMap;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface AbstractDB {
|
public interface AbstractDB {
|
||||||
|
|
||||||
@ -224,7 +231,7 @@ public interface AbstractDB {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param cluster PlotCluster Object
|
* @param cluster PlotCluster Object
|
||||||
* @param uuid Player that should be removed
|
* @param uuid Player that should be removed
|
||||||
*/
|
*/
|
||||||
void setHelper(PlotCluster cluster, UUID uuid);
|
void setHelper(PlotCluster cluster, UUID uuid);
|
||||||
|
|
||||||
@ -276,7 +283,7 @@ public interface AbstractDB {
|
|||||||
/**
|
/**
|
||||||
* Removes the specified comment from the given plot.
|
* Removes the specified comment from the given plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param comment the comment to remove
|
* @param comment the comment to remove
|
||||||
*/
|
*/
|
||||||
void removeComment(Plot plot, PlotComment comment);
|
void removeComment(Plot plot, PlotComment comment);
|
||||||
@ -284,7 +291,7 @@ public interface AbstractDB {
|
|||||||
/**
|
/**
|
||||||
* Clears the specified inbox on the given plot.
|
* Clears the specified inbox on the given plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param inbox the inbox to clear
|
* @param inbox the inbox to clear
|
||||||
*/
|
*/
|
||||||
void clearInbox(Plot plot, String inbox);
|
void clearInbox(Plot plot, String inbox);
|
||||||
@ -292,13 +299,13 @@ public interface AbstractDB {
|
|||||||
/**
|
/**
|
||||||
* Adds the specified comment to the given plot.
|
* Adds the specified comment to the given plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param comment the comment to add
|
* @param comment the comment to add
|
||||||
*/
|
*/
|
||||||
void setComment(Plot plot, PlotComment comment);
|
void setComment(Plot plot, PlotComment comment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets Plot Comments.
|
* Gets Plot comments.
|
||||||
*
|
*
|
||||||
* @param plot The Plot to get comments from
|
* @param plot The Plot to get comments from
|
||||||
*/
|
*/
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.database;
|
package com.github.intellectualsites.plotsquared.plot.database;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.ResultSetMetaData;
|
import java.sql.ResultSetMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database Functions
|
* Database Functions
|
||||||
@ -74,6 +82,8 @@ public class DBFunc {
|
|||||||
DBFunc.dbManager.validateAllPlots(plots);
|
DBFunc.dbManager.validateAllPlots(plots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO Consider Removal
|
||||||
/**
|
/**
|
||||||
* Check if a {@link ResultSet} contains a column.
|
* Check if a {@link ResultSet} contains a column.
|
||||||
*
|
*
|
||||||
@ -81,7 +91,7 @@ public class DBFunc {
|
|||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean hasColumn(ResultSet resultSet, String name) {
|
@Deprecated public static boolean hasColumn(ResultSet resultSet, String name) {
|
||||||
try {
|
try {
|
||||||
ResultSetMetaData meta = resultSet.getMetaData();
|
ResultSetMetaData meta = resultSet.getMetaData();
|
||||||
int count = meta.getColumnCount();
|
int count = meta.getColumnCount();
|
||||||
|
@ -24,29 +24,21 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
BlockBucket blocks) {
|
BlockBucket blocks) {
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case "floor":
|
case "floor":
|
||||||
setFloor(plotId, blocks);
|
return setFloor(plotId, blocks);
|
||||||
return true;
|
|
||||||
case "wall":
|
case "wall":
|
||||||
setWallFilling(plotId, blocks);
|
return setWallFilling(plotId, blocks);
|
||||||
return true;
|
|
||||||
case "all":
|
case "all":
|
||||||
setAll(plotId, blocks);
|
return setAll(plotId, blocks);
|
||||||
return true;
|
|
||||||
case "air":
|
case "air":
|
||||||
setAir(plotId, blocks);
|
return setAir(plotId, blocks);
|
||||||
return true;
|
|
||||||
case "main":
|
case "main":
|
||||||
setMain(plotId, blocks);
|
return setMain(plotId, blocks);
|
||||||
return true;
|
|
||||||
case "middle":
|
case "middle":
|
||||||
setMiddle(plotId, blocks);
|
return setMiddle(plotId, blocks);
|
||||||
return true;
|
|
||||||
case "outline":
|
case "outline":
|
||||||
setOutline(plotId, blocks);
|
return setOutline(plotId, blocks);
|
||||||
return true;
|
|
||||||
case "border":
|
case "border":
|
||||||
setWall(plotId, blocks);
|
return setWall(plotId, blocks);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -54,8 +46,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
||||||
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING);
|
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING);
|
||||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
||||||
GlobalBlockQueue.IMP.addTask(whenDone);
|
return GlobalBlockQueue.IMP.addTask(whenDone);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setFloor(PlotId plotId, BlockBucket blocks) {
|
public boolean setFloor(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -70,8 +61,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
queue.setCuboid(pos1, pos2, blocks);
|
queue.setCuboid(pos1, pos2, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setAll(PlotId plotId, BlockBucket blocks) {
|
public boolean setAll(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -86,8 +76,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ);
|
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ);
|
||||||
queue.setCuboid(pos1, pos2, blocks);
|
queue.setCuboid(pos1, pos2, blocks);
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setAir(PlotId plotId, BlockBucket blocks) {
|
public boolean setAir(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -103,8 +92,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ);
|
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ);
|
||||||
queue.setCuboid(pos1, pos2, blocks);
|
queue.setCuboid(pos1, pos2, blocks);
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setMain(PlotId plotId, BlockBucket blocks) {
|
public boolean setMain(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -119,8 +107,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT - 1, region.maxZ);
|
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT - 1, region.maxZ);
|
||||||
queue.setCuboid(pos1, pos2, blocks);
|
queue.setCuboid(pos1, pos2, blocks);
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setMiddle(PlotId plotId, BlockBucket blocks) {
|
public boolean setMiddle(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -134,8 +121,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
||||||
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
||||||
queue.setBlock(x, classicPlotWorld.PLOT_HEIGHT, z, blocks.getBlock());
|
queue.setBlock(x, classicPlotWorld.PLOT_HEIGHT, z, blocks.getBlock());
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setOutline(PlotId plotId, BlockBucket blocks) {
|
public boolean setOutline(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -187,8 +173,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
queue.setCuboid(pos1, pos2, blocks);
|
queue.setCuboid(pos1, pos2, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setWallFilling(PlotId plotId, BlockBucket blocks) {
|
public boolean setWallFilling(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -235,8 +220,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setWall(PlotId plotId, BlockBucket blocks) {
|
public boolean setWall(PlotId plotId, BlockBucket blocks) {
|
||||||
@ -276,8 +260,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
queue.setBlock(x, y, z, blocks.getBlock());
|
queue.setBlock(x, y, z, blocks.getBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -308,8 +291,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK);
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean createRoadSouth(Plot plot) {
|
@Override public boolean createRoadSouth(Plot plot) {
|
||||||
@ -337,8 +319,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), classicPlotWorld.WALL_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), classicPlotWorld.WALL_BLOCK);
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean createRoadSouthEast(Plot plot) {
|
@Override public boolean createRoadSouthEast(Plot plot) {
|
||||||
@ -356,8 +337,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
PlotBlock.get((short) 7, (byte) 0));
|
PlotBlock.get((short) 7, (byte) 0));
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean removeRoadEast(Plot plot) {
|
@Override public boolean removeRoadEast(Plot plot) {
|
||||||
@ -377,8 +357,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK);
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), classicPlotWorld.TOP_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), classicPlotWorld.TOP_BLOCK);
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean removeRoadSouth(Plot plot) {
|
@Override public boolean removeRoadSouth(Plot plot) {
|
||||||
@ -398,8 +377,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean removeRoadSouthEast(Plot plot) {
|
@Override public boolean removeRoadSouthEast(Plot plot) {
|
||||||
@ -416,14 +394,14 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
||||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz),
|
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz),
|
||||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
||||||
queue.enqueue();
|
return queue.enqueue();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED).
|
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED).
|
||||||
*/
|
*/
|
||||||
@Override public boolean finishPlotMerge(List<PlotId> plotIds) {
|
@Override public boolean finishPlotMerge(List<PlotId> plotIds) {
|
||||||
|
//TODO This method shouldn't always return true
|
||||||
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||||
plotIds.forEach(id -> setWall(id, block));
|
plotIds.forEach(id -> setWall(id, block));
|
||||||
if (Settings.General.MERGE_REPLACE_WALL) {
|
if (Settings.General.MERGE_REPLACE_WALL) {
|
||||||
@ -434,12 +412,14 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
|
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
|
||||||
|
//TODO This method shouldn't always return true
|
||||||
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||||
plotIds.forEach(id -> setWall(id, block));
|
plotIds.forEach(id -> setWall(id, block));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean regenerateAllPlotWalls() {
|
@Override public boolean regenerateAllPlotWalls() {
|
||||||
|
//TODO This method shouldn't always return true
|
||||||
for (Plot plot : classicPlotWorld.getPlots()) {
|
for (Plot plot : classicPlotWorld.getPlots()) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK);
|
setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK);
|
||||||
@ -460,8 +440,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
|
|
||||||
@Override public boolean claimPlot(Plot plot) {
|
@Override public boolean claimPlot(Plot plot) {
|
||||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||||
setWall(plot.getId(), claim);
|
return setWall(plot.getId(), claim);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] getPlotComponents(PlotId plotId) {
|
@Override public String[] getPlotComponents(PlotId plotId) {
|
||||||
|
@ -2418,20 +2418,16 @@ public class Plot {
|
|||||||
* @param direction
|
* @param direction
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Plot getRelative(int direction) {
|
@Deprecated public Plot getRelative(int direction) {
|
||||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the plot in a relative direction<br>
|
* Gets the plot in a relative direction
|
||||||
* 0 = north<br>
|
|
||||||
* 1 = east<br>
|
|
||||||
* 2 = south<br>
|
|
||||||
* 3 = west<br>
|
|
||||||
* Note: May be null if the partial plot area does not include the relative location
|
* Note: May be null if the partial plot area does not include the relative location
|
||||||
*
|
*
|
||||||
* @param direction
|
* @param direction
|
||||||
* @return
|
* @return the plot relative to this one
|
||||||
*/
|
*/
|
||||||
public Plot getRelative(Direction direction) {
|
public Plot getRelative(Direction direction) {
|
||||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||||
@ -2441,7 +2437,7 @@ public class Plot {
|
|||||||
* Gets a set of plots connected (and including) this plot<br>
|
* Gets a set of plots connected (and including) this plot<br>
|
||||||
* - This result is cached globally
|
* - This result is cached globally
|
||||||
*
|
*
|
||||||
* @return
|
* @return a Set of Plots connected to this Plot
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getConnectedPlots() {
|
public Set<Plot> getConnectedPlots() {
|
||||||
if (this.settings == null) {
|
if (this.settings == null) {
|
||||||
@ -2802,6 +2798,11 @@ public class Plot {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the owner of this Plot is online.
|
||||||
|
*
|
||||||
|
* @return true if the owner of the Plot is online
|
||||||
|
*/
|
||||||
public boolean isOnline() {
|
public boolean isOnline() {
|
||||||
if (this.owner == null) {
|
if (this.owner == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -3098,23 +3099,23 @@ public class Plot {
|
|||||||
return getFlags().containsKey(flag);
|
return getFlags().containsKey(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public boolean removeComment(PlotComment comment) {
|
public boolean removeComment(PlotComment comment) {
|
||||||
return getSettings().removeComment(comment);
|
return getSettings().removeComment(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public void removeComments(List<PlotComment> comments) {
|
public void removeComments(List<PlotComment> comments) {
|
||||||
getSettings().removeComments(comments);
|
getSettings().removeComments(comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public List<PlotComment> getComments(String inbox) {
|
public List<PlotComment> getComments(String inbox) {
|
||||||
return getSettings().getComments(inbox);
|
return getSettings().getComments(inbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public void addComment(PlotComment comment) {
|
public void addComment(PlotComment comment) {
|
||||||
getSettings().addComment(comment);
|
getSettings().addComment(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public void setComments(List<PlotComment> list) {
|
public void setComments(List<PlotComment> list) {
|
||||||
getSettings().setComments(list);
|
getSettings().setComments(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,9 +102,10 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void enqueue() {
|
@Override public boolean enqueue() {
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.enqueue();
|
return parent.enqueue();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public class GlobalBlockQueue {
|
|||||||
|
|
||||||
public GlobalBlockQueue(QueueProvider provider, int threads) {
|
public GlobalBlockQueue(QueueProvider provider, int threads) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
activeQueues = new ConcurrentLinkedDeque<>();
|
this.activeQueues = new ConcurrentLinkedDeque<>();
|
||||||
inactiveQueues = new ConcurrentLinkedDeque<>();
|
this.inactiveQueues = new ConcurrentLinkedDeque<>();
|
||||||
runnables = new ConcurrentLinkedDeque<>();
|
this.runnables = new ConcurrentLinkedDeque<>();
|
||||||
running = new AtomicBoolean();
|
this.running = new AtomicBoolean();
|
||||||
this.PARALLEL_THREADS = threads;
|
this.PARALLEL_THREADS = threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,12 +151,20 @@ public class GlobalBlockQueue {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enqueue(LocalBlockQueue queue) {
|
/**
|
||||||
inactiveQueues.remove(queue);
|
* TODO Documentation needed.
|
||||||
|
*
|
||||||
|
* @param queue todo
|
||||||
|
* @return true if added to queue, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean enqueue(LocalBlockQueue queue) {
|
||||||
|
boolean success = false;
|
||||||
|
success = inactiveQueues.remove(queue);
|
||||||
if (queue.size() > 0 && !activeQueues.contains(queue)) {
|
if (queue.size() > 0 && !activeQueues.contains(queue)) {
|
||||||
queue.optimize();
|
queue.optimize();
|
||||||
activeQueues.add(queue);
|
success = activeQueues.add(queue);
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dequeue(LocalBlockQueue queue) {
|
public void dequeue(LocalBlockQueue queue) {
|
||||||
|
@ -96,8 +96,8 @@ public abstract class LocalBlockQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enqueue() {
|
public boolean enqueue() {
|
||||||
GlobalBlockQueue.IMP.enqueue(this);
|
return GlobalBlockQueue.IMP.enqueue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCuboid(Location pos1, Location pos2, PlotBlock block) {
|
public void setCuboid(Location pos1, Location pos2, PlotBlock block) {
|
||||||
|
Loading…
Reference in New Issue
Block a user