geforkt von Mirrors/Paper
SPIGOT-6200: Improve entity events when summon command is used
* Calls the LightningStrikeEvent for summoned lightning * Uses the new COMMAND SpawnReason for other entities By: Julian van den Berkmortel <julianvdberkmortel@outlook.com>
Dieser Commit ist enthalten in:
Ursprung
da56cad3fc
Commit
9d5bc88891
@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/commands/CommandSummon.java
|
||||
+++ b/net/minecraft/server/commands/CommandSummon.java
|
||||
@@ -64,7 +64,7 @@
|
||||
((EntityInsentient) entity).prepare(commandlistenerwrapper.getWorld(), commandlistenerwrapper.getWorld().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
}
|
||||
|
||||
- if (!worldserver.addAllEntitiesSafely(entity)) {
|
||||
+ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND"
|
||||
throw CommandSummon.b.create();
|
||||
} else {
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.summon.success", new Object[]{entity.getScoreboardDisplayName()}), true);
|
@ -462,7 +462,7 @@
|
||||
|
||||
if (ichunkaccess instanceof Chunk) {
|
||||
((Chunk) ichunkaccess).b(entity);
|
||||
@@ -1029,10 +1195,33 @@
|
||||
@@ -1029,10 +1195,32 @@
|
||||
this.everyoneSleeping();
|
||||
}
|
||||
|
||||
@ -472,8 +472,7 @@
|
||||
+ }
|
||||
+
|
||||
+ public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) {
|
||||
+ LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause);
|
||||
+ this.getServer().getPluginManager().callEvent(lightning);
|
||||
+ LightningStrikeEvent lightning = CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause);
|
||||
+
|
||||
+ if (lightning.isCancelled()) {
|
||||
+ return false;
|
||||
@ -496,7 +495,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -1041,6 +1230,12 @@
|
||||
@@ -1041,6 +1229,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.locY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.locZ();
|
||||
|
||||
@ -509,7 +508,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -1079,7 +1274,18 @@
|
||||
@@ -1079,7 +1273,18 @@
|
||||
Iterator iterator = this.navigators.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@ -529,7 +528,7 @@
|
||||
|
||||
if (!navigationabstract.i()) {
|
||||
navigationabstract.b(blockposition);
|
||||
@@ -1101,10 +1307,20 @@
|
||||
@@ -1101,10 +1306,20 @@
|
||||
|
||||
@Override
|
||||
public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
|
||||
@ -550,7 +549,7 @@
|
||||
if (explosion_effect == Explosion.Effect.NONE) {
|
||||
explosion.clearBlocks();
|
||||
}
|
||||
@@ -1169,13 +1385,20 @@
|
||||
@@ -1169,13 +1384,20 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
@ -573,7 +572,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1217,7 +1440,7 @@
|
||||
@@ -1217,7 +1439,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition a(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
|
||||
@ -582,7 +581,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1255,7 +1478,13 @@
|
||||
@@ -1255,7 +1477,13 @@
|
||||
@Override
|
||||
public WorldMap a(String s) {
|
||||
return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().b(() -> {
|
||||
@ -597,7 +596,7 @@
|
||||
}, s);
|
||||
}
|
||||
|
||||
@@ -1386,9 +1615,9 @@
|
||||
@@ -1386,9 +1614,9 @@
|
||||
reputationhandler.a(reputationevent, entity);
|
||||
}
|
||||
|
||||
@ -609,7 +608,7 @@
|
||||
Throwable throwable = null;
|
||||
|
||||
try {
|
||||
@@ -1432,7 +1661,7 @@
|
||||
@@ -1432,7 +1660,7 @@
|
||||
CrashReport crashreport = new CrashReport("Level dump", new Exception("dummy"));
|
||||
|
||||
this.a(crashreport);
|
||||
@ -618,7 +617,7 @@
|
||||
Throwable throwable3 = null;
|
||||
|
||||
try {
|
||||
@@ -1455,8 +1684,8 @@
|
||||
@@ -1455,8 +1683,8 @@
|
||||
|
||||
}
|
||||
|
||||
@ -629,7 +628,7 @@
|
||||
Throwable throwable6 = null;
|
||||
|
||||
try {
|
||||
@@ -1479,8 +1708,8 @@
|
||||
@@ -1479,8 +1707,8 @@
|
||||
|
||||
}
|
||||
|
||||
@ -640,7 +639,7 @@
|
||||
Throwable throwable9 = null;
|
||||
|
||||
try {
|
||||
@@ -1503,8 +1732,8 @@
|
||||
@@ -1503,8 +1731,8 @@
|
||||
|
||||
}
|
||||
|
||||
@ -651,7 +650,7 @@
|
||||
Throwable throwable12 = null;
|
||||
|
||||
try {
|
||||
@@ -1566,6 +1795,11 @@
|
||||
@@ -1566,6 +1794,11 @@
|
||||
@Override
|
||||
public void update(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebugWorld()) {
|
||||
@ -663,7 +662,7 @@
|
||||
this.applyPhysics(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1580,12 +1814,12 @@
|
||||
@@ -1580,12 +1813,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlatWorld() {
|
||||
@ -678,7 +677,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1605,9 +1839,9 @@
|
||||
@@ -1605,9 +1838,9 @@
|
||||
|
||||
@VisibleForTesting
|
||||
public String F() {
|
||||
@ -690,7 +689,7 @@
|
||||
return IRegistry.BLOCK_ENTITY_TYPE.getKey(tileentity.getTileType());
|
||||
}), this.getBlockTickList().a(), this.getFluidTickList().a(), this.P());
|
||||
}
|
||||
@@ -1615,7 +1849,7 @@
|
||||
@@ -1615,7 +1848,7 @@
|
||||
private static <T> String a(Collection<T> collection, Function<T, MinecraftKey> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<MinecraftKey> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@ -699,7 +698,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1624,7 +1858,8 @@
|
||||
@@ -1624,7 +1857,8 @@
|
||||
object2intopenhashmap.addTo(minecraftkey, 1);
|
||||
}
|
||||
|
||||
@ -709,7 +708,7 @@
|
||||
return it_unimi_dsi_fastutil_objects_object2intmap_entry.getKey() + ":" + it_unimi_dsi_fastutil_objects_object2intmap_entry.getIntValue();
|
||||
}).collect(Collectors.joining(","));
|
||||
} catch (Exception exception) {
|
||||
@@ -1633,16 +1868,32 @@
|
||||
@@ -1633,16 +1867,32 @@
|
||||
}
|
||||
|
||||
public static void a(WorldServer worldserver) {
|
||||
|
@ -214,6 +214,7 @@ import org.bukkit.event.raid.RaidStopEvent;
|
||||
import org.bukkit.event.raid.RaidTriggerEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
import org.bukkit.event.world.LootGenerateEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
@ -584,6 +585,9 @@ public class CraftEventFactory {
|
||||
event = CraftEventFactory.callProjectileLaunchEvent(entity);
|
||||
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Vehicle) {
|
||||
event = CraftEventFactory.callVehicleCreateEvent(entity);
|
||||
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.LightningStrike) {
|
||||
LightningStrikeEvent.Cause cause = (spawnReason == SpawnReason.COMMAND ? LightningStrikeEvent.Cause.COMMAND : LightningStrikeEvent.Cause.UNKNOWN);
|
||||
event = CraftEventFactory.callLightningStrikeEvent((LightningStrike) entity.getBukkitEntity(), cause);
|
||||
} else if (!(entity instanceof EntityPlayer)) {
|
||||
event = CraftEventFactory.callEntitySpawnEvent(entity);
|
||||
}
|
||||
@ -1518,6 +1522,12 @@ public class CraftEventFactory {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static LightningStrikeEvent callLightningStrikeEvent(LightningStrike entity, LightningStrikeEvent.Cause cause) {
|
||||
LightningStrikeEvent event = new LightningStrikeEvent(entity.getWorld(), entity, cause);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raid events
|
||||
*/
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren