类org.bukkit.scoreboard.Scoreboard源码实例Demo

下面列出了怎么用org.bukkit.scoreboard.Scoreboard的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: HeavySpleef   文件: FlagSpectate.java
@Subscribe(priority = Subscribe.Priority.LOW)
public void onGameEnd(GameEndEvent event) {
    boolean showScoreboard = config.getSpectateSection().isShowScoreboard();
    if (!showScoreboard) {
        return;
    }

    Scoreboard scoreboard = getScoreboard();
    if (scoreboard == null) {
        return;
    }

    scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
    for (SpleefPlayer player : spectators) {
        player.getBukkitPlayer().setScoreboard(scoreboard);
    }
}
 
源代码2 项目: HeavySpleef   文件: FlagInvisibleSpectate.java
@SuppressWarnings("deprecation")
@Subscribe
public void onSpectateLeave(FlagSpectate.SpectateLeaveEvent event) {
	SpleefPlayer player = event.getPlayer();
	Player bukkitPlayer = player.getBukkitPlayer();
	
	team.removePlayer(bukkitPlayer);
	bukkitPlayer.removePotionEffect(PotionEffectType.INVISIBILITY);
	
	for (SpleefPlayer ingamePlayer : game.getPlayers()) {
		if (ingamePlayer.getBukkitPlayer().canSee(bukkitPlayer)) {
			continue;
		}
		
		ingamePlayer.getBukkitPlayer().showPlayer(bukkitPlayer);
	}
	
	Scoreboard mainScoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
	bukkitPlayer.setScoreboard(mainScoreboard);
}
 
源代码3 项目: GlobalWarming   文件: GScoreboard.java
/**
 * Get any scoreboard by world
 * - Note: players should use their associated-world (not current-world)
 */
private Scoreboard getScoreboard(UUID worldId, boolean isCreateIfNotFound) {
    Scoreboard scoreboard = null;
    if (ClimateEngine.getInstance().isClimateEngineEnabled(worldId)) {
        if (scoreboards.containsKey(worldId)) {
            //Existing scoreboard:
            scoreboard = scoreboards.get(worldId);
        } else if (isCreateIfNotFound) {
            //New scoreboard:
            scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
            scoreboards.put(worldId, scoreboard);

            //Objective (scoreboard title / group):
            Objective objective = scoreboard.registerNewObjective(
                    GLOBAL_WARMING,
                    "scores",
                    "Carbon Score");

            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
        }
    }

    return scoreboard;
}
 
源代码4 项目: GlobalWarming   文件: GScoreboard.java
/**
 * Connect the player to the scoreboard
 * - Disconnects from any existing scoreboards
 * - Creates a new scoreboard for the world if required
 */
public void connect(GPlayer gPlayer) {
    if (gPlayer != null && isEnabled) {
        //Disconnect the player from the current scoreboard (if required):
        disconnect(gPlayer);

        //Connect online players to their associated-world scoreboards:
        Player onlinePlayer = gPlayer.getOnlinePlayer();
        if (onlinePlayer != null) {
            Scoreboard scoreboard = getScoreboard(gPlayer);
            onlinePlayer.setScoreboard(scoreboard);
            Team team = scoreboard.registerNewTeam(onlinePlayer.getName());
            team.addEntry(onlinePlayer.getName());
            update(gPlayer);
        }
    }
}
 
源代码5 项目: GlobalWarming   文件: GScoreboard.java
/**
 * 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);
        }
    }
}
 
源代码6 项目: GlobalWarming   文件: GScoreboard.java
/**
 * Update the global score for all worlds
 */
private void updateGlobalScores() {
    for (World world : Bukkit.getWorlds()) {
        //Do not update worlds with disabled climate-engines:
        WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID());
        if (climateEngine != null && climateEngine.isEnabled()) {
            //Get the scoreboard for this world:
            Scoreboard scoreboard = getScoreboard(world.getUID(), false);

            //Get its objective (scoreboard title / group):
            Objective objective = null;
            if (scoreboard != null) {
                objective = scoreboard.getObjective(GLOBAL_WARMING);
            }

            //Update the title to show this world's temperature:
            if (objective != null) {
                double temperature = climateEngine.getTemperature();
                objective.setDisplayName(climateEngine.formatTemp(temperature));
            }
        }
    }
}
 
源代码7 项目: GlobalWarming   文件: GScoreboard.java
/**
 * Display a player's score
 * - Uses the player's associated-world scoreboard
 * - Note: the player may be in a different world, that's ok
 * - Player names are mapped to color warmth (based on their score)
 */
