mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
uhg
This commit is contained in:
parent
fcdbd341d8
commit
0d3f6d5e0b
@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -26,12 +25,11 @@ import com.intellectualcrafters.plot.commands.Buy;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.PlotMeConverter;
|
||||
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
||||
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
||||
@ -39,8 +37,8 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
||||
import com.intellectualcrafters.plot.listeners.WorldEditListener;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
||||
import com.intellectualcrafters.plot.util.Metrics;
|
||||
@ -53,6 +51,7 @@ import com.intellectualcrafters.plot.util.SetBlockSlow;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
||||
@ -60,6 +59,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
||||
public static BukkitMain THIS = null;
|
||||
public static PlotSquared MAIN = null;
|
||||
|
||||
// TODO restructure this
|
||||
public static boolean hasPermission(final Player player, final String perm) {
|
||||
if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) {
|
||||
return true;
|
||||
@ -78,6 +78,50 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO restructure this
|
||||
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
|
||||
Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot);
|
||||
final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, bot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
final Location location = PlotHelper.getPlotHome(Bukkit.getWorld(bot.world), bot);
|
||||
|
||||
int x = location.getX();
|
||||
int z = location.getZ();
|
||||
|
||||
|
||||
if ((x >= 29999999) || (x <= -29999999) || (z >= 299999999) || (z <= -29999999)) {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
if (Settings.TELEPORT_DELAY == 0 || hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
BukkitUtil.teleportPlayer(player, location);
|
||||
return true;
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + "");
|
||||
final String name = player.getName();
|
||||
TaskManager.TELEPORT_QUEUE.add(name);
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!TaskManager.TELEPORT_QUEUE.contains(name)) {
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORT_FAILED);
|
||||
return;
|
||||
}
|
||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
BukkitUtil.teleportPlayer(player, location);
|
||||
}
|
||||
}, Settings.TELEPORT_DELAY * 20);
|
||||
return true;
|
||||
}
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void worldLoad(WorldLoadEvent event) {
|
||||
UUIDHandler.cacheAll();
|
||||
|
@ -2,8 +2,12 @@ package com.intellectualcrafters.plot;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
|
@ -160,11 +160,11 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||
String worldname = world.getName();
|
||||
PlotWorld plotworld = PlotSquared.getWorldSettings(worldname);
|
||||
if (plotworld.TYPE == 2) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = PlotHelper.getCurrentPlot(loc);
|
||||
Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -183,7 +183,7 @@ public class Auto extends SubCommand {
|
||||
//
|
||||
for (int i = 0; i <= max; i++) {
|
||||
PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
Plot current = PlotHelper.getPlot(world, currentId);
|
||||
Plot current = PlotHelper.getPlot(worldname, currentId);
|
||||
if (current != null && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
||||
Claim.claimPlot(plr, current, true, true);
|
||||
return true;
|
||||
@ -197,10 +197,9 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
|
||||
boolean br = false;
|
||||
String worldname = world.getName();
|
||||
if ((size_x == 1) && (size_z == 1)) {
|
||||
while (!br) {
|
||||
final Plot plot = PlotHelper.getPlot(world, getLastPlot(worldname));
|
||||
final Plot plot = PlotHelper.getPlot(worldname, getLastPlot(worldname));
|
||||
if ((plot.owner == null)) {
|
||||
Claim.claimPlot(plr, plot, true, true);
|
||||
br = true;
|
||||
@ -215,21 +214,21 @@ public class Auto extends SubCommand {
|
||||
PlotHelper.lastPlot.put(worldname, start);
|
||||
if (lastPlot) {
|
||||
}
|
||||
if ((PlotSquared.getPlots(world).get(start) != null) && (PlotSquared.getPlots(world).get(start).owner != null)) {
|
||||
if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) {
|
||||
continue;
|
||||
} else {
|
||||
lastPlot = false;
|
||||
}
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
if (PlotHelper.isUnowned(world, start, end)) {
|
||||
if (PlotHelper.isUnowned(worldname, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
final Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));
|
||||
final Plot plot = PlotHelper.getPlot(worldname, new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
Claim.claimPlot(plr, plot, teleport, true);
|
||||
}
|
||||
}
|
||||
if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(start, end))) {
|
||||
if (!PlotHelper.mergePlots(plr, worldname, PlayerFunctions.getPlotSelectionIds(start, end))) {
|
||||
return false;
|
||||
}
|
||||
br = true;
|
||||
|
@ -21,12 +21,12 @@
|
||||
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
/**
|
||||
|
@ -90,6 +90,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
public Location add(int x, int y, int z) {
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
@ -128,6 +129,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
y <= max.getY() && z >= min.getX() && z < max.getZ();
|
||||
}
|
||||
|
||||
public void lookTowards(int x, int y) {
|
||||
double l = this.x - x;
|
||||
double w = this.z - z;
|
||||
double c = Math.sqrt(l * l + w * w);
|
||||
@ -139,6 +141,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
public Location subtract(int x, int y, int z) {
|
||||
this.x -= x;
|
||||
this.y -= y;
|
||||
this.z -= z;
|
||||
|
@ -32,9 +32,9 @@ public abstract class BlockManager {
|
||||
return (int) r;
|
||||
}
|
||||
|
||||
public abstract void functionSetBlock(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 setSign(String worldname, int x, int y, int z, String[] lines);
|
||||
public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines);
|
||||
|
||||
|
||||
public static void setBlocks(String worldname, int[] x, int y[], int z[], PlotBlock[][] blocks) {
|
||||
@ -60,6 +60,11 @@ public abstract class BlockManager {
|
||||
setBlocks(worldname, x, y, z, id, data);
|
||||
}
|
||||
|
||||
public static void setSign(String worldname, int x, int y, int z, String[] lines) {
|
||||
manager.functionSetSign(worldname, x, y, z, lines);
|
||||
}
|
||||
|
||||
public static void setBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) {
|
||||
manager.functionSetBlocks(worldname, x, y, z, id, data);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -53,7 +54,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
@ -137,7 +138,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
public static boolean mergePlots(final Player plr, final String world, final ArrayList<PlotId> plotIds) {
|
||||
|
||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||
if (PlotSquared.useEconomy && plotworld.USE_ECONOMY) {
|
||||
if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) {
|
||||
final double cost = plotIds.size() * plotworld.MERGE_PRICE;
|
||||
if (cost > 0d) {
|
||||
final Economy economy = PlotSquared.economy;
|
||||
@ -289,20 +290,17 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
if (name == null) {
|
||||
name = "unknown";
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(p.world);
|
||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(p.world);
|
||||
final Location loc = manager.getSignLoc(plotworld, p);
|
||||
|
||||
final Block bs = loc.getBlock();
|
||||
bs.setType(Material.AIR);
|
||||
bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
|
||||
final String id = p.id.x + ";" + p.id.y;
|
||||
final Sign sign = (Sign) bs.getState();
|
||||
sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id));
|
||||
sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name));
|
||||
sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name));
|
||||
sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name));
|
||||
sign.update(true);
|
||||
String[] lines = new String[] {
|
||||
C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id),
|
||||
C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name)
|
||||
};
|
||||
BukkitUtil.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||
}
|
||||
|
||||
public static String getPlayerName(final UUID uuid) {
|
||||
@ -379,7 +377,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
}
|
||||
merge = false;
|
||||
}
|
||||
update(player.getLocation());
|
||||
update(BukkitUtil.getLocation(player));
|
||||
}
|
||||
|
||||
private static boolean ownsPlots(final String world, final ArrayList<PlotId> plots, final Player player, final int dir) {
|
||||
@ -403,6 +401,18 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void update(Location loc) {
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
final int distance = Bukkit.getViewDistance();
|
||||
for (int cx = -distance; cx < distance; cx++) {
|
||||
for (int cz = -distance; cz < distance; cz++) {
|
||||
Chunk chunk = BukkitUtil.getChunkAt(loc.getWorld(), loc.getX(), loc.getZ());
|
||||
chunks.add(chunk);
|
||||
}
|
||||
}
|
||||
AbstractSetBlock.setBlockManager.update(chunks);
|
||||
}
|
||||
|
||||
public static void updateWorldBorder(Plot plot) {
|
||||
if (!worldBorder.containsKey(plot.world)) {
|
||||
return;
|
||||
@ -413,8 +423,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id);
|
||||
Location top = manager.getPlotTopLocAbs(plotworld, plot.id);
|
||||
int border = worldBorder.get(plot.world);
|
||||
int botmax = Math.max(Math.abs(bot.getBlockX()), Math.abs(bot.getBlockZ()));
|
||||
int topmax = Math.max(Math.abs(top.getBlockX()), Math.abs(top.getBlockZ()));
|
||||
int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ()));
|
||||
int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ()));
|
||||
int max = Math.max(botmax, topmax);
|
||||
if (max > border ) {
|
||||
worldBorder.put(plot.world, max);
|
||||
@ -428,7 +438,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
if (PlotHelper.worldBorder.containsKey(plot.world)) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
World w = player.getWorld();
|
||||
String w = BukkitUtil.getWorld(player);
|
||||
UUID uuid = UUIDHandler.getUUID(player);
|
||||
Plot p = createPlotAbs(uuid, plot);
|
||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(w);
|
||||
@ -449,34 +459,6 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
return p;
|
||||
}
|
||||
|
||||
public static int getLoadedChunks(final String world) {
|
||||
return world.getLoadedChunks().length;
|
||||
}
|
||||
|
||||
public static int getEntities(final String world) {
|
||||
|
||||
return world.getEntities().size();
|
||||
}
|
||||
|
||||
|
||||
public static int getTileEntities(final String world) {
|
||||
|
||||
PlotSquared.getWorldSettings(world);
|
||||
int x = 0;
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
x += chunk.getTileEntities().length;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static double getWorldFolderSize(final String world) {
|
||||
|
||||
// long size = FileUtil.sizeOfDirectory(world.getWorldFolder());
|
||||
final File folder = world.getWorldFolder();
|
||||
final long size = folder.length();
|
||||
return (((size) / 1024) / 1024);
|
||||
}
|
||||
|
||||
public static String createId(final int x, final int z) {
|
||||
return x + ";" + z;
|
||||
}
|
||||
@ -494,15 +476,13 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
}
|
||||
|
||||
public static void clearAllEntities(final String world, final Plot plot, final boolean tile) {
|
||||
|
||||
|
||||
final List<Entity> entities = world.getEntities();
|
||||
final List<Entity> entities = BukkitUtil.getEntities(world);
|
||||
for (final Entity entity : entities) {
|
||||
final PlotId id = PlayerFunctions.getPlot(entity.getLocation());
|
||||
if (plot.id.equals(id)) {
|
||||
if (entity instanceof Player) {
|
||||
final Player player = (Player) entity;
|
||||
PlotSquared.teleportPlayer(player, entity.getLocation(), plot);
|
||||
BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||
PlotListener.plotExit(player, plot);
|
||||
} else {
|
||||
entity.remove();
|
||||
@ -530,8 +510,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
|
||||
final int prime = 31;
|
||||
int h = 1;
|
||||
h = (prime * h) + pos1.getBlockX();
|
||||
h = (prime * h) + pos1.getBlockZ();
|
||||
h = (prime * h) + pos1.getX();
|
||||
h = (prime * h) + pos1.getZ();
|
||||
state = h;
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
@ -593,8 +573,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
}
|
||||
|
||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||
final Block block = world.getBlockAt(x, y, z);
|
||||
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
||||
setBlock(world, x, y, z, newblock.id, newblock.data);
|
||||
@ -611,8 +591,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
return;
|
||||
}
|
||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||
final int i = random(blocks.length);
|
||||
final PlotBlock newblock = blocks[i];
|
||||
final Block block = world.getBlockAt(x, y, z);
|
||||
@ -627,8 +607,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
||||
|
||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||
final Block block = world.getBlockAt(x, y, z);
|
||||
if (!((block.getTypeId() == newblock.id))) {
|
||||
setBlock(world, x, y, z, newblock.id, (byte) 0);
|
||||
@ -640,10 +620,10 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
|
||||
public static void setBiome(final String world, final Plot plot, final Biome b) {
|
||||
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX();
|
||||
final int topX = getPlotTopLoc(world, plot.id).getBlockX() + 1;
|
||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ();
|
||||
final int topZ = getPlotTopLoc(world, plot.id).getBlockZ() + 1;
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
||||
final int topX = getPlotTopLoc(world, plot.id).getX() + 1;
|
||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
||||
final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1;
|
||||
|
||||
final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
||||
final Biome biome = block.getBiome();
|
||||
@ -696,8 +676,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
PlotManager manager = PlotSquared.getPlotManager(w);
|
||||
if (home == null || (home.x == 0 && home.z == 0)) {
|
||||
final Location top = getPlotTopLoc(w, plotid);
|
||||
final int x = ((top.getBlockX() - bot.getBlockX())/2) + bot.getBlockX();
|
||||
final int z = ((top.getBlockZ() - bot.getBlockZ())/2) + bot.getBlockZ();
|
||||
final int x = ((top.getX() - bot.getX())/2) + bot.getX();
|
||||
final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ();
|
||||
final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY());
|
||||
return new Location(w, x, y, z);
|
||||
}
|
||||
@ -716,7 +696,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
*/
|
||||
public static Location getPlotHomeDefault(final Plot plot) {
|
||||
final Location l = getPlotBottomLoc(plot.getWorld(), plot.getId()).subtract(0, 0, 0);
|
||||
l.setY(getHeighestBlock(plot.getWorld(), l.getBlockX(), l.getBlockZ()));
|
||||
l.setY(getHeighestBlock(plot.getWorld(), l.getX(), l.getZ()));
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -742,10 +722,10 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
*/
|
||||
public static void refreshPlotChunks(final String world, final Plot plot) {
|
||||
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX();
|
||||
final int topX = getPlotTopLoc(world, plot.id).getBlockX();
|
||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ();
|
||||
final int topZ = getPlotTopLoc(world, plot.id).getBlockZ();
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
||||
final int topX = getPlotTopLoc(world, plot.id).getX();
|
||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
||||
final int topZ = getPlotTopLoc(world, plot.id).getZ();
|
||||
|
||||
final int minChunkX = (int) Math.floor((double) bottomX / 16);
|
||||
final int maxChunkX = (int) Math.floor((double) topX / 16);
|
||||
@ -818,7 +798,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager;
|
||||
*/
|
||||
public static int getPlotWidth(final String world, final PlotId id) {
|
||||
|
||||
return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX();
|
||||
return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
|
||||
public abstract class TaskManager {
|
||||
|
||||
public HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||
public static HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||
|
||||
public abstract void taskRepeat(final Runnable r, int interval);
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.util.bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -10,7 +11,10 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.SetBlockManager;
|
||||
@ -51,6 +55,19 @@ public class BukkitUtil extends BlockManager {
|
||||
SetBlockManager.setBlockManager.update(chunks);
|
||||
}
|
||||
|
||||
public static String getWorld(Entity entity) {
|
||||
return entity.getWorld().getName();
|
||||
}
|
||||
|
||||
public static void teleportPlayer(Player player, Location loc) {
|
||||
org.bukkit.Location bukkitLoc = new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ());
|
||||
player.teleport(bukkitLoc);
|
||||
}
|
||||
|
||||
public static List<Entity> getEntities(String worldname) {
|
||||
return getWorld(worldname).getEntities();
|
||||
}
|
||||
|
||||
public static void setBlock(World world, int x, int y, int z, int id, byte data) {
|
||||
try {
|
||||
SetBlockManager.setBlockManager.set(world, x, y, z, id, data);
|
||||
@ -61,8 +78,14 @@ public class BukkitUtil extends BlockManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static Location getLocation(Entity entity) {
|
||||
org.bukkit.Location loc = entity.getLocation();
|
||||
String world = loc.getWorld().getName();
|
||||
return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void functionSetBlock(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) {
|
||||
public void functionSetBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) {
|
||||
World world = getWorld(worldname);
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
BukkitUtil.setBlock(world, x[i], y[i], z[i], id[i], data[i]);
|
||||
@ -70,7 +93,7 @@ public class BukkitUtil extends BlockManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSign(String worldname, int x, int y, int z, String[] lines) {
|
||||
public void functionSetSign(String worldname, int x, int y, int z, String[] lines) {
|
||||
World world = getWorld(worldname);
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
block.setType(Material.AIR);
|
||||
@ -80,6 +103,7 @@ public class BukkitUtil extends BlockManager {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
((Sign) blockstate).setLine(i, lines[i]);
|
||||
}
|
||||
((Sign) blockstate).update(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user