mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23: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.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ public class Condense extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String worldname = args[0];
|
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");
|
MainUtil.sendMessage(plr, "INVALID WORLD");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,9 @@ public class Debug extends SubCommand {
|
|||||||
for (final String world : PlotSquared.getPlotWorlds()) {
|
for (final String world : PlotSquared.getPlotWorlds()) {
|
||||||
worlds.append(world).append(" ");
|
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(header);
|
||||||
information.append(getSection(section, "Lag / TPS"));
|
information.append(getSection(section, "Lag / TPS"));
|
||||||
information.append(getLine(line, "Ticks Per Second", Lag.getTPS()));
|
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.ArrayList;
|
||||||
import java.util.UUID;
|
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.google.common.collect.BiMap;
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
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.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
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.AChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,22 +51,24 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@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, "");
|
return claimPlot(player, plot, teleport, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
|
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
|
||||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true);
|
// FIXME call claim event
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
// boolean result = event result
|
||||||
if (!event.isCancelled()) {
|
boolean result = true;
|
||||||
MainUtil.createPlot(player, plot);
|
|
||||||
MainUtil.setSign(player, plot);
|
if (!result) {
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED);
|
MainUtil.createPlot(player.getUUID(), plot);
|
||||||
|
MainUtil.setSign(player.getName(), plot);
|
||||||
|
MainUtil.sendMessage(player, C.CLAIMED);
|
||||||
if (teleport) {
|
if (teleport) {
|
||||||
MainUtil.teleportPlayer(player, player.getLocation(), plot);
|
MainUtil.teleportPlayer(player, player.getLocation(), plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return event.isCancelled();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,8 +77,8 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
if (args.length < 3) {
|
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}");
|
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]);
|
String world = args[0];
|
||||||
if ((world == null) || !PlotSquared.isPlotWorld(world)) {
|
if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) {
|
||||||
return !MainUtil.sendMessage(null, "&cInvalid plot world!");
|
return !MainUtil.sendMessage(null, "&cInvalid plot world!");
|
||||||
}
|
}
|
||||||
PlotId min, max;
|
PlotId min, max;
|
||||||
@ -103,19 +102,15 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Location loc = manager.getSignLoc(world, plotworld, plot);
|
final Location loc = manager.getSignLoc(plotworld, plot);
|
||||||
final Chunk chunk = world.getChunkAt(loc);
|
ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||||
if (!chunk.isLoaded()) {
|
boolean result = AChunkManager.manager.loadChunk(world, chunk);
|
||||||
final boolean result = chunk.load(false);
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
String[] lines = BlockManager.manager.getSign(loc);
|
||||||
final Block block = world.getBlockAt(loc);
|
if (lines != null) {
|
||||||
if (block != null) {
|
String line = lines[2];
|
||||||
if (block.getState() instanceof Sign) {
|
|
||||||
final Sign sign = (Sign) block.getState();
|
|
||||||
String line = sign.getLine(2);
|
|
||||||
if ((line != null) && (line.length() > 2)) {
|
if ((line != null) && (line.length() > 2)) {
|
||||||
line = line.substring(2);
|
line = line.substring(2);
|
||||||
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||||
@ -142,7 +137,6 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (plots.size() > 0) {
|
if (plots.size() > 0) {
|
||||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
||||||
DBFunc.createPlots(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.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
|
import com.intellectualcrafters.plot.util.AChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
@ -101,7 +102,7 @@ public abstract class HybridUtils {
|
|||||||
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||||
boolean toCheck = false;
|
boolean toCheck = false;
|
||||||
if ((id1 == null) || (id2 == null) || (id1 != id2)) {
|
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 (result) {
|
||||||
if (id1 != null) {
|
if (id1 != null) {
|
||||||
final Plot p1 = MainUtil.getPlot(world, id1);
|
final Plot p1 = MainUtil.getPlot(world, id1);
|
||||||
|
@ -20,6 +20,8 @@ public abstract class AChunkManager {
|
|||||||
return new ChunkLoc(x, z);
|
return new ChunkLoc(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract boolean loadChunk(String world, ChunkLoc loc);
|
||||||
|
|
||||||
public abstract List<ChunkLoc> getChunkChunks(String world);
|
public abstract List<ChunkLoc> getChunkChunks(String world);
|
||||||
|
|
||||||
public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
|
public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
@ -28,6 +29,10 @@ public abstract class BlockManager {
|
|||||||
return (int) r;
|
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 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);
|
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);
|
UUIDHandler.players.remove(plr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWorld(String world) {
|
@Override
|
||||||
|
public boolean isWorld(String world) {
|
||||||
return getWorld(world) != null;
|
return getWorld(world) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,10 +53,6 @@ public class BukkitUtil extends BlockManager {
|
|||||||
return lastPlotPlayer;
|
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) {
|
public static Biome getBiome(final Location loc) {
|
||||||
return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ());
|
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) {
|
public void functionSetBlock(String worldname, int x, int y, int z, int id, byte data) {
|
||||||
BukkitUtil.setBlock(getWorld(worldname), x, y, z, id, 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