@EventHandler public void onCommand(PlayerCommandPreprocessEvent e) { String spell = e.getMessage().replace('/', ' '); if (plugin.SpellManager.isSpell(spell)) { plugin.SpellManager.getSpell(spell).cast(e.getPlayer()); } }
@EventHandler public void onPlayerChat(AsyncPlayerChatEvent e) { if (plugin.getConfig().getBoolean("spell-castable-with-chat")) { if (plugin.SpellManager.isSpell(e.getMessage().substring(0, e.getMessage().length() - 1))) { plugin.SpellManager.getSpell(e.getMessage().substring(0, e.getMessage().length() - 1)) .cast(e.getPlayer()); return; } } if (sonorus.contains(e.getPlayer().getName())) { e.setCancelled(true); plugin .getServer() .broadcastMessage( e.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + e.getMessage()); sonorus.remove(e.getPlayer().getName()); } }