mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Working on experimental plot analysis + ignore some interactions
This commit is contained in:
parent
eb2c901d73
commit
411900f474
@ -4,12 +4,16 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.apache.commons.lang.mutable.MutableInt;
|
import org.apache.commons.lang.mutable.MutableInt;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.BukkitMain;
|
import com.intellectualcrafters.plot.BukkitMain;
|
||||||
@ -18,7 +22,9 @@ import com.intellectualcrafters.plot.config.C;
|
|||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -28,27 +34,60 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
|
|
||||||
public class BukkitHybridUtils extends HybridUtils {
|
public class BukkitHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
public void checkModified(final Plot plot, final RunnableVal whenDone) {
|
@Override
|
||||||
TaskManager.index.increment();
|
public void analyzePlot(Plot plot, RunnableVal<PlotAnalysis> whenDone) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
// int diff, int variety, int verticies, int rotation, int height_sd
|
||||||
|
|
||||||
|
/*
|
||||||
|
* diff: compare to base by looping through all blocks
|
||||||
|
* variety: add to hashset for each plotblock
|
||||||
|
* height_sd: loop over all blocks and get top block
|
||||||
|
*
|
||||||
|
* verticies: store air map and compare with neighbours
|
||||||
|
* for each block check the adjacent
|
||||||
|
* - Store all blocks then go through in second loop
|
||||||
|
* - recheck each block
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
World world = Bukkit.getWorld(plot.world);
|
||||||
|
ChunkGenerator gen = world.getGenerator();
|
||||||
|
BiomeGrid base = new BiomeGrid() { @Override public void setBiome(int a, int b, Biome c) {} @Override public Biome getBiome(int a, int b) {return null;}};
|
||||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||||
|
|
||||||
int bx = bot.getX() >> 4;
|
int bx = bot.getX() >> 4;
|
||||||
int bz = bot.getZ() >> 4;
|
int bz = bot.getZ() >> 4;
|
||||||
|
|
||||||
int tx = top.getX() >> 4;
|
int tx = top.getX() >> 4;
|
||||||
int tz = top.getZ() >> 4;
|
int tz = top.getZ() >> 4;
|
||||||
|
Random r = new Random();
|
||||||
|
for (int X = bx; X <= tx; X++) {
|
||||||
|
for (int Z = bz; Z <= tz; Z++) {
|
||||||
|
Chunk chunk = world.getChunkAt(X, Z);
|
||||||
|
short[][] result = gen.generateExtBlockSections(world, r, x, z, base);
|
||||||
|
for (int x = 0; x < 16; x++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
short[] [] result = gen.generateExtBlockSections(world, null, x, z, )
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkModified(final Plot plot, final RunnableVal<Integer> whenDone) {
|
||||||
|
TaskManager.index.increment();
|
||||||
|
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
|
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||||
|
int bx = bot.getX() >> 4;
|
||||||
|
int bz = bot.getZ() >> 4;
|
||||||
|
int tx = top.getX() >> 4;
|
||||||
|
int tz = top.getZ() >> 4;
|
||||||
World world = BukkitUtil.getWorld(plot.world);
|
World world = BukkitUtil.getWorld(plot.world);
|
||||||
|
|
||||||
final HashSet<Chunk> chunks = new HashSet<>();
|
final HashSet<Chunk> chunks = new HashSet<>();
|
||||||
for (int X = bx; X <= tx; X++) {
|
for (int X = bx; X <= tx; X++) {
|
||||||
for (int Z = bz; Z <= tz; Z++) {
|
for (int Z = bz; Z <= tz; Z++) {
|
||||||
chunks.add(world.getChunkAt(X,Z));
|
chunks.add(world.getChunkAt(X,Z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||||
if (!(plotworld instanceof ClassicPlotWorld)) {
|
if (!(plotworld instanceof ClassicPlotWorld)) {
|
||||||
whenDone.value = -1;
|
whenDone.value = -1;
|
||||||
@ -263,5 +302,4 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
}, 20, 20);
|
}, 20, 20);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
|||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||||
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.PlotLoc;
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
@ -22,7 +23,9 @@ public abstract class HybridUtils {
|
|||||||
|
|
||||||
public static HybridUtils manager;
|
public static HybridUtils manager;
|
||||||
|
|
||||||
public abstract void checkModified(final Plot plot, final RunnableVal whenDone);
|
public abstract void checkModified(final Plot plot, final RunnableVal<Integer> whenDone);
|
||||||
|
|
||||||
|
public abstract void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone);
|
||||||
|
|
||||||
public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
|
public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
|
||||||
|
|
||||||
|
@ -72,6 +72,9 @@ import org.bukkit.event.vehicle.VehicleCreateEvent;
|
|||||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.StructureGrowEvent;
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.material.Tree;
|
||||||
|
import org.bukkit.material.Wool;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
import org.bukkit.projectiles.BlockProjectileSource;
|
||||||
@ -827,6 +830,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (block == null) {
|
if (block == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Material type = block.getType();
|
||||||
|
if (true || type.isSolid() && type.isBlock() && type.isOccluding()) {
|
||||||
|
BlockState state = block.getState();
|
||||||
|
MaterialData data = state.getData();
|
||||||
|
if (data instanceof Tree || data instanceof Wool || state.getData().getClass().equals(MaterialData.class)) {
|
||||||
|
Class<? extends BlockState> clazz = state.getClass();
|
||||||
|
if (clazz.getSimpleName().equals("CraftBlockState")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
if (!PlotSquared.isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
public class PlotAnalysis {
|
||||||
|
public final long diff;
|
||||||
|
public final long variety;
|
||||||
|
public final long verticies;
|
||||||
|
public final long rotation;
|
||||||
|
public final long height_sd;
|
||||||
|
|
||||||
|
public PlotAnalysis(int diff, int variety, int verticies, int rotation, int height_sd) {
|
||||||
|
this.diff = diff;
|
||||||
|
this.variety = variety;
|
||||||
|
this.verticies = verticies;
|
||||||
|
this.rotation = rotation;
|
||||||
|
this.height_sd = height_sd;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
public abstract class RunnableVal implements Runnable {
|
public abstract class RunnableVal<T> implements Runnable {
|
||||||
public Object value;
|
public T value;
|
||||||
|
|
||||||
public abstract void run();
|
public abstract void run();
|
||||||
}
|
}
|
||||||
|
@ -124,10 +124,10 @@ public class ExpireManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||||
RunnableVal run = new RunnableVal() {
|
RunnableVal run = new RunnableVal<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int changed = (int) this.value;
|
int changed = (Integer) this.value;
|
||||||
if (Settings.MIN_BLOCKS_CHANGED_IGNORED > 0 || Settings.MIN_BLOCKS_CHANGED > 0 && manager instanceof ClassicPlotManager) {
|
if (Settings.MIN_BLOCKS_CHANGED_IGNORED > 0 || Settings.MIN_BLOCKS_CHANGED > 0 && manager instanceof ClassicPlotManager) {
|
||||||
if (changed >= Settings.MIN_BLOCKS_CHANGED && Settings.MIN_BLOCKS_CHANGED > 0) {
|
if (changed >= Settings.MIN_BLOCKS_CHANGED && Settings.MIN_BLOCKS_CHANGED > 0) {
|
||||||
PlotSquared.log("&7[&5Expire&dManager&7] &bKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
|
PlotSquared.log("&7[&5Expire&dManager&7] &bKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
|
||||||
|
Loading…
Reference in New Issue
Block a user