Solved Kit fisherman help please :D

Discussion in 'Plugin Development' started by TCO_007, Mar 9, 2014.

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

    TCO_007

    So I have been working on my kit fisherman plugin. For whatever reason, I cant figure out why it wont work. When I issue the command, it gives me the items but the event doesnt seem to be working. It will not teleport them to me and I dont know why. Can anyone help me? Thanks!
    Events class:
    Code:java
    1. package me.TCOB055.MultiKits;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Material;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.entity.PlayerDeathEvent;
    9. import org.bukkit.event.player.PlayerFishEvent;
    10.  
    11. public class Events implements Listener {
    12. private Main plugin;
    13. public Events(Main instance){
    14. plugin = instance; }
    15.  
    16. @EventHandler
    17. public void fishermanUse(PlayerFishEvent e){
    18. Player p = e.getPlayer();
    19. Player c = (Player) e.getCaught();
    20. if(plugin.Fisherman.contains(p.getName())){
    21. if(p.getInventory().getItemInHand().equals(Material.FISHING_ROD)){
    22. c.teleport(p.getLocation());
    23. p.sendMessage(ChatColor.AQUA + "You have fished " + ChatColor.DARK_GREEN + c.getName() + ChatColor.AQUA + " to you!");
    24. }
    25. }
    26.  
    27. }
    28. @EventHandler
    29. public void onDeath(PlayerDeathEvent e){
    30. Player p = e.getEntity();
    31. if(plugin.kitused.contains(p.getName())){
    32. plugin.kitused.remove(p.getName());
    33. if(plugin.Fisherman.contains(p.getName())){
    34. plugin.Fisherman.remove(p.getName());
    35. if(plugin.PvP.contains(p.getName())){
    36. plugin.PvP.remove(p.getName());
    37. }
    38. }
    39. }
    40. }
    41. }


    Main class:
    Code:java
    1. package me.TCOB055.MultiKits;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.plugin.PluginManager;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class Main extends JavaPlugin {
    9. private Events Events = new Events(this);
    10. //array lists for kits
    11. ArrayList<String> PvP = new ArrayList<String>();
    12. ArrayList<String> Fisherman = new ArrayList<String>();
    13. ArrayList<String> kitused = new ArrayList<String>();
    14. //end of array lists
    15. @Override
    16. public void onEnable() {
    17. commands();
    18. events();
    19.  
    20. }
    21.  
    22. public void commands(){
    23. getCommand("PvP").setExecutor(new PvP(this));
    24. getCommand("Fisherman").setExecutor(new Fisherman(this));
    25.  
    26. }
    27.  
    28. public void events(){
    29. PluginManager pm = getServer().getPluginManager();
    30. pm.registerEvents(Events, this);
    31.  
    32. }
    33. }
    34.  
     
  2. Offline

    The Fancy Whale

    Make sure to check if what is caught is an instance of player. Other than that I am not sure.
     
  3. Offline

    Arcoz

    Do as said above, also do you get any errors in your console?
     
  4. Offline

    TCO_007

    The Fancy Whale This probably sounds really noobish but I dont know how to do that. Im brand new to coding so Im still trying to get used to it. Any help?
    Arcoz I dont believe so. All it says is Multikits enabled
     
  5. Offline

    The Fancy Whale

    Code:java
    1. if (e.getCaught() instanceof player){
    2. //do whatever
    3. }

    Also is there an error when you "catch" someone not on enable?
     
  6. Offline

    TCO_007

    The Fancy Whale
    No error has ever popped up for it but I will check again and see. Thank you!

    The Fancy Whale
    Yes, there is an error and I just didnt notice it before haha
    I used the fishing rod and it said


    [15:46:54 ERROR]: Could not pass event ProjectileLaunchEvent to AntiCheat v2.0.2

    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectile
    LaunchEvent(CraftEventFactory.java:597) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b
    2974jnks]
    at net.minecraft.server.v1_7_R1.World.addEntity(World.java:904) [craftbu
    kkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.World.addEntity(World.java:871) [craftbu
    kkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.ItemFishingRod.a(ItemFishingRod.java:31)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.ItemStack.a(ItemStack.java:92) [craftbuk
    kit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PlayerInteractManager.useItem(PlayerInte
    ractManager.java:328) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :606) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.a(SourceFile:60)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.handle(SourceFile
    :9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.lang.NoSuchMethodError: org.bukkit.entity.Projectile.getShooter(
    )Lorg/bukkit/projectiles/ProjectileSource;
    at net.gravitydevelopment.anticheat.event.PlayerListener.onProjectileLau
    nch(PlayerListener.java:81) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_45]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_45]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    ... 19 more
    >

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  7. Offline

    The Fancy Whale

    TCO_007 You have a plugin called anticheat on there?
     
  8. Offline

    TCO_007

  9. Offline

    The Fancy Whale

    TCO_007 Seems to be. Try the plugin without it. If you don't want to delete the anticheat I would be willing to test on my test server.
     
  10. Offline

    TCO_007

    I deleted AntiCheat but it still doesnt activate the event. By that I mean it still doesnt tell you who you caught and it doesnt teleport them to you. The Fancy Whale
     
  11. Offline

    The Fancy Whale

    TCO_007 Is there an error now?
     
  12. Offline

    TCO_007

    If there is, it doesnt show up in the console so I dont believe so. The Fancy Whale
     
  13. Offline

    The Fancy Whale

    TCO_007 Ok then you are going to want to debug. Put messages all over the event that isn't working and see if the event is called and when it stops working
     
  14. Offline

    TCO_007

    This probably seems really noobish but Im new to coding. I dont know what you mean by that The Fancy Whale
    Sorry. Am I just suppose to put // all over the place or....
    I've never had to debug before or I would probably know what you meant haha.

    Thank you The Fancy Whale ! I changed a bit of the code and it works perfect now! Thanks so much for helping me!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  15. Offline

    Caprei

    TCO_007 Don't put // all over the place, that's a comment, it doesn't execute. What The Fancy Whale means is you should put lines which are sort of like checkpoints in your code, so like
    Code:
    System.out.println("Everything so far is working fine.")
    EDIT: Nevermind...
     
  16. Offline

    TCO_007

    Caprei Oh alright. That makes sense. Ill know to do that then next time I run into an error like this. Thanks!
     
    Caprei likes this.
Thread Status:
Not open for further replies.

Share This Page