mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
Fixes
Fixes #556 Fixes #540 Fixed plot analysis being slow Fixed auto updating
This commit is contained in:
parent
be94aa53d3
commit
d0605b9b55
8
.gitignore
vendored
8
.gitignore
vendored
@ -3,7 +3,8 @@
|
|||||||
*.bat
|
*.bat
|
||||||
|
|
||||||
### Maven template
|
### Maven template
|
||||||
target/
|
target/classes
|
||||||
|
target/maven-archiver
|
||||||
pom.xml.tag
|
pom.xml.tag
|
||||||
pom.xml.releaseBackup
|
pom.xml.releaseBackup
|
||||||
pom.xml.versionsBackup
|
pom.xml.versionsBackup
|
||||||
@ -123,7 +124,7 @@ local.properties
|
|||||||
.mtj.tmp/
|
.mtj.tmp/
|
||||||
|
|
||||||
# Package Files #
|
# Package Files #
|
||||||
*.jar
|
|
||||||
*.war
|
*.war
|
||||||
*.ear
|
*.ear
|
||||||
*.zip
|
*.zip
|
||||||
@ -132,3 +133,6 @@ local.properties
|
|||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
|
|
||||||
|
*.java
|
||||||
|
target/PlotSquared-Null.jar
|
||||||
|
target/PlotSquared-Uber.jar
|
||||||
|
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.1.0</version>
|
<version>3.1.1</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -109,6 +109,7 @@ public class PS {
|
|||||||
private File storageFile;
|
private File storageFile;
|
||||||
private File FILE = null; // This file
|
private File FILE = null; // This file
|
||||||
private int[] VERSION = null;
|
private int[] VERSION = null;
|
||||||
|
private String PLATFORM = null;
|
||||||
private String LAST_VERSION;
|
private String LAST_VERSION;
|
||||||
private boolean LOADING_WORLD = false;
|
private boolean LOADING_WORLD = false;
|
||||||
private ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> plots;
|
private ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> plots;
|
||||||
@ -120,7 +121,7 @@ public class PS {
|
|||||||
* Initialize PlotSquared with the desired Implementation class
|
* Initialize PlotSquared with the desired Implementation class
|
||||||
* @param imp_class
|
* @param imp_class
|
||||||
*/
|
*/
|
||||||
public PS(final IPlotMain imp_class) {
|
public PS(final IPlotMain imp_class, String platform) {
|
||||||
try {
|
try {
|
||||||
instance = this;
|
instance = this;
|
||||||
this.thread = Thread.currentThread();
|
this.thread = Thread.currentThread();
|
||||||
@ -135,13 +136,11 @@ public class PS {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||||
if (!FILE.exists()) {
|
if (!FILE.exists()) {
|
||||||
FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared-Bukkit.jar");
|
FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared-" + platform + ".jar");
|
||||||
if (!FILE.exists()) {
|
|
||||||
FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared-Sponge.jar");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VERSION = IMP.getPluginVersion();
|
VERSION = IMP.getPluginVersion();
|
||||||
|
PLATFORM = platform;
|
||||||
EconHandler.manager = IMP.getEconomyHandler();
|
EconHandler.manager = IMP.getEconomyHandler();
|
||||||
if (getJavaVersion() < 1.7) {
|
if (getJavaVersion() < 1.7) {
|
||||||
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
||||||
@ -220,9 +219,6 @@ public class PS {
|
|||||||
URL url = getUpdate();
|
URL url = getUpdate();
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
update = url;
|
update = url;
|
||||||
log("&6You are running an older version of PlotSquared...");
|
|
||||||
log("&8 - &3Use: &7/plot update");
|
|
||||||
log("&8 - &3Or: &7" + url);
|
|
||||||
}
|
}
|
||||||
else if (LAST_VERSION != null && !StringMan.join(VERSION,".").equals(LAST_VERSION)) {
|
else if (LAST_VERSION != null && !StringMan.join(VERSION,".").equals(LAST_VERSION)) {
|
||||||
log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
|
log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
|
||||||
@ -324,6 +320,14 @@ public class PS {
|
|||||||
public int[] getVersion() {
|
public int[] getVersion() {
|
||||||
return VERSION;
|
return VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the platform this is running on (Bukkit, Sponge)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getPlatform() {
|
||||||
|
return PLATFORM;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message to the IPlotMain logger
|
* Log a message to the IPlotMain logger
|
||||||
@ -1412,48 +1416,38 @@ public class PS {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public URL getUpdate() {
|
public URL getUpdate() {
|
||||||
String resource = "plotsquared.1177";
|
String pom = "https://raw.githubusercontent.com/IntellectualSites/PlotSquared/master/pom.xml";
|
||||||
String url = "https://www.spigotmc.org/resources/" + resource + "/history";
|
String dl = "https://raw.githubusercontent.com/IntellectualSites/PlotSquared/master/target/PlotSquared-${PLATFORM}.jar";
|
||||||
String download = "<a href=\"resources/" + resource + "/download?version=";
|
String agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1";
|
||||||
String version = "<td class=\"version\">";
|
|
||||||
try {
|
try {
|
||||||
URL history = new URL(url);
|
URL page = new URL(pom);
|
||||||
URLConnection con = history.openConnection();
|
URLConnection con = page.openConnection();
|
||||||
con.addRequestProperty("User-Agent", "Mozilla/5.0");
|
con.addRequestProperty("User-Agent", agent);
|
||||||
InputStream stream = con.getInputStream();
|
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(stream));
|
String line = null;
|
||||||
String l;
|
while ((line = in.readLine()) != null) {
|
||||||
URL link = null;
|
line = line.trim();
|
||||||
String cur_ver = config.getString("version");
|
if (line.startsWith("<version>")) {
|
||||||
String new_ver = null;
|
line = line.replaceAll("[^\\d.]", "");
|
||||||
while ((l = in.readLine()) != null) {
|
|
||||||
if (l.length() > version.length() && l.startsWith(version)) {
|
|
||||||
new_ver = l.substring(version.length(), l.length() - 5);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (link == null && l.length() > download.length() && l.startsWith(download)) {
|
|
||||||
String subString = l.substring(download.length());
|
|
||||||
link = new URL("https://www.spigotmc.org/resources/" + resource + "/download?version=" + subString.substring(0, subString.indexOf("\"")));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stream.close();
|
|
||||||
in.close();
|
in.close();
|
||||||
if (new_ver == null || !canUpdate(cur_ver, new_ver)) {
|
if (!canUpdate(config.getString("version"), line) ) {
|
||||||
PS.debug("&7PlotSquared is already up to date!");
|
PS.debug("&7PlotSquared is already up to date!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (link == null) {
|
dl = dl.replaceAll("${PLATFORM}", getPlatform());
|
||||||
PS.debug("&dCould not check for updates (1)");
|
log("&6PlotSquared v" + line + " is available:");
|
||||||
PS.debug("&7 - Manually check for updates: " + url);
|
log("&8 - &3Use: &7/plot update");
|
||||||
return null;
|
log("&8 - &3Or: &7" + dl);
|
||||||
}
|
return new URL(dl);
|
||||||
return link;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
PS.debug("&dCould not check for updates (2)");
|
e.printStackTrace();
|
||||||
PS.debug("&7 - Manually check for updates: " + url);
|
log("&dCould not check for updates (0)");
|
||||||
return null;
|
log("&7 - Manually check for updates: " + pom);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(PlotPlayer sender, URL url) {
|
public boolean update(PlotPlayer sender, URL url) {
|
||||||
@ -1505,7 +1499,6 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
public void copyFile(String file, String folder) {
|
public void copyFile(String file, String folder) {
|
||||||
try {
|
try {
|
||||||
byte[] buffer = new byte[2048];
|
|
||||||
File output = IMP.getDirectory();
|
File output = IMP.getDirectory();
|
||||||
if (!output.exists()) {
|
if (!output.exists()) {
|
||||||
output.mkdirs();
|
output.mkdirs();
|
||||||
@ -1514,26 +1507,39 @@ public class PS {
|
|||||||
if (newFile.exists()) {
|
if (newFile.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE));
|
InputStream stream = IMP.getClass().getResourceAsStream(file);
|
||||||
ZipEntry ze = zis.getNextEntry();
|
byte[] buffer = new byte[2048];
|
||||||
while (ze != null) {
|
if (stream == null) {
|
||||||
String name = ze.getName();
|
ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE));
|
||||||
if (name.equals(file)) {
|
ZipEntry ze = zis.getNextEntry();
|
||||||
new File(newFile.getParent()).mkdirs();
|
while (ze != null) {
|
||||||
FileOutputStream fos = new FileOutputStream(newFile);
|
String name = ze.getName();
|
||||||
int len;
|
if (name.equals(file)) {
|
||||||
while ((len = zis.read(buffer)) > 0) {
|
new File(newFile.getParent()).mkdirs();
|
||||||
fos.write(buffer, 0, len);
|
FileOutputStream fos = new FileOutputStream(newFile);
|
||||||
|
int len;
|
||||||
|
while ((len = zis.read(buffer)) > 0) {
|
||||||
|
fos.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
fos.close();
|
||||||
|
ze = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ze = zis.getNextEntry();
|
||||||
}
|
}
|
||||||
fos.close();
|
|
||||||
ze = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ze = zis.getNextEntry();
|
|
||||||
}
|
}
|
||||||
|
zis.closeEntry();
|
||||||
|
zis.close();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
zis.closeEntry();
|
newFile.createNewFile();
|
||||||
zis.close();
|
FileOutputStream fos = new FileOutputStream(newFile);
|
||||||
|
int len;
|
||||||
|
while ((len = stream.read(buffer)) > 0) {
|
||||||
|
fos.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
fos.close();
|
||||||
|
stream.close();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1726,6 +1732,7 @@ public class PS {
|
|||||||
public void setupConfig() {
|
public void setupConfig() {
|
||||||
LAST_VERSION = config.getString("version");
|
LAST_VERSION = config.getString("version");
|
||||||
config.set("version", StringMan.join(VERSION,"."));
|
config.set("version", StringMan.join(VERSION,"."));
|
||||||
|
config.set("platform", PLATFORM);
|
||||||
|
|
||||||
final Map<String, Object> options = new HashMap<>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
// Command confirmation
|
// Command confirmation
|
||||||
|
@ -88,7 +88,7 @@ public class Clear extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Settings.DONE_RESTRICTS_BUILDING && FlagManager.isPlotFlagTrue(plot, "done" ) && (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr)))) {
|
if (FlagManager.isPlotFlagTrue(plot, "done" ) && (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr)))) {
|
||||||
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,10 @@ public class Continue extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (FlagManager.isPlotFlagTrue(plot, "done" ) && (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr)))) {
|
||||||
|
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (MainUtil.runners.containsKey(plot)) {
|
if (MainUtil.runners.containsKey(plot)) {
|
||||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||||
return false;
|
return false;
|
||||||
|
@ -124,11 +124,11 @@ public class FlagCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
|
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase()) && !Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase())) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
|
||||||
final Object parsed = af.parseValueRaw(value);
|
final Object parsed = af.parseValueRaw(value);
|
||||||
if (parsed == null) {
|
if (parsed == null) {
|
||||||
MainUtil.sendMessage(player, "&c" + af.getValueDesc());
|
MainUtil.sendMessage(player, "&c" + af.getValueDesc());
|
||||||
@ -157,11 +157,15 @@ public class FlagCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
|
final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
|
||||||
|
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
||||||
|
for (String entry : args[2].split(",")) {
|
||||||
|
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
|
||||||
|
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
MainUtil.sendMessage(player, C.FLAG_NOT_IN_PLOT);
|
MainUtil.sendMessage(player, C.FLAG_NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
@ -195,8 +199,12 @@ public class FlagCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
for (String entry : args[2].split(",")) {
|
||||||
return false;
|
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
|
||||||
|
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
final Object parsed = af.parseValueRaw(value);
|
final Object parsed = af.parseValueRaw(value);
|
||||||
|
@ -34,7 +34,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
permission = "plots.admin",
|
permission = "plots.admin",
|
||||||
description = "Update PlotSquared",
|
description = "Update PlotSquared",
|
||||||
usage = "/plot update",
|
usage = "/plot update",
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
aliases = {"updateplugin"},
|
aliases = {"updateplugin"},
|
||||||
category = CommandCategory.DEBUG
|
category = CommandCategory.DEBUG
|
||||||
)
|
)
|
||||||
|
@ -213,7 +213,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Done
|
* Done
|
||||||
*/
|
*/
|
||||||
DONE_ALREADY_DONE("$2This plot is already marked as done.","Done"),
|
DONE_ALREADY_DONE("$2This plot is already marked as done, and you are not allowed to claim more plots","Done"),
|
||||||
DONE_NOT_DONE("$2This plot is not marked as done.","Done"),
|
DONE_NOT_DONE("$2This plot is not marked as done.","Done"),
|
||||||
DONE_INSUFFICIENT_COMPLEXITY("$2This plot is too simple. Please add more detail before using this command.","Done"),
|
DONE_INSUFFICIENT_COMPLEXITY("$2This plot is too simple. Please add more detail before using this command.","Done"),
|
||||||
DONE_SUCCESS("$1Successfully marked this plot as done.","Done"),
|
DONE_SUCCESS("$1Successfully marked this plot as done.","Done"),
|
||||||
|
@ -181,6 +181,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
last = System.currentTimeMillis();
|
last = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
|
CLOSED = false;
|
||||||
connection = database.forceConnection();
|
connection = database.forceConnection();
|
||||||
} catch (SQLException | ClassNotFoundException e) {
|
} catch (SQLException | ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -2419,6 +2420,15 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateAllPlots(Set<Plot> toValidate) {
|
public void validateAllPlots(Set<Plot> toValidate) {
|
||||||
|
try {
|
||||||
|
if (connection.isClosed() || CLOSED) {
|
||||||
|
CLOSED = false;
|
||||||
|
connection = database.forceConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
PS.debug("$1All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
|
PS.debug("$1All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
|
||||||
commit();
|
commit();
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.config.Configuration;
|
|||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.util.BO3Handler;
|
import com.intellectualcrafters.plot.util.BO3Handler;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -118,12 +119,16 @@ public class Plot {
|
|||||||
public int temp;
|
public int temp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session only plot metadata (session is until the server stops)
|
* Session only plot metadata (session is until the server stops)<br>
|
||||||
|
* <br>
|
||||||
|
* For persistent metadata use the flag system
|
||||||
|
* @see FlagManager
|
||||||
*/
|
*/
|
||||||
private ConcurrentHashMap<String, Object> meta;
|
private ConcurrentHashMap<String, Object> meta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for a new plot
|
* Constructor for a new plot<br>
|
||||||
|
* (Only changes after plot.create() will be properly set in the database)
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world
|
||||||
* @param id
|
* @param id
|
||||||
@ -136,7 +141,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for a temporary plot
|
* Constructor for a temporary plot (use -1 for temp)<br>
|
||||||
|
* The database will ignore any queries regarding temporary plots.
|
||||||
|
* Please note that some bulk plot management functions may still affect temporary plots (TODO: fix this)
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world
|
||||||
* @param id
|
* @param id
|
||||||
@ -151,7 +158,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for a saved plots
|
* Constructor for a saved plots (Used by the database manager when plots are fetched)
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param owner
|
* @param owner
|
||||||
@ -180,7 +187,10 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set some session only metadata for the plot
|
* Session only plot metadata (session is until the server stops)<br>
|
||||||
|
* <br>
|
||||||
|
* For persistent metadata use the flag system
|
||||||
|
* @see FlagManager
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@ -245,18 +255,18 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the player is either the owner or on the trusted list
|
* Check if the player is either the owner or on the trusted/added list
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid
|
||||||
*
|
*
|
||||||
* @return true if the player is added as a helper or is the owner
|
* @return true if the player is added/trusted or is the owner
|
||||||
*/
|
*/
|
||||||
public boolean isAdded(final UUID uuid) {
|
public boolean isAdded(final UUID uuid) {
|
||||||
return PlotHandler.isAdded(this, uuid);
|
return PlotHandler.isAdded(this, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the player be allowed to enter?
|
* Should the player be denied from entering?
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid
|
||||||
*
|
*
|
||||||
@ -303,6 +313,10 @@ public class Plot {
|
|||||||
return !settings.getMerged(0) && !settings.getMerged(3);
|
return !settings.getMerged(0) && !settings.getMerged(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the plot is merged
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean isMerged() {
|
public boolean isMerged() {
|
||||||
if (settings == null) {
|
if (settings == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -310,6 +324,10 @@ public class Plot {
|
|||||||
return settings.getMerged(0) || settings.getMerged(2) || settings.getMerged(1) || settings.getMerged(3);
|
return settings.getMerged(0) || settings.getMerged(2) || settings.getMerged(1) || settings.getMerged(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timestamp in milliseconds of when the plot was created (unreliable)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
if (timestamp == 0) {
|
if (timestamp == 0) {
|
||||||
timestamp = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
@ -363,7 +381,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deny someone (use DBFunc.addDenied() as well)
|
* Deny someone (updates database as well)
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
@ -372,7 +390,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add someone as a helper (use DBFunc as well)
|
* Add someone as a helper (updates database as well)
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
@ -381,7 +399,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add someone as a trusted user (use DBFunc as well)
|
* Add someone as a trusted user (updates database as well)
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
@ -390,7 +408,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the plot owner
|
* Set the plot owner (and update the database)
|
||||||
* @param owner
|
* @param owner
|
||||||
*/
|
*/
|
||||||
public void setOwner(final UUID owner) {
|
public void setOwner(final UUID owner) {
|
||||||
@ -811,8 +829,7 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* Get the plot hashcode
|
* Get the plot hashcode
|
||||||
*
|
*
|
||||||
* @return integer. You can easily make this a character array <br> xI = c[0] x = c[1 -> xI...] yI = c[xI ... + 1] y
|
* @return integer.
|
||||||
* = c[xI ... + 2 -> yI ...]
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -66,7 +66,7 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void runTask() {
|
public static void runTask() {
|
||||||
ExpireManager.task = TaskManager.runTaskRepeat(new Runnable() {
|
ExpireManager.task = TaskManager.runTaskRepeatAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
@ -526,8 +526,13 @@ public class MainUtil {
|
|||||||
|
|
||||||
public static int getBorder(final String worldname) {
|
public static int getBorder(final String worldname) {
|
||||||
if (worldBorder.containsKey(worldname)) {
|
if (worldBorder.containsKey(worldname)) {
|
||||||
PS.get().getPlotWorld(worldname);
|
int border = worldBorder.get(worldname) + 16;
|
||||||
return worldBorder.get(worldname) + 16;
|
if (border == 0) {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return border;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,6 @@ public class Permissions {
|
|||||||
if (player.hasPermission(perm)) {
|
if (player.hasPermission(perm)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final String[] nodes = perm.split("\\.");
|
|
||||||
final StringBuilder n = new StringBuilder();
|
|
||||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
|
||||||
n.append(nodes[i] + ("."));
|
|
||||||
if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
THIS = this;
|
THIS = this;
|
||||||
PS.instance = new PS(this);
|
PS.instance = new PS(this, "Bukkit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,6 +105,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
@ -877,11 +878,20 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFade(final BlockFadeEvent e) {
|
public void onFade(final BlockFadeEvent e) {
|
||||||
final Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
String world = b.getWorld().getName();
|
||||||
if (PS.get().isPlotWorld(loc.getWorld())) {
|
PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||||
if (MainUtil.isPlotRoad(loc)) {
|
if (plotworld == null) {
|
||||||
e.setCancelled(true);
|
return;
|
||||||
|
}
|
||||||
|
PlotManager manager = PS.get().getPlotManager(world);
|
||||||
|
PlotId id = manager.getPlotId(plotworld, b.getX(), b.getY(), b.getZ());
|
||||||
|
if (id == null) {
|
||||||
|
if (plotworld.TYPE == 2) {
|
||||||
|
if (ClusterManager.getClusterAbs(BukkitUtil.getLocation(b.getLocation())) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +171,9 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
final Plot plot = event.getPlot();
|
final Plot plot = event.getPlot();
|
||||||
if (FlagManager.getPlotFlag(plot, "greeting") != null) {
|
Flag greeting = FlagManager.getPlotFlag(plot, "greeting");
|
||||||
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString()));
|
if (greeting != null) {
|
||||||
|
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + greeting.getValueString()));
|
||||||
}
|
}
|
||||||
Flag feed = FlagManager.getPlotFlag(plot, "feed");
|
Flag feed = FlagManager.getPlotFlag(plot, "feed");
|
||||||
if (feed != null) {
|
if (feed != null) {
|
||||||
@ -222,8 +223,9 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (FlagManager.getPlotFlag(plot, "farewell") != null) {
|
Flag farewell = FlagManager.getPlotFlag(plot, "farewell");
|
||||||
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString()));
|
if (farewell != null) {
|
||||||
|
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + farewell.getValueString()));
|
||||||
}
|
}
|
||||||
final PlotPlayer pl = BukkitUtil.getPlayer(leaver);
|
final PlotPlayer pl = BukkitUtil.getPlayer(leaver);
|
||||||
String name = leaver.getName();
|
String name = leaver.getName();
|
||||||
|
@ -28,12 +28,13 @@ public class WEManager {
|
|||||||
HashSet<RegionWrapper> regions = new HashSet<>();
|
HashSet<RegionWrapper> regions = new HashSet<>();
|
||||||
UUID uuid = player.getUUID();
|
UUID uuid = player.getUUID();
|
||||||
for (Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) {
|
for (Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) {
|
||||||
if (Settings.DONE_RESTRICTS_BUILDING && plot.isBasePlot() && FlagManager.getPlotFlag(plot, "done") == null) {
|
if (!plot.isBasePlot() || Settings.DONE_RESTRICTS_BUILDING && FlagManager.getPlotFlag(plot, "done") != null) {
|
||||||
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
continue;
|
||||||
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
}
|
||||||
Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
||||||
regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()));
|
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
}
|
Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||||
|
regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return regions;
|
return regions;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.plotsquared.bukkit.object;
|
package com.plotsquared.bukkit.object;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -68,26 +69,45 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(final String perm) {
|
public boolean hasPermission(final String node) {
|
||||||
if (Settings.PERMISSION_CACHING) {
|
if (Settings.PERMISSION_CACHING) {
|
||||||
if (this.noPerm.contains(perm)) {
|
if (this.noPerm.contains(node)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.hasPerm.contains(perm)) {
|
if (this.hasPerm.contains(node)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final boolean result = this.player.hasPermission(perm);
|
|
||||||
if (!result) {
|
|
||||||
this.noPerm.add(perm);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.hasPerm.add(perm);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (offline && EconHandler.manager != null) {
|
if (offline && EconHandler.manager != null) {
|
||||||
return EconHandler.manager.hasPermission(getName(), perm);
|
return EconHandler.manager.hasPermission(getName(), node);
|
||||||
}
|
}
|
||||||
return this.player.hasPermission(perm);
|
boolean value = this.player.hasPermission(node);
|
||||||
|
if (!value) {
|
||||||
|
Permission perm = Bukkit.getServer().getPluginManager().getPermission(node);
|
||||||
|
if (perm == null) {
|
||||||
|
perm = new Permission(node, PermissionDefault.FALSE);
|
||||||
|
Map<String, Boolean> children = perm.getChildren();
|
||||||
|
|
||||||
|
final String[] nodes = node.split("\\.");
|
||||||
|
final StringBuilder n = new StringBuilder();
|
||||||
|
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||||
|
n.append(nodes[i] + ("."));
|
||||||
|
children.put(n + C.PERMISSION_STAR.s(), true);
|
||||||
|
}
|
||||||
|
Bukkit.getServer().getPluginManager().addPermission(perm);
|
||||||
|
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
||||||
|
value = this.player.hasPermission(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Settings.PERMISSION_CACHING) {
|
||||||
|
if (value) {
|
||||||
|
this.hasPerm.add(node);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.noPerm.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
@ -34,7 +35,6 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
@Override
|
@Override
|
||||||
public void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
|
public void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
|
||||||
// int diff, int variety, int verticies, int rotation, int height_sd
|
// int diff, int variety, int verticies, int rotation, int height_sd
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* diff: compare to base by looping through all blocks
|
* diff: compare to base by looping through all blocks
|
||||||
* variety: add to hashset for each plotblock
|
* variety: add to hashset for each plotblock
|
||||||
@ -46,208 +46,213 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
* - recheck each block
|
* - recheck each block
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
final World world = Bukkit.getWorld(plot.world);
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
final ChunkGenerator gen = world.getGenerator();
|
|
||||||
if (gen == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final BiomeGrid base = new BiomeGrid() { @Override public void setBiome(int a, int b, Biome c) {} @Override public Biome getBiome(int a, int b) {return null;}};
|
|
||||||
Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
|
||||||
Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
|
||||||
final int bx = bot.getX();
|
|
||||||
final int bz = bot.getZ();
|
|
||||||
final int tx = top.getX();
|
|
||||||
final int tz = top.getZ();
|
|
||||||
final int cbx = bx >> 4;
|
|
||||||
final int cbz = bz >> 4;
|
|
||||||
final int ctx = tx >> 4;
|
|
||||||
final int ctz = tz >> 4;
|
|
||||||
final Random r = new Random();
|
|
||||||
MainUtil.initCache();
|
|
||||||
final int width = tx - bx + 1;
|
|
||||||
final int length = tz - bz + 1;
|
|
||||||
|
|
||||||
System.gc();
|
|
||||||
System.gc();
|
|
||||||
final short[][][] oldblocks = new short[256][width][length];
|
|
||||||
final short[][][] newblocks = new short[256][width][length];
|
|
||||||
|
|
||||||
final List<ChunkLoc> chunks = new ArrayList<>();
|
|
||||||
final List<ChunkLoc> processed_chunks = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int X = cbx; X <= ctx; X++) {
|
|
||||||
for (int Z = cbz; Z <= ctz; Z++) {
|
|
||||||
// Chunk chunk = world.getChunkAt(X, Z);
|
|
||||||
chunks.add(new ChunkLoc(X, Z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final Runnable run = new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (ChunkLoc chunk : processed_chunks) {
|
final World world = Bukkit.getWorld(plot.world);
|
||||||
short[][] result = gen.generateExtBlockSections(world, r, chunk.x, chunk.z, base);
|
final ChunkGenerator gen = world.getGenerator();
|
||||||
int X = chunk.x;
|
if (gen == null) {
|
||||||
int Z = chunk.z;
|
|
||||||
int xb = ((X) << 4) - bx;
|
|
||||||
int zb = ((Z) << 4) - bz;
|
|
||||||
for (int i = 0; i < result.length; i++) {
|
|
||||||
if (result[i] == null) {
|
|
||||||
for (int j = 0; j < 4096; j++) {
|
|
||||||
int x = MainUtil.x_loc[i][j] + xb;
|
|
||||||
if (x < 0 || x >= width) continue;
|
|
||||||
int z = MainUtil.z_loc[i][j] + zb;
|
|
||||||
if (z < 0 || z >= length) continue;
|
|
||||||
int y = MainUtil.y_loc[i][j];
|
|
||||||
oldblocks[y][x][z] = 0;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (int j = 0; j < result[i].length; j++) {
|
|
||||||
int x = MainUtil.x_loc[i][j] + xb;
|
|
||||||
if (x < 0 || x >= width) continue;
|
|
||||||
int z = MainUtil.z_loc[i][j] + zb;
|
|
||||||
if (z < 0 || z >= length) continue;
|
|
||||||
int y = MainUtil.y_loc[i][j];
|
|
||||||
oldblocks[y][x][z] = result[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int size = width * length;
|
|
||||||
int[] changes = new int[size];
|
|
||||||
int[] faces = new int[size];
|
|
||||||
int[] data = new int[size];
|
|
||||||
int[] air = new int[size];
|
|
||||||
int[] variety = new int[size];
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (int x = 0; x < width;x++) {
|
|
||||||
for (int z = 0; z < length;z++) {
|
|
||||||
HashSet<Short> types = new HashSet<>();
|
|
||||||
for (int y = 0; y < 256; y++) {
|
|
||||||
short old = oldblocks[y][x][z];
|
|
||||||
short now = newblocks[y][x][z];
|
|
||||||
if (old != now) {
|
|
||||||
changes[i]++;
|
|
||||||
}
|
|
||||||
if (now == 0) {
|
|
||||||
air[i]++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// check verticies
|
|
||||||
// modifications_adjacent
|
|
||||||
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 && y < 255) {
|
|
||||||
if (newblocks[y - 1][x][z] == 0) faces[i]++;
|
|
||||||
if (newblocks[y][x - 1][z] == 0) faces[i]++;
|
|
||||||
if (newblocks[y][x][z - 1] == 0) faces[i]++;
|
|
||||||
if (newblocks[y + 1][x][z] == 0) faces[i]++;
|
|
||||||
if (newblocks[y][x + 1][z] == 0) faces[i]++;
|
|
||||||
if (newblocks[y][x][z + 1] == 0) faces[i]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
Material material = Material.getMaterial(now);
|
|
||||||
Class<? extends MaterialData> md = material.getData();
|
|
||||||
if (md.equals(Directional.class)) {
|
|
||||||
data[i] += 8;
|
|
||||||
}
|
|
||||||
else if (!md.equals(MaterialData.class)) {
|
|
||||||
data[i]++;
|
|
||||||
}
|
|
||||||
types.add(now);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
variety[i] = types.size();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// analyze plot
|
|
||||||
// put in analysis obj
|
|
||||||
|
|
||||||
// run whenDone
|
|
||||||
PlotAnalysis analysis = new PlotAnalysis();
|
|
||||||
analysis.changes = (int) (MathMan.getMean(changes) * 100);
|
|
||||||
analysis.faces = (int) (MathMan.getMean(faces) * 100);
|
|
||||||
analysis.data = (int) (MathMan.getMean(data) * 100);
|
|
||||||
analysis.air = (int) (MathMan.getMean(air) * 100);
|
|
||||||
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
|
||||||
|
|
||||||
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes));
|
|
||||||
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces));
|
|
||||||
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data));
|
|
||||||
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air));
|
|
||||||
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety));
|
|
||||||
|
|
||||||
List<Integer> result = new ArrayList<>();
|
|
||||||
result.add(analysis.changes);
|
|
||||||
result.add(analysis.faces);
|
|
||||||
result.add(analysis.data);
|
|
||||||
result.add(analysis.air);
|
|
||||||
result.add(analysis.variety);
|
|
||||||
|
|
||||||
result.add(analysis.changes_sd);
|
|
||||||
result.add(analysis.faces_sd);
|
|
||||||
result.add(analysis.data_sd);
|
|
||||||
result.add(analysis.air_sd);
|
|
||||||
result.add(analysis.variety_sd);
|
|
||||||
Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
|
|
||||||
FlagManager.addPlotFlag(plot, flag);
|
|
||||||
System.gc();
|
|
||||||
System.gc();
|
|
||||||
whenDone.value = analysis;
|
|
||||||
whenDone.run();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
System.gc();
|
|
||||||
MainUtil.initCache();
|
|
||||||
TaskManager.index.incrementAndGet();
|
|
||||||
final Integer currentIndex = TaskManager.index.get();
|
|
||||||
final Integer task = TaskManager.runTaskRepeat(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
int index = chunks.size() - 1;
|
|
||||||
if (index == -1) {
|
|
||||||
PS.get().TASK.cancelTask(TaskManager.tasks.get(currentIndex));
|
|
||||||
TaskManager.runTaskAsync(run);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ChunkLoc chunk = chunks.remove(0);
|
final BiomeGrid base = new BiomeGrid() { @Override public void setBiome(int a, int b, Biome c) {} @Override public Biome getBiome(int a, int b) {return null;}};
|
||||||
world.loadChunk(chunk.x, chunk.z);
|
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
processed_chunks.add(chunk);
|
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||||
int X = chunk.x;
|
final int bx = bot.getX();
|
||||||
int Z = chunk.z;
|
final int bz = bot.getZ();
|
||||||
int minX;
|
final int tx = top.getX();
|
||||||
int minZ;
|
final int tz = top.getZ();
|
||||||
int maxX;
|
final int cbx = bx >> 4;
|
||||||
int maxZ;
|
final int cbz = bz >> 4;
|
||||||
if (X == cbx) minX = bx & 0x0f;
|
final int ctx = tx >> 4;
|
||||||
else minX = 0;
|
final int ctz = tz >> 4;
|
||||||
if (Z == cbz) minZ = bz & 0x0f;
|
final Random r = new Random();
|
||||||
else minZ = 0;
|
MainUtil.initCache();
|
||||||
if (X == ctx) maxX = tx & 0x0f;
|
final int width = tx - bx + 1;
|
||||||
else maxX = 16;
|
final int length = tz - bz + 1;
|
||||||
if (Z == ctz) maxZ = tz & 0x0f;
|
|
||||||
else maxZ = 16;
|
System.gc();
|
||||||
|
System.gc();
|
||||||
int cbx = X << 4;
|
final short[][][] oldblocks = new short[256][width][length];
|
||||||
int cbz = Z << 4;
|
final short[][][] newblocks = new short[256][width][length];
|
||||||
|
|
||||||
int xb = (cbx) - bx;
|
final Runnable run = new Runnable() {
|
||||||
int zb = (cbz) - bz;
|
@Override
|
||||||
for (int x = minX; x <= maxX; x++) {
|
public void run() {
|
||||||
int xx = cbx + cbz;
|
ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
@Override
|
||||||
int zz = cbz + z;
|
public void run() {
|
||||||
for (int y = 0; y < 256; y++) {
|
// TODO [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
|
||||||
Block block = world.getBlockAt(xx, y, zz);
|
int X = value[0];
|
||||||
int xr = xb + x;
|
int Z = value[1];
|
||||||
int zr = zb + z;
|
short[][] result = gen.generateExtBlockSections(world, r, X, Z, base);
|
||||||
newblocks[y][xr][zr] = (short) block.getTypeId();
|
int xb = ((X) << 4) - bx;
|
||||||
}
|
int zb = ((Z) << 4) - bz;
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
if (result[i] == null) {
|
||||||
|
for (int j = 0; j < 4096; j++) {
|
||||||
|
int x = MainUtil.x_loc[i][j] + xb;
|
||||||
|
if (x < 0 || x >= width) continue;
|
||||||
|
int z = MainUtil.z_loc[i][j] + zb;
|
||||||
|
if (z < 0 || z >= length) continue;
|
||||||
|
int y = MainUtil.y_loc[i][j];
|
||||||
|
oldblocks[y][x][z] = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < result[i].length; j++) {
|
||||||
|
int x = MainUtil.x_loc[i][j] + xb;
|
||||||
|
if (x < 0 || x >= width) continue;
|
||||||
|
int z = MainUtil.z_loc[i][j] + zb;
|
||||||
|
if (z < 0 || z >= length) continue;
|
||||||
|
int y = MainUtil.y_loc[i][j];
|
||||||
|
oldblocks[y][x][z] = result[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
int size = width * length;
|
||||||
|
int[] changes = new int[size];
|
||||||
|
int[] faces = new int[size];
|
||||||
|
int[] data = new int[size];
|
||||||
|
int[] air = new int[size];
|
||||||
|
int[] variety = new int[size];
|
||||||
|
int i = 0;
|
||||||
|
for (int x = 0; x < width;x++) {
|
||||||
|
for (int z = 0; z < length;z++) {
|
||||||
|
HashSet<Short> types = new HashSet<>();
|
||||||
|
for (int y = 0; y < 256; y++) {
|
||||||
|
short old = oldblocks[y][x][z];
|
||||||
|
short now = newblocks[y][x][z];
|
||||||
|
if (old != now) {
|
||||||
|
changes[i]++;
|
||||||
|
}
|
||||||
|
if (now == 0) {
|
||||||
|
air[i]++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// check verticies
|
||||||
|
// modifications_adjacent
|
||||||
|
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 && y < 255) {
|
||||||
|
if (newblocks[y - 1][x][z] == 0) faces[i]++;
|
||||||
|
if (newblocks[y][x - 1][z] == 0) faces[i]++;
|
||||||
|
if (newblocks[y][x][z - 1] == 0) faces[i]++;
|
||||||
|
if (newblocks[y + 1][x][z] == 0) faces[i]++;
|
||||||
|
if (newblocks[y][x + 1][z] == 0) faces[i]++;
|
||||||
|
if (newblocks[y][x][z + 1] == 0) faces[i]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Material material = Material.getMaterial(now);
|
||||||
|
Class<? extends MaterialData> md = material.getData();
|
||||||
|
if (md.equals(Directional.class)) {
|
||||||
|
data[i] += 8;
|
||||||
|
}
|
||||||
|
else if (!md.equals(MaterialData.class)) {
|
||||||
|
data[i]++;
|
||||||
|
}
|
||||||
|
types.add(now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
variety[i] = types.size();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// analyze plot
|
||||||
|
// put in analysis obj
|
||||||
|
|
||||||
|
// run whenDone
|
||||||
|
PlotAnalysis analysis = new PlotAnalysis();
|
||||||
|
analysis.changes = (int) (MathMan.getMean(changes) * 100);
|
||||||
|
analysis.faces = (int) (MathMan.getMean(faces) * 100);
|
||||||
|
analysis.data = (int) (MathMan.getMean(data) * 100);
|
||||||
|
analysis.air = (int) (MathMan.getMean(air) * 100);
|
||||||
|
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
||||||
|
|
||||||
|
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes));
|
||||||
|
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces));
|
||||||
|
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data));
|
||||||
|
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air));
|
||||||
|
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety));
|
||||||
|
|
||||||
|
List<Integer> result = new ArrayList<>();
|
||||||
|
result.add(analysis.changes);
|
||||||
|
result.add(analysis.faces);
|
||||||
|
result.add(analysis.data);
|
||||||
|
result.add(analysis.air);
|
||||||
|
result.add(analysis.variety);
|
||||||
|
|
||||||
|
result.add(analysis.changes_sd);
|
||||||
|
result.add(analysis.faces_sd);
|
||||||
|
result.add(analysis.data_sd);
|
||||||
|
result.add(analysis.air_sd);
|
||||||
|
result.add(analysis.variety_sd);
|
||||||
|
Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
|
||||||
|
FlagManager.addPlotFlag(plot, flag);
|
||||||
|
System.gc();
|
||||||
|
System.gc();
|
||||||
|
whenDone.value = analysis;
|
||||||
|
whenDone.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 5);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
world.unloadChunkRequest(chunk.x, chunk.z, true);
|
System.gc();
|
||||||
|
MainUtil.initCache();
|
||||||
|
ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
int X = value[0];
|
||||||
|
int Z = value[1];
|
||||||
|
world.loadChunk(X, Z);
|
||||||
|
int minX;
|
||||||
|
int minZ;
|
||||||
|
int maxX;
|
||||||
|
int maxZ;
|
||||||
|
if (X == cbx) minX = bx & 15;
|
||||||
|
else minX = 0;
|
||||||
|
if (Z == cbz) minZ = bz & 15;
|
||||||
|
else minZ = 0;
|
||||||
|
if (X == ctx) maxX = tx & 15;
|
||||||
|
else maxX = 16;
|
||||||
|
if (Z == ctz) maxZ = tz & 15;
|
||||||
|
else maxZ = 16;
|
||||||
|
|
||||||
|
int cbx = X << 4;
|
||||||
|
int cbz = Z << 4;
|
||||||
|
|
||||||
|
int xb = (cbx) - bx;
|
||||||
|
int zb = (cbz) - bz;
|
||||||
|
for (int x = minX; x <= maxX; x++) {
|
||||||
|
int xx = cbx + x;
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
int zz = cbz + z;
|
||||||
|
for (int y = 0; y < 256; y++) {
|
||||||
|
Block block = world.getBlockAt(xx, y, zz);
|
||||||
|
int xr = xb + x;
|
||||||
|
int zr = zb + z;
|
||||||
|
newblocks[y][xr][zr] = (short) block.getTypeId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
world.unloadChunkRequest(X, Z, true);
|
||||||
|
}
|
||||||
|
}, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TaskManager.runTaskAsync(run);
|
||||||
|
}
|
||||||
|
}, 5);
|
||||||
}
|
}
|
||||||
}, 1);
|
});
|
||||||
TaskManager.tasks.put(currentIndex, task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -229,7 +229,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
server = game.getServer();
|
server = game.getServer();
|
||||||
//
|
//
|
||||||
|
|
||||||
PS.instance = new PS(this);
|
PS.instance = new PS(this, "Sponge");
|
||||||
|
|
||||||
// TODO Until P^2 has json chat stuff for sponge, disable this
|
// TODO Until P^2 has json chat stuff for sponge, disable this
|
||||||
Settings.FANCY_CHAT = false;
|
Settings.FANCY_CHAT = false;
|
||||||
|
@ -2,13 +2,8 @@ package com.plotsquared.sponge.object;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.spongepowered.api.data.key.Keys;
|
|
||||||
import org.spongepowered.api.data.manipulator.mutable.TargetedLocationData;
|
|
||||||
import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData;
|
|
||||||
import org.spongepowered.api.data.value.mutable.Value;
|
|
||||||
import org.spongepowered.api.entity.player.Player;
|
import org.spongepowered.api.entity.player.Player;
|
||||||
import org.spongepowered.api.entity.player.gamemode.GameMode;
|
import org.spongepowered.api.entity.player.gamemode.GameMode;
|
||||||
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
||||||
@ -96,7 +91,11 @@ public class SpongePlayer extends PlotPlayer {
|
|||||||
this.hasPerm.add(perm);
|
this.hasPerm.add(perm);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return this.player.hasPermission(perm);
|
boolean value = this.player.hasPermission(perm);
|
||||||
|
|
||||||
|
// TODO check children
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
BIN
target/PlotSquared-Bukkit.jar
Normal file
BIN
target/PlotSquared-Bukkit.jar
Normal file
Binary file not shown.
BIN
target/PlotSquared-Sponge.jar
Normal file
BIN
target/PlotSquared-Sponge.jar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user