Disallow people spawning invalid entities using monster eggs. Thanks to md-5 for the PR.
Dieser Commit ist enthalten in:
Ursprung
390a79e098
Commit
25050e38eb
@ -9,7 +9,7 @@ public class ItemMonsterEgg extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
|
public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
|
||||||
if (world.isStatic) {
|
if (world.isStatic || itemstack.getData() == 48 || itemstack.getData() == 49 || itemstack.getData() == 63) { // CraftBukkit
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
i += Facing.b[l];
|
i += Facing.b[l];
|
||||||
@ -17,7 +17,7 @@ public class ItemMonsterEgg extends Item {
|
|||||||
k += Facing.d[l];
|
k += Facing.d[l];
|
||||||
Entity entity = EntityTypes.a(itemstack.getData(), world);
|
Entity entity = EntityTypes.a(itemstack.getData(), world);
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null && entity instanceof EntityLiving) { // CraftBukkit
|
||||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||||
--itemstack.count;
|
--itemstack.count;
|
||||||
}
|
}
|
||||||
@ -29,4 +29,4 @@ public class ItemMonsterEgg extends Item {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,8 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.craftbukkit.ChunkCompressionThread;
|
import org.bukkit.craftbukkit.ChunkCompressionThread;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -89,6 +91,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
public CraftPlayer getPlayer() {
|
public CraftPlayer getPlayer() {
|
||||||
return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
private final static HashSet<Integer> invalidItems = new HashSet<Integer>(Arrays.asList(8, 9, 10, 11, 26, 34, 36, 51, 52, 55, 59, 60, 63, 64, 68, 71, 75, 78, 83, 90, 92, 93, 94, 95));
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public void a() {
|
public void a() {
|
||||||
@ -1012,7 +1015,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
boolean flag = packet107setcreativeslot.a < 0;
|
boolean flag = packet107setcreativeslot.a < 0;
|
||||||
ItemStack itemstack = packet107setcreativeslot.b;
|
ItemStack itemstack = packet107setcreativeslot.b;
|
||||||
boolean flag1 = packet107setcreativeslot.a >= 36 && packet107setcreativeslot.a < 36 + PlayerInventory.getHotbarSize();
|
boolean flag1 = packet107setcreativeslot.a >= 36 && packet107setcreativeslot.a < 36 + PlayerInventory.getHotbarSize();
|
||||||
boolean flag2 = itemstack == null || itemstack.id < Item.byId.length && itemstack.id >= 0 && Item.byId[itemstack.id] != null;
|
boolean flag2 = itemstack == null || itemstack.id < Item.byId.length && itemstack.id >= 0 && Item.byId[itemstack.id] != null && !invalidItems.contains(itemstack.id); // CraftBukkit
|
||||||
boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0;
|
boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0;
|
||||||
|
|
||||||
if (flag1 && flag2 && flag3) {
|
if (flag1 && flag2 && flag3) {
|
||||||
@ -1142,4 +1145,4 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren