Ok, so I made a plugin called massgrief for fun, and eclipse shows NO errors, but it cant load it, here is the error log below, and can anyone tell me how to spawn multiple mobs at once, I know the method for spawning a single mob, but how do you spawn multiple ones? Here is the error log. 18:17:38 [SEVERE] Could not load 'plugins/MassGrief.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305) at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230) at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222) at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:198) at net.minecraft.server.ServerConfigurationManagerAbstract.<init>(ServerConfigurationManagerAbstract.java:50) at net.minecraft.server.ServerConfigurationManager.<init>(SourceFile:11) at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:105) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:378) at net.minecraft.server.ThreadServerApplication.run(SourceFile:539) Caused by: java.lang.NullPointerException at MassGrief.MassGriefMain.<init>(MassGriefMain.java:66) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149) ... 9 more
yeah, heres the main class, package MassGrief; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.CreatureType; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.java.JavaPlugin; import java.util.logging.Logger; public class MassGriefMain extends JavaPlugin { public void onEnable(){ getLogger().info("MassGrief has been enabled, you better hope you have rollback"); } public void onDisable(){ getLogger().info("MassGrief has been disabled, are you to scared to use it?"); } public void onPlayerMove(PlayerMoveEvent evt) { Location loc = evt.getPlayer().getLocation(); World w = loc.getWorld(); loc.setY(loc.getY() - 1); Block b = w.getBlockAt(loc); b.setTypeId(46); b.setData((byte)1); } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("BOOM")){ if (args.length > 1) { sender.sendMessage("Too many arguments!"); returnfalse; } if (args.length < 1) { sender.sendMessage("Not enough arguments!"); returnfalse; } Player s = (Player)sender; Player target = s.getServer().getPlayer(args[0]); if (target == null) { sender.sendMessage("The specified player is not online."); returnfalse; } target.setHealth(0); target.getWorld().spawnCreature(target.getLocation(), CreatureType.CREEPER); returntrue; } returnfalse; }{ for(Player player: getServer().getOnlinePlayers()) { if(player.hasPermission("massgrief.boomrepeat")) { float explosionPower = 10F; player.getWorld().createExplosion(player.getLocation(), (Float) explosionPower); } } } public void onPlyerJoin(PlayerJoinEvent evt) { Player player = evt.getPlayer(); PlayerInventory inventory = player.getInventory(); ItemStack itemstack = new ItemStack(Material.TNT, 1728); if (inventory.contains(itemstack)) { inventory.addItem(itemstack); player.sendMessage("Ready to Grief? Have fun!"); } } } and heres the plugin yml, name: MassGrief main: MassGrief.MassGriefMain version: 1.0 commands: BOOM: description: This spawns a creeper on a specified player. usage: /<command> [player] permission: massgrief.BOOM permission-message: You can't spawn creepers! permissions: massgrief.*: description: Gives all access to the massgrief plugin. children: massgrief.BOOM massgrief.BoomRepeat massgrief.BOOM: description: Allows usage of the BOOM command. default: op massgrief.BoomRepeat: description: Bypasses BoomRepeat death. default: op the yml is properly spaced, it just got rearranged. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Well... Lots of stuff o-O You need to implement Listener, register the events onEnable, and add @EventHandler on each of the events. If you still have problems please put the code in code lol. Code:
After extends JavaPlugin write implements Listener. Then in onEnable put getServer().getPluginManager().registerEvents(this, this); Then before your events just write @EventHandler.
I tried it, heres the error log, the code will be below. I couldn't put @EventHandler before the if permission thing cause it wanted an enum identifier, so i didn't. Heres the error log. 13:47:38 [SEVERE] Could not load 'plugins/MassGrief.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305) at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230) at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222) at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:198) at net.minecraft.server.ServerConfigurationManagerAbstract.<init>(ServerConfigurationManagerAbstract.java:50) at net.minecraft.server.ServerConfigurationManager.<init>(SourceFile:11) at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:105) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:378) at net.minecraft.server.ThreadServerApplication.run(SourceFile:539) Caused by: java.lang.NullPointerException at MassGrief.MassGriefMain.<init>(MassGriefMain.java:75) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149) ... 9 more Here is the code. package MassGrief; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.CreatureType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.java.JavaPlugin; import java.util.logging.Logger; public class MassGriefMain extends JavaPlugin implements Listener{ public void onEnable(){ getLogger().info("MassGrief has been enabled, you better hope you have rollback"); getServer().getPluginManager().registerEvents(this, this); } public void onDisable(){ getLogger().info("MassGrief has been disabled, are you to scared to use it?"); } @EventHandler public void onPlayerMove(PlayerMoveEvent evt) { Location loc = evt.getPlayer().getLocation(); World w = loc.getWorld(); loc.setY(loc.getY() - 1); Block b = w.getBlockAt(loc); b.setTypeId(46); b.setData((byte)1); } @EventHandler public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("BOOM")){ if (args.length > 1) { sender.sendMessage("Too many arguments!"); return false; } if (args.length < 1) { sender.sendMessage("Not enough arguments!"); return false; } Player s = (Player)sender; Player target = s.getServer().getPlayer(args[0]); if (target == null) { sender.sendMessage("The specified player is not online."); return false; } target.setHealth(0); target.getWorld().spawnCreature(target.getLocation(), CreatureType.CREEPER); return true; } return false; } {for(Player player: getServer().getOnlinePlayers()) { if(player.hasPermission("massgrief.DeathByBomb")) { float explosionPower = 10F; player.getWorld().createExplosion(player.getLocation(), (Float) explosionPower); } } } public void onPlyerJoin(PlayerJoinEvent evt) { Player player = evt.getPlayer(); PlayerInventory inventory = player.getInventory(); ItemStack itemstack = new ItemStack(Material.TNT, 1728); if (inventory.contains(itemstack)) { inventory.addItem(itemstack); player.sendMessage("Ready to Grief? Have fun!"); } } }
MassGriefMain.java:75 And I didn't tell you to put @EventHandler for your health, you need it. And don't put it before onCommand, as that's not an event.
Changed it, Im probably doing something very wrong, Im a newb. Error log \/ 19:57:22 [SEVERE] Could not load 'plugins/MassGrief.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305) at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230) at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222) at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:198) at net.minecraft.server.ServerConfigurationManagerAbstract.<init>(ServerConfigurationManagerAbstract.java:50) at net.minecraft.server.ServerConfigurationManager.<init>(SourceFile:11) at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:105) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:378) at net.minecraft.server.ThreadServerApplication.run(SourceFile:539) Caused by: java.lang.NullPointerException at MassGrief.MassGriefMain.<init>(MassGriefMain.java:75) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149) ... 9 more Source Code \/ package MassGrief; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.CreatureType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.java.JavaPlugin; import java.util.logging.Logger; public class MassGriefMain extends JavaPlugin implements Listener{ public void onEnable(){ getLogger().info("MassGrief has been enabled, you better hope you have rollback"); getServer().getPluginManager().registerEvents(this, this); } public void onDisable(){ getLogger().info("MassGrief has been disabled, are you to scared to use it?"); } @EventHandler public void onPlayerMove(PlayerMoveEvent evt) { Location loc = evt.getPlayer().getLocation(); World w = loc.getWorld(); loc.setY(loc.getY() - 1); Block b = w.getBlockAt(loc); b.setTypeId(46); b.setData((byte)1); } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("BOOM")){ if (args.length > 1) { sender.sendMessage("Too many arguments!"); return false; } if (args.length < 1) { sender.sendMessage("Not enough arguments!"); return false; } Player s = (Player)sender; Player target = s.getServer().getPlayer(args[0]); if (target == null) { sender.sendMessage("The specified player is not online."); return false; } target.setHealth(0); target.getWorld().spawnCreature(target.getLocation(), CreatureType.CREEPER); return true; } return false; } {for(Player player: getServer().getOnlinePlayers()) { if(player.hasPermission("massgrief.DeathByBomb")) { float explosionPower = 10F; player.getWorld().createExplosion(player.getLocation(), (Float) explosionPower); } } } public void onPlyerJoin(PlayerJoinEvent evt) { Player player = evt.getPlayer(); PlayerInventory inventory = player.getInventory(); ItemStack itemstack = new ItemStack(Material.TNT, 1728); if (inventory.contains(itemstack)) { inventory.addItem(itemstack); player.sendMessage("Ready to Grief? Have fun!"); } } }
Just poking my head into this thread for a second, didn't really read anything. You might wanna use [ CODE ] tags or [ SYNTAX=JAVA ] tags to make the code your posts easier to read. Code: [CODE]Example[/CODE ] Code:JAVA [SYNTAX=JAVA]Example[/SYNTAX]
ok, thx, but that doesn't help me. I'm kinda looking for plugin developers, so far the most helpful people have also made some of the best plugins. One made battle night, it was sniperzxx or something, also zavoris helped, he made auto announcer, its used on my server, its awesome, point is, people who have experiance r helpful, do u have experience? ur advice was helpful, but not what im looking for. Sorry
This will help you learn to read the stack traces. http://forums.bukkit.org/threads/ho...ubleshoot-your-own-plugins-by-yourself.32457/ from the last one you posted your error is on line 75. Code: Caused by: java.lang.NullPointerException at MassGrief.MassGriefMain.<init>(MassGriefMain.java:75) Also.. it really is a good idea to use [ CODE ] or [ SYNTAX=JAVA ] tags.. cause now anyone that wants to help is gonna have to reformat your code before they can read it.
Yea, after I cleaned up your code I found a bunch of stuff wrong with it that would have been easy to spot if you had used [ CODE ] or [ SYNTAX=JAVA ] tags. Here's what I've got after some cleaning; plugin.yml - Cleaned up the plugin.yml code - Added default group for massgrief.* - Corrected format of massgrief.* children - Removed massgrief.BoomRepeat as it's not used Code: name: MassGrief main: MassGrief.MassGriefMain version: 1.0 commands: BOOM: description: This spawns a creeper on a specified player. permission: massgrief.BOOM permission-message: You can't spawn creepers! permissions: massgrief.*: description: Gives all access to the massgrief plugin. default: op children: massgrief.BOOM: true massgrief.BOOM: description: Allows usage of the BOOM command. default: op MassGriefMain.java - Cleaned up the MassGriefMain code - Changed target.getWorld().spawnCreature(target.getLocation(), CreatureType.CREEPER); to target.getWorld().spawnEntity(target.getLocation(), EntityType.CREEPER); as spawnCreature is depreciated - Added @EventHandler to onPlayerJoin - Changed new ItemStack(Material.TNT, 1728) in onPlayerJoin to new ItemStack(Material.TNT, 64) as a number that high might break something - Changed if(inventory.contains(itemstack)) in onPlayerJoin to if(!inventory.contains(itemstack)) - Removed the massgrief.DeathByBomb part as it's not referenced anywhere else, and I'm not even sure what you wanted to trigger it Code:JAVA package MassGrief; import org.bukkit.Location;import org.bukkit.Material;import org.bukkit.World;import org.bukkit.block.Block;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.EntityType;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.event.player.PlayerMoveEvent;import org.bukkit.inventory.ItemStack;import org.bukkit.inventory.PlayerInventory;import org.bukkit.plugin.java.JavaPlugin; public class MassGriefMain extends JavaPlugin implements Listener { public void onEnable() { getLogger().info("MassGrief has been enabled, you better hope you have rollback"); getServer().getPluginManager().registerEvents(this, this); } public void onDisable(){ getLogger().info("MassGrief has been disabled, are you to scared to use it?"); } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("BOOM")){ if(args.length > 1) { sender.sendMessage("Too many arguments!"); return false; } if(args.length < 1) { sender.sendMessage("Not enough arguments!"); return false; } Player s = (Player) sender; Player target = s.getServer().getPlayer(args[0]); if(target == null) { sender.sendMessage("The specified player is not online."); return false; } target.setHealth(0); target.getWorld().spawnEntity(target.getLocation(), EntityType.CREEPER); return true; } return false; } @EventHandler public void onPlayerMove(PlayerMoveEvent evt) { Location loc = evt.getPlayer().getLocation(); loc.setY(loc.getY() - 1); World w = loc.getWorld(); Block b = w.getBlockAt(loc); b.setTypeId(46); b.setData((byte)1); } @EventHandler public void onPlyerJoin(PlayerJoinEvent evt) { Player player = evt.getPlayer(); PlayerInventory inventory = player.getInventory(); ItemStack itemstack = new ItemStack(Material.TNT, 64); if(!inventory.contains(itemstack)) { inventory.addItem(itemstack); player.sendMessage("Ready to Grief? Have fun!"); } }} See how much proper presentation helps?