private void updatePlayerScore(GPlayer gPlayer) {
    if (gPlayer != null) {
        //Do not update associated-worlds with disabled climate-engines:
        // - Ignore offline players (e.g., someone completing an offline player's bounty)
        Player onlinePlayer = gPlayer.getOnlinePlayer();
        if (onlinePlayer != null && ClimateEngine.getInstance().isClimateEngineEnabled(gPlayer.getAssociatedWorldId())) {
            //Update the player's score:
            Scoreboard scoreboard = getScoreboard(gPlayer);
            if (scoreboard != null) {
                Objective objective = scoreboard.getObjective(GLOBAL_WARMING);
                if (objective != null) {
                    Team team = scoreboard.getPlayerTeam(onlinePlayer);
                    if (team != null) {
                        team.setColor(Colorizer.getScoreColor(gPlayer.getCarbonScore()));
                        objective.getScore(onlinePlayer).setScore(gPlayer.getCarbonScore());
                    }
                }
            }
        }
    }
}
 
源代码8 项目: ProjectAres   文件: ScoreboardMatchModule.java
public Scoreboard getScoreboard(Party party) {
    return MapUtils.computeIfAbsent(partyScoreboards, party, () -> {
        // Create the new party's scoreboard
        Scoreboard scoreboard = getMatch().getServer().getScoreboardManager().getNewScoreboard();
        logger.fine("Created scoreboard " + toString(scoreboard) + " for party " + party);

        // Add all other party scoreboards to the new party's scoreboard
        for(Party oldParty : partyScoreboards.keySet()) {
            createPartyScoreboardTeam(oldParty, scoreboard, !(party instanceof Competitor));
        }

        // Add the new party to its own scoreboard
        createPartyScoreboardTeam(party, scoreboard, !(party instanceof Competitor));

        // Add the new party to the hidden scoreboard
        createPartyScoreboardTeam(party, hiddenScoreboard, false);

        // Add the new party to all other party scoreboards
        for(Map.Entry<Party, Scoreboard> entry : partyScoreboards.entrySet()) {
            createPartyScoreboardTeam(party, entry.getValue(), !(entry.getKey() instanceof Competitor));
        }
        return scoreboard;
    });
}
 
源代码9 项目: ProjectAres   文件: RaindropsListener.java
@EventHandler(priority = EventPriority.MONITOR)
public void displayScoreboard(final PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    final User user = userStore.getUser(player);
    final PlayerId playerId = tc.oc.api.bukkit.users.Users.playerId(player);
    final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
    final Objective objective = getOrCreateObjective(scoreboard, player.getName(), "dummy");
    final String raindropsName = ChatColor.AQUA + "Raindrops";

    objective.setDisplayName(renderer.renderLegacy(generalFormatter.brandName(), event.getPlayer()));

    objective.getScore(raindropsName).setScore(2);
    Utils.displayScoreboard(player, objective);
    setRaindropsCount(player, user.raindrops());
    GizmoUtils.setGizmo(player, Gizmos.emptyGizmo, true);
}
 
源代码10 项目: ProjectAres   文件: RaindropsListener.java
private void setRaindropsCount(Player player, int count) {
    if(player == null) return;

    final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
    Objective objective = scoreboard.getObjective(player.getName());

    Integer oldCount = raindrops.get(player);
    if(oldCount != null) {
        Utils.removeScore(player, String.format("%,d", oldCount));
    }
    Utils.addScore(player, objective, String.format("%,d", count), 1);

    raindrops.put(player, count);

    Utils.giveGhastTear(player, count);
}
 
