Strip events from book pages on signing
Dieser Commit ist enthalten in:
Ursprung
815922ab1a
Commit
e4ca2af9c4
@ -28,6 +28,7 @@ import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftMetaBook;
|
||||||
import org.bukkit.craftbukkit.util.CraftDamageSource;
|
import org.bukkit.craftbukkit.util.CraftDamageSource;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
@ -834,7 +835,12 @@ public class CraftEventFactory {
|
|||||||
if (editBookEvent.isSigning()) {
|
if (editBookEvent.isSigning()) {
|
||||||
itemInHand.setItem(Items.WRITTEN_BOOK);
|
itemInHand.setItem(Items.WRITTEN_BOOK);
|
||||||
}
|
}
|
||||||
CraftItemStack.setItemMeta(itemInHand, editBookEvent.getNewBookMeta());
|
CraftMetaBook meta = (CraftMetaBook) editBookEvent.getNewBookMeta();
|
||||||
|
List<IChatBaseComponent> pages = meta.pages;
|
||||||
|
for (int i = 0; i < pages.size(); i++) {
|
||||||
|
pages.set(i, stripEvents(pages.get(i)));
|
||||||
|
}
|
||||||
|
CraftItemStack.setItemMeta(itemInHand, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client will have updated its idea of the book item; we need to overwrite that
|
// Client will have updated its idea of the book item; we need to overwrite that
|
||||||
@ -843,6 +849,32 @@ public class CraftEventFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IChatBaseComponent stripEvents(IChatBaseComponent c) {
|
||||||
|
ChatModifier modi = c.getChatModifier();
|
||||||
|
if (modi != null) {
|
||||||
|
modi.setChatClickable(null);
|
||||||
|
modi.setChatHoverable(null);
|
||||||
|
}
|
||||||
|
c.setChatModifier(modi);
|
||||||
|
if (c instanceof ChatMessage) {
|
||||||
|
ChatMessage cm = (ChatMessage) c;
|
||||||
|
Object[] oo = cm.j();
|
||||||
|
for (int i = 0; i < oo.length; i++) {
|
||||||
|
Object o = oo[i];
|
||||||
|
if (o instanceof IChatBaseComponent) {
|
||||||
|
oo[i] = stripEvents((IChatBaseComponent) o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<IChatBaseComponent> ls = c.a();
|
||||||
|
if (ls != null) {
|
||||||
|
for (int i = 0; i < ls.size(); i++) {
|
||||||
|
ls.set(i, stripEvents(ls.get(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player) {
|
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player) {
|
||||||
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity());
|
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity());
|
||||||
entity.world.getServer().getPluginManager().callEvent(event);
|
entity.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
@ -23,7 +23,7 @@ import net.minecraft.server.NBTTagString;
|
|||||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||||
|
|
||||||
@DelegateDeserialization(SerializableMeta.class)
|
@DelegateDeserialization(SerializableMeta.class)
|
||||||
class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||||
static final ItemMetaKey BOOK_TITLE = new ItemMetaKey("title");
|
static final ItemMetaKey BOOK_TITLE = new ItemMetaKey("title");
|
||||||
static final ItemMetaKey BOOK_AUTHOR = new ItemMetaKey("author");
|
static final ItemMetaKey BOOK_AUTHOR = new ItemMetaKey("author");
|
||||||
static final ItemMetaKey BOOK_PAGES = new ItemMetaKey("pages");
|
static final ItemMetaKey BOOK_PAGES = new ItemMetaKey("pages");
|
||||||
@ -34,7 +34,7 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||||||
|
|
||||||
protected String title;
|
protected String title;
|
||||||
protected String author;
|
protected String author;
|
||||||
protected List<IChatBaseComponent> pages = new ArrayList<IChatBaseComponent>();
|
public List<IChatBaseComponent> pages = new ArrayList<IChatBaseComponent>();
|
||||||
protected Integer generation;
|
protected Integer generation;
|
||||||
|
|
||||||
CraftMetaBook(CraftMetaItem meta) {
|
CraftMetaBook(CraftMetaItem meta) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren