Plugin Help.

Discussion in 'Plugin Development' started by camman00, Jun 6, 2015.

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

    camman00

    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 :)
     
  2. Offline

    Tecno_Wizard

    @camman00, listen to the player move event and be very careful about how much you do in it.
     
    camman00 likes this.
  3. Offline

    benzimmer123

    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.
     
    camman00 likes this.
  4. Offline

    camman00

    Thanks for the feedback, can I get a example of the code please :D 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 :D
     
    Last edited: Jun 6, 2015
  5. Offline

    Tecno_Wizard

    @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.
     
  6. Offline

    camman00

    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 :D)

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Jun 7, 2015
  7. Offline

    Konato_K

    @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
     
  8. Offline

    camman00

    Thanks I fixed that problem and the plugin works :D, 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
     
  9. Offline

    Googlelover1234

    @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.
     
  10. Offline

    camman00

    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.
     
    Last edited by a moderator: Jun 12, 2016
  11. Offline

    I Al Istannen

    @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.
     
  12. Offline

    camman00

    I deleted the plugin.yml file create it in the src folder still get the same error :(

    [​IMG]

    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
     
    Last edited: Jun 8, 2015
  13. Offline

    I Al Istannen

    @camman00 Whats the error now? Still
    ?
     
  14. Offline

    camman00

    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 :D.

    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.
     
    Last edited by a moderator: Jun 12, 2016
  15. @camman00 What Java version are you using?
     
  16. Offline

    camman00

    I'm using Java 8
     
  17. @camman00 The plugin was most likely compiled with Java 7
     
  18. Offline

    I Al Istannen

    @bwfcwalshy It seems to say Unsupported Major Minor version 52. If he uses java 8, why would that be a iussue?
     
  19. Online

    timtower Administrator Administrator Moderator

    It wouldn't.
     
  20. Offline

    camman00

    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?
     
  21. Online

    timtower Administrator Administrator Moderator

    @camman00 Are you sure that you are compiling with java 7?
     
  22. Offline

    camman00

    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
     
    Last edited: Jun 10, 2015
  23. Offline

    camman00

Thread Status:
Not open for further replies.

Share This Page