源代码11 项目: QualityArmory   文件: QAMain.java
/**
 * 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();
	}
}
 
源代码12 项目: CombatLogX   文件: ScoreBoardManager.java
public void removeScoreboard(Player player) {
    UUID uuid = player.getUniqueId();
    CustomScoreBoard customScoreBoard = this.customScoreBoardMap.remove(uuid);
    if(customScoreBoard == null) return;
    
    customScoreBoard.disableScoreboard();
    if(shouldSavePrevious() && this.previousScoreboardMap.containsKey(uuid)) {
        Scoreboard previousScoreboard = this.previousScoreboardMap.get(uuid);
        if(previousScoreboard == null) return;
        
        Objective objective = previousScoreboard.getObjective("combatlogx");
        if(objective != null) return;
        
        player.setScoreboard(previousScoreboard);
    }
}
 
源代码13 项目: PGM   文件: ScoreboardMatchModule.java
protected Team createPartyScoreboardTeam(
    Party party, Scoreboard scoreboard, boolean forObservers) {
  match
      .getLogger()
      .fine("Creating team for party " + party + " on scoreboard " + toString(scoreboard));

  Team team = scoreboard.registerNewTeam(getScoreboardTeamName(party));
  updatePartyScoreboardTeam(party, team, forObservers);
  for (MatchPlayer player : party.getPlayers()) {
    team.addPlayer(player.getBukkit());
  }

  return team;
}
 
源代码14 项目: FunnyGuilds   文件: IndividualPrefixManager.java
public static void updatePlayer(Player player) {
    if (!player.isOnline()) {
        return;
    }

    User user = User.get(player);
    UserCache cache = user.getCache();
    Scoreboard cachedScoreboard = cache.getScoreboard();
    PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration();

    if (cachedScoreboard == null) {
        FunnyGuilds.getInstance().getPluginLogger().debug(
                "We're trying to update player scoreboard, but cached scoreboard is null (server has been reloaded?)");

        Bukkit.getScheduler().runTask(FunnyGuilds.getInstance(), () -> {
            Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
            player.setScoreboard(scoreboard);
            cache.setScoreboard(scoreboard);

            if (config.guildTagEnabled) {
                IndividualPrefix prefix = new IndividualPrefix(user);
                prefix.initialize();

                cache.setIndividualPrefix(prefix);
            }

            cache.getDummy().updateScore(user);
        });

        return;
    }

    try {
        player.setScoreboard(cachedScoreboard);
    } catch (IllegalStateException e) {
        FunnyGuilds.getInstance().getPluginLogger().warning("[IndividualPrefix] java.lang.IllegalStateException: Cannot set scoreboard for invalid CraftPlayer (" + player.getClass() + ")");
    }
}
 
源代码15 项目: PGM   文件: ScoreboardMatchModule.java
protected void updatePlayer(MatchPlayer player, Party party, boolean show) {
  if (show) {
    Scoreboard scoreboard = partyScoreboards.get(party);
    match.getLogger().fine("Setting player " + player + " to scoreboard " + toString(scoreboard));
    player.getBukkit().setScoreboard(scoreboard);
  } else {
    match.getLogger().fine("Setting player " + player + " to hidden scoreboard");
    player.getBukkit().setScoreboard(getHiddenScoreboard());
  }
}
 
源代码16 项目: PGM   文件: ScoreboardMatchModule.java
public void updatePartyScoreboardTeam(Party party) {
  String teamName = getScoreboardTeamName(party);
  updatePartyScoreboardTeam(party, hiddenScoreboard.getTeam(teamName), false);
  for (Map.Entry<Party, Scoreboard> entry : partyScoreboards.entrySet()) {
    updatePartyScoreboardTeam(
        party, entry.getValue().getTeam(teamName), !(entry.getKey() instanceof Competitor));
  }
}
 
源代码17 项目: Assemble   文件: AssembleBoard.java
public Objective getObjective() {
	Scoreboard scoreboard = getScoreboard();
	if (scoreboard.getObjective("Assemble") == null) {
		Objective objective = scoreboard.registerNewObjective("Assemble", "dummy");
		objective.setDisplaySlot(DisplaySlot.SIDEBAR);
		objective.setDisplayName(getAssemble().getAdapter().getTitle(Bukkit.getPlayer(getUuid())));
		return objective;
	} else {
		return scoreboard.getObjective("Assemble");
	}
}
 
源代码18 项目: Assemble   文件: AssembleBoard.java
private void setup(Player player) {
	Scoreboard scoreboard = getScoreboard();
	player.setScoreboard(scoreboard);
	getObjective();

	//Send Update
	AssembleBoardCreatedEvent createdEvent = new AssembleBoardCreatedEvent(this);
	Bukkit.getPluginManager().callEvent(createdEvent);
}
 
源代码19 项目: Kettle   文件: CraftPlayer.java
@Override
public void setScoreboard(Scoreboard scoreboard) {
    Validate.notNull(scoreboard, "Scoreboard cannot be null");
    NetHandlerPlayServer connection = getHandle().connection;
    if (connection == null) {
        return;
    }
    if (connection.isDisconnected()) {
    }

    this.server.getScoreboardManager().setPlayerBoard(this, scoreboard);
}
 
源代码20 项目: GlobalWarming   文件: GScoreboard.java
/**
 * Show or hide the scoreboard (UI)
 */
public void show(GPlayer gPlayer, boolean isVisible) {
    if (!isEnabled) {
        return;
    }
    Scoreboard scoreboard = getScoreboard(gPlayer);
    if (isVisible) {
        Objective objective = scoreboard.getObjective(GLOBAL_WARMING);
        if (objective != null) {
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
        }
    } else {
        scoreboard.clearSlot(DisplaySlot.SIDEBAR);
    }
}
 
源代码21 项目: KTP   文件: UHTeam.java
public UHTeam(String name, String displayName, ChatColor color, UHPlugin plugin) {
	this.name = name;
	this.displayName = displayName;
	this.color = color;
	this.plugin = plugin;
	
	Scoreboard sb = this.plugin.getScoreboard();
	sb.registerNewTeam(this.name);

	Team t = sb.getTeam(this.name);
	t.setDisplayName(this.displayName);
	t.setCanSeeFriendlyInvisibles(true);
	t.setPrefix(this.color+"");
}
 
源代码22 项目: skRayFall   文件: Core.java
/**
 * Generates a new private scoreboard for the player when they join the server if
 * enableFastScoreboards is set to true.
 *
 * @param evt The Player Join Event
 */
@EventHandler
public void onJoinScoreboards(PlayerJoinEvent evt) {
    if (enableFastScoreboards) {
        Player player = evt.getPlayer();
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        player.setScoreboard(board);
    }
}
 
源代码23 项目: TabooLib   文件: TagUtils.java
public static void cleanTeamInScoreboard(Scoreboard scoreboard) {
    try {
        scoreboard.getTeams().forEach(Team::unregister);
    } catch (Exception e) {
        TLogger.getGlobalLogger().error("TagUtils.cleanTeamInScoreboard() 异常: " + e.toString());
    }
}
 
源代码24 项目: TabooLib   文件: TagUtils.java
public static void cleanEntryInScoreboard(Scoreboard scoreboard, String entry) {
    try {
        Optional.ofNullable(scoreboard.getEntryTeam(entry)).ifPresent(x -> x.removeEntry(entry));
    } catch (Exception e) {
        TLogger.getGlobalLogger().error("TagUtils.cleanEntryInScoreboard() 异常: " + e.toString());
    }
}
 
源代码25 项目: TabooLib   文件: TagUtils.java
public static void cleanEmptyTeamInScoreboard(Scoreboard scoreboard) {
    try {
        scoreboard.getTeams().stream().filter(team -> team.getEntries().size() == 0).forEach(Team::unregister);
    } catch (Exception e) {
        TLogger.getGlobalLogger().error("TagUtils.cleanEmptyTeamInScoreboard() 异常: " + e.toString());
    }
}
 
源代码26 项目: TabooLib   文件: TagUtils.java
public static Scoreboard getScoreboardComputeIfAbsent(Player player) {
    Scoreboard scoreboard = player.getScoreboard();
    if (scoreboard == null) {
        player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
    }
    return player.getScoreboard();
}
 
源代码27 项目: TabooLib   文件: TagUtils.java
public static Team getTeamComputeIfAbsent(Scoreboard scoreboard, String teamName) {
    Team team = scoreboard.getTeam(teamName);
    if (team == null) {
        scoreboard.registerNewTeam(teamName);
    }
    return scoreboard.getTeam(teamName);
}
 
源代码28 项目: FunnyGuilds   文件: IndividualPrefix.java
protected void addPlayer(String player) {
    if (player == null) {
        return;
    }
    
    User user = User.get(player);
    if (!user.hasGuild()) {
        return;
    }
    
    Scoreboard scoreboard = getScoreboard();
    Team team = scoreboard.getEntryTeam(player);
    
    if (team != null) {
        team.removeEntry(player);
    }
    
    team = scoreboard.getTeam(user.getGuild().getTag());
    if (team == null) {
        addGuild(user.getGuild());
        team = scoreboard.getTeam(user.getGuild().getTag());
    }
    
    if (this.getUser().hasGuild()) {
        if (this.getUser().equals(user) || this.getUser().getGuild().getMembers().contains(user)) {
            team.setPrefix(replace(FunnyGuilds.getInstance().getPluginConfiguration().prefixOur, "{TAG}", user.getGuild().getTag()));
        }
    }
    
    team.addEntry(player);
}
 
源代码29 项目: TabooLib   文件: TagDataHandler.java
private void cancelPlayerVariable(Player player, TagPlayerData playerData) {
    if (playerData == null) {
        return;
    }
    for (Player online : Bukkit.getOnlinePlayers()) {
        Scoreboard scoreboard = TagUtils.getScoreboardComputeIfAbsent(player);
        TagUtils.cleanEntryInScoreboard(scoreboard, playerData.getNameDisplay());
        // 傻逼 BedWarsRel 我草你妈的
        if (TabooLib.getConfig().getBoolean("TABLIST-AUTO-CLEAN-TEAM", true)) {
            TagUtils.cleanEmptyTeamInScoreboard(scoreboard);
        }
    }
}
 
源代码30 项目: ProjectAres   文件: ScoreboardMatchModule.java
protected Team createPartyScoreboardTeam(Party party, Scoreboard scoreboard, boolean forObservers) {
    logger.fine("Creating team for party " + party + " on scoreboard " + toString(scoreboard));

    Team team = scoreboard.registerNewTeam(getScoreboardTeamName(party));
    updatePartyScoreboardTeam(party, team, forObservers);
    for(MatchPlayer player : party.getPlayers()) {
        team.addPlayer(player.getBukkit());
    }

    return team;
}
 
 类所在包
 同包方法