I got a problem with plugin.yml This is the code of it: Code: name: Freezer main: com.Baummann.Freezer version: 1.0 commands: freezer: description: Freeze a player. usage: | /freeze [Player] and the source: Freezer.java: Code: package com.Baummann.Freezer; import java.io.File; import java.util.logging.Logger; import org.bukkit.event.Event; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; public class Freezer extends JavaPlugin { Logger log = Logger.getLogger("Minecraft"); String name; String version; String maker; private final FreezerPlayerListener playerListener = new FreezerPlayerListener(this); public static PermissionHandler permissionHandler; public Freezer() { name = "Freezer"; version = "1.0"; maker = "Baummann1703"; } public void onEnable() { setupPermissions(); log.info(name + " " + version + " by " + maker + " enabled."); PluginManager pm = this.getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.Normal, this); log.info("[Freezer] Currently running Bukkit version " + this.getServer().getVersion() + "!"); } public void onDisable() { log.info(name + " " + version + " by " + maker + " disabled."); } public void setupPermissions() { Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions"); if (this.permissionHandler == null) { if (permissionsPlugin != null) { this.permissionHandler = ((Permissions) permissionsPlugin).getHandler(); } else { log.warning("[Freezer] Permissions system not detected, defaulting to OP"); } } } } FreezerPlayerListener.java: Code: package com.Baummann.Freezer; import java.util.HashMap; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerListener; public class FreezerPlayerListener extends PlayerListener { private HashMap<String, Player> frozen = new HashMap<String, Player>(); Freezer fr = new Freezer(); public static Freezer plugin; public FreezerPlayerListener(Freezer instance) { plugin = instance; } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (!Freezer.permissionHandler.has((Player) sender, "freezer.freeze")) { sender.sendMessage("§cYou don't have permission to use this!"); return true; } else { if (cmd.getName().equalsIgnoreCase("freeze")) { Player target = (Player) fr.getServer().matchPlayer(args[1]); if (Freezer.permissionHandler.has(target, "freezer.noFreeze")) { sender.sendMessage("§3[§bFreezer§3] §bYou may not freeze that person!"); return true; } else { if (frozen.get(target.getName()) != null) { frozen.remove(target.getName()); sender.sendMessage("§3[§bFreezer§3] §bYou thawed §b" + target.getName()); target.sendMessage("§3[§bFreezer§3] §bYou have been thawed by §b" + ((Command) sender).getName()); return true; } frozen.put(target.getName(), target); sender.sendMessage("§3[§bFreezer§3] §bYou froze §b" + target.getName()); target.sendMessage("§3[§bFreezer§3] §bYou have been frozen by " + ((Command) sender).getName()); return true; } } } return false; } public void onPlayerMove(Player player, Location from, Location to) { if (frozen.get(player.getName()) != null) { player.teleport(from); } } } If i export it i get this error (eclipse): Resource is out of sync with the file system: '/Freezer/plugin.yml' And an exception: Code: 16:21:17 [SCHWERWIEGEND] Could not load 'plugins/Freezer.jar' in folder 'plugins': java.io.FileNotFoundException: Jar does not contain plugin.yml at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:63) at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:194) at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:117) at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:103) at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:339) at org.bukkit.command.SimpleCommandMap$ReloadCommand.execute(SimpleCommandMap.java:247) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:128) at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:273) at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:425) at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:410) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:308) at net.minecraft.server.ThreadServerApplication.run(SourceFile:422) What is wrong with it?
mmmm then I redo my project in netbeans ok i put it in my package and.. I get the same exception EDIT by Moderator: merged posts, please use the edit button instead of double posting.
hmm i dont know actually u could open another plugin with WinRar and copy it over to ur Plugin. Then u just change the name and all that stuff. Thats what i did first when i didnt import a Plugin.yml .
It wrote it does not contain the plugin.yml In eclipse go to your project,right click on the src->new->file. Name it to plugin.yml and ta-da. Btw its better (or at least i think its better) if you use that layout in the plugin.yml commands: Code: commands: freeze: description: Your description usage: <command> And dont replace the <command>
Thanks it worked And here comes the next problem -.-: Code: public boolean onPlayerCommandPreprocessEvent(CommandSender sender, Command cmd, String commandLine, String args[]) { if (cmd.getName().equalsIgnoreCase("test")) { sender.sendMessage("§eIt works!"); return true; } return false; } If i type the command it says test not It works EDIT by Moderator: merged posts, please use the edit button instead of double posting.
You're confusing onPlayerCommandPreprocessEvent() with onCommand(). The onCommand() method belongs either in the main plugin class or in a class that implements CommandExecutor.
Yep,use onCommand and instead of: Code: if (cmd.getName().equalsIgnoreCase("test")) use the third string.equalsignoreCase("test) (actually commandLine): Code: if (commandLine.equalsIgnoreCase("test")) I hope that works. Ps: Did you registered the command in plugin.yml as i said?
There's nothing wrong with doing cmd.getName(). In fact, I believe it's probably better, since if you use aliases the command label will vary. Isn't that the way it works? It's the way I've always assumed it works.
Then im sorry,i always used it with the third string. If you post the error here we can more easily help. If there is no errors then the problem in the plugin.yml
Now i got this: (Yes i did buy the game) AntiPlayer.java: Code: package com.bukkit.baummann.AntiPlayer; import java.util.logging.Logger; import org.bukkit.event.Event; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; import org.bukkit.plugin.Plugin; public class AntiPlayer extends JavaPlugin { public static PermissionHandler permissionHandler; private Logger log; String name; String version; String maker; private final AntiPlayerPlayerListener playerListener; public AntiPlayer() { log = Logger.getLogger("Minecraft"); name = "AntiPlayer"; version = "1.0 Bukkit"; maker = "Baummann1703"; playerListener = new AntiPlayerPlayerListener(this); } public void onEnable() { setupPermissions(); log.info(name + " " + version + " by " + maker + " enabled."); PluginManager pm = this.getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.Normal, this); } public void onDisable() { log.info(name + " " + version + " by " + maker + " enabled."); } public void setupPermissions() { Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions"); if (AntiPlayer.permissionHandler == null) { if (permissionsPlugin != null) { AntiPlayer.permissionHandler = ((Permissions) permissionsPlugin).getHandler(); } else { log.info("Permission system not detected, defaulting to OP"); } } } } AntiPlayerPlayerListener.java: Code: package com.bukkit.baummann.AntiPlayer; import java.util.ArrayList; import java.util.logging.Logger; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerListener; public class AntiPlayerPlayerListener extends PlayerListener { static ArrayList<String> allowed; Logger log = Logger.getLogger("Minecraft"); public AntiPlayerPlayerListener() { allowed = new ArrayList<String>(); } public static AntiPlayer plugin; public AntiPlayerPlayerListener(AntiPlayer instance) { plugin = instance; } public void onPlayerLogin(Player player) { if (!allowed.contains("@")) { if (!AntiPlayer.permissionHandler.has(player, "antiplayer.ignore")) { if (player.getDisplayName().equalsIgnoreCase("Player") || player.getDisplayName().equalsIgnoreCase("") || player.getDisplayName().equalsIgnoreCase(" ")) { player.kickPlayer("Illegal name!"); } } } else { } } public boolean onCommand(CommandSender sender, Command cmd, String commandLine, String[] args) { if (!AntiPlayer.permissionHandler.has((Player) sender, "antiplayer.allowplayer")) { if (cmd.getName().equalsIgnoreCase("allowplayer")) { if (!allowed.contains("@")) { allowed.add("@"); sender.sendMessage("&ePlayer named players are now allowed!"); log.info("[AntiPlayer] Player named players are enabled by " + ((Player) sender).getDisplayName()); return true; } allowed.remove("@"); sender.sendMessage("&ePlayer named players are now disallowed!"); log.info("[AntiPlayer] Player named players are now disallowed!"); return true; } } return false; } } Error: Code: 20:41:49 [SCHWERWIEGEND] Nag author: '<NoAuthorGiven>' of 'AntiPlayer' about the following: onPlayerCommandPreprocess has been replaced with a new signature, (PlayerCommandPreprocessEvent) plugin.yml: Code: name: AntiPlayer main: com.bukkit.baummann.AntiPlayer.AntiPlayer version: 1.0 commands: allowplayer: description: Allows Player named players usage: <command> And before I make another thread: Will the onPlayerLogin code work?
As I said, the onCommand() method goes in your plugin class, not your player listener. And your onPlayerLogin won't work because it doesn't have the right signature. It should be onPlayerLogin(PlayerLoginEvent event). This website is your friend: http://jd.bukkit.org.
Ohh thanks that's what i searched for! I'll try it in my plugin class. Still same. Do I have to call the hook (or event...) like this?: Code: pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, (Listener) this, Event.Priority.Normal, this); EDIT by Moderator: merged posts, please use the edit button instead of double posting.
You do not have to register the command event. When you specified the command in the plugin YML file you just have to override the onCommand method in the plugin class. Look here for more information