mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
parent
05caa2ca8d
commit
62531a42c7
@ -2,63 +2,19 @@ package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedUtils;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Beacon;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.BrewingStand;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.block.Dispenser;
|
||||
import org.bukkit.block.Dropper;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.block.Hopper;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.block.NoteBlock;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
@ -665,7 +621,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer pp = entry.getValue();
|
||||
Location pLoc = pp.getLocation();
|
||||
if (!pLoc.getChunkLoc().equals(loc)) {
|
||||
if (!StringMan.isEqual(world, pLoc.getWorld()) || !pLoc.getChunkLoc().equals(loc)) {
|
||||
continue;
|
||||
}
|
||||
pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ()));
|
||||
|
@ -20,27 +20,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.jnbt.IntTag;
|
||||
import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.jnbt.*;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
@ -49,6 +29,14 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Schematic Handler
|
||||
|
@ -125,7 +125,7 @@ public class SendChunk {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
|
||||
public void sendChunk(final String worldname, final Collection<ChunkLoc> locs) {
|
||||
final World myworld = Bukkit.getWorld(worldname);
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
for (final ChunkLoc loc : locs) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -23,6 +21,8 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_7 extends SlowQueue {
|
||||
|
||||
private final RefClass classBlock = getRefClass("{nms}.Block");
|
||||
@ -173,9 +173,8 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
toUpdate.remove(wrapper);
|
||||
}
|
||||
chunksender.sendChunk(world, locs);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -25,6 +23,8 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_8 extends SlowQueue {
|
||||
|
||||
private final RefMethod methodInitLighting;
|
||||
@ -376,9 +376,8 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
toUpdate.remove(wrapper);
|
||||
}
|
||||
chunksender.sendChunk(world, locs);
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,14 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Chunk;
|
||||
@ -26,13 +20,10 @@ import org.bukkit.block.Biome;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
@ -407,9 +398,8 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
toUpdate.remove(wrapper);
|
||||
}
|
||||
chunksender.sendChunk(world, locs);
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,14 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Chunk;
|
||||
@ -26,13 +20,10 @@ import org.bukkit.block.Biome;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
@ -456,13 +447,17 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
* @param locs
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locs) {
|
||||
public void sendChunk(final String world, final Collection<ChunkLoc> locs) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
toUpdate.remove(wrapper);
|
||||
}
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chunksender.sendChunk(world, locs);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
@ -356,16 +356,6 @@ public class PS {
|
||||
return database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the global reference
|
||||
* to a plot object
|
||||
*
|
||||
* @param plot Plot Object to update
|
||||
*/
|
||||
public boolean updatePlot(final Plot plot) {
|
||||
return plot.getArea().addPlot(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the relevant plot area for a location.<br>
|
||||
* - If there is only one plot area globally that will be returned<br>
|
||||
@ -705,12 +695,14 @@ public class PS {
|
||||
public void run(PlotArea value) {
|
||||
for (final PlotFilter filter : filters) {
|
||||
if (!filter.allowsArea(value)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) {
|
||||
Plot plot = entry2.getValue();
|
||||
for (final PlotFilter filter : filters) {
|
||||
if (!filter.allowsPlot(plot)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
set.add(plot);
|
||||
@ -771,7 +763,7 @@ public class PS {
|
||||
@Override
|
||||
public void run(PlotArea value) {
|
||||
for (Plot plot : value.getPlots()) {
|
||||
if (plot.getMerged(0) || plot.getMerged(3)) {
|
||||
if (!plot.isBasePlot()) {
|
||||
continue;
|
||||
}
|
||||
result.add(plot);
|
||||
|
@ -171,7 +171,7 @@ public class Auto extends SubCommand {
|
||||
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
Plot current = plotarea.getPlotAbs(currentId);
|
||||
if (current.canClaim(plr)) {
|
||||
Claim.claimPlot(plr, current, true, true);
|
||||
current.claim(plr, true, null);
|
||||
return true;
|
||||
}
|
||||
id = getNextPlotId(id, 1);
|
||||
@ -185,7 +185,7 @@ public class Auto extends SubCommand {
|
||||
while (!br) {
|
||||
Plot plot = plotarea.getPlotAbs(getLastPlotId(plotarea));
|
||||
if (plot.canClaim(plr)) {
|
||||
Claim.claimPlot(plr, plot, true, true);
|
||||
plot.claim(plr, true, null);
|
||||
br = true;
|
||||
}
|
||||
plotarea.setMeta("lastPlot", getNextPlotId(plot.getId(), 1));
|
||||
@ -200,7 +200,7 @@ public class Auto extends SubCommand {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
Claim.claimPlot(plr, plot, teleport, true);
|
||||
plot.claim(plr, teleport, null);
|
||||
}
|
||||
}
|
||||
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {
|
||||
|
@ -22,9 +22,13 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
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.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -36,50 +40,6 @@ requiredType = RequiredType.NONE,
|
||||
permission = "plots.claim",
|
||||
usage = "/plot claim")
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final boolean auto) {
|
||||
return claimPlot(player, plot, teleport, "", auto);
|
||||
}
|
||||
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
|
||||
if (plot.hasOwner() || plot.isMerged()) {
|
||||
return false;
|
||||
}
|
||||
final boolean result = EventUtil.manager.callClaim(player, plot, false);
|
||||
if (result) {
|
||||
plot.create(player.getUUID(), true);
|
||||
plot.setSign(player.getName());
|
||||
MainUtil.sendMessage(player, C.CLAIMED);
|
||||
if (teleport) {
|
||||
plot.teleportPlayer(player);
|
||||
}
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||
Schematic sch;
|
||||
if (schematic.isEmpty()) {
|
||||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
} else {
|
||||
sch = SchematicHandler.manager.getSchematic(schematic);
|
||||
if (sch == null) {
|
||||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
}
|
||||
}
|
||||
SchematicHandler.manager.paste(sch, plot, 0, 0, 0, true, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
if (value) {
|
||||
MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
plotworld.getPlotManager().claimPlot(plotworld, plot);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
String schematic = "";
|
||||
@ -137,6 +97,6 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
return claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return plot.claim(plr, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class Database extends SubCommand {
|
||||
MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp);
|
||||
continue;
|
||||
}
|
||||
PS.get().updatePlot(plot);
|
||||
plot.create();
|
||||
plots.add(entry2.getValue());
|
||||
}
|
||||
} else {
|
||||
|
@ -119,7 +119,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
});
|
||||
for (final Plot plot : plots) {
|
||||
PS.get().updatePlot(plot);
|
||||
plot.create();
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||
} else {
|
||||
|
@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import com.plotsquared.listener.WEManager;
|
||||
|
||||
import javax.script.*;
|
||||
import java.io.File;
|
||||
@ -100,6 +101,11 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
// Instances
|
||||
scope.put("PS", PS.get());
|
||||
scope.put("SetQueue", SetQueue.IMP);
|
||||
scope.put("ExpireManager", ExpireManager.IMP);
|
||||
if (PS.get().worldedit != null) {
|
||||
scope.put("WEManager", new WEManager());
|
||||
}
|
||||
scope.put("TaskManager", PS.get().TASK);
|
||||
scope.put("TitleManager", AbstractTitle.TITLE_CLASS);
|
||||
scope.put("ConsolePlayer", ConsolePlayer.getConsole());
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -16,16 +14,13 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@CommandDeclaration(command = "download", aliases = { "dl" }, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download")
|
||||
public class Download extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
if (!Settings.METRICS) {
|
||||
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
return false;
|
||||
}
|
||||
final String world = plr.getLocation().getWorld();
|
||||
if (!PS.get().hasPlotArea(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
|
@ -21,18 +21,25 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = { "version" }, category = CommandCategory.INFO)
|
||||
public class plugin extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
ChunkLoc cl = loc.getChunkLoc();
|
||||
SetQueue.IMP.queue.sendChunk(loc.getWorld(), Collections.singletonList(cl));
|
||||
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), ".")));
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92");
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
|
@ -431,6 +431,9 @@ public class Plot {
|
||||
}
|
||||
|
||||
public void setArea(final PlotArea area) {
|
||||
if (this.getArea() == area) {
|
||||
return;
|
||||
}
|
||||
if (this.getArea() != null) {
|
||||
this.area.removePlot(this.id);
|
||||
}
|
||||
@ -1167,8 +1170,9 @@ public class Plot {
|
||||
if (baseSettings.getRatings().containsKey(uuid)) {
|
||||
return false;
|
||||
}
|
||||
baseSettings.getRatings().put(uuid, rating.getAggregate());
|
||||
DBFunc.setRating(base, uuid, this.temp);
|
||||
int aggregate = rating.getAggregate();
|
||||
baseSettings.getRatings().put(uuid, aggregate);
|
||||
DBFunc.setRating(base, uuid, aggregate);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1260,6 +1264,45 @@ public class Plot {
|
||||
return this.create(this.owner, true);
|
||||
}
|
||||
|
||||
public boolean claim(final PlotPlayer pp, boolean teleport, String schematic) {
|
||||
if (!canClaim(pp)) {
|
||||
return false;
|
||||
}
|
||||
final boolean result = EventUtil.manager.callClaim(pp, this, false);
|
||||
if (!result || !create(pp.getUUID(), true)) {
|
||||
return false;
|
||||
}
|
||||
setSign(pp.getName());
|
||||
MainUtil.sendMessage(pp, C.CLAIMED);
|
||||
if (teleport) {
|
||||
teleportPlayer(pp);
|
||||
}
|
||||
final PlotArea plotworld = getArea();
|
||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||
SchematicHandler.Schematic sch;
|
||||
if (schematic.isEmpty()) {
|
||||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
} else {
|
||||
sch = SchematicHandler.manager.getSchematic(schematic);
|
||||
if (sch == null) {
|
||||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
}
|
||||
}
|
||||
SchematicHandler.manager.paste(sch, this, 0, 0, 0, true, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
if (value) {
|
||||
MainUtil.sendMessage(pp, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, C.SCHEMATIC_PASTE_FAILED);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
plotworld.getPlotManager().claimPlot(plotworld, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a plot and create it in the database<br>
|
||||
* - The plot will not be created if the owner is null<br>
|
||||
@ -2697,7 +2740,6 @@ public class Plot {
|
||||
DBFunc.setDenied(other, denied);
|
||||
}
|
||||
}
|
||||
PS.get().updatePlot(other);
|
||||
}
|
||||
// copy terrain
|
||||
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions());
|
||||
|
@ -414,28 +414,28 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
||||
final HashSet<Plot> plots = new HashSet<>();
|
||||
final HashSet<Plot> myplots = new HashSet<>();
|
||||
foreachPlotAbs(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot value) {
|
||||
if (value.owner.equals(uuid)) {
|
||||
plots.add(value);
|
||||
myplots.add(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return plots;
|
||||
return myplots;
|
||||
}
|
||||
|
||||
public Set<Plot> getPlots(UUID uuid) {
|
||||
HashSet<Plot> plots = new HashSet<>();
|
||||
HashSet<Plot> myplots = new HashSet<>();
|
||||
for (Plot plot : getPlots()) {
|
||||
if (plot.isBasePlot()) {
|
||||
if (plot.isOwner(uuid)) {
|
||||
plots.add(plot);
|
||||
myplots.add(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
return plots;
|
||||
return myplots;
|
||||
}
|
||||
|
||||
public Set<Plot> getPlots(PlotPlayer player) {
|
||||
@ -558,14 +558,14 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public Set<Plot> getBasePlots() {
|
||||
HashSet<Plot> plots = new HashSet<>(getPlots());
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
HashSet<Plot> myplots = new HashSet<>(getPlots());
|
||||
Iterator<Plot> iter = myplots.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!iter.next().isBasePlot()) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
return plots;
|
||||
return myplots;
|
||||
}
|
||||
|
||||
public void foreachPlotAbs(RunnableVal<Plot> run) {
|
||||
|
@ -671,8 +671,8 @@ public abstract class SchematicHandler {
|
||||
HashMap<String, Tag> map = new HashMap<String, Tag>(value.getValue());
|
||||
map.put("Flags", tag);
|
||||
value.setValue(map);
|
||||
whenDone.run(value);
|
||||
}
|
||||
whenDone.run(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user