Java Code Examples for org.bukkit.scoreboard.Team#unregister()

The following examples show how to use org.bukkit.scoreboard.Team#unregister() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GScoreboard.java    From GlobalWarming with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Disconnect the player from the scoreboard
 * - Removes the player from their team (i.e., player-color)
 * - Removes their score from the scoreboard
 * - The scoreboard will still be displayed on the player's client
 * until a new scoreboard is assigned or the user exits
 */
public void disconnect(GPlayer gPlayer) {
    if (!isEnabled) {
        return;
    }
    UUID associatedWorldId = gPlayer.getAssociatedWorldId();
    Scoreboard scoreboard = getScoreboard(associatedWorldId, false);
    if (scoreboard != null) {
        //Remove the team (i.e., player-color)
        OfflinePlayer player = Bukkit.getOfflinePlayer(gPlayer.getUuid());
        Team team = scoreboard.getTeam(player.getName());
        if (team != null) {
            team.removeEntry(player.getName());
            team.unregister();
        }

        //Remove the player's score:
        scoreboard.resetScores(player.getName());

        //Delete unused scoreboards:
        if (scoreboard.getEntries().size() == 0) {
            scoreboards.remove(associatedWorldId);
        }
    }
}
 
Example 2
Source File: QAMain.java    From QualityArmory with GNU General Public License v3.0 6 votes vote down vote up
/**
 * GUNLIST:
 * <p>
 * 2: P30 3 PKP 4 MP5K 5 AK47 6: AK 7 M16 8 Remmington 9 FNFal 10 RPG 11 UMP 12
 * SW1911 13 M40 14 Ammo 556 15 9mm 16 buckshot 17 rocketRPG 18 Enfield 19 Henry
 * 20 MouserC96
 * <p>
 * 22 Grenades
 */

@Override
public void onDisable() {
	for (Entry<MaterialStorage, CustomBaseObject> misc : miscRegister.entrySet()) {
		if (misc instanceof ThrowableItems) {
			for (Entry<Entity, ThrowableHolder> e : ThrowableItems.throwItems.entrySet()) {
				if (e.getKey() instanceof Item)
					e.getKey().remove();
			}
		}
	}

	for (Scoreboard s : coloredGunScoreboard)
		for (Team t : s.getTeams())
			t.unregister();

	for (Gunner g : gunners) {
		g.dispose();
	}
}
 
Example 3
Source File: SimpleScoreboard.java    From ScoreboardLib with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void deactivate() {
    if (!activated) return;
    activated = false;
    // Set to the main scoreboard
    if (holder.isOnline()) {
        synchronized (this) {
            holder.setScoreboard((Bukkit.getScoreboardManager().getMainScoreboard()));
        }
    }
    // Unregister teams that are created for this scoreboard
    for (Team team : teamCache.rowKeySet()) {
        team.unregister();
    }
    // Stop updating
    updateTask.cancel();
}
 
Example 4
Source File: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
public IslandGuard1_9(final ASkyBlock plugin) {
    this.plugin = plugin;
    this.thrownPotions = new HashMap<>();
    if (!Settings.allowPushing) {
        // try to remove the team from the scoreboard
        try {
            ScoreboardManager manager = plugin.getServer().getScoreboardManager();
            if (manager != null) {
                Scoreboard scoreboard = manager.getMainScoreboard();
                if (scoreboard != null) {
                    Team pTeam = scoreboard.getTeam(NO_PUSH_TEAM_NAME);
                    if (pTeam != null) {
                        pTeam.unregister();
                    }
                }
            }
        } catch (Exception e) {
            plugin.getLogger().warning("Problem removing no push from scoreboard.");
        }
    }
}
 
Example 5
Source File: Lobby.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
private void setupScoreboard() {
    Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
    for(Team team : scoreboard.getTeams()) {
        team.unregister();
    }
    for(Objective objective : scoreboard.getObjectives()) {
        objective.unregister();
    }
}
 
Example 6
Source File: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Triggers a push protection change or not
 * @param e - event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent e) {
    if (Settings.allowPushing) {           
        Team t = e.getPlayer().getScoreboard().getTeam(NO_PUSH_TEAM_NAME);
        if (t != null) {
            t.unregister();
        }
        return;
    }
    setPush(e.getPlayer());
}
 
Example 7
Source File: IndividualPrefix.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
protected void removeGuild(Guild guild) {
    if (guild == null || guild.getTag() == null || guild.getTag().isEmpty()) {
        return;
    }
    
    Team team = this.getUser().getCache().getScoreboard().getTeam(guild.getTag());

    if (team != null) {
        team.unregister();
    }
}
 
Example 8
Source File: NametagCommand.java    From NametagEdit with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Base command for NametagEdit. See the Wiki for usage and examples.
 */
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (isNotPermissed(sender, "nametagedit.use")) return false;
    if (args.length < 1) {
        sendUsage(sender);
    } else {
        switch (args[0].toLowerCase()) {
            case "reload":
                cmdReload(sender);
                break;
            case "convert":
                cmdConvert(sender, args);
                break;
            case "debug":
                handler.toggleDebug();
                NametagMessages.DEBUG_TOGGLED.send(sender, handler.debug() ? "&aENABLED" : "&cDISABLED");
                break;
            case "player":
                cmdPlayer(sender, args);
                break;
            case "group":
                cmdGroups(sender, args);
                break;
            case "longtags":
                handler.toggleLongTags();
                NametagMessages.LONG_TAGS.send(sender, handler.isLongNametagsEnabled() ? "&aENABLED" : "&cDISABLED");
                break;
            case "teams":
                int emptyTeams = 0;
                boolean unregister = args.length > 1 && args[1].equalsIgnoreCase("clear");
                for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) {
                    if (team.getEntries().isEmpty()) {
                        if (unregister) {
                            team.unregister();
                        }
                        emptyTeams++;
                    }
                }

                NametagMessages.CLEARED_TEAMS.send(sender, emptyTeams, unregister);
                break;
            case "priority":
                cmdPriority(sender, args);
                break;
            default:
                sendUsage(sender);
                break;
        }
    }

    return false;
}