本文整理汇总了Java中org.bukkit.Achievement类的典型用法代码示例。如果您正苦于以下问题:Java Achievement类的具体用法?Java Achievement怎么用?Java Achievement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Achievement类属于org.bukkit包,在下文中一共展示了Achievement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.bukkit.Achievement; //导入依赖的package包/类
public static void load() {
Registration.registerEnum(Achievement.class, "achievement", Achievement.values())
.document("Achievement", "1.4.10", "An achievement that a player can get. "
+ "Note that achievements were removed in Minecraft 1.12 and thus this syntax will not work if you are running Bukkit/Spigot 1.12 and above.");
Registration.registerEffect(EffAwardAch.class, "award achieve[ment] %achievement% to %player%")
.document("Award Achievement", "1.4.10", "Awards the specified achievement to the specified player. "
+ "Note that achievements were removed in Minecraft 1.12 and thus this syntax will not work if you are running Bukkit/Spigot 1.12 and above.");
Registration.registerEffect(EffRemoveAch.class, "remove achieve[ment] %achievement% from %player%")
.document("Remove Achievement", "1.4.10", "Removes the specified achievement from the specified player. "
+ "Note that achievements were removed in Minecraft 1.12 and thus this syntax will not work if you are running Bukkit/Spigot 1.12 and above.");
Registration.registerEvent("Achievement Award", EvtAchAward.class, PlayerAchievementAwardedEvent.class, "achieve[ment] [%-achievement%] award", "award of achieve[ment] [%-achievement%]")
.document("Achievement Award", "1.4.10", "Called when a player is awarded either the specified achievement or any achievement. "
+ "Note that achievements were removed in Minecraft 1.12 and thus this syntax will not work if you are running Bukkit/Spigot 1.12 and above.")
.eventValue(Achievement.class, "1.4.10", "The achievement that was awarded.");
Registration.registerEventValue(PlayerAchievementAwardedEvent.class, Achievement.class, PlayerAchievementAwardedEvent::getAchievement);
Registration.registerExpression(ExprParentAch.class,Achievement.class, ExpressionType.PROPERTY,"parent of achieve[ment] %achievement%")
.document("Parent of Achievement", "1.4.10", "An expression for the parent achievement of the specified achievement. "
+ "Note that achievements were removed in Minecraft 1.12 and thus this syntax will not work if you are running Bukkit/Spigot 1.12 and above.");
Registration.registerExpression(ExprAllAch.class,Achievement.class,ExpressionType.PROPERTY,"achieve[ment]s of %player%", "%player%'s achieve[ment]s")
.document("Achievements of Player", "1.4.10", "An expression for a list of the achievements that the specified player has.");
Registration.registerExpressionCondition(CondHasAch.class,ExpressionType.PROPERTY,"%player% has achieve[ment] %achievement%")
.document("Player has Achievement", "1.4.10", "Checks whether the specified player has the specified achievement.");
}
示例2: onPlayerAchievement
import org.bukkit.Achievement; //导入依赖的package包/类
@EventHandler
public void onPlayerAchievement(PlayerAchievementAwardedEvent event){
Achievement a = event.getAchievement();
for(String s : bonusTags.keySet()){
BonusTag t = bonusTags.get(s);
if(t instanceof AchievementTag){
AchievementTag tag = (AchievementTag) t;
Achievement a2 = tag.getAchievement();
if(a2 == a){
String id = tag.getIdentifier();
ArrayList<String> certs = database.getCertsOfPlayer(event.getPlayer().getUniqueId());
if(!certs.contains(id)){
certs.add(id);
}
database.updateCertsOfPlayer(event.getPlayer().getUniqueId(), certs);
event.getPlayer().sendMessage("You have unlocked the tag " + tag.getTagFormatted() + ", do /certs tag to set it.");
return;
}
}
}
}
示例3: run
import org.bukkit.Achievement; //导入依赖的package包/类
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
StringBuilder output = new StringBuilder();
Random randomGenerator = new Random();
String[] words = TotalFreedomMod.CAKE_LYRICS.split(" ");
for (String word : words)
{
String color_code = Integer.toHexString(1 + randomGenerator.nextInt(14));
output.append(ChatColor.COLOR_CHAR).append(color_code).append(word).append(" ");
}
for (Player player : server.getOnlinePlayers())
{
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
player.getInventory().setItem(player.getInventory().firstEmpty(), heldItem);
player.awardAchievement(Achievement.MINE_WOOD);
player.awardAchievement(Achievement.BUILD_WORKBENCH);
player.awardAchievement(Achievement.BUILD_HOE);
player.awardAchievement(Achievement.BAKE_CAKE);
}
TFM_Util.bcastMsg(output.toString());
return true;
}
示例4: serialize
import org.bukkit.Achievement; //导入依赖的package包/类
@Override
public Map<String, Object> serialize() {
final Object serializedObject;
switch (this.type) {
case SHOW_ACHIEVEMENT:
serializedObject = ((Achievement)this.object).name();
break;
case SHOW_ITEM: // ItemStack is ConfigurationSerializable
case SHOW_TEXT: // String[] is supported automatically
serializedObject = this.object;
break;
default:
throw new IllegalArgumentException("Should never be here!");
}
return ImmutableMap.<String, Object>of(
"type", this.type.name(),
"object", serializedObject
);
}
示例5: init
import org.bukkit.Achievement; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
// TODO Auto-generated method stub
ach = (Expression<Achievement>) expr[0];
return true;
}
示例6: init
import org.bukkit.Achievement; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
// TODO Auto-generated method stub
player = (Expression<Player>) expr[0];
ach = (Expression<Achievement>) expr[1];
return true;
}
示例7: init
import org.bukkit.Achievement; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expr, int matchedPattern,
Kleenean paramKleenean, ParseResult paramParseResult) {
ach = (Expression<Achievement>) expr[0];
player = (Expression<Player>) expr[1];
return true;
}
示例8: init
import org.bukkit.Achievement; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern,
Kleenean paramKleenean, ParseResult paramParseResult) {
// TODO Auto-generated method stub
ach = (Expression<Achievement>) expr[0];
player = (Expression<Player>) expr[1];
return true;
}
示例9: get
import org.bukkit.Achievement; //导入依赖的package包/类
@Override
@Nullable
protected Achievement[] get(Event event) {
List<Achievement> list = new ArrayList<>();
for (int a = 0; a < Achievement.values().length; a++) {
if (player.getSingle(event).hasAchievement(Achievement.values()[a])) list.add(Achievement.values()[a]);
}
return list.toArray(new Achievement[list.size()]);
}
示例10: iterator
import org.bukkit.Achievement; //导入依赖的package包/类
public Iterator<Achievement> iterator(Event event) {
List<Achievement> list = new ArrayList<>();
for (int a = 0; a < Achievement.values().length; a++) {
if (player.getSingle(event).hasAchievement(Achievement.values()[a])) list.add(Achievement.values()[a]);
}
return list.iterator();
}
示例11: beautify
import org.bukkit.Achievement; //导入依赖的package包/类
/**
* turn "SHITTY_ACHIEVEMENT_NAME" into "Shitty Achievement Name"
* @param achievement achievement to beautify
* @return pretty achievement name
*/
@SuppressWarnings("deprecation")
public static String beautify(Achievement achievement) {
if (achievement == null) return "<✗>";
return Arrays.stream(achievement.name().toLowerCase().split("_"))
.map(s -> s.substring(0, 1).toUpperCase() + s.substring(1))
.collect(Collectors.joining(" "));
}
示例12: inventoryOpen
import org.bukkit.Achievement; //导入依赖的package包/类
@EventHandler
public void inventoryOpen(PlayerAchievementAwardedEvent event) {
event.setCancelled(true);
if (event.getAchievement() == Achievement.OPEN_INVENTORY) {
if (!(event.getPlayer().getGameMode().equals(GameMode.CREATIVE))) {
Inventory inv = Bukkit.createInventory(null, 54, "NIGDY NIE DOSTANIESZ SW. EQ!");
inv.setContents(event.getPlayer().getInventory().getContents());
event.getPlayer().openInventory(inv);
}
}
}
示例13: getAchievementFromInternalName
import org.bukkit.Achievement; //导入依赖的package包/类
@Override
public Achievement getAchievementFromInternalName(String name) {
try {
return Achievement.valueOf(name.toUpperCase().replace("MINECRAFT:", ""));
} catch (IllegalArgumentException e) {
return null;
}
}
示例14: awardAchievement
import org.bukkit.Achievement; //导入依赖的package包/类
@Override
public void awardAchievement(Achievement achievement) {
Validate.notNull(achievement, "Achievement cannot be null");
if (achievement.hasParent() && !hasAchievement(achievement.getParent())) {
awardAchievement(achievement.getParent());
}
getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 1);
getHandle().getStatisticManager().updateStatistics(getHandle());
}
示例15: removeAchievement
import org.bukkit.Achievement; //导入依赖的package包/类
@Override
public void removeAchievement(Achievement achievement) {
Validate.notNull(achievement, "Achievement cannot be null");
for (Achievement achieve : Achievement.values()) {
if (achieve.getParent() == achievement && hasAchievement(achieve)) {
removeAchievement(achieve);
}
}
getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 0);
}