Solved How to check a players biome

Discussion in 'Plugin Development' started by LogandadLoga, May 13, 2016.

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

    LogandadLoga

    So im trying to make a plugin were they do /biome and it says there biome but i cant find anything that detects the biome the players on..

    please help :0

     
  2. Offline

    Zombie_Striker

    World.getChunk(X, Z).getBiome(); should return the the BiomeType the player is in, if you provide the X divided by 16, and Z divided by 16
     
  3. Offline

    I Al Istannen

  4. Offline

    LogandadLoga


    So how am i suppose to do this ...........
     
  5. Offline

    I Al Istannen

  6. Offline

    LogandadLoga

    Code:
    package flamingcore;
    
    import org.bukkit.ChatColor;
    import org.bukkit.block.Biome;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    
    public class FlamingCore { {
       
    }{
    
      } {
    }
     
    
       
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (label.equalsIgnoreCase("biome")) {
               
    
                if (!(sender instanceof Player)) {
                    sender.sendMessage("Only in-game players can find out there biomes");
                    return false;
                }
    
                Player player = (Player) sender;
                player.sendMessage(ChatColor.AQUA + "You are currently in " + (ChatColor.LIGHT_PURPLE + "Biome " + Player#getLocation()#getBlock()#getBiome()
                return false; {
                        return false;
    
               
               
    
               
                   
                }}
    
    }{
    
    }{}}
        
    Anything i should define leave them blank or make un defined methods

    heres my code
     
  7. Offline

    I Al Istannen

    @LogandadLoga
    • You have random instruction blocks floating around :confused: I will just assume you cut out parts of your code, as what you have won't even remotely work.
    • You are also quite creative in where to put brackets in general... .
      • This for example makes no sense:
      • "return false; {
      • return false;"
    • You also never close the round brackets for the method invocation of player.sendMessage().
    • Also, the # in what I wrote stands for a method of a class. In java this is a ".". It is also not a static method, so you will need to call it on a player object and not "Player".
    • Compare the "command", not the "label". This way aliases will work too.


    My conclusion would be, that you will probably have to learn some Java first.
     
    cococow123 likes this.
  8. Offline

    LogandadLoga


    Umm. I have made plugins before and thats the way i do my commands so can you just stop i just... Need a code that tells a players biome
     
  9. Offline

    Gonmarte

    No1 will spoonfeed you in this forum.
    If you want code, request it on Plugin Requests section.
     
  10. Offline

    I Al Istannen

    @LogandadLoga
    Which I have given you. You just didn't implement "Player#getLocation()#getBlock()#getBiome()" correctly.

    If you have made plugins before (or read the javadoc I linked), you surely know, that getLocation() is an instance method that requires a player object.

    Second, if you have made plugins before, you do also know, that no method can be invoked with #. You need to use a "." for that. And if you would just do that and the thing above, you would see that it actually works. It will compile.

    And to that:
    If you have always done your commands in a bad way, then that is no excuse, to not make it better. Especially if you just need to replace "label" with "command.getName()".
    If you always just continue with what you have done before, you won't get any better. It is actually a good idea to follow advice, if the advice it correct. In this case most of the people in this forum will answer you, that comparing the command is indeed the right way.
     
    cococow123 likes this.
  11. Offline

    LogandadLoga

    Solved my problem this thread can be locked or its done..
     
  12. Offline

    I Al Istannen

    @LogandadLoga
    Please mark it as solved then, using the ThreadTools at the top of the thread. There you can edit the title and add a Solved Prefix.
     
  13. Offline

    LogandadLoga

    Ok its done... Thanks for the help! it worked all out.

    This is how i polished it but do you know how to make it lowercase cause it all comes out in caps

    Code:
                    Player player = (Player) sender;
                    player.sendMessage(ChatColor.DARK_AQUA + "You are currently in a " + (ChatColor.LIGHT_PURPLE + (player.getLocation().getBlock().getBiome()
                         + "" + ChatColor.DARK_AQUA + " Biome.")));
     
  14. Offline

    I Al Istannen

    @LogandadLoga
    Calling ".name()" as it is an enum and then toLowerCase() on the String.
     
Thread Status:
Not open for further replies.

Share This Page