mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-15 13:28:35 +00:00
Update favs
This commit is contained in:
@ -0,0 +1,134 @@
|
||||
package com.thevoxelbox.voxelsniper.util;
|
||||
|
||||
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* @author MikeMatrix
|
||||
*/
|
||||
public class BlockWrapper
|
||||
{
|
||||
|
||||
private int id;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int data;
|
||||
private World world;
|
||||
|
||||
/**
|
||||
* @param block
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockWrapper(final AsyncBlock block)
|
||||
{
|
||||
this.setId(block.getTypeId());
|
||||
this.setX(block.getX());
|
||||
this.setY(block.getY());
|
||||
this.setZ(block.getZ());
|
||||
this.setPropertyId(block.getPropertyId());
|
||||
this.setWorld(block.getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data
|
||||
*/
|
||||
public final int getPropertyId()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public final int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the world
|
||||
*/
|
||||
public final World getWorld()
|
||||
{
|
||||
return this.world;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the x
|
||||
*/
|
||||
public final int getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the y
|
||||
*/
|
||||
public final int getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the z
|
||||
*/
|
||||
public final int getZ()
|
||||
{
|
||||
return this.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data
|
||||
* the data to set
|
||||
*/
|
||||
public final void setPropertyId(final int data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the id to set
|
||||
*/
|
||||
public final void setId(final int id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* the world to set
|
||||
*/
|
||||
public final void setWorld(final World world)
|
||||
{
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* the x to set
|
||||
*/
|
||||
public final void setX(final int x)
|
||||
{
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param y
|
||||
* the y to set
|
||||
*/
|
||||
public final void setY(final int y)
|
||||
{
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param z
|
||||
* the z to set
|
||||
*/
|
||||
public final void setZ(final int z)
|
||||
{
|
||||
this.z = z;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
|
||||
package com.thevoxelbox.voxelsniper.util;
|
||||
|
||||
import com.thevoxelbox.voxelsniper.Undo;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class UndoDelegate implements BlockChangeDelegate
|
||||
{
|
||||
private final World targetWorld;
|
||||
private Undo currentUndo;
|
||||
|
||||
public Undo getUndo()
|
||||
{
|
||||
final Undo pastUndo = currentUndo;
|
||||
currentUndo = new Undo();
|
||||
return pastUndo;
|
||||
}
|
||||
|
||||
public UndoDelegate(World targetWorld)
|
||||
{
|
||||
this.targetWorld = targetWorld;
|
||||
this.currentUndo = new Undo();
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean setBlock(Block b)
|
||||
{
|
||||
this.currentUndo.put(this.targetWorld.getBlockAt(b.getLocation()));
|
||||
this.targetWorld.getBlockAt(b.getLocation()).setBlockData(b.getBlockData());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
|
||||
this.currentUndo.put(this.targetWorld.getBlockAt(x, y, z));
|
||||
this.targetWorld.getBlockAt(x, y, z).setBlockData(blockData);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
return this.targetWorld.getBlockAt(x, y, z).getBlockData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return this.targetWorld.getMaxHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(int x, int y, int z)
|
||||
{
|
||||
return this.targetWorld.getBlockAt(x, y, z).isEmpty();
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.thevoxelbox.voxelsniper.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Container class for multiple ID/Datavalue pairs.
|
||||
*/
|
||||
public class VoxelList
|
||||
{
|
||||
|
||||
private BlockMask mask = new BlockMask(NullExtent.INSTANCE);
|
||||
|
||||
/**
|
||||
* Adds the specified id, data value pair to the VoxelList. A data value of -1 will operate on all data values of that id.
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
public void add(BlockState i)
|
||||
{
|
||||
this.mask = mask.toBuilder().add(i).build(NullExtent.INSTANCE);
|
||||
}
|
||||
|
||||
public void add(BlockMask mask)
|
||||
{
|
||||
|
||||
this.mask = (BlockMask) mask.and(mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified id, data value pair from the VoxelList.
|
||||
*
|
||||
* @return true if this list contained the specified element
|
||||
*/
|
||||
public boolean removeValue(final BlockState state)
|
||||
{
|
||||
this.mask = mask.toBuilder().remove(state).build(NullExtent.INSTANCE);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeValue(final BlockMask state)
|
||||
{
|
||||
this.mask = (BlockMask) mask.and(state.inverse());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
* @return true if this list contains the specified element
|
||||
*/
|
||||
public boolean contains(final BlockData i)
|
||||
{
|
||||
return mask.test(BukkitAdapter.adapt(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the VoxelList.
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
mask = mask.toBuilder().clear().build(NullExtent.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this list contains no elements.
|
||||
*
|
||||
* @return true if this list contains no elements
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return mask.toBuilder().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a defensive copy of the List with pairs.
|
||||
*
|
||||
* @return defensive copy of the List with pairs
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return mask.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user