[Solved] Skulls not updating

Discussion in 'Spigot Plugin Development' started by Artish1, Jul 9, 2015.

  1. Code (Text):
        public Skull getSkull(){
            if(isSkullLocation(getSkullLocation())){
                BlockState bs = getSkullLocation().getBlock().getState();
                Skull skull = (Skull) bs;
                return skull;
            }
            return null;
        }
     
        private boolean isSkullLocation(Location loc){
            if(getSkullLocation() == null)
                return false;
         
            if(getSkullLocation().getBlock().getLocation().equals(loc.getBlock().getLocation())){
                if(loc.getBlock().getType() == Material.SKULL)
                    return true;
                return false;
            }
            return false;
        }
    Code (Text):
    if(getSkull() == null){
                    Bukkit.broadcastMessage("Skull is null?");
                    return;
                }
             
                getSkull().setOwner(oPlayer.getName());
                getSkull().update();
                Bukkit.broadcastMessage("Updated skull!");
               
    Code (Text):
                OfflinePlayer oPlayer = Bukkit.getOfflinePlayer(getTopPlayer());
     
    Code (Text):
    public UUID getTopPlayer(){
            List<String> uuids = getEntries();
            UUID topPlayer = UUID.fromString("c3ce322d-5c9e-4a6b-9fa5-67d34d7ed5fa");
            int topScore = 0;
         
            for(String s : uuids){
                if(getScore(UUID.fromString(s)) > topScore){
                    Bukkit.broadcastMessage(Bukkit.getOfflinePlayer(UUID.fromString(s)).getName());
                    topScore = getScore(UUID.fromString(s));
                    topPlayer = UUID.fromString(s);
                }
            }
         
            return topPlayer;
        }

    Dunno... it's just not working -shrugs-.
    [​IMG]
    lol... looking back at my code it's too sloppy, mb. ignore that i'll clean it myself
     
  2. Anything happening in output? Can we have a specific line that is not working?
     
  3. @bman7842
    No errors in console, all lines are working.
     
  4. I don't have much experience with player skulls so sorry, hopefully someone can help you.
     
  5. Try changing
    Code (Java):
    getSkull().update();
    to
    Code (Java):
    getSkull().update(true);
    to force an update. More information here.
     
    #6 Disoriented, Jul 9, 2015
    Last edited: Jul 9, 2015
  6. @Disoriented
    This is really interesting....
    Code (Text):
    getSkull().setOwner(oPlayer.getName());
                if(getSkull().update(true)){
                    Bukkit.broadcastMessage("Updated skull! Woo!");

                }else{
                    Bukkit.broadcastMessage("Failed to update skull/!?!?!?");
                }
    with:
    [​IMG]
     
  7. -cries- Why isn't it working?!?!?!? MOJANG
    -erupts with frustration-
     
  8. SOLVEDD!!!!

    For future people looking, you must use the same instance instead of creating a new one.

    Hence:
    Code (Text):
    Skull skull = getSkull();
                if(skull == null){
                    return;
                }
               
                skull.setOwner(oPlayer.getName());
                skull.update(true);
               
    Instead of just using getSkull() again and again.
     
    • Useful Useful x 1