mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Bump version / misc
Fix regenallroads Add schematic y_offset Change visit/list for multi-owner plots Fix updater (pre-1.7.10)
This commit is contained in:
parent
109715e0d7
commit
f00ac79c91
14 changed files with 85 additions and 78 deletions
|
@ -34,7 +34,7 @@ public class GenChunk extends PlotChunk<Chunk> {
|
|||
@Override
|
||||
public Chunk getChunkAbs() {
|
||||
ChunkWrapper wrap = getChunkWrapper();
|
||||
if (wrap.x != chunk.getX() || wrap.z != chunk.getZ()) {
|
||||
if (chunk == null || wrap.x != chunk.getX() || wrap.z != chunk.getZ()) {
|
||||
chunk = BukkitUtil.getWorld(wrap.world).getChunkAt(wrap.x, wrap.z);
|
||||
}
|
||||
return chunk;
|
||||
|
@ -65,9 +65,14 @@ public class GenChunk extends PlotChunk<Chunk> {
|
|||
modified = true;
|
||||
result[i] = v = new short[4096];
|
||||
}
|
||||
v[MainUtil.CACHE_J[y][x][z]] = (short) id;
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
v[j] = (short) id;
|
||||
if (data != 0) {
|
||||
getChunk().getBlock(x, y, z).setData(data);
|
||||
byte[] vd = result_data[i];
|
||||
if (vd == null) {
|
||||
result_data[i] = vd = new byte[4096];
|
||||
}
|
||||
vd[j] = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1332,6 +1332,10 @@ public class PS {
|
|||
return getPlots(player.getUUID());
|
||||
}
|
||||
|
||||
public Set<Plot> getBasePlots(final PlotPlayer player) {
|
||||
return getBasePlots(player.getUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots for a UUID
|
||||
* @param uuid
|
||||
|
@ -1350,6 +1354,19 @@ public class PS {
|
|||
return new HashSet<>(myplots);
|
||||
}
|
||||
|
||||
public Set<Plot> getBasePlots(final UUID uuid) {
|
||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||
foreachBasePlot(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot value) {
|
||||
if (value.isOwner(uuid)) {
|
||||
myplots.add(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return new HashSet<>(myplots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots for a UUID
|
||||
* @param uuid
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package com.intellectualcrafters.plot;
|
||||
|
||||
import static com.intellectualcrafters.plot.PS.log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellectualcrafters.plot.PS.log;
|
||||
|
||||
public class Updater {
|
||||
|
||||
|
@ -44,42 +43,32 @@ public class Updater {
|
|||
|
||||
public static URL getUpdate() {
|
||||
String str = readUrl("https://api.github.com/repos/IntellectualSites/PlotSquared/releases/latest");
|
||||
Gson gson = new Gson();
|
||||
URL url = null;
|
||||
Release release = gson.fromJson(str, Release.class);
|
||||
JSONObject release = new JSONObject(str);
|
||||
JSONArray assets = (JSONArray) release.get("assets");
|
||||
String downloadURL = String.format("PlotSquared-%s%n.jar", PS.get().getPlatform());
|
||||
List<Release.Asset> assets = release.assets;
|
||||
for (Release.Asset asset : assets) {
|
||||
if (asset.name.equals(downloadURL)) {
|
||||
for (int i = 0; i < assets.length(); i++) {
|
||||
JSONObject asset = assets.getJSONObject(i);
|
||||
String name = asset.getString("name");
|
||||
if (downloadURL.equals(name)) {
|
||||
try {
|
||||
url = new URL(asset.downloadUrl);
|
||||
break;
|
||||
String version = release.getString("name");
|
||||
URL url = new URL(asset.getString("downloadUrl"));
|
||||
if (!PS.get().canUpdate(PS.get().config.getString("version"), version)) {
|
||||
PS.debug("&7PlotSquared is already up to date!");
|
||||
return null;
|
||||
}
|
||||
log("&6PlotSquared " + version + " is available:");
|
||||
log("&8 - &3Use: &7/plot update");
|
||||
log("&8 - &3Or: &7" + downloadURL);
|
||||
return url;
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
log("&dCould not check for updates (0)");
|
||||
log("&dCould not check for updates (1)");
|
||||
log("&7 - Manually check for updates: https://github.com/IntellectualSites/PlotSquared/releases");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!PS.get().canUpdate(PS.get().config.getString("version"), release.name)) {
|
||||
PS.debug("&7PlotSquared is already up to date!");
|
||||
return null;
|
||||
}
|
||||
log("&6PlotSquared " + release.tagName + " is available:");
|
||||
log("&8 - &3Use: &7/plot update");
|
||||
log("&8 - &3Or: &7" + downloadURL);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
private static class Release {
|
||||
public String name;
|
||||
@SerializedName("tag_name") String tagName;
|
||||
List<Asset> assets;
|
||||
static class Asset {
|
||||
public String name;
|
||||
@SerializedName("browser_download_url") String downloadUrl;
|
||||
}
|
||||
|
||||
log("You are running the latest version of PlotSquared");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class Claim extends SubCommand {
|
|||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
}
|
||||
}
|
||||
SchematicHandler.manager.paste(sch, plot, 0, 0, new RunnableVal<Boolean>() {
|
||||
SchematicHandler.manager.paste(sch, plot, 0, 0, 0, true, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
if (value) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class Load extends SubCommand {
|
|||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
|
||||
return;
|
||||
}
|
||||
SchematicHandler.manager.paste(schematic, plot, 0, 0, new RunnableVal<Boolean>() {
|
||||
SchematicHandler.manager.paste(schematic, plot, 0, 0, 0, true, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
plot.removeRunning();
|
||||
|
|
|
@ -61,7 +61,7 @@ public class RegenAllRoads extends SubCommand {
|
|||
return false;
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
if (area == null || WorldUtil.IMP.isWorld(area.worldname)) {
|
||||
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[0]);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -20,20 +20,10 @@
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
|
@ -41,6 +31,11 @@ import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
|||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "schematic",
|
||||
permission = "plots.schematic",
|
||||
|
@ -114,7 +109,7 @@ public class SchematicCmd extends SubCommand {
|
|||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
|
||||
return;
|
||||
}
|
||||
SchematicHandler.manager.paste(schematic, plot, 0, 0, new RunnableVal<Boolean>() {
|
||||
SchematicHandler.manager.paste(schematic, plot, 0, 0, 0, true, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
running = false;
|
||||
|
|
|
@ -20,14 +20,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
@ -39,6 +31,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "visit",
|
||||
permission = "plots.visit",
|
||||
|
@ -83,11 +77,11 @@ public class Visit extends SubCommand {
|
|||
final UUID user = UUIDHandler.getCachedUUID(args[0], null);
|
||||
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
|
||||
page = Integer.parseInt(args[0]);
|
||||
unsorted = PS.get().getPlots(player);
|
||||
unsorted = PS.get().getBasePlots(player);
|
||||
break;
|
||||
}
|
||||
if (user != null) {
|
||||
unsorted = PS.get().getPlots(user);
|
||||
unsorted = PS.get().getBasePlots(user);
|
||||
} else if (PS.get().getPlotAreaByString(args[0]) != null) {
|
||||
unsorted = PS.get().getPlotAreaByString(args[0]).getPlots();
|
||||
} else {
|
||||
|
|
|
@ -132,7 +132,7 @@ public class list extends SubCommand {
|
|||
return false;
|
||||
}
|
||||
sort = false;
|
||||
plots = PS.get().sortPlotsByTemp(PS.get().getPlots(plr));
|
||||
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(plr));
|
||||
break;
|
||||
}
|
||||
case "shared": {
|
||||
|
|
|
@ -409,7 +409,7 @@ public abstract class HybridUtils {
|
|||
}
|
||||
if (blocks != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : blocks.entrySet()) {
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, sy + entry.getKey(), z + Z + plotworld.ROAD_OFFSET_Z, entry.getValue());
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, entry.getKey(), z + Z + plotworld.ROAD_OFFSET_Z, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,8 @@ public abstract class SchematicHandler {
|
|||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Paste a schematic
|
||||
|
@ -107,7 +109,7 @@ public abstract class SchematicHandler {
|
|||
*
|
||||
* @return boolean true if succeeded
|
||||
*/
|
||||
public void paste(final Schematic schematic, final Plot plot, final int x_offset, final int z_offset, final RunnableVal<Boolean> whenDone) {
|
||||
public void paste(final Schematic schematic, final Plot plot, final int x_offset, final int y_offset, final int z_offset, final boolean autoHeight, final RunnableVal<Boolean> whenDone) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -147,18 +149,23 @@ public abstract class SchematicHandler {
|
|||
final short[] ids = schematic.ids;
|
||||
final byte[] datas = schematic.datas;
|
||||
// Calculate the optimal height to paste the schematic at
|
||||
final int y_offset;
|
||||
if (HEIGHT >= 256) {
|
||||
y_offset = 0;
|
||||
} else {
|
||||
PlotArea pw = plot.getArea();
|
||||
if (pw instanceof ClassicPlotWorld) {
|
||||
y_offset = ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
||||
final int y_offset_actual;
|
||||
if (autoHeight) {
|
||||
if (HEIGHT >= 256) {
|
||||
y_offset_actual = y_offset;
|
||||
} else {
|
||||
y_offset = MainUtil.getHeighestBlock(plot.getArea().worldname, region.minX + 1, region.minZ + 1);
|
||||
PlotArea pw = plot.getArea();
|
||||
if (pw instanceof ClassicPlotWorld) {
|
||||
y_offset_actual = y_offset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
||||
} else {
|
||||
y_offset_actual = y_offset + MainUtil.getHeighestBlock(plot.getArea().worldname, region.minX + 1, region.minZ + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
final Location pos1 = new Location(plot.getArea().worldname, region.minX + x_offset, y_offset, region.minZ + z_offset);
|
||||
else {
|
||||
y_offset_actual = y_offset;
|
||||
}
|
||||
final Location pos1 = new Location(plot.getArea().worldname, region.minX + x_offset, y_offset_actual, region.minZ + z_offset);
|
||||
final Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||
// TODO switch to ChunkManager.chunkTask(pos1, pos2, task, whenDone, allocate);
|
||||
final int p1x = pos1.getX();
|
||||
|
@ -203,7 +210,7 @@ public abstract class SchematicHandler {
|
|||
// Paste schematic here
|
||||
|
||||
for (int ry = 0; ry < Math.min(256, HEIGHT); ry++) {
|
||||
final int yy = y_offset + ry;
|
||||
final int yy = y_offset_actual + ry;
|
||||
if (yy > 255) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ import java.util.*;
|
|||
* Created by robin on 01/11/2014
|
||||
*/
|
||||
|
||||
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.3.0", dependencies = "before:WorldEdit")
|
||||
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.3.1", dependencies = "before:WorldEdit")
|
||||
public class SpongeMain implements IPlotMain {
|
||||
public static SpongeMain THIS;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ buildscript {
|
|||
}
|
||||
|
||||
group = 'com.intellectualcrafters'
|
||||
version = '3.3.0'
|
||||
version = '3.3.1'
|
||||
description = """PlotSquared"""
|
||||
|
||||
subprojects {
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.1</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
|
Loading…
Reference in a new issue