mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
last commit before 4.0.0
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
@ -69,7 +69,15 @@ import java.util.*;
|
||||
if (this.engine != null) {
|
||||
return;
|
||||
}
|
||||
this.engine = new ScriptEngineManager(null).getEngineByName("nashorn");
|
||||
//create script engine manager
|
||||
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
||||
//create nashorn engine
|
||||
this.engine = scriptEngineManager.getEngineByName("nashorn");
|
||||
try {
|
||||
engine.eval("print('PlotSquared Scripting Test');");
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (this.engine == null) {
|
||||
this.engine = new ScriptEngineManager(null).getEngineByName("JavaScript");
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
|
||||
@CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot",
|
||||
aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE) public class Move extends SubCommand {
|
||||
aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
|
||||
public class Move extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
|
@ -9,8 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players",
|
||||
usage = "/plot near", category = CommandCategory.INFO) public class Near extends Command {
|
||||
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
|
||||
public class Near extends Command {
|
||||
public Near() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ import java.util.Set;
|
||||
MainUtil.sendMessage(null, " - TIME ESTIMATE: 12 Parsecs");
|
||||
TaskManager.objectTask(plots, new RunnableVal<Plot>() {
|
||||
@Override public void run(Plot plot) {
|
||||
Location pos1 = plot.getBottom();
|
||||
Location pos2 = plot.getTop();
|
||||
Location pos1 = plot.getCorners()[0];
|
||||
Location pos2 = plot.getCorners()[1];
|
||||
int ccx1 = pos1.getX() >> 9;
|
||||
int ccz1 = pos1.getZ() >> 9;
|
||||
int ccx2 = pos2.getX() >> 9;
|
||||
|
@ -44,7 +44,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
@Override public boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
setWallFilling(dpw, plot.getId(), dpw.WALL_FILLING);
|
||||
setWall(dpw, plot.getId(), dpw.WALL_BLOCK);
|
||||
|
@ -57,7 +57,11 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
|
||||
@Override public Location clone() {
|
||||
return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch);
|
||||
try {
|
||||
return (Location) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError(); //can't happen
|
||||
}
|
||||
}
|
||||
|
||||
public PlotArea getPlotArea() {
|
||||
@ -65,7 +69,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
|
||||
public Plot getOwnedPlot() {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
||||
PlotArea area = getPlotArea();
|
||||
if (area != null) {
|
||||
return area.getOwnedPlot(this);
|
||||
} else {
|
||||
@ -74,7 +78,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
|
||||
public Plot getOwnedPlotAbs() {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
||||
PlotArea area = getPlotArea();
|
||||
if (area != null) {
|
||||
return area.getOwnedPlotAbs(this);
|
||||
} else {
|
||||
@ -83,16 +87,16 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
|
||||
public boolean isPlotArea() {
|
||||
return PlotSquared.get().getPlotAreaAbs(this) != null;
|
||||
return getPlotArea() != null;
|
||||
}
|
||||
|
||||
public boolean isPlotRoad() {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
||||
PlotArea area = getPlotArea();
|
||||
return area != null && area.getPlotAbs(this) == null;
|
||||
}
|
||||
|
||||
public boolean isUnownedPlotArea() {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
||||
PlotArea area = getPlotArea();
|
||||
return area != null && area.getOwnedPlotAbs(this) == null;
|
||||
}
|
||||
|
||||
@ -106,7 +110,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
|
||||
public Plot getPlotAbs() {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
||||
PlotArea area = getPlotArea();
|
||||
if (area != null) {
|
||||
return area.getPlotAbs(this);
|
||||
} else {
|
||||
@ -115,7 +119,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
|
||||
public Plot getPlot() {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
||||
PlotArea area = getPlotArea();
|
||||
if (area != null) {
|
||||
return area.getPlot(this);
|
||||
} else {
|
||||
|
@ -226,7 +226,7 @@ public class Plot {
|
||||
* @see PlotPlayer#getCurrentPlot() if a player is expected here.
|
||||
*/
|
||||
public static Plot getPlot(Location location) {
|
||||
PlotArea pa = PlotSquared.get().getPlotAreaAbs(location);
|
||||
PlotArea pa = location.getPlotArea();
|
||||
if (pa != null) {
|
||||
return pa.getPlot(location);
|
||||
}
|
||||
@ -457,7 +457,7 @@ public class Plot {
|
||||
* Gets or create plot settings.
|
||||
*
|
||||
* @return PlotSettings
|
||||
* @deprecated use equivalent plot method;
|
||||
* @deprecated use equivalent plot method; please file github issue if one does not exist.
|
||||
*/
|
||||
@Deprecated public PlotSettings getSettings() {
|
||||
if (this.settings == null) {
|
||||
@ -837,7 +837,7 @@ public class Plot {
|
||||
};
|
||||
for (Plot current : plots) {
|
||||
if (isDelete || current.owner == null) {
|
||||
manager.unclaimPlot(Plot.this.area, current, null);
|
||||
manager.unClaimPlot(Plot.this.area, current, null);
|
||||
} else {
|
||||
manager.claimPlot(Plot.this.area, current);
|
||||
}
|
||||
@ -1567,13 +1567,19 @@ public class Plot {
|
||||
*/
|
||||
public boolean swapData(Plot plot, Runnable whenDone) {
|
||||
if (this.owner == null) {
|
||||
if (plot != null && plot.hasOwner()) {
|
||||
if (plot == null) {
|
||||
return false;
|
||||
}
|
||||
if (plot.hasOwner()) {
|
||||
plot.moveData(this, whenDone);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (plot == null || plot.owner == null) {
|
||||
if (plot == null) {
|
||||
this.moveData(plot, whenDone);
|
||||
return true;
|
||||
} else if (plot.owner == null) {
|
||||
this.moveData(plot, whenDone);
|
||||
return true;
|
||||
}
|
||||
@ -2900,7 +2906,7 @@ public class Plot {
|
||||
getManager().claimPlot(current.getArea(), current);
|
||||
Plot originPlot = originArea.getPlotAbs(
|
||||
new PlotId(current.id.x - offset.x, current.id.y - offset.y));
|
||||
originPlot.getManager().unclaimPlot(originArea, originPlot, null);
|
||||
originPlot.getManager().unClaimPlot(originArea, originPlot, null);
|
||||
}
|
||||
plot.setSign();
|
||||
TaskManager.runTask(whenDone);
|
||||
|
@ -31,7 +31,7 @@ public abstract class PlotManager {
|
||||
|
||||
public abstract boolean claimPlot(PlotArea plotArea, Plot plot);
|
||||
|
||||
public abstract boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone);
|
||||
public abstract boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone);
|
||||
|
||||
public abstract Location getSignLoc(PlotArea plotArea, Plot plot);
|
||||
|
||||
|
@ -83,10 +83,7 @@ public class StringPlotBlock extends PlotBlock {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
StringPlotBlock other = (StringPlotBlock) obj;
|
||||
|
@ -46,7 +46,7 @@ public class SinglePlotManager extends PlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
@Override public boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
|
@ -76,11 +76,7 @@ public abstract class EventUtil {
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (Settings.Teleport.ON_LOGIN && plot != null) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override public void run() {
|
||||
plot.teleportPlayer(player);
|
||||
}
|
||||
});
|
||||
TaskManager.runTask(() -> plot.teleportPlayer(player));
|
||||
MainUtil.sendMessage(player,
|
||||
Captions.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot
|
||||
.getId().y + ")");
|
||||
@ -97,19 +93,13 @@ public abstract class EventUtil {
|
||||
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type,
|
||||
Location location, LazyBlock block, boolean notifyPerms) {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(location);
|
||||
Plot plot;
|
||||
if (area != null) {
|
||||
plot = area.getPlot(location);
|
||||
} else {
|
||||
plot = null;
|
||||
}
|
||||
if (plot == null) {
|
||||
if (area == null) {
|
||||
PlotArea area = location.getPlotArea();
|
||||
assert area != null;
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
if (plot.isAdded(player.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
} else if (plot.isAdded(player.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
switch (type) {
|
||||
case TELEPORT_OBJECT:
|
||||
@ -400,8 +390,6 @@ public abstract class EventUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case PLACE_HANGING: // Handled elsewhere
|
||||
return true;
|
||||
case PLACE_MISC: {
|
||||
if (plot == null) {
|
||||
return Permissions
|
||||
|
@ -70,8 +70,8 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue {
|
||||
return parent.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override public boolean setBiome(int x, int y, String biome) {
|
||||
return parent.setBiome(x, y, biome);
|
||||
@Override public boolean setBiome(int x, int z, String biome) {
|
||||
return parent.setBiome(x, z, biome);
|
||||
}
|
||||
|
||||
@Override public String getWorld() {
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.object;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class LocationTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(LocationTest.class.getName());
|
||||
|
||||
@Test public void cloning() {
|
||||
String world = "plotworld";
|
||||
Location location1 = new Location(world, 0, 0, 0);
|
||||
logger.info(location1.toString());
|
||||
Location clone = location1.clone();
|
||||
world = "normal";
|
||||
logger.info(clone.toString());
|
||||
location1.getBlockVector3()
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user