Bug with invisibility [HELP]

Discussion in 'Plugin Development' started by VinexAx789, Nov 22, 2015.

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

    VinexAx789

    Hello, I've coded a minigame and one of the kits are called Ghost but it's not working it's the simplest thing to make but it's not working.

    Problem: The problem is when the game starts you get the kit and everything is working your invisible but your teammates should be able to see your tag and your ghost like skin which is working as well. The main issue is the other team can see that your invisible but they see your tag. I've debugged so many times been at it for hours I was on 1.7 - 1.8 now I switch to 1.8.8 to see if it was the version which it wasn't. I have no clue where this bug is in my code there's not even an error in the console.

    If you can help me it'd will be much appreciated!

    Thanks again,

    - Vinex_
     
  2. Offline

    Scimiguy

    Wanna know something cool?
    We have no idea where the bug is in your code either.

    Maybe if you showed it to us, we'd have a better chance
     
    PeterXonwiiXx likes this.
  3. Offline

    VinexAx789

    @Scimiguy
    Way to big. Try to tone it down a bit to bud.

    I think it's a problem with the teams.

    Code:
    if (activated) {
                Bukkit.getServer().getPluginManager().registerEvents(this, this);
    
                board = Bukkit.getServer().getScoreboardManager()
                        .getNewScoreboard();
                obj = board.registerNewObjective("dummy", "dummy");
                obj.setDisplaySlot(DisplaySlot.SIDEBAR);
    
                obj.setDisplayName("  §c§lRekt§f§lWarfare§c");
                red = obj.getScore("§cRed Team");
                blue = obj.getScore("§9Blue Team");
    
                red.setScore(0);
                blue.setScore(0);
    
                addred = board.registerNewTeam("Red");
                addblue = board.registerNewTeam("Blue");
                // This is the place where I set the color.
                addred.setPrefix("§c"); //This goes in tab. Not sure about chat.
                addblue.setPrefix("§9");
               
                addred.setCanSeeFriendlyInvisibles(true);
                addblue.setCanSeeFriendlyInvisibles(true);
    
                addred.setAllowFriendlyFire(false);
                addblue.setAllowFriendlyFire(false);
    That's just the team part.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 22, 2015
  4. Offline

    Zombie_Striker

    This has been address SOO many time on other threads. Use ChatColor and not the paragraph symbols. You just creating problems for later.
     
    PeterXonwiiXx and VinexAx789 like this.
  5. or ttranslate the & or § and then get the prefix from the config,thats what i do and works fine .
     
  6. Offline

    mcdorli

    Then DON'T, translateAlternateColors should only be used for text handling. ChatColor.COLORNAME isn't there out of accident.
     
    Zombie_Striker likes this.
  7. yes i kow,but still maybe handy for him to know that its better to use something else then & of § in codes.....
     
  8. Offline

    VinexAx789

    Would you guys know howto make this into a command using /t
    Code:
    @EventHandler
        public void onPlayerChatRed(AsyncPlayerChatEvent event) {
            if (event.getMessage().startsWith(".")) {
                Player p = event.getPlayer();
                Team team;
                if (addred.hasPlayer(p)) {
                    team = addred;
                } else {
                    return;
                }
                event.setCancelled(true);
                for (OfflinePlayer oplr : team.getPlayers()) {
                    String message = "§c[" + "§c" + team.getName() + "§c] §c<"
                            + "§f" + p.getName() + "§c> " + "§f"
                            + event.getMessage().substring(1);
                    if (oplr.isOnline()) {
                        ((Player) oplr).sendMessage(message);
                    }
                }
            }
        }
    
        @EventHandler
        public void onPlayerChatBlue(AsyncPlayerChatEvent event) {
            if (event.getMessage().startsWith(".")) {
                Player p = event.getPlayer();
                Team team;
    
                if (addblue.hasPlayer(p)) {
                    team = addblue;
                } else {
                    return;
                }
                event.setCancelled(true);
                for (OfflinePlayer oplr : team.getPlayers()) {
                    String message = "§9[" + "§9" + team.getName() + "§9] §9<"
                            + "§f" + p.getName() + "§9> " + "§f"
                            + event.getMessage().substring(1);
                    if (oplr.isOnline()) {
                        ((Player) oplr).sendMessage(message);
                    }
                }
            }
        }
     
  9. Offline

    Xerox262

    Just make a command that calls an AsyncPlayerChatEvent with a . at the start. Also you could do this with a single listener rather than separate ones.
     
Thread Status:
Not open for further replies.

Share This Page