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... Code: Spoiler (Move your mouse to the spoiler area to reveal the content) Show Spoiler Hide Spoiler Code:java 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{@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);}} and the Error: Spoiler (Move your mouse to the spoiler area to reveal the content) Show Spoiler Hide Spoiler Code:java org.bukkit.plugin.InvalidPluginException: java.lang.ClassCastException: class com.tschagg.ChatFormat.ChatMainat org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184)at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugins(CraftServer.java:239)at org.bukkit.craftbukkit.v1_4_6.CraftServer.<init>(CraftServer.java:217)at net.minecraft.server.v1_4_6.PlayerList.<init>(PlayerList.java:52)at net.minecraft.server.v1_4_6.DedicatedPlayerList.<init>(SourceFile:11)at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java:104)at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:399)at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)Caused by: java.lang.ClassCastException: class com.tschagg.ChatFormat.ChatMainat java.lang.Class.asSubclass(Unknown Source)at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:174)... 9 more Thank you!
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.
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.
I suggest eclipse for java programming. It is much better than others and its 100% free no strings attached. http://www.eclipse.org/