mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 06:24:06 +01:00
Merge branch 'master' of github.com:Bukkit/CraftBukkit
This commit is contained in:
commit
d92376e106
@ -7,6 +7,7 @@ import org.bukkit.event.block.BlockIgniteEvent;
|
|||||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class BlockFire extends Block {
|
public class BlockFire extends Block {
|
||||||
@ -90,7 +91,7 @@ public class BlockFire extends Block {
|
|||||||
Server server = ((WorldServer)world).getServer();
|
Server server = ((WorldServer)world).getServer();
|
||||||
CraftWorld cworld = ((WorldServer)world).getWorld();
|
CraftWorld cworld = ((WorldServer)world).getWorld();
|
||||||
|
|
||||||
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i1, j1, k1));
|
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i1, k1, j1));
|
||||||
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
|
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
|
||||||
Player thePlayer = null;
|
Player thePlayer = null;
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ public class BlockFire extends Block {
|
|||||||
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
|
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
|
||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -116,31 +117,36 @@ public class BlockFire extends Block {
|
|||||||
|
|
||||||
if (random.nextInt(l) < i1) {
|
if (random.nextInt(l) < i1) {
|
||||||
boolean flag = world.a(i, j, k) == Block.am.bi;
|
boolean flag = world.a(i, j, k) == Block.am.bi;
|
||||||
|
// CraftBukkit start: BlockBurnEvent
|
||||||
|
Server server = ((WorldServer)world).getServer();
|
||||||
|
CraftWorld cworld = ((WorldServer)world).getWorld();
|
||||||
|
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i, j, k));
|
||||||
|
BlockBurnEvent burnEvent = new BlockBurnEvent(theBlock);
|
||||||
|
server.getPluginManager().callEvent(burnEvent);
|
||||||
|
if(!burnEvent.isCancelled()) {
|
||||||
|
if (random.nextInt(2) == 0) {
|
||||||
|
// CraftBukkit start: Call to stop very slow spread of fire.
|
||||||
|
|
||||||
if (random.nextInt(2) == 0) {
|
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SLOW_SPREAD;
|
||||||
// CraftBukkit start: Call to stop very slow spread of fire.
|
Player thePlayer = null;
|
||||||
Server server = ((WorldServer)world).getServer();
|
|
||||||
CraftWorld cworld = ((WorldServer)world).getWorld();
|
if (theBlock.getTypeId() != Block.ar.bi){
|
||||||
|
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
|
||||||
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i, j, k));
|
server.getPluginManager().callEvent(event);
|
||||||
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SLOW_SPREAD;
|
if (event.isCancelled()) {
|
||||||
Player thePlayer = null;
|
return;
|
||||||
|
}
|
||||||
if (theBlock.getTypeId() != Block.ar.bi){
|
|
||||||
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
|
|
||||||
server.getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
world.e(i, j, k, bi);
|
||||||
|
} else {
|
||||||
|
world.e(i, j, k, 0);
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
Block.am.a(world, i, j, k, 0);
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
|
||||||
world.e(i, j, k, bi);
|
|
||||||
} else {
|
|
||||||
world.e(i, j, k, 0);
|
|
||||||
}
|
|
||||||
if (flag) {
|
|
||||||
Block.am.a(world, i, j, k, 0);
|
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end: BlockBurnEvent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,9 @@ import java.util.Random;
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.entity.CraftCreature;
|
import org.bukkit.craftbukkit.entity.CraftCreature;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntityCreature extends EntityLiving {
|
public class EntityCreature extends EntityLiving {
|
||||||
@ -27,12 +30,37 @@ public class EntityCreature extends EntityLiving {
|
|||||||
float f = 16F;
|
float f = 16F;
|
||||||
|
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
d = l();
|
// CraftBukkit start
|
||||||
|
Entity target = l();
|
||||||
|
if(target != null) {
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), TargetReason.CLOSEST_PLAYER);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
a = l.a(((Entity) (this)), d, f);
|
a = l.a(((Entity) (this)), d, f);
|
||||||
}
|
}
|
||||||
} else if (!d.B()) {
|
} else if (!d.B()) {
|
||||||
d = null;
|
// CraftBukkit start
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.TARGET_DIED);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
} else {
|
} else {
|
||||||
float f1 = d.a(((Entity) (this)));
|
float f1 = d.a(((Entity) (this)));
|
||||||
|
|
||||||
|
@ -5,10 +5,13 @@ import java.util.Random;
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.entity.CraftMonster;
|
import org.bukkit.craftbukkit.entity.CraftMonster;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntityMobs extends EntityCreature implements IMobs {
|
public class EntityMobs extends EntityCreature implements IMobs {
|
||||||
@ -57,7 +60,22 @@ public class EntityMobs extends EntityCreature implements IMobs {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (entity != this) {
|
if (entity != this) {
|
||||||
d = entity;
|
// CraftBukkit start
|
||||||
|
org.bukkit.entity.Entity bukkitTarget = null;
|
||||||
|
if(entity != null) {
|
||||||
|
bukkitTarget = entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_ENTITY);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,7 +5,10 @@ import java.util.Random;
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPigZombie;
|
import org.bukkit.craftbukkit.entity.CraftPigZombie;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntityPigZombie extends EntityZombie {
|
public class EntityPigZombie extends EntityZombie {
|
||||||
@ -82,9 +85,24 @@ public class EntityPigZombie extends EntityZombie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void g(Entity entity) {
|
private void g(Entity entity) {
|
||||||
d = entity;
|
// CraftBukkit start
|
||||||
a = 400 + W.nextInt(400);
|
org.bukkit.entity.Entity bukkitTarget = null;
|
||||||
b = W.nextInt(40);
|
if(entity != null) {
|
||||||
|
bukkitTarget = entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
a = 400 + W.nextInt(400);
|
||||||
|
b = W.nextInt(40);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String e() {
|
protected String e() {
|
||||||
|
@ -4,7 +4,10 @@ import java.util.Random;
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.entity.CraftSpider;
|
import org.bukkit.craftbukkit.entity.CraftSpider;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit stop
|
// CraftBukkit stop
|
||||||
|
|
||||||
public class EntitySpider extends EntityMobs {
|
public class EntitySpider extends EntityMobs {
|
||||||
@ -52,8 +55,19 @@ public class EntitySpider extends EntityMobs {
|
|||||||
float f2 = b(1.0F);
|
float f2 = b(1.0F);
|
||||||
|
|
||||||
if (f2 > 0.5F && W.nextInt(100) == 0) {
|
if (f2 > 0.5F && W.nextInt(100) == 0) {
|
||||||
this.d = null;
|
// CraftBukkit start
|
||||||
return;
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.FORGOT_TARGET);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
this.d = null;
|
||||||
|
} else {
|
||||||
|
this.d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
if (f1 > 2.0F && f1 < 6F && W.nextInt(10) == 0) {
|
if (f1 > 2.0F && f1 < 6F && W.nextInt(10) == 0) {
|
||||||
if (A) {
|
if (A) {
|
||||||
|
@ -160,6 +160,10 @@ public class MinecraftServer implements ICommandListener, Runnable {
|
|||||||
|
|
||||||
private void g() {
|
private void g() {
|
||||||
a.info("Stopping server");
|
a.info("Stopping server");
|
||||||
|
if(server != null) {
|
||||||
|
server.disablePlugins();
|
||||||
|
}
|
||||||
|
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
f.d();
|
f.d();
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,10 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disablePlugins() {
|
||||||
|
pluginManager.disablePlugins();
|
||||||
|
}
|
||||||
|
|
||||||
private void loadPlugin(Plugin plugin) {
|
private void loadPlugin(Plugin plugin) {
|
||||||
List<Command> pluginCommands = PluginCommandYamlParser.parse(plugin);
|
List<Command> pluginCommands = PluginCommandYamlParser.parse(plugin);
|
||||||
if (!pluginCommands.isEmpty()) {
|
if (!pluginCommands.isEmpty()) {
|
||||||
@ -168,5 +172,9 @@ public final class CraftServer implements Server {
|
|||||||
|
|
||||||
console.e.k = monsters ? 1 : 0;
|
console.e.k = monsters ? 1 : 0;
|
||||||
console.e.a(monsters, animals);
|
console.e.a(monsters, animals);
|
||||||
|
|
||||||
|
pluginManager.clearPlugins();
|
||||||
|
commandMap.clearCommands();
|
||||||
|
loadPlugins();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,11 @@ package org.bukkit.craftbukkit;
|
|||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.entity.*;
|
import org.bukkit.craftbukkit.entity.*;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import net.minecraft.server.*;
|
import net.minecraft.server.*;
|
||||||
@ -316,4 +319,44 @@ public class CraftWorld implements World {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Entity> getEntities() {
|
||||||
|
List<Entity> list = new ArrayList<Entity>();
|
||||||
|
|
||||||
|
for (Object o : world.b) {
|
||||||
|
if (o instanceof net.minecraft.server.Entity) {
|
||||||
|
net.minecraft.server.Entity mcEnt
|
||||||
|
= (net.minecraft.server.Entity)o;
|
||||||
|
|
||||||
|
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||||
|
|
||||||
|
// Assuming that bukkitEntity isn't null
|
||||||
|
if (bukkitEntity != null) {
|
||||||
|
list.add(bukkitEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LivingEntity> getLivingEntities() {
|
||||||
|
List<LivingEntity> list = new ArrayList<LivingEntity>();
|
||||||
|
|
||||||
|
for (Object o : world.b) {
|
||||||
|
if (o instanceof net.minecraft.server.Entity) {
|
||||||
|
net.minecraft.server.Entity mcEnt
|
||||||
|
= (net.minecraft.server.Entity)o;
|
||||||
|
|
||||||
|
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||||
|
|
||||||
|
// Assuming that bukkitEntity isn't null
|
||||||
|
if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) {
|
||||||
|
list.add((LivingEntity)bukkitEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +337,14 @@ public class CraftBlock implements Block {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBlockPowered() {
|
||||||
|
return world.getHandle().o(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlockIndirectlyPowered() {
|
||||||
|
return world.getHandle().p(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
type = world.getHandle().a(x, y, z);
|
type = world.getHandle().a(x, y, z);
|
||||||
data = (byte)world.getHandle().b(x, y, z);
|
data = (byte)world.getHandle().b(x, y, z);
|
||||||
|
@ -110,4 +110,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
entity.a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))));
|
entity.a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean performCommand(String command) {
|
||||||
|
return server.dispatchCommand(this, command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user