Merge branch 'master' of github.com:Dinnerbone/Bukkit

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2010-12-31 21:58:47 +00:00
commit a2010332f6
5 changed files with 62 additions and 19 deletions

View file

@ -9,7 +9,8 @@ public enum BlockFace {
South(1, 0, 0),
West(0, 0, 1),
Up(0, 1, 0),
Down(0, -1, 0);
Down(0, -1, 0),
Self(0, 0, 0);
private final int modX;
private final int modY;

View file

@ -1,6 +1,8 @@
package org.bukkit.event.block;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Block;
import org.bukkit.BlockFace;
import org.bukkit.event.Event;
@ -9,7 +11,7 @@ import org.bukkit.event.Event;
* Holds information for events with a source block and a destination block
*/
public class BlockFlowEvent extends BlockEvent {
protected HashSet<BlockFlow> faceList;
protected final HashSet<BlockFlow> faceList;
public BlockFlowEvent(final Event.Type type, final Block block, BlockFace... faces) {
super(type, block);
@ -20,14 +22,25 @@ public class BlockFlowEvent extends BlockEvent {
}
}
}
public BlockFlowEvent(final Event.Type type, final Block block, List<BlockFace> faces) {
super(type, block);
this.faceList = new HashSet<BlockFlow>();
if (faces != null && faces.size() > 0) {
for (BlockFace theFace : faces) {
faceList.add(new BlockFlow(theFace));
}
}
}
/**
* Gets the location this player moved to
* We don't want plugins changing the eligible flowing faces
* therefore give them a new HashSet instance
*
* @return Block the block is event originated from
*/
public HashSet<BlockFlow> getFaces() {
return faceList;
return new HashSet<BlockFlow>(faceList);
}
/**
@ -61,7 +74,7 @@ public class BlockFlowEvent extends BlockEvent {
}
public boolean equals(BlockFlow flow) {
return flow.flowDirection.equals(flow);
return flowDirection.equals(flow.flowDirection);
}
@Override

View file

@ -8,11 +8,13 @@ import org.bukkit.event.Event;
* Holds information for events with a source block and a destination block
*/
public class BlockFromToEvent extends BlockEvent {
protected BlockFace face;
protected Block from;
protected BlockFace face;
public BlockFromToEvent(final Event.Type type, final Block block, final BlockFace face) {
super(type, block);
this.face = face;
this.from = block.getRelative(face.getModX(), face.getModY(), face.getModZ());
}
/**
@ -29,7 +31,7 @@ public class BlockFromToEvent extends BlockEvent {
*
* @return Block the faced block
*/
public Block getFacedBlock() {
return block.getRelative(face.getModX(), face.getModY(), face.getModZ());
public Block getFromBlock() {
return from;
}
}

View file

@ -1,13 +1,9 @@
/**
*
*/
package org.bukkit.event.block;
import org.bukkit.Block;
/**
* @author jmartin
*
* Not implemented yet
*/
public class BlockPlacedEvent extends BlockEvent {

View file

@ -4,19 +4,50 @@
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.BlockFace;
import org.bukkit.ItemStack;
import org.bukkit.Player;
/**
* Not implemented yet
* @author durron597
*/
public class BlockRightClickedEvent extends BlockEvent {
protected Player clicker;
protected BlockFace direction;
protected ItemStack clickedWith;
/**
* @param type
* @param theBlock
* @param type The type of event this is
* @param theBlock The clicked block
* @param direction The face we clicked from
* @param clicker The player who clicked a block
* @param clickedWith Item in player's hand
*/
public BlockRightClickedEvent(Type type, Block theBlock) {
public BlockRightClickedEvent(Type type, Block theBlock, BlockFace direction, Player clicker, ItemStack clickedWith) {
super(type, theBlock);
// TODO Auto-generated constructor stub
this.direction = direction;
this.clicker = clicker;
this.clickedWith = clickedWith;
}
/**
* @return the clicker
*/
public Player getClicker() {
return clicker;
}
/**
* @return the direction
*/
public BlockFace getDirection() {
return direction;
}
/**
* @return the clickedWith
*/
public ItemStack getClickedWith() {
return clickedWith;
}
}