本文整理匯總了Java中org.bukkit.scoreboard.Score.getScore方法的典型用法代碼示例。如果您正苦於以下問題:Java Score.getScore方法的具體用法?Java Score.getScore怎麽用?Java Score.getScore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.scoreboard.Score
的用法示例。
在下文中一共展示了Score.getScore方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setLine
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
/**
* Updates the given text for the line and given objectiveName
*
* @param objectiveName objectiveName
* @param line line
* @param text text
* @return scoreboard
*/
public SimpleScoreboard setLine(String objectiveName, int line, String text) {
final Objective objective = this.getObjective(objectiveName);
final Objective bufferObjective;
if (objective.getName().endsWith("_buf")) {
bufferObjective = this.scoreboard.registerNewObjective(objectiveName.substring(0, objective.getName().indexOf("_buf")), objective.getCriteria());
} else {
bufferObjective = this.scoreboard.registerNewObjective(objectiveName + "_buf", objective.getCriteria());
}
for (final String s : this.scoreboard.getEntries()) {
final Score score = objective.getScore(s);
if (score.getScore() != 0 && score.getScore() != line) {
bufferObjective.getScore(s).setScore(score.getScore());
}
}
if (text != null) {
bufferObjective.getScore(ChatColor.translateAlternateColorCodes('&', text)).setScore(line);
}
bufferObjective.setDisplayName(objective.getDisplayName());
bufferObjective.setDisplaySlot(objective.getDisplaySlot());
objective.unregister();
return this;
}
示例2: updatePlayerBoard
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
/**
* Counts players for scoreboard. Override to count differently.
*/
protected void updatePlayerBoard() {
if (playerTagScore > 0) {
Score score = objective.getScore(ChatColor
.translateAlternateColorCodes('&', "&6&lPlayers"));
if (score.getScore() != playerTagScore)
score.setScore(playerTagScore);
}
if (playerCounterScore > 0) {
board.resetScores(lastPlayerCount + "");
lastPlayerCount = getPlayers().length;
objective.getScore(lastPlayerCount + "").setScore(
playerCounterScore);
}
}
示例3: setNameTag
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
public static void setNameTag(Player player, String nameTag) {
if (nameTag != null && nameTag.length() > 16) {
nameTag = nameTag.substring(0, 16); //Nametags can only be up to 16 chars in length
}
Logging.debug(SkinManager.class, "Setting nametag of " + player.getName() + " to " + nameTag);
String oldNameTag = getNameTag(player);
if (nameTag == null) {
nameTag = player.getName();
}
Team team = player.getScoreboard() != null ? player.getScoreboard().getEntryTeam(player.getName()) : null;
if (team != null) {
team.removeEntry(player.getName());
Scheduling.syncDelay(1, () -> team.addEntry(player.getName()));
}
Objective objective = player.getScoreboard() != null ? player.getScoreboard().getObjective(DisplaySlot.BELOW_NAME) : null;
Score score = null;
int actualScore = 0;
if (objective != null) {
score = objective.getScore(player.getName());
actualScore = score.getScore();
score.setScore(0);
}
nameTags.put(player, nameTag);
refreshPlayer(player);
updateTablistName(player);
if (objective != null) {
score.setScore(actualScore);
}
nameTags.forEach((nameTagOwner, s) -> {
if (s.equals(oldNameTag)) {
Team team1 = nameTagOwner.getScoreboard() != null ? nameTagOwner.getScoreboard().getEntryTeam(nameTagOwner.getName()) : null;
if (team1 != null) {
team1.removeEntry(nameTagOwner.getName());
Scheduling.syncDelay(1, () -> team1.addEntry(nameTagOwner.getName()));
}
}
});
}
示例4: shouldUpdate
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
public static Boolean shouldUpdate(String ID, String board, String value, int slot) {
if (styleBoards.containsKey(board)) {
StyleBoard scoreboard = memoryData.get(ID);
if (!getTeamValue(scoreboard.getTeam()).equals(value)) {
return true;
}
Score score = styleBoards.get(board).getObjective("StylishBoards").getScore(scoreboard.getTeam().getName());
if (score.getScore() != slot) {
return true;
}
}
return false;
}
示例5: updateTimeBoard
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
/**
* Decrements time. Override to change up the countdown.
*/
protected void updateTimeBoard() {
if (this.timeTagScore > 0) {
Score score = objective.getScore(ChatColor
.translateAlternateColorCodes('&', "&6&lTime"));
if (score.getScore() != timeTagScore)
score.setScore(timeTagScore);
}
if (timeCounterScore > 0) {
board.resetScores(lastTimeRemaining + "");
lastTimeRemaining = counter;
objective.getScore(lastTimeRemaining + "").setScore(
timeCounterScore);
}
}
示例6: check
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
@Override
public boolean check(String playerID) throws QuestRuntimeException {
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
Objective obj = board.getObjective(objective);
if (obj == null) {
throw new QuestRuntimeException("Scoreboard objective " + objective + " does not exist!");
}
Score score = obj.getScore(PlayerConverter.getName(playerID));
return score.getScore() >= count.getInt(playerID);
}
示例7: setScore
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
@Override
public void setScore(String name, int score) {
Score scoreboardScore = scoreboard.getObjective(this.name).getScore(name);
if (score == 0 && scoreboardScore.getScore() == 0) {
scoreboardScore.setScore(1);
}
scoreboardScore.setScore(score);
}
示例8: addScore
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
@Override
public void addScore(String name, int amount) {
Score scoreboardScore = scoreboard.getObjective(this.name).getScore(name);
if (scoreboardScore.getScore() + amount == 0) {
scoreboardScore.setScore(1);
}
scoreboardScore.setScore(scoreboardScore.getScore() + amount);
}
示例9: onItemClick
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void onItemClick(PlayerInteractEvent event)
{
Player player = event.getPlayer();
ItemStack mainItem = player.getInventory().getItemInMainHand();
Score score_dualWieldMsg = tech_dualWieldMsg.getScore(player);
if(mainItem.getType() == Material.GOLD_AXE)
{
if(dualWield.getScore(player).getScore() == 0)
{
if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR)
{
if(spin.getScore(player).getScore() == 0)
{
if(player.getFoodLevel() > 6)
{
Random rand = new Random();
Spin(player);
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
player.setFoodLevel(player.getFoodLevel() - 1);
int chance_reduceDur = rand.nextInt(10) + 1;
switch(chance_reduceDur)
{
case 1:
mainItem.setDurability((short)(mainItem.getDurability() + 1));
break;
default:
}
if(mainItem.getDurability() >= 32)
{
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getInventory().setItemInMainHand(null);
}
player.updateInventory();
}
else
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Lack of energy, unable to spin"));
}
}
}
}
else
{
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 1);
else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 2);
if(score_dualWieldMsg.getScore() == 2)
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to dual-wield with Valkyrie's Axe"));
}
}
}
score_dualWieldMsg.setScore(0);
}
示例10: onItemClick
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void onItemClick(PlayerInteractEvent event)
{
Player player = event.getPlayer();
ItemStack mainItem = player.getInventory().getItemInMainHand();
ItemStack offItem = player.getInventory().getItemInOffHand();
Score score_dualWieldMsg = tech_dualWieldMsg.getScore(player);
if(mainItem.getType() == Material.GOLD_HOE)
{
if(dualWield.getScore(player).getScore() == 0)
{
if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)
{
if(player.isSprinting())
{
if(charge.getScore(player).getScore() == 0)
{
Random rand = new Random();
ChargeForward(player, 3);
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
player.setFoodLevel(player.getFoodLevel() - 1);
int chance_reduceDur = rand.nextInt(10) + 1;
switch(chance_reduceDur)
{
case 1:
mainItem.setDurability((short)(mainItem.getDurability() + 1));
break;
default:
}
if(event.getItem().getDurability() >= 32)
{
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getInventory().setItemInMainHand(null);
}
player.updateInventory();
}
else
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to Charge immediately"));
}
}
}
}
else
{
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 1);
else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 2);
if(score_dualWieldMsg.getScore() >= 2)
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to dual-wield with Giant Blade"));
}
}
}
else if(offItem.getType() == Material.GOLD_HOE)
{
if(dualWield.getScore(player).getScore() != 0)
{
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 1);
else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 2);
if(score_dualWieldMsg.getScore() >= 2)
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to dual-wield with Giant Blade"));
}
}
}
score_dualWieldMsg.setScore(0);
}
示例11: saveScores
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
public static void saveScores(Player p) {
if (!(MySQL.mySQLenabled())) {
if (Main.LobbyCreditsScore.get(p.getName()) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".Credits", Main.LobbyCreditsScore.get(p.getName()).getScore());
if (Main.LobbyLevelScore.get(p.getName()) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".Level", Main.LobbyLevelScore.get(p.getName()).getScore());
if (Main.LobbyKillsScore.get(p.getName()) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".Kills", Main.LobbyKillsScore.get(p.getName()).getScore());
if (Main.LobbyDeathsScore.get(p.getName()) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".Deaths", Main.LobbyDeathsScore.get(p.getName()).getScore());
if ((Main.LobbyDeathsScore.get(p.getName()) != null) && (Main.highestKillstreak.get(p.getName()) != null)) {
Score GameKillStreakScore = Main.GameKillStreakScore.get(p.getName());
Score highestKS = Main.highestKillstreak.get(p.getName());
if (GameKillStreakScore != null) {
if (highestKS.getScore() < GameKillStreakScore.getScore()) {
highestKS.setScore(GameKillStreakScore.getScore());
}
}
}
if (Main.highestKillstreak.get(p.getName()) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".HighestKillStreak", Main.highestKillstreak.get(p.getName()).getScore());
if (Exp.ExpNow.get(p) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".Exp", Exp.getExp(p));
if (Exp.NeededExpNow.get(p) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".NeededExp", Exp.getNeededExp(p));
if (Exp.NeededExpFromBefore.get(p) != null) ScoresFile.getData().set("Scores." + p.getUniqueId() + ".NeededExpBefore", Exp.getNeededExpFromBefore(p));
ScoresFile.saveData();
ScoresFile.reloadData();
}else{
try {
Connection conn = MySQL.getConnection();
String INSERT = "INSERT INTO CODScores VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Credits=?, Level=?, Kills=?, Deaths=?"
+ ", HighestKillStreak=?, Exp=?, NeededExp=?, NeededExpBefore=?";
PreparedStatement ps = conn.prepareStatement(INSERT);
ps.setString(1, p.getUniqueId().toString());
ps.setInt(2, Main.LobbyCreditsScore.get(p.getName()).getScore());
ps.setInt(10, Main.LobbyCreditsScore.get(p.getName()).getScore());
ps.setInt(3, Main.LobbyLevelScore.get(p.getName()).getScore());
ps.setInt(11, Main.LobbyLevelScore.get(p.getName()).getScore());
ps.setInt(4, Main.LobbyKillsScore.get(p.getName()).getScore());
ps.setInt(12, Main.LobbyKillsScore.get(p.getName()).getScore());
ps.setInt(5, Main.LobbyDeathsScore.get(p.getName()).getScore());
ps.setInt(13, Main.LobbyDeathsScore.get(p.getName()).getScore());
ps.setInt(6, Main.highestKillstreak.get(p.getName()).getScore());
ps.setInt(14, Main.highestKillstreak.get(p.getName()).getScore());
ps.setInt(7, Exp.getExp(p));
ps.setInt(15, Exp.getExp(p));
ps.setInt(8, Exp.getNeededExp(p));
ps.setInt(16, Exp.getNeededExp(p));
ps.setInt(9, Exp.getNeededExpFromBefore(p));
ps.setInt(17, Exp.getNeededExpFromBefore(p));
ps.executeUpdate();
ps.close();
conn.close();
}catch (Exception e) {
e.printStackTrace();
}
}
}
示例12: IleNaboi
import org.bukkit.scoreboard.Score; //導入方法依賴的package包/類
public static int IleNaboi(Player p){
Scoreboard board = p.getScoreboard();
Objective objective = board.getObjective(DisplaySlot.SIDEBAR);
Score score = objective.getScore(Bukkit.getOfflinePlayer("§6Naboje"));
return score.getScore();
}