Skip to content

Instantly share code, notes, and snippets.

@Jikoo
Created July 30, 2015 22:57
Show Gist options
  • Save Jikoo/3bda662215f4fae4079b to your computer and use it in GitHub Desktop.
Save Jikoo/3bda662215f4fae4079b to your computer and use it in GitHub Desktop.
No book color Bukkit plugin
name: NoBookColor
main: com.github.jikoo.nobookcolor.NoBookColor
version: 1.0
author: Jikoo
package com.github.jikoo.nobookcolor;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerEditBookEvent;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class NoBookColor extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable() {
}
@EventHandler
public void onEvent(PlayerEditBookEvent event) {
if (event.getPlayer().hasPermission("book.color")) {
return;
}
BookMeta newMeta = event.getNewBookMeta();
ArrayList<String> pages = new ArrayList<String>(newMeta.getPages());
Iterator<String> pageIterator = pages.iterator();
pages.clear();
while (pageIterator.hasNext()) {
pages.add(ChatColor.stripColor(pageIterator.next()));
}
newMeta.setPages(pages);
event.setNewBookMeta(newMeta);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment