Created
September 27, 2013 01:14
-
-
Save ucchyocean/6722906 to your computer and use it in GitHub Desktop.
スコアボードのテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ScoreboardTestPlugin | |
main: jp.ucchy.ScoreboardTestPlugin | |
version: 0.0.1 | |
author: ucchy | |
description: scoreboard test | |
commands: | |
scoreboardtest: | |
description: scoreboard test command | |
aliases: [st] | |
usage: /<command> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.ucchy; | |
import org.bukkit.Bukkit; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import org.bukkit.scoreboard.DisplaySlot; | |
import org.bukkit.scoreboard.Objective; | |
import org.bukkit.scoreboard.Scoreboard; | |
public class ScoreboardTestPlugin extends JavaPlugin { | |
private Objective ob; | |
/** | |
* コマンド実行時に呼び出されるメソッド | |
* @see org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[]) | |
*/ | |
@Override | |
public boolean onCommand( | |
CommandSender sender, Command command, | |
String label, String[] args) { | |
if ( ob == null ) { | |
Scoreboard sb = getServer().getScoreboardManager().getMainScoreboard(); | |
if ( sb.getObjective("testobjective") != null ) { | |
ob = sb.getObjective("testobjective"); | |
} else { | |
ob = sb.registerNewObjective("testobjective", "dummy"); | |
ob.setDisplaySlot(DisplaySlot.PLAYER_LIST); | |
} | |
} | |
Player[] players = Bukkit.getOnlinePlayers(); | |
for ( Player p : players ) { | |
int score = ob.getScore(p).getScore(); | |
ob.getScore(p).setScore(score - 1); | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment