(Breaking) Moved some packages around.

Most of the changes should not break *most* WorldEdit-using plugins,
but implementations of WorldEdit are broken by this change.
This commit is contained in:
sk89q
2014-04-02 19:08:50 -07:00
parent 6e70e8c862
commit 469cb8c8b3
185 changed files with 13303 additions and 13270 deletions

View File

@ -17,13 +17,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.buffer;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.pattern.Pattern;

View File

@ -17,11 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.cache;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
/**
* Returns the same cached {@link BaseBlock} for repeated calls to

View File

@ -0,0 +1,199 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.inventory;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.blocks.*;
/**
* Represents a source to get blocks from and store removed ones.
*
* @author sk89q
*/
public abstract class BlockBag {
/**
* Stores a block as if it was mined.
*
* @param id
* @throws BlockBagException
* @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead
*/
@Deprecated
public void storeDroppedBlock(int id) throws BlockBagException {
storeDroppedBlock(id, 0);
}
/**
* Stores a block as if it was mined.
*
* @param id
* @param data
* @throws BlockBagException
*/
public void storeDroppedBlock(int id, int data) throws BlockBagException {
BaseItem dropped = BlockType.getBlockBagItem(id, data);
if (dropped == null) return;
if (dropped.getType() == BlockID.AIR) return;
storeItem(dropped);
}
/**
* Sets a block as if it was placed by hand.
*
* @param id
* @throws BlockBagException
* @deprecated Use {@link #fetchPlacedBlock(int,int)} instead
*/
@Deprecated
public void fetchPlacedBlock(int id) throws BlockBagException {
fetchPlacedBlock(id, 0);
}
/**
* Sets a block as if it was placed by hand.
*
* @param id
* @param data TODO
* @throws BlockBagException
*/
public void fetchPlacedBlock(int id, int data) throws BlockBagException {
try {
// Blocks that can't be fetched...
switch (id) {
case BlockID.BEDROCK:
case BlockID.GOLD_ORE:
case BlockID.IRON_ORE:
case BlockID.COAL_ORE:
case BlockID.DIAMOND_ORE:
case BlockID.TNT:
case BlockID.MOB_SPAWNER:
case BlockID.CROPS:
case BlockID.REDSTONE_ORE:
case BlockID.GLOWING_REDSTONE_ORE:
case BlockID.SNOW:
case BlockID.LIGHTSTONE:
case BlockID.PORTAL:
throw new UnplaceableBlockException();
case BlockID.WATER:
case BlockID.STATIONARY_WATER:
case BlockID.LAVA:
case BlockID.STATIONARY_LAVA:
// Override liquids
return;
default:
fetchBlock(id);
break;
}
} catch (OutOfBlocksException e) {
BaseItem placed = BlockType.getBlockBagItem(id, data);
if (placed == null) throw e; // TODO: check
if (placed.getType() == BlockID.AIR) throw e; // TODO: check
fetchItem(placed);
}
}
/**
* Get a block.
*
* Either this method or fetchItem needs to be overridden
*
* @param id
* @throws BlockBagException
*/
public void fetchBlock(int id) throws BlockBagException {
fetchItem(new BaseItem(id));
}
/**
* Get a block.
*
* Either this method or fetchBlock needs to be overridden
*
* @param item
* @throws BlockBagException
*/
public void fetchItem(BaseItem item) throws BlockBagException {
fetchBlock(item.getType());
}
/**
* Store a block.
*
* Either this method or storeItem needs to be overridden
*
* @param id
* @throws BlockBagException
*/
public void storeBlock(int id) throws BlockBagException {
storeItem(new BaseItem(id));
}
/**
* Store a block.
*
* Either this method or storeBlock needs to be overridden
*
* @param item
* @throws BlockBagException
*/
public void storeItem(BaseItem item) throws BlockBagException {
storeBlock(item.getType());
}
/**
* Checks to see if a block exists without removing it.
*
* @param id
* @return whether the block exists
*/
public boolean peekBlock(int id) {
try {
fetchBlock(id);
storeBlock(id);
return true;
} catch (BlockBagException e) {
return false;
}
}
/**
* Flush any changes. This is called at the end.
*/
public abstract void flushChanges();
/**
* Adds a position to be used a source.
*
* @param pos
*/
public abstract void addSourcePosition(WorldVector pos);
/**
* Adds a position to be used a source.
*
* @param pos
*/
public abstract void addSingleSourcePosition(WorldVector pos);
}

View File

@ -0,0 +1,28 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.inventory;
/**
*
* @author sk89q
*/
public class BlockBagException extends Exception {
private static final long serialVersionUID = 4672190086028430655L;
}

View File

@ -17,14 +17,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.inventory;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.bags.BlockBagException;
import com.sk89q.worldedit.bags.UnplaceableBlockException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.extent.inventory.BlockBagException;
import com.sk89q.worldedit.extent.inventory.UnplaceableBlockException;
import com.sk89q.worldedit.blocks.BaseBlock;
import javax.annotation.Nullable;

View File

@ -0,0 +1,28 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.inventory;
/**
*
* @author sk89q
*/
public class OutOfBlocksException extends BlockBagException {
private static final long serialVersionUID = 7495899825677689509L;
}

View File

@ -0,0 +1,48 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.inventory;
/**
*
* @author sk89q
*/
public class OutOfSpaceException extends BlockBagException {
private static final long serialVersionUID = -2962840237632916821L;
/**
* Stores the block ID.
*/
private int id;
/**
* Construct the object.
* @param id
*/
public OutOfSpaceException(int id) {
this.id = id;
}
/**
* @return the id
*/
public int getID() {
return id;
}
}

View File

@ -0,0 +1,29 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.inventory;
/**
*
* @author sk89q
*/
public class UnplaceableBlockException extends BlockBagException {
private static final long serialVersionUID = 7227883966999843526L;
}

View File

@ -17,11 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.logging;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
/**
* An abstract class to implement block loggers and so on with.

View File

@ -17,12 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.validation;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
import static com.google.common.base.Preconditions.checkArgument;

View File

@ -17,12 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.validation;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.world;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
@ -25,6 +25,8 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -17,12 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.world;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.ExtentDelegate;
import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -17,13 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent;
package com.sk89q.worldedit.extent.world;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.ExtentDelegate;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;