Hi, im kinda new to coding plugins and I dont speak english so well but Im creating a that when a player walks through a bush it gives them damages. Dont ask me why im make this random plugin,(its for my friends wierd server). So anyways the thing I need help with is I want to make it so that when a player holds sheers it instantly breaks the 31:1 block aka Grass. Thank for your help
Before going into more advanced plugins, I would suggest starting with the basics. Maybe watching a few youtube videos or following some kind of tutorials.
Thanks for the feedback, can I get a example of the code please I just want to know how its setup disregarding the whole plugin so maybe can I see some example code so I can learn from it (I want the sheers to destory the grass block when right clicked.) Thanks for all your help im very generous to have such a nice community of people
@camman00, I'm going to say this for the thousandth time but if it doesn't apply to you disregard it and skip to the next paragraph. If you do not know Java well, please learn Java before you attempt to make a plugin. It will make your life so much easier. As far as example code, there is a Bukkit wiki that explains the basics of plugins such as the config file and YAML file which instructs the server what the plugin is and what to do with it. http://wiki.bukkit.org/Plugin_Tutorial It's a shame that many people don't go to this page because it truly is very well put together.
Im have expeirence with the java. I just want an example of what the code looks like for sheers to break grass block. I maybe should of said this in my first post, im somewhat experienced with java, i just want an example of what the code looks like,(maybe of pastebin ) EDIT by Timtower: merged posts
@camman00 Please do not double post, use the edit button. Here are some examples of codes on how to get events working, the event you're looking for is PlayerInteractEvent
Thanks I fixed that problem and the plugin works , But I have ran into a very weird problem. The old version of my plugin works but I added some more stuff to the code. The console of my friends server says Could not load 'plugins/camman00.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: Cannot find main class `main.java' To add to this here is my plugin yml: --- author: camman00 description: camman00 main: main.java name: camman00 version: 2.0 And here is the first couple lines of code in my plugin: package me.test.test.core; import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class main extends JavaPlugin{ (my package is named me.test.test.core) Thanks for your help guys <3
@camman00 The "main" in the plugin.yml needs to direct to a class, so for example, you would use "me.test.test.core.main" as your main.
I just tried that now the console says that plugin.yml is invalid. Is there something I did wrong with the spacing? Sorry for Bumping but I really need to fix this, my friend is making his server public tomorrow. Here is the error I get Could not load 'plugins/camman00.jar' in folder 'plugins' org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:150) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins(CraftServer.java:355) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at org.bukkit.craftbukkit.v1_7_R3.CraftServer.<init>(CraftServer.java:317) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at net.minecraft.server.v1_7_R3.PlayerList.<init>(PlayerList.java:68) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at net.minecraft.server.v1_7_R3.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at net.minecraft.server.v1_7_R3.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:436) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks] Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml ... 9 more EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@camman00 Your plugin yml needs to be exactly in the src folder. Not in any subfolder. The error happens because no plugin.yml is found.
I deleted the plugin.yml file create it in the src folder still get the same error If the image doesnt load use this http://gyazo.com/a4a55cb699d5b9ced70361d22e0b951e Also here is my plugin.yml currently --- author: camman00 description: camman00 main: me.test.test.core.main name: camman00 version: 2.0
The error is that my plugin cannot run because the plugin.yml is setup (there is no errors in my code atm) Well I took a couple looks at my plugin yml and found that there was a hidden spaces. I fixed it and now my plugin is working perfectly thanks to this awesome community. Thank you so much guys . EDIT by Timtower: merged posts I woke up this morning to find yet another error, Unsupported major.minor version 52.0 being spammed in the console. the thing that is weird is that I tried it on my server and It worked just fine. My servers version is 1.7.9 his is 1.8.1. (my complier is set to 1.7) EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@bwfcwalshy It seems to say Unsupported Major Minor version 52. If he uses java 8, why would that be a iussue?
The weird thing is that the plugin works perfect on a 1.7.9 server but on a 1.8 server it just says that error :V? Any suggestions guys?
What should my compiler be set to, 1.7 or 1.8. Also for FYI, I got a new computer yesterday and reinstalled eclipse I never had this error with my old computer Here is the exact error org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/test/test/core/main : Unsupported major.minor version 52.0 please help me <3