why is the iron golem not attacking?

Discussion in 'Plugin Development' started by gopro_2027, Jun 26, 2014.

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

    gopro_2027

    the iron golem should be attacking any player besides the one riding it. i cant figure out why he wont work properly. it should work fine.
    heres the part of the code im concerned about. btw i have the setTarget and stuff configured right. i have a working plugin using getTarget and setTarget in the same way. i just dont know why the iron golem isnt attacking anyone except the player riding him. he wont attack anyone.
    Code:java
    1. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    2. public void run() {
    3. final Player anyplayer = null;
    4. if(anyplayer != player) {
    5.  
    6.  
    7. entity.getTarget();
    8. entity.setTarget(anyplayer);
    9.  
    10.  
    11. }
    12. }
    13. }
    14. , 1, 1);


    heres the full code


    Code:java
    1. package me.gopro2027.human;
    2.  
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Location;
    7. import org.bukkit.World;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Creature;
    11. import org.bukkit.entity.EntityType;
    12. import org.bukkit.entity.LivingEntity;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.event.EventHandler;
    15. import org.bukkit.event.Listener;
    16. import org.bukkit.event.player.PlayerQuitEvent;
    17.  
    18. import org.bukkit.plugin.java.JavaPlugin;
    19.  
    20. public class Main extends JavaPlugin implements Listener {
    21. public void onEnable() {
    22. getLogger().info("Plugin Enabled");
    23. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    24. }
    25. public void onDisable() {
    26. getLogger().info("Plugin Disabled");
    27. }
    28.  
    29.  
    30. @EventHandler
    31. public void OnPlayerQuit(PlayerQuitEvent event)
    32. {
    33.  
    34. Player player57 = event.getPlayer();
    35. if (player57.isInsideVehicle()) {
    36.  
    37. player57.setMaxHealth(20.0);
    38. LivingEntity entitytank2 = (LivingEntity) player57.getVehicle();
    39. entitytank2.setHealth(0.0);
    40. player57.leaveVehicle();
    41. tankallow = 1;
    42. Bukkit.getScheduler().cancelTasks(this);
    43. }
    44. }
    45.  
    46.  
    47. int placeholder;
    48. int tankallow = 1;
    49.  
    50.  
    51. @SuppressWarnings("deprecation")
    52. public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
    53.  
    54. if(sender instanceof Player) {
    55. final Player player = (Player) sender;
    56. /*if(cmd.getName().equalsIgnoreCase("tankr") && player.hasPermission("tank.reload")) {
    57.  
    58. EntityType entityr = EntityType.IRON_GOLEM;
    59. final LivingEntity entityrr = Class<org.bukkit.entity.IronGolem>;
    60. player.setMaxHealth(20.0);
    61. Bukkit.getScheduler().cancelTasks(this);
    62. placeholder = 1;
    63. Bukkit.broadcastMessage("tank plugin semi reloaded :)");
    64. }*/
    65. if (alias.equalsIgnoreCase("tank") && tankallow == 1 && player.hasPermission("tank.spawn")) {
    66. tankallow = 0;
    67. if (args.length == 0) {
    68. if (player .isInsideVehicle()) {
    69. LivingEntity tank3 = (LivingEntity) player.getVehicle();
    70. tank3.setHealth(0.0);
    71. player.setMaxHealth(20.0);
    72. player.leaveVehicle();
    73. }
    74. else{
    75. }
    76. Location loc = player.getLocation();
    77. World w = Bukkit.getServer().getWorld("world");
    78. double y = loc.getY();
    79. double x = loc.getX();
    80. double z = loc.getZ();
    81. Location loc1 = new Location(w,x,y,z);
    82. placeholder = 0;
    83. Bukkit.getScheduler().cancelTasks(this);
    84. final Creature entity = (Creature) Bukkit.getWorld("world").spawnEntity(loc1, EntityType.IRON_GOLEM);
    85. entity.setMaxHealth(250.0);
    86. entity.setHealth(250.0);
    87. entity.setPassenger(player);
    88. //player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 100000, 10000));
    89. player.setMaxHealth(250.0);
    90. player.setHealth(250.0);
    91. //entity.teleport(player);
    92. Bukkit.broadcastMessage(ChatColor.DARK_AQUA + "a tank has been spawned!");
    93.  
    94. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    95. public void run() {
    96. final Player anyplayer = null;
    97. if(anyplayer != player) {
    98.  
    99.  
    100. entity.getTarget();
    101. entity.setTarget(anyplayer);
    102.  
    103.  
    104. }
    105. }
    106. }
    107. , 1, 1);
    108.  
    109.  
    110. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    111. public void run() {
    112. //Bukkit.broadcastMessage("1");
    113.  
    114.  
    115. if(entity.getPassenger() instanceof Player || placeholder == 1) {
    116. }
    117. else{
    118. entity.setHealth(0.0);
    119. player.setMaxHealth(20.0);
    120. player.setHealth(20.0);
    121. //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
    122. placeholder = 1;
    123. tankallow = 1;
    124. //Bukkit.broadcastMessage("pk");
    125.  
    126.  
    127. }
    128. }
    129. }
    130.  
    131.  
    132.  
    133.  
    134. , 1, 1);
    135.  
    136.  
    137. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    138. public void run() {
    139. //Bukkit.broadcastMessage("1");
    140. if(placeholder == 1) {
    141. }
    142. else{
    143. entity.setHealth(0.0);
    144. player.setMaxHealth(20.0);
    145. player.setHealth(20.0);
    146. //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
    147. placeholder = 1;
    148. tankallow = 1;
    149. //Bukkit.broadcastMessage("ck");
    150.  
    151. }
    152. }
    153. }
    154. , 1200, 1200);//try adding L
    155. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    156. public void run() {
    157. //Bukkit.broadcastMessage("1");
    158.  
    159.  
    160. if(player.isDead() || entity.isDead()) {
    161. entity.setHealth(0.0);
    162. player.setMaxHealth(20.0);
    163. placeholder = 1;
    164. tankallow = 1;
    165. }
    166. else if(placeholder == 1){
    167. //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
    168. //placeholder = 1;
    169. //Bukkit.broadcastMessage("pk");
    170.  
    171.  
    172. }
    173. }
    174. }
    175.  
    176.  
    177.  
    178.  
    179. , 1, 1);
    180. }
    181. else if(player.hasPermission("tank.spawn.all")){//player needs tank.spawn along with this to work
    182. tankallow = 0;
    183. final Player player1 = Bukkit.getPlayerExact(args[0]);
    184. if (player1 == null) {
    185. player.sendMessage("Your target " + args[0] + " is not online!");
    186. } else {
    187. if (player1 .isInsideVehicle()) {
    188. LivingEntity tank2 = (LivingEntity) player1.getVehicle();
    189. tank2.setHealth(0.0);
    190. player1.setMaxHealth(20.0);
    191. player1.leaveVehicle();
    192. }
    193. else{
    194. }
    195. player1.setMaxHealth(20.0);
    196. player1.leaveVehicle();
    197. Location loc = player1.getLocation();
    198. World w = Bukkit.getServer().getWorld("world");
    199. double y = loc.getY();
    200. double x = loc.getX();
    201. double z = loc.getZ();
    202. Location loc1 = new Location(w,x,y,z);
    203. placeholder = 0;
    204. Bukkit.getScheduler().cancelTasks(this);
    205. final Creature entity = (Creature) Bukkit.getWorld("world").spawnEntity(loc1, EntityType.IRON_GOLEM);
    206. entity.setMaxHealth(250.0);
    207. entity.setHealth(250.0);
    208. entity.setPassenger(player1);
    209. //player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 100000, 10000));
    210. player1.setMaxHealth(250.0);
    211. player1.setHealth(250.0);
    212. //entity.teleport(player);
    213. Bukkit.broadcastMessage(ChatColor.DARK_AQUA + "a tank has been spawned!");
    214.  
    215. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    216. public void run() {
    217. final Player anyplayer = null;
    218. if(anyplayer != player) {
    219.  
    220.  
    221. entity.getTarget();
    222. entity.setTarget(anyplayer);
    223.  
    224.  
    225. }
    226. }
    227. }
    228. , 1, 1);
    229.  
    230. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    231. public void run() {
    232. //Bukkit.broadcastMessage("1");
    233.  
    234. //entity.teleport(player);
    235. //Location locp = player.getLocation();
    236. //World w = Bukkit.getServer().getWorld("world");
    237. //double y = locp.getY();
    238. //double x = locp.getX();
    239. //double z = locp.getZ();
    240. //Location loce = new Location(w,x-5,y,z);
    241. //entity.teleport(loce);
    242.  
    243.  
    244. if(entity.getPassenger() instanceof Player || placeholder == 1) {
    245. }
    246. else{
    247. entity.setHealth(0.0);
    248. player1.setMaxHealth(20.0);
    249. player1.setHealth(20.0);
    250. //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
    251. placeholder = 1;
    252. tankallow = 1;
    253.  
    254.  
    255.  
    256. }
    257.  
    258. }
    259. }
    260.  
    261.  
    262. , 1, 1);
    263.  
    264.  
    265. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    266. public void run() {
    267. //Bukkit.broadcastMessage("1");
    268. if(placeholder == 1) {
    269. }
    270. else{
    271. entity.setHealth(0.0);
    272. player1.setMaxHealth(20.0);
    273. player1.setHealth(20.0);
    274. //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
    275. placeholder = 1;
    276. tankallow = 1;
    277. //Bukkit.broadcastMessage("ck");
    278.  
    279. }
    280. }
    281. }
    282. , 1200, 1200);//try adding L
    283. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    284. public void run() {
    285. //Bukkit.broadcastMessage("1");
    286.  
    287.  
    288. if(player1.isDead() || entity.isDead()) {
    289. entity.setHealth(0.0);
    290. player1.setMaxHealth(20.0);
    291. placeholder = 1;
    292. tankallow = 1;
    293. }
    294. else if(placeholder == 1){
    295. //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
    296. //placeholder = 1;
    297. //Bukkit.broadcastMessage("pk");
    298.  
    299.  
    300. }
    301. }
    302. }
    303.  
    304.  
    305.  
    306.  
    307. , 1, 1);
    308.  
    309.  
    310. }
    311.  
    312. }
    313.  
    314. }
    315. else{
    316.  
    317. }
    318. }
    319. {return false;
    320. }
    321. }
    322. }


    please dont steal my code :) thanks!
     
  2. gopro_2027
    I didn't go through the full code, but 'anyplayer' seems to be null, you never set it equal to anything. I'd recommend you to loop through nearby players and pick a random one to set as the target.
     
  3. Offline

    gopro_2027

    how can i do that? as in pick a random one?

    ok i got it to work. it spams the console with errors though. i think its because its checking for all entities when it will only will go for players and of course evil mobs. is there any way to supress the console output? btw heres the code i used in replace of the old part
    Code:
                        Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                            public void run() {
                             
                                List<?> nearby = player.getNearbyEntities(16, 16, 16);
                                Collections.shuffle(nearby);
                             
                                Object randomEntity1 = nearby.get(0);
                             
                             
                                entity.getTarget();
                                entity.setTarget((Player) randomEntity1);
                             
                             
                                     
                             
                            }
                            }
                        , 1, 1);
    id also like to mention that if you dont do the code right (while i was working on the code this happened) the iron golem will target itself and fly up into the air until he kills himself and u fall to ur death :D its weird to see it happen. i think if you want him to do that all u have to do is replace entity.setTarget((Player) randomEntity1); with entity.setTarget((LivingEntity) randomEntity1);

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. gopro_2027
    I like the fact that you actually tried it yourself, usually people just request to get the code rather that trying something themselves.

    Anyways, I'd assume that the error is a ClassCastException. Before setting target, you should check if the Object 'randomEntity1' is an instance of Player. Also, you're not doing anything with the 'entity.getTarget()' method so you can remove that.
    Code:
    Object randomEntity1 = nearby.get(0);
     
    if(randomEntity1 instanceof Player) {
        Player target = (Player) randomEntity1;
        entity.setTarget(target);
    }
     
  5. Offline

    gopro_2027

    i thought getTarget was needed for settarget? ok then. also i got it to stop the runnables or whtever by their own but only when the golem dies (still something that is very needed) ill add the instanceof in and see if that can get rid of the yucky console spam

    ok i put the instnceof and i got errors after the golem died. im not sure why though. but its the opposite of what i had (which is bad) because id rather have the spam last for the duration of the tank rather than the duration of the server O.O wanna check out the code and see if you can find an error? btw i tried your example and my own version of your last post and they both made the errors but i have a feeling that with your example it wont work right because its making a new player and yea... lol heres the updated code anyways:
    Code:
    package me.gopro2027.human;
     
     
     
    import java.util.Collections;
    import java.util.List;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Creature;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.LivingEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerQuitEvent;
     
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin implements Listener {
        public void onEnable() {
            getLogger().info("Plugin Enabled");
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
        public void onDisable() {
            getLogger().info("Plugin Disabled");
        }
       
       
        @EventHandler
        public void OnPlayerQuit(PlayerQuitEvent event)
        {
       
        Player player57 = event.getPlayer();
        if (player57.isInsideVehicle()) {
           
            player57.setMaxHealth(20.0);
            LivingEntity entitytank2 = (LivingEntity) player57.getVehicle();
            entitytank2.setHealth(0.0);
            player57.leaveVehicle();
            tankallow = 1;
            Bukkit.getScheduler().cancelTasks(this);
        }
        }
               
       
        int placeholder;
        int tankallow = 1;
       
     
        @SuppressWarnings("deprecation")
        public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
     
            if(sender instanceof Player) {
                final Player player = (Player) sender;
                /*if(cmd.getName().equalsIgnoreCase("tankr") && player.hasPermission("tank.reload")) {
                   
                    EntityType entityr = EntityType.IRON_GOLEM;
                    final LivingEntity entityrr = Class<org.bukkit.entity.IronGolem>;
                    player.setMaxHealth(20.0);
                    Bukkit.getScheduler().cancelTasks(this);
                    placeholder = 1;
                    Bukkit.broadcastMessage("tank plugin semi reloaded :)");
                }*/
                if (alias.equalsIgnoreCase("tank") && tankallow == 1 && player.hasPermission("tank.spawn")) {
                    tankallow = 0;
                    if (args.length == 0) {
                        if (player .isInsideVehicle()) {
                        LivingEntity tank3 = (LivingEntity) player.getVehicle();
                        tank3.setHealth(0.0);
                        player.setMaxHealth(20.0);
                        player.leaveVehicle();
                    }
                    else{
                    }
                    Location loc = player.getLocation();
                        World w = Bukkit.getServer().getWorld("world");
                        double y = loc.getY();
                        double x = loc.getX();
                        double z = loc.getZ();
                        Location loc1 = new Location(w,x,y,z);
                        placeholder = 0;
                        Bukkit.getScheduler().cancelTasks(this);
                        final Creature entity = (Creature) Bukkit.getWorld("world").spawnEntity(loc1, EntityType.IRON_GOLEM);
                        entity.setMaxHealth(250.0);
                        entity.setHealth(250.0);
                        entity.setPassenger(player);
                        //player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 100000, 10000));
                        player.setMaxHealth(250.0);
                        player.setHealth(250.0);
                        //entity.teleport(player);
                        Bukkit.broadcastMessage(ChatColor.DARK_AQUA + "a tank has been spawned!");
                       
                        int task1 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                            public void run() {
                               
                                List<?> nearby = player.getNearbyEntities(16, 16, 16);
                                Collections.shuffle(nearby);
                               
                                Object randomEntity1 = nearby.get(0);
                               
                               
                                if(randomEntity1 instanceof Player) {
                                    entity.setTarget((Player) randomEntity1);
                                    }
                               
                               
                                       
                               
                            }
                            }
                        , 1, 1);
                   
                   
                        int task2 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                            public void run() {
                                //Bukkit.broadcastMessage("1");
                       
                           
                        if(entity.getPassenger() instanceof Player || placeholder == 1) {
                        }
                        else{
                                    entity.setHealth(0.0);
                                    player.setMaxHealth(20.0);
                                    player.setHealth(20.0);
                                    //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
                                    placeholder = 1;
                                    tankallow = 1;
                                    //Bukkit.broadcastMessage("pk");
                                   
                       
                                }
                        }
                            }
                       
                   
                       
                       
                    , 1, 1);
           
               
                        int task3 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                        public void run() {
                            //Bukkit.broadcastMessage("1");
                        if(placeholder == 1) {
                        }
                        else{
                                    entity.setHealth(0.0);
                                    player.setMaxHealth(20.0);
                                    player.setHealth(20.0);
                                    //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
                                    placeholder = 1;
                                    tankallow = 1;
                                    //Bukkit.broadcastMessage("ck");
                                   
                        }
                        }
                        }
                    , 1200, 1200);//try adding L
                        int task4 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                            public void run() {
                                //Bukkit.broadcastMessage("1");
                       
                           
                        if(player.isDead() || entity.isDead()) {
                            entity.setHealth(0.0);
                            player.setMaxHealth(20.0);
                            placeholder = 1;
                            tankallow = 1;
                        }
                        else if(placeholder == 1){
                                    //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
                                    //placeholder = 1;
                                    //Bukkit.broadcastMessage("pk");
                                   
                                   
                                }
                        }
                            }
                       
                   
                       
                       
                    , 1, 1);
                        if(placeholder == 1) {
                            Bukkit.getScheduler().cancelTask(task1);
                            Bukkit.getScheduler().cancelTask(task2);
                            Bukkit.getScheduler().cancelTask(task3);
                            Bukkit.getScheduler().cancelTask(task4);
                        }
            }
                   
                    else if(player.hasPermission("tank.spawn.all")){//player needs tank.spawn along with this to work
                        tankallow = 0;
                        final Player player1 = Bukkit.getPlayerExact(args[0]);
                        if (player1 == null) {
                        player.sendMessage("Your target " + args[0] + " is not online!");
                        } else {
                            if (player1 .isInsideVehicle()) {
                                LivingEntity tank2 = (LivingEntity) player1.getVehicle();
                                tank2.setHealth(0.0);
                                player1.setMaxHealth(20.0);
                                player1.leaveVehicle();
                            }
                            else{
                            }
                            player1.setMaxHealth(20.0);
                            player1.leaveVehicle();
                            Location loc = player1.getLocation();
                            World w = Bukkit.getServer().getWorld("world");
                            double y = loc.getY();
                            double x = loc.getX();
                            double z = loc.getZ();
                            Location loc1 = new Location(w,x,y,z);
                            placeholder = 0;
                            Bukkit.getScheduler().cancelTasks(this);
                            final Creature entity = (Creature) Bukkit.getWorld("world").spawnEntity(loc1, EntityType.IRON_GOLEM);
                            entity.setMaxHealth(250.0);
                            entity.setHealth(250.0);
                            entity.setPassenger(player1);
                            //player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 100000, 10000));
                            player1.setMaxHealth(250.0);
                            player1.setHealth(250.0);
                            //entity.teleport(player);
                            Bukkit.broadcastMessage(ChatColor.DARK_AQUA + "a tank has been spawned!");
                           
                            int task5 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                                public void run() {
                                   
                                    List<?> nearby = player.getNearbyEntities(16, 16, 16);
                                    Collections.shuffle(nearby);
                                   
                                    Object randomEntity1 = nearby.get(0);
                                   
                                    if(randomEntity1 instanceof Player) {
                                    entity.setTarget((Player) randomEntity1);
                                    }
                                   
                                           
                                   
                                }
                                }
                            , 1, 1);
                       
                            int task6 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                                public void run() {
                                    //Bukkit.broadcastMessage("1");
                           
                                    //entity.teleport(player);
                                    //Location locp = player.getLocation();
                                    //World w = Bukkit.getServer().getWorld("world");
                                    //double y = locp.getY();
                                    //double x = locp.getX();
                                    //double z = locp.getZ();
                                    //Location loce = new Location(w,x-5,y,z);
                                    //entity.teleport(loce);
                                   
                               
                            if(entity.getPassenger() instanceof Player || placeholder == 1) {
                            }
                            else{
                                        entity.setHealth(0.0);
                                        player1.setMaxHealth(20.0);
                                        player1.setHealth(20.0);
                                        //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
                                        placeholder = 1;
                                        tankallow = 1;
                                       
                                       
                                       
                                    }
                           
                                }
                                }
                           
                           
                        , 1, 1);
               
                   
                            int task7 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                            public void run() {
                                //Bukkit.broadcastMessage("1");
                            if(placeholder == 1) {
                            }
                            else{
                                        entity.setHealth(0.0);
                                        player1.setMaxHealth(20.0);
                                        player1.setHealth(20.0);
                                        //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
                                        placeholder = 1;
                                        tankallow = 1;
                                        //Bukkit.broadcastMessage("ck");
                                       
                            }
                            }
                            }
                        , 1200, 1200);//try adding L
                            int task8 = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                                public void run() {
                                    //Bukkit.broadcastMessage("1");
                           
                               
                            if(player1.isDead() || entity.isDead()) {
                                entity.setHealth(0.0);
                                player1.setMaxHealth(20.0);
                                placeholder = 1;
                                tankallow = 1;
                            }
                            else if(placeholder == 1){
                                        //player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
                                        //placeholder = 1;
                                        //Bukkit.broadcastMessage("pk");
                                       
                                       
                                    }
                            }
                                }
                           
                           
                               
                           
                        , 1, 1);
                            if(placeholder == 1) {
                                Bukkit.getScheduler().cancelTask(task5);
                                Bukkit.getScheduler().cancelTask(task6);
                                Bukkit.getScheduler().cancelTask(task7);
                                Bukkit.getScheduler().cancelTask(task8);
                            }
               
                           
                        }
                       
                    }
                   
                    }
                else{
                   
                }   
                    }
        {return false;
        }
        }
        }
    ok i fixed it. not exactly sure what i did though. i added in a couple of return false and put back the instanceof Player and i got no errors in the console :D

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

    gopro_2027

    it seems as though i get errors later on and it crashes the server...
     
Thread Status:
Not open for further replies.

Share This Page