Discussion in 'Plugin Development' started by tschagg, Jan 23, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    hey guys , i wanted to make like a test plugin for chat formating
    the code is only for testing, but, it dont works, and i've no idea why...

    Show Spoiler

    2. package com.tschagg.ChatFormat;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.EventPriority;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.player.AsyncPlayerChatEvent;
    10. import ru.tehkode.permissions.PermissionUser;
    11. import ru.tehkode.permissions.bukkit.PermissionsEx;
    13. public class ChatMain implements Listener{
    14. @EventHandler (priority = EventPriority.LOW)
    15. public void onPlayerChat(AsyncPlayerChatEvent event) {
    16. Player player = event.getPlayer();
    17. PermissionUser user = PermissionsEx.getUser(player);
    18. String suffix = user.getSuffix();
    19. player.setPlayerListName(suffix + player.getName());
    20. String eventMessage = event.getMessage();
    21. player.sendMessage(ChatColor.GREEN + "Nachricht Gesendet!");
    22. event.setMessage("Test" + eventMessage);
    23. }
    24. }

    and the Error:
    Show Spoiler

    2. org.bukkit.plugin.InvalidPluginException: java.lang.ClassCastException: class com.tschagg.ChatFormat.ChatMain
    3. at
    4. at org.bukkit.plugin.SimplePluginManager.loadPlugin(
    5. at org.bukkit.plugin.SimplePluginManager.loadPlugins(
    6. at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugins(
    7. at org.bukkit.craftbukkit.v1_4_6.CraftServer.<init>(
    8. at net.minecraft.server.v1_4_6.PlayerList.<init>(
    9. at net.minecraft.server.v1_4_6.DedicatedPlayerList.<init>(SourceFile:11)
    10. at net.minecraft.server.v1_4_6.DedicatedServer.init(
    11. at
    12. at
    13. Caused by: java.lang.ClassCastException: class com.tschagg.ChatFormat.ChatMain
    14. at java.lang.Class.asSubclass(Unknown Source)
    15. at
    16. ... 9 more

    Thank you!
  2. Offline


    Your ChatMain class needs to extend JavaPlugin.
    tschagg likes this.
  3. Offline


    ok thx, i'll try it :)

    ok i fixed this error problem, now, the code is not workin, i get no messages from it when im ingame... (no other plugins installed) any ideas why that isnt workin?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 31, 2016
  4. Offline


    Did you register the events?
    tschagg likes this.
  5. Offline


    package com.tschagg.ChatFormat;
    import org.bukkit.ChatColor; import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent;
    import ru.tehkode.permissions.PermissionUser;
    import ru.tehkode.permissions.bukkit.PermissionsEx;
    public class ChatMain implements Listener{
    public void onEnable(){
    getServer().getPluginManager().registerEvents(this, this);

    @EventHandler (priority = EventPriority.LOW)
    public void onPlayerChat(AsyncPlayerChatEvent event) {
    Player player = event.getPlayer();
    PermissionUser user = PermissionsEx.getUser(player);
    String suffix = user.getSuffix();
    player.setPlayerListName(suffix + player.getName());
    String eventMessage = event.getMessage();
    player.sendMessage(ChatColor.GREEN + "Nachricht Gesendet!");
    event.setMessage("Test" + eventMessage);
    should work now but i did write it in gedit so it might be inperfect.
    tschagg likes this.
  6. Offline


    I suggest eclipse for java programming. It is much better than others and its 100% free no strings attached.
  7. Offline


    LOL i use eclipse xD but i cba to open it.
  8. Offline


    oh i forgot to register this event lol....

    thank you so much guys!!! <3
Thread Status:
Not open for further replies.

Share This Page