mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	@@ -7,7 +7,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
 | 
			
		||||
    public static int PLOT_WIDTH_DEFAULT = 42;
 | 
			
		||||
    public static int ROAD_WIDTH_DEFAULT = 7;
 | 
			
		||||
    public static int ROAD_OFFSET_X_DEFAULT = 0;
 | 
			
		||||
    public static int ROAD_OFFSET__Z_DEFAULT = 0;
 | 
			
		||||
    public static int ROAD_OFFSET_Z_DEFAULT = 0;
 | 
			
		||||
    public int PLOT_WIDTH;
 | 
			
		||||
    public int ROAD_WIDTH;
 | 
			
		||||
    public int ROAD_OFFSET_X;
 | 
			
		||||
 
 | 
			
		||||
@@ -100,6 +100,16 @@ public abstract class ChunkManager {
 | 
			
		||||
    
 | 
			
		||||
    public abstract void setChunk(final ChunkWrapper loc, final PlotBlock[][] result);
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 0 = Entity
 | 
			
		||||
     * 1 = Animal
 | 
			
		||||
     * 2 = Monster
 | 
			
		||||
     * 3 = Mob
 | 
			
		||||
     * 4 = Boat
 | 
			
		||||
     * 5 = Misc
 | 
			
		||||
     * @param plot
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public abstract int[] countEntities(final Plot plot);
 | 
			
		||||
    
 | 
			
		||||
    public abstract boolean loadChunk(final String world, final ChunkLoc loc, final boolean force);
 | 
			
		||||
 
 | 
			
		||||
@@ -42,11 +42,13 @@ import com.intellectualcrafters.jnbt.Tag;
 | 
			
		||||
import com.intellectualcrafters.json.JSONArray;
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotBlock;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RunnableVal;
 | 
			
		||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
 | 
			
		||||
@@ -138,7 +140,7 @@ public abstract class SchematicHandler {
 | 
			
		||||
     * @return boolean true if succeeded
 | 
			
		||||
     */
 | 
			
		||||
    public void paste(final Schematic schematic, final Plot plot, final int x_offset, final int z_offset, final RunnableVal<Boolean> whenDone) {
 | 
			
		||||
        TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
        TaskManager.runTask(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (whenDone != null) {
 | 
			
		||||
@@ -170,10 +172,14 @@ public abstract class SchematicHandler {
 | 
			
		||||
                    if (HEIGHT >= 256) {
 | 
			
		||||
                        y_offset = 0;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        y_offset = MainUtil.getHeighestBlock(plot.world, region.minX + 1, region.minZ + 1);
 | 
			
		||||
                        PlotWorld pw = plot.getWorld();
 | 
			
		||||
                        if (pw instanceof ClassicPlotWorld) {
 | 
			
		||||
                            y_offset = ((ClassicPlotWorld) pw).PLOT_HEIGHT;
 | 
			
		||||
                        } else {
 | 
			
		||||
                            y_offset = MainUtil.getHeighestBlock(plot.world, region.minX + 1, region.minZ + 1);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    final Location pos1 = new Location(plot.world, region.minX + x_offset, y_offset, region.minZ + z_offset);
 | 
			
		||||
//                    Location pos2 = new Location(plot.world, region.maxX, region.maxY, region.maxZ);
 | 
			
		||||
                    final Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
 | 
			
		||||
                    // TODO switch to ChunkManager.chunkTask(pos1, pos2, task, whenDone, allocate);
 | 
			
		||||
                    final int p1x = pos1.getX();
 | 
			
		||||
@@ -817,6 +823,57 @@ public abstract class SchematicHandler {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return collection;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        public Schematic copySection(RegionWrapper region) {
 | 
			
		||||
 | 
			
		||||
            int x1 = region.minX;
 | 
			
		||||
            int x2 = region.maxX;
 | 
			
		||||
            
 | 
			
		||||
            int z1 = region.minZ;
 | 
			
		||||
            int z2 = region.maxZ;
 | 
			
		||||
            
 | 
			
		||||
            int y1 = region.minY;
 | 
			
		||||
            int y2 = Math.min(region.maxY, 255);
 | 
			
		||||
            
 | 
			
		||||
            int width = x2 - x1 + 1;
 | 
			
		||||
            int length = z2 - z1 + 1;
 | 
			
		||||
            int height = y2 - y1 + 1;
 | 
			
		||||
            
 | 
			
		||||
            short[] ids2 = new short[width * length * height];
 | 
			
		||||
            byte[] datas2 = new byte[width * length * height];
 | 
			
		||||
 | 
			
		||||
            int dx = schematicDimension.getX();
 | 
			
		||||
            int dy = schematicDimension.getY();
 | 
			
		||||
            int dz = schematicDimension.getZ();
 | 
			
		||||
            
 | 
			
		||||
            for (int y = y1; y <= y2; y++) {
 | 
			
		||||
                int yy = y >= 0 ? (y < dy ? y : y - dy) : y + dy;
 | 
			
		||||
                int i1 = yy * dx * dz;
 | 
			
		||||
                int j1 = (y - y1) * width * length;
 | 
			
		||||
                for (int z = z1; z <= z2; z++) {
 | 
			
		||||
                    int zz = z >= 0 ? (z < dz ? z : z - dz) : z + dz;
 | 
			
		||||
                    int i2 = i1 + zz * dx;
 | 
			
		||||
                    int j2 = j1 + (z - z1) * width;
 | 
			
		||||
                    for (int x = x1; x <= x2; x++) {
 | 
			
		||||
                        int xx = x >= 0 ? (x < dx ? x : x - dx) : x + dx;
 | 
			
		||||
                        int i3 = i2 + xx;
 | 
			
		||||
                        int j3 = j2 + (x - x1);
 | 
			
		||||
                        ids2[j3] = ids[i3];
 | 
			
		||||
                        datas2[j3] = datas[i3];
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return new Schematic(ids2, datas2, new Dimension(width, height, length));
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        public void save(final File file) {
 | 
			
		||||
            byte[] ids2 = new byte[ids.length];
 | 
			
		||||
            for (int i = 0; i < ids.length; i++) {
 | 
			
		||||
                ids2[i] = (byte) ids[i];
 | 
			
		||||
            }
 | 
			
		||||
            CompoundTag tag = createTag(ids2, datas, schematicDimension);
 | 
			
		||||
            SchematicHandler.this.save(tag, file.toString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -156,7 +156,7 @@ public class LikePlotMeConverter {
 | 
			
		||||
            if (!connector.isValidConnection(connection)) {
 | 
			
		||||
                sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            sendMessage(plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
 | 
			
		||||
            
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package com.plotsquared.bukkit.generator;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.bukkit.block.Biome;
 | 
			
		||||
@@ -109,7 +110,7 @@ public class HybridPop extends BukkitPlotPopulator {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (requiredRegion != null) {
 | 
			
		||||
        if (requiredRegion != null) {
 | 
			
		||||
            if (!doFloor && !doFilling && plotworld.G_SCH_DATA == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
@@ -127,8 +128,8 @@ public class HybridPop extends BukkitPlotPopulator {
 | 
			
		||||
                            final int absZ = ((sz + z) % size);
 | 
			
		||||
                            final PlotLoc loc = new PlotLoc(absX, absZ);
 | 
			
		||||
                            final HashMap<Short, Byte> blocks = plotworld.G_SCH_DATA.get(loc);
 | 
			
		||||
                            if (blocks != null) {
 | 
			
		||||
                                for (final short y : blocks.keySet()) {
 | 
			
		||||
                            if (blocks != null) {
 | 
			
		||||
                                for (Entry<Short, Byte> entry : blocks.entrySet()) {
 | 
			
		||||
                                    setBlockAbs(x, (short) (plotheight + entry.getKey()), z, entry.getValue());
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
@@ -164,8 +165,8 @@ public class HybridPop extends BukkitPlotPopulator {
 | 
			
		||||
                    if (plotworld.PLOT_SCHEMATIC) {
 | 
			
		||||
                        final PlotLoc loc = new PlotLoc(absX, absZ);
 | 
			
		||||
                        final HashMap<Short, Byte> blocks = plotworld.G_SCH_DATA.get(loc);
 | 
			
		||||
                        if (blocks != null) {
 | 
			
		||||
                            for (final short y : blocks.keySet()) {
 | 
			
		||||
                        if (blocks != null) {
 | 
			
		||||
                            for (Entry<Short, Byte> entry : blocks.entrySet()) {
 | 
			
		||||
                                setBlockAbs(x, (short) (plotheight + entry.getKey()), z, entry.getValue());
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
@@ -199,8 +200,8 @@ public class HybridPop extends BukkitPlotPopulator {
 | 
			
		||||
                    if (plotworld.ROAD_SCHEMATIC_ENABLED) {
 | 
			
		||||
                        final PlotLoc loc = new PlotLoc(absX, absZ);
 | 
			
		||||
                        final HashMap<Short, Byte> blocks = plotworld.G_SCH_DATA.get(loc);
 | 
			
		||||
                        if (blocks != null) {
 | 
			
		||||
                            for (final short y : blocks.keySet()) {
 | 
			
		||||
                        if (blocks != null) {
 | 
			
		||||
                            for (Entry<Short, Byte> entry : blocks.entrySet()) {
 | 
			
		||||
                                setBlockAbs(x, (short) (roadheight + entry.getKey()), z, entry.getValue());
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 
 | 
			
		||||
@@ -74,7 +74,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerEggThrowEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerInteractEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerLoginEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerJoinEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerMoveEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerQuitEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerTeleportEvent;
 | 
			
		||||
@@ -405,7 +405,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 | 
			
		||||
    public void onConnect(final PlayerJoinEvent event) {
 | 
			
		||||
        final Player player = event.getPlayer();
 | 
			
		||||
@@ -428,7 +428,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
 | 
			
		||||
        }
 | 
			
		||||
        // Async
 | 
			
		||||
        TaskManager.runTaskLaterAsync(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (!player.hasPlayedBefore() && player.isOnline()) {
 | 
			
		||||
                    player.saveData();
 | 
			
		||||
@@ -1623,12 +1623,19 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            Plot now = MainUtil.getPlot(loc);
 | 
			
		||||
            final Plot lastPlot = (Plot) pp.getMeta("lastplot");
 | 
			
		||||
            final Plot lastPlot = (Plot) pp.getMeta("lastplot");
 | 
			
		||||
            if (now == null) {
 | 
			
		||||
                if ((lastPlot != null) && !plotExit(pp, lastPlot) && tmp_teleport) {
 | 
			
		||||
                    MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
 | 
			
		||||
                    if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
 | 
			
		||||
                        tmp_teleport = false;
 | 
			
		||||
                        player.teleport(from);
 | 
			
		||||
                        player.teleport(from);
 | 
			
		||||
                        tmp_teleport = true;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
 | 
			
		||||
                        if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
 | 
			
		||||
                            tmp_teleport = false;
 | 
			
		||||
                            player.teleport(player.getWorld().getSpawnLocation());
 | 
			
		||||
                            tmp_teleport = true;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
@@ -1636,29 +1643,43 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            } else if ((lastPlot != null) && now.equals(lastPlot)) {
 | 
			
		||||
                return;
 | 
			
		||||
                return;
 | 
			
		||||
            } else {
 | 
			
		||||
                if (!plotEntry(pp, now)) {
 | 
			
		||||
                if (!plotEntry(pp, now) && tmp_teleport) {
 | 
			
		||||
                    MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
 | 
			
		||||
                    if (!now.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
 | 
			
		||||
                        tmp_teleport = false;
 | 
			
		||||
                        player.teleport(from);
 | 
			
		||||
                        player.teleport(from);
 | 
			
		||||
                        tmp_teleport = true;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
 | 
			
		||||
                        if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
 | 
			
		||||
                            tmp_teleport = false;
 | 
			
		||||
                            player.teleport(player.getWorld().getSpawnLocation());
 | 
			
		||||
                            tmp_teleport = true;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    event.setCancelled(true);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            }
 | 
			
		||||
            final Integer border = MainUtil.worldBorder.get(worldname);
 | 
			
		||||
            if (border != null && tmp_teleport) {
 | 
			
		||||
                if (z2 > border) {
 | 
			
		||||
                    to.setZ(border - 4);
 | 
			
		||||
                    tmp_teleport = false;
 | 
			
		||||
                    player.teleport(event.getTo());
 | 
			
		||||
                    tmp_teleport = true;
 | 
			
		||||
                    MainUtil.sendMessage(pp, C.BORDER);
 | 
			
		||||
                    return;
 | 
			
		||||
                } else if (z2 < -border) {
 | 
			
		||||
                    to.setZ(-border + 4);
 | 
			
		||||
                    tmp_teleport = false;
 | 
			
		||||
                    player.teleport(event.getTo());
 | 
			
		||||
                    tmp_teleport = true;
 | 
			
		||||
                    MainUtil.sendMessage(pp, C.BORDER);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user