當前位置: 首頁>>代碼示例>>Java>>正文


Java Achievement類代碼示例

本文整理匯總了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.");
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:24,代碼來源:AchievementMundo.java

示例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;
			}
		}
	}
}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:22,代碼來源:SQRankup2.java

示例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;
}
 
開發者ID:Yoshi41023,項目名稱:TatsuCraftMod,代碼行數:27,代碼來源:Command_cake.java

示例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
    );
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:20,代碼來源:Hover.java

示例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;
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:8,代碼來源:ExprParentAch.java

示例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;
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:9,代碼來源:CondHasAch.java

示例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;
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:8,代碼來源:EffAwardAch.java

示例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;
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:10,代碼來源:EffRemoveAch.java

示例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()]);
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:10,代碼來源:ExprAllAch.java

示例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();
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:8,代碼來源:ExprAllAch.java

示例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(" "));
}
 
開發者ID:Scarsz,項目名稱:DiscordSRV,代碼行數:14,代碼來源:PrettyUtil.java

示例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);
		}
	}
}
 
開發者ID:xdev-pl,項目名稱:LeagueOfLegends,代碼行數:12,代碼來源:PlayerAchievementAwardedList.java

示例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;
	}
}
 
開發者ID:rutgerkok,項目名稱:Pokkit,代碼行數:9,代碼來源:PokkitUnsafe.java

示例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());
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:10,代碼來源:CraftPlayer.java

示例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);
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:11,代碼來源:CraftPlayer.java


注:本文中的org.bukkit.Achievement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。