Runnables...

Discussion in 'Plugin Development' started by VictoryShot, Nov 19, 2014.

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

    VictoryShot

    Alright so my event here:

    Code:java
    1. public static void spawnFrost(Player player) {
    2. boolean check = plugin.getConfig().getBoolean(player.getName() + ".ForstMount");
    3. if (!check) {
    4. plugin.getConfig().set(plugin.getName() + ".FrostMount", true);
    5. plugin.saveFile();
    6. player.sendMessage(ChatColor.GREEN + "Mount unlocked! Click on it again to use!");
    7. } else if (check) {
    8. org.bukkit.entity.Horse horse = (org.bukkit.entity.Horse) Bukkit.getWorld("world").spawnEntity(player.getLocation(), EntityType.HORSE);
    9. horse.setCustomName(ChatColor.AQUA + "" + player.getName() + "'s Horse");
    10. horse.setCustomNameVisible(true);
    11. horse.setAdult();
    12. horse.setAgeLock(true);
    13. horse.setColor(Color.WHITE);
    14. horse.setStyle(Style.WHITE);
    15. horse.setVariant(Variant.HORSE);
    16. horse.setOwner(player);
    17. horse.setMaxDomestication(1);
    18. player.sendMessage(ChatColor.GREEN + "Mount Spawned");
    19. particles.add((Player) horse);
    20. }
    21. }


    As you can see at the end it add the entity to the Hashmap. Now I want to make a runnable like so:

    Code:java
    1. public static void frostparticles() {
    2. new Runnable() {
    3.  
    4. @Override
    5. public void run() {
    6. if (particles.contains();
    7.  
    8. }
    9. };


    I basically want to see if it contains the horse so It can run the runnable. I am briefly stuck on this part please help.
     
  2. Offline

    Skionz

  3. Offline

    VictoryShot

    Only aviable option.
     
  4. Offline

    Skionz

  5. Offline

    pookeythekid

    VictoryShot It appears you have a typo in your "check" boolean. I would imagine it'd get quite frustrating if you didn't catch it now, then began testing the plugin and got some random error.
    Code:java
    1. getBoolean(player.getName() + ".ForstMount")// "Forst", not "Frost"


    Edit: I finished reading your code and went and did some Bukkit JavaDoc research (which I do when I'm reading unfamiliar Bukkit plugin code), and I'm not sure why you would have any reason to cast your horse to Player. If your HashMap is using either Horse or Entity, I wouldn't think you'd need to cast.
     
  6. Offline

    VictoryShot

    No clue
     
  7. Offline

    mythbusterma

    Skionz likes this.
  8. Offline

    pookeythekid

    If you have no clue on what that generic type would be, I believe he means you should change your list's type--which is apparently Player at the current moment--to Entity. Entity is the generic type of Player, Horse, Villager, and, well, all other entities.
    If you happen to be clueless about the definition of "generic": Google "define generic"
     
Thread Status:
Not open for further replies.

Share This Page