13
0
geforkt von Mirrors/Paper

Line endings, damnit!

Dieser Commit ist enthalten in:
Dinnerbone 2011-03-27 20:57:46 +01:00
Ursprung f1ffeb256d
Commit c47db7092b
3 geänderte Dateien mit 228 neuen und 228 gelöschten Zeilen

Datei anzeigen

@ -53,7 +53,7 @@ public class ItemBucket extends Item {
if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0) { if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0) {
// CraftBukkit start // CraftBukkit start
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Item.WATER_BUCKET); PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Item.WATER_BUCKET);
if (event.isCancelled()) { if (event.isCancelled()) {
return itemstack; return itemstack;
} }
@ -68,7 +68,7 @@ public class ItemBucket extends Item {
if (world.getMaterial(i, j, k) == Material.LAVA && world.getData(i, j, k) == 0) { if (world.getMaterial(i, j, k) == Material.LAVA && world.getData(i, j, k) == 0) {
// CraftBukkit start // CraftBukkit start
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Item.LAVA_BUCKET); PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Item.LAVA_BUCKET);
if (event.isCancelled()) { if (event.isCancelled()) {
return itemstack; return itemstack;
@ -84,7 +84,7 @@ public class ItemBucket extends Item {
} else { } else {
if (this.a < 0) { if (this.a < 0) {
// CraftBukkit start // CraftBukkit start
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, i, j, k, movingobjectposition.e, itemstack); PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, i, j, k, movingobjectposition.e, itemstack);
if (event.isCancelled()) { if (event.isCancelled()) {
return itemstack; return itemstack;
@ -129,7 +129,7 @@ public class ItemBucket extends Item {
return itemstack; return itemstack;
} }
// CraftBukkit end // CraftBukkit end
if (world.m.d && this.a == Block.WATER.id) { if (world.m.d && this.a == Block.WATER.id) {
world.a(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.k.nextFloat() - world.k.nextFloat()) * 0.8F); world.a(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.k.nextFloat() - world.k.nextFloat()) * 0.8F);

Datei anzeigen

@ -70,7 +70,7 @@ public class ItemInWorldManager {
if (l == Block.WOODEN_DOOR.id) { if (l == Block.WOODEN_DOOR.id) {
// For some reason *BOTH* the bottom/top part have to be marked updated. // For some reason *BOTH* the bottom/top part have to be marked updated.
boolean bottom = (this.b.getData(i, j, k) & 8) == 0; boolean bottom = (this.b.getData(i, j, k) & 8) == 0;
((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j, k, this.b))); ((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j, k, this.b)));
((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, this.b))); ((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, this.b)));
} }
} else { } else {

Datei anzeigen

@ -1,224 +1,224 @@
package org.bukkit.craftbukkit.event; package org.bukkit.craftbukkit.event;
import net.minecraft.server.ChunkCoordinates; import net.minecraft.server.ChunkCoordinates;
import net.minecraft.server.EntityChicken; import net.minecraft.server.EntityChicken;
import net.minecraft.server.EntityCow; import net.minecraft.server.EntityCow;
import net.minecraft.server.EntityCreeper; import net.minecraft.server.EntityCreeper;
import net.minecraft.server.EntityGhast; import net.minecraft.server.EntityGhast;
import net.minecraft.server.EntityGiantZombie; import net.minecraft.server.EntityGiantZombie;
import net.minecraft.server.EntityHuman; import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityPig; import net.minecraft.server.EntityPig;
import net.minecraft.server.EntityPigZombie; import net.minecraft.server.EntityPigZombie;
import net.minecraft.server.EntitySheep; import net.minecraft.server.EntitySheep;
import net.minecraft.server.EntitySkeleton; import net.minecraft.server.EntitySkeleton;
import net.minecraft.server.EntitySlime; import net.minecraft.server.EntitySlime;
import net.minecraft.server.EntitySpider; import net.minecraft.server.EntitySpider;
import net.minecraft.server.EntitySquid; import net.minecraft.server.EntitySquid;
import net.minecraft.server.EntityZombie; import net.minecraft.server.EntityZombie;
import net.minecraft.server.Item; import net.minecraft.server.Item;
import net.minecraft.server.ItemStack; import net.minecraft.server.ItemStack;
import net.minecraft.server.World; import net.minecraft.server.World;
import net.minecraft.server.WorldServer; import net.minecraft.server.WorldServer;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
public class CraftEventFactory { public class CraftEventFactory {
private static boolean canBuild(CraftWorld world, Player player, int x, int z) { private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
WorldServer worldServer = world.getHandle(); WorldServer worldServer = world.getHandle();
int spawnSize = worldServer.x.spawnProtection; int spawnSize = worldServer.x.spawnProtection;
if (spawnSize <= 0) return true; if (spawnSize <= 0) return true;
if (player.isOp()) return true; if (player.isOp()) return true;
ChunkCoordinates chunkcoordinates = worldServer.l(); ChunkCoordinates chunkcoordinates = worldServer.l();
int distanceFromSpawn = (int) Math.max(Math.abs(x - chunkcoordinates.a), Math.abs(z - chunkcoordinates.c)); int distanceFromSpawn = (int) Math.max(Math.abs(x - chunkcoordinates.a), Math.abs(z - chunkcoordinates.c));
return distanceFromSpawn > spawnSize; return distanceFromSpawn > spawnSize;
} }
/** /**
* Block place methods * Block place methods
*/ */
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, int type) { public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, int type) {
return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, net.minecraft.server.Block.byId[type]); return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, net.minecraft.server.Block.byId[type]);
} }
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, net.minecraft.server.Block block) { public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, net.minecraft.server.Block block) {
return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, new ItemStack(block)); return callBlockPlaceEvent(world, who, replacedBlockState, clickedX, clickedY, clickedZ, new ItemStack(block));
} }
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, ItemStack itemstack) { public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ, ItemStack itemstack) {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer(); CraftServer craftServer = ((WorldServer) world).getServer();
Player player = (who == null) ? null : (Player) who.getBukkitEntity(); Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftItemStack itemInHand = new CraftItemStack(itemstack);
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ); Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
Block placedBlock = replacedBlockState.getBlock(); Block placedBlock = replacedBlockState.getBlock();
boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ()); boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ());
BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, itemInHand, player, canBuild); BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, itemInHand, player, canBuild);
craftServer.getPluginManager().callEvent(event); craftServer.getPluginManager().callEvent(event);
return event;
}
/**
* Bucket methods
*/
public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand) {
return (PlayerBucketEmptyEvent) getPlayerBucketEvent(Type.PLAYER_BUCKET_EMPTY, who, clickedX, clickedY, clickedZ, clickedFace, itemInHand, Item.BUCKET);
}
public static PlayerBucketFillEvent callPlayerBucketFillEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand, net.minecraft.server.Item bucket) {
return (PlayerBucketFillEvent) getPlayerBucketEvent(Type.PLAYER_BUCKET_FILL, who, clickedX, clickedY, clickedZ, clickedFace, itemInHand, bucket);
}
private static PlayerEvent getPlayerBucketEvent(Type type, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(new ItemStack(item));
Material bucket = Material.getMaterial(itemstack.id);
CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftServer craftServer = (CraftServer) player.getServer();
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
PlayerEvent event = null;
if (type == Type.PLAYER_BUCKET_EMPTY) {
event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
} else if(type == Type.PLAYER_BUCKET_FILL) {
event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
}
craftServer.getPluginManager().callEvent(event);
return event;
}
/**
* Player Interact event
*/
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
throw new IllegalArgumentException();
}
return callPlayerInteractEvent(who, action, 0, 255, 0, 0, itemstack);
}
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack);
CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftServer craftServer = (CraftServer) player.getServer();
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
if (clickedY == 255) {
blockClicked = null;
switch (action) {
case LEFT_CLICK_BLOCK:
action = Action.LEFT_CLICK_AIR;
break;
case RIGHT_CLICK_BLOCK:
action = Action.RIGHT_CLICK_AIR;
break;
}
}
if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
itemInHand = null;
}
PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
return event; return event;
} }
/** /**
* BlockDamageEvent * Bucket methods
*/ */
public static BlockDamageEvent callBlockDamageEvent(EntityHuman who, int x, int y, int z, ItemStack itemstack, boolean instaBreak) { public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand) {
Player player = (who == null) ? null : (Player) who.getBukkitEntity(); return (PlayerBucketEmptyEvent) getPlayerBucketEvent(Type.PLAYER_BUCKET_EMPTY, who, clickedX, clickedY, clickedZ, clickedFace, itemInHand, Item.BUCKET);
CraftItemStack itemInHand = new CraftItemStack(itemstack); }
CraftWorld craftWorld = (CraftWorld) player.getWorld(); public static PlayerBucketFillEvent callPlayerBucketFillEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand, net.minecraft.server.Item bucket) {
CraftServer craftServer = (CraftServer) player.getServer(); return (PlayerBucketFillEvent) getPlayerBucketEvent(Type.PLAYER_BUCKET_FILL, who, clickedX, clickedY, clickedZ, clickedFace, itemInHand, bucket);
}
Block blockClicked = craftWorld.getBlockAt(x, y, z);
private static PlayerEvent getPlayerBucketEvent(Type type, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak); Player player = (who == null) ? null : (Player) who.getBukkitEntity();
craftServer.getPluginManager().callEvent(event); CraftItemStack itemInHand = new CraftItemStack(new ItemStack(item));
Material bucket = Material.getMaterial(itemstack.id);
return event;
} CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftServer craftServer = (CraftServer) player.getServer();
/**
* CreatureSpawnEvent Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
*/ BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving) {
org.bukkit.entity.Entity entity = entityliving.getBukkitEntity(); PlayerEvent event = null;
CraftServer craftServer = (CraftServer) entity.getServer(); if (type == Type.PLAYER_BUCKET_EMPTY) {
event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
CreatureType type = null; ((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
} else if(type == Type.PLAYER_BUCKET_FILL) {
if (entityliving instanceof EntityChicken) { event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
type = CreatureType.CHICKEN; ((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
} else if (entityliving instanceof EntityCow) { }
type = CreatureType.COW;
} else if (entityliving instanceof EntityCreeper) { craftServer.getPluginManager().callEvent(event);
type = CreatureType.CREEPER;
} else if (entityliving instanceof EntityGhast) { return event;
type = CreatureType.GHAST; }
} else if (entityliving instanceof EntityGiantZombie) {
type = CreatureType.GIANT; /**
} else if (entityliving instanceof EntityPig) { * Player Interact event
type = CreatureType.PIG; */
} else if (entityliving instanceof EntityPigZombie) {
type = CreatureType.PIG_ZOMBIE; public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
} else if (entityliving instanceof EntitySheep) { if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
type = CreatureType.SHEEP; throw new IllegalArgumentException();
} else if (entityliving instanceof EntitySkeleton) { }
type = CreatureType.SKELETON; return callPlayerInteractEvent(who, action, 0, 255, 0, 0, itemstack);
} else if (entityliving instanceof EntitySpider) { }
type = CreatureType.SPIDER; public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
} else if (entityliving instanceof EntityZombie) { Player player = (who == null) ? null : (Player) who.getBukkitEntity();
type = CreatureType.ZOMBIE; CraftItemStack itemInHand = new CraftItemStack(itemstack);
} else if (entityliving instanceof EntitySlime) {
type = CreatureType.SLIME; CraftWorld craftWorld = (CraftWorld) player.getWorld();
} else if (entityliving instanceof EntitySquid) { CraftServer craftServer = (CraftServer) player.getServer();
type = CreatureType.SQUID;
} Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
CreatureSpawnEvent event = new CreatureSpawnEvent(entity, type, entity.getLocation());
craftServer.getPluginManager().callEvent(event); if (clickedY == 255) {
return event; blockClicked = null;
} switch (action) {
} case LEFT_CLICK_BLOCK:
action = Action.LEFT_CLICK_AIR;
break;
case RIGHT_CLICK_BLOCK:
action = Action.RIGHT_CLICK_AIR;
break;
}
}
if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
itemInHand = null;
}
PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
return event;
}
/**
* BlockDamageEvent
*/
public static BlockDamageEvent callBlockDamageEvent(EntityHuman who, int x, int y, int z, ItemStack itemstack, boolean instaBreak) {
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack);
CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftServer craftServer = (CraftServer) player.getServer();
Block blockClicked = craftWorld.getBlockAt(x, y, z);
BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak);
craftServer.getPluginManager().callEvent(event);
return event;
}
/**
* CreatureSpawnEvent
*/
public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving) {
org.bukkit.entity.Entity entity = entityliving.getBukkitEntity();
CraftServer craftServer = (CraftServer) entity.getServer();
CreatureType type = null;
if (entityliving instanceof EntityChicken) {
type = CreatureType.CHICKEN;
} else if (entityliving instanceof EntityCow) {
type = CreatureType.COW;
} else if (entityliving instanceof EntityCreeper) {
type = CreatureType.CREEPER;
} else if (entityliving instanceof EntityGhast) {
type = CreatureType.GHAST;
} else if (entityliving instanceof EntityGiantZombie) {
type = CreatureType.GIANT;
} else if (entityliving instanceof EntityPig) {
type = CreatureType.PIG;
} else if (entityliving instanceof EntityPigZombie) {
type = CreatureType.PIG_ZOMBIE;
} else if (entityliving instanceof EntitySheep) {
type = CreatureType.SHEEP;
} else if (entityliving instanceof EntitySkeleton) {
type = CreatureType.SKELETON;
} else if (entityliving instanceof EntitySpider) {
type = CreatureType.SPIDER;
} else if (entityliving instanceof EntityZombie) {
type = CreatureType.ZOMBIE;
} else if (entityliving instanceof EntitySlime) {
type = CreatureType.SLIME;
} else if (entityliving instanceof EntitySquid) {
type = CreatureType.SQUID;
}
CreatureSpawnEvent event = new CreatureSpawnEvent(entity, type, entity.getLocation());
craftServer.getPluginManager().callEvent(event);
return event;
}
}