Created
July 30, 2015 22:57
-
-
Save Jikoo/3bda662215f4fae4079b to your computer and use it in GitHub Desktop.
No book color Bukkit plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: NoBookColor | |
main: com.github.jikoo.nobookcolor.NoBookColor | |
version: 1.0 | |
author: Jikoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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