mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
DCT
This commit is contained in:
parent
66e7275949
commit
bfd4a77c66
@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
||||
@ -54,7 +55,7 @@ public class Condense extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String worldname = args[0];
|
||||
if (!BukkitUtil.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) {
|
||||
if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) {
|
||||
MainUtil.sendMessage(plr, "INVALID WORLD");
|
||||
return false;
|
||||
}
|
||||
|
@ -59,6 +59,9 @@ public class Debug extends SubCommand {
|
||||
for (final String world : PlotSquared.getPlotWorlds()) {
|
||||
worlds.append(world).append(" ");
|
||||
}
|
||||
|
||||
// FIXME not sure if we actually need any of this debug info as we should just do a timings report which is more detailed anyway
|
||||
|
||||
information.append(header);
|
||||
information.append(getSection(section, "Lag / TPS"));
|
||||
information.append(getLine(line, "Ticks Per Second", Lag.getTPS()));
|
||||
|
@ -23,26 +23,23 @@ package com.intellectualcrafters.plot.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.AChunkManager;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
@ -54,22 +51,24 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) {
|
||||
return claimPlot(player, plot, teleport, "");
|
||||
}
|
||||
|
||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
|
||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
MainUtil.createPlot(player, plot);
|
||||
MainUtil.setSign(player, plot);
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED);
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
|
||||
// FIXME call claim event
|
||||
// boolean result = event result
|
||||
boolean result = true;
|
||||
|
||||
if (!result) {
|
||||
MainUtil.createPlot(player.getUUID(), plot);
|
||||
MainUtil.setSign(player.getName(), plot);
|
||||
MainUtil.sendMessage(player, C.CLAIMED);
|
||||
if (teleport) {
|
||||
MainUtil.teleportPlayer(player, player.getLocation(), plot);
|
||||
}
|
||||
}
|
||||
return event.isCancelled();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,8 +77,8 @@ public class DebugClaimTest extends SubCommand {
|
||||
if (args.length < 3) {
|
||||
return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
|
||||
}
|
||||
final World world = Bukkit.getWorld(args[0]);
|
||||
if ((world == null) || !PlotSquared.isPlotWorld(world)) {
|
||||
String world = args[0];
|
||||
if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) {
|
||||
return !MainUtil.sendMessage(null, "&cInvalid plot world!");
|
||||
}
|
||||
PlotId min, max;
|
||||
@ -103,19 +102,15 @@ public class DebugClaimTest extends SubCommand {
|
||||
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
||||
continue;
|
||||
}
|
||||
final Location loc = manager.getSignLoc(world, plotworld, plot);
|
||||
final Chunk chunk = world.getChunkAt(loc);
|
||||
if (!chunk.isLoaded()) {
|
||||
final boolean result = chunk.load(false);
|
||||
final Location loc = manager.getSignLoc(plotworld, plot);
|
||||
ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
boolean result = AChunkManager.manager.loadChunk(world, chunk);
|
||||
if (!result) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
final Block block = world.getBlockAt(loc);
|
||||
if (block != null) {
|
||||
if (block.getState() instanceof Sign) {
|
||||
final Sign sign = (Sign) block.getState();
|
||||
String line = sign.getLine(2);
|
||||
String[] lines = BlockManager.manager.getSign(loc);
|
||||
if (lines != null) {
|
||||
String line = lines[2];
|
||||
if ((line != null) && (line.length() > 2)) {
|
||||
line = line.substring(2);
|
||||
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||
@ -142,7 +137,6 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plots.size() > 0) {
|
||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
||||
DBFunc.createPlots(plots);
|
||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.util.AChunkManager;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
@ -101,7 +102,7 @@ public abstract class HybridUtils {
|
||||
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||
boolean toCheck = false;
|
||||
if ((id1 == null) || (id2 == null) || (id1 != id2)) {
|
||||
final boolean result = BukkitUtil.loadChunk(world, chunk);
|
||||
final boolean result = AChunkManager.manager.loadChunk(world, chunk);
|
||||
if (result) {
|
||||
if (id1 != null) {
|
||||
final Plot p1 = MainUtil.getPlot(world, id1);
|
||||
|
@ -20,6 +20,8 @@ public abstract class AChunkManager {
|
||||
return new ChunkLoc(x, z);
|
||||
}
|
||||
|
||||
public abstract boolean loadChunk(String world, ChunkLoc loc);
|
||||
|
||||
public abstract List<ChunkLoc> getChunkChunks(String world);
|
||||
|
||||
public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
||||
@ -28,6 +29,10 @@ public abstract class BlockManager {
|
||||
return (int) r;
|
||||
}
|
||||
|
||||
public abstract String[] getSign(Location loc);
|
||||
|
||||
public abstract boolean isWorld(String world);
|
||||
|
||||
public abstract void functionSetBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data);
|
||||
|
||||
public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines);
|
||||
|
@ -38,7 +38,8 @@ public class BukkitUtil extends BlockManager {
|
||||
UUIDHandler.players.remove(plr);
|
||||
}
|
||||
|
||||
public static boolean isWorld(String world) {
|
||||
@Override
|
||||
public boolean isWorld(String world) {
|
||||
return getWorld(world) != null;
|
||||
}
|
||||
|
||||
@ -52,10 +53,6 @@ public class BukkitUtil extends BlockManager {
|
||||
return lastPlotPlayer;
|
||||
}
|
||||
|
||||
public static boolean loadChunk(String world, ChunkLoc loc) {
|
||||
return getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false);
|
||||
}
|
||||
|
||||
public static Biome getBiome(final Location loc) {
|
||||
return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ());
|
||||
}
|
||||
@ -202,4 +199,16 @@ public class BukkitUtil extends BlockManager {
|
||||
public void functionSetBlock(String worldname, int x, int y, int z, int id, byte data) {
|
||||
BukkitUtil.setBlock(getWorld(worldname), x, y, z, id, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSign(Location loc) {
|
||||
Block block = getWorld(loc.getWorld()).getBlockAt(loc.getX(), loc.getY(), loc.getZ());
|
||||
if (block != null) {
|
||||
if (block.getState() instanceof Sign) {
|
||||
final Sign sign = (Sign) block.getState();
|
||||
return sign.getLines();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -755,4 +755,9 @@ public class ChunkManager extends AChunkManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadChunk(String world, ChunkLoc loc) {
|
||||
return BukkitUtil.getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user