org.bukkit.advancement.Advancement Java Examples

The following examples show how to use org.bukkit.advancement.Advancement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdvancementNotifyIO.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
private void revoke(NamespacedKey id, Player player) {
    Advancement advancement = Bukkit.getAdvancement(id);
    AdvancementProgress progress = player.getAdvancementProgress(advancement);
    if (progress.isDone()) {
        for (String criteria : progress.getRemainingCriteria()) {
            progress.revokeCriteria(criteria);
        }
    }
}
 
Example #2
Source File: AdvancementNotifyIO.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
private void grant(NamespacedKey id, Player player) {
    Advancement advancement = Bukkit.getAdvancement(id);
    AdvancementProgress progress = player.getAdvancementProgress(advancement);
    if (!progress.isDone()) {
        for (String criteria : progress.getRemainingCriteria()) {
            progress.awardCriteria(criteria);
        }
    }
}
 
Example #3
Source File: CraftMagicNumbers.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Advancement loadAdvancement(NamespacedKey key, String advancement) {
    if (Bukkit.getAdvancement(key) != null) {
        throw new IllegalArgumentException("Advancement " + key + " already exists.");
    }

    net.minecraft.advancements.Advancement.Builder nms = JsonUtils.gsonDeserialize(AdvancementManager.GSON, advancement, net.minecraft.advancements.Advancement.Builder.class);
    if (nms != null) {
        AdvancementManager.ADVANCEMENT_LIST.loadAdvancements(Maps.newHashMap(Collections.singletonMap(CraftNamespacedKey.toMinecraft(key), nms)));
        Advancement bukkit = Bukkit.getAdvancement(key);

        if (bukkit != null) {
            File file = new File(MinecraftServer.getServerCB().getAdvancementManager().advancementsDir, key.getNamespace() + File.separator + key.getKey() + ".json");
            file.getParentFile().mkdirs();

            try {
                Files.write(advancement, file, Charsets.UTF_8);
            } catch (IOException ex) {
                Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex);
            }

            MinecraftServer.getServerCB().getPlayerList().reloadResources();

            return bukkit;
        }
    }

    return null;
}
 
Example #4
Source File: PlayerAdvancementCriterionGrantEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public PlayerAdvancementCriterionGrantEvent(Player who, Advancement advancement, String criterion) {
    super(who);
    this.advancement = advancement;
    this.criterion = criterion;
}
 
Example #5
Source File: MockServer.java    From SaneEconomy with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Iterator<Advancement> advancementIterator() {
    return null;
}
 
Example #6
Source File: AdvancementArgument.java    From 1.13-Command-API with Apache License 2.0 4 votes vote down vote up
@Override
public Class<?> getPrimitiveType() {
	return Advancement.class;
}
 
Example #7
Source File: NMS.java    From 1.13-Command-API with Apache License 2.0 4 votes vote down vote up
/** Argument implementations with CommandSyntaxExceptions */
Advancement         getAdvancement(CommandContext<?> cmdCtx, String key) throws CommandSyntaxException;
 
Example #8
Source File: CraftAdvancementProgress.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Advancement getAdvancement() {
    return advancement;
}
 
Example #9
Source File: PlayerAdvancementDoneEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public PlayerAdvancementDoneEvent(Player who, Advancement advancement) {
    super(who);
    this.advancement = advancement;
}
 
Example #10
Source File: MockServer.java    From Chimera with MIT License 3 votes vote down vote up
@Override
public Advancement getAdvancement(NamespacedKey key) {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
Example #11
Source File: MockServer.java    From Chimera with MIT License 3 votes vote down vote up
@Override
public Iterator<Advancement> advancementIterator() {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
Example #12
Source File: MockServer.java    From SaneEconomy with GNU General Public License v3.0 3 votes vote down vote up
@Override
public Advancement getAdvancement(NamespacedKey namespacedKey) {
    return null;
}
 
Example #13
Source File: Bukkit.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get an iterator through all advancements. Advancements cannot be removed
 * from this iterator,
 *
 * @return an advancement iterator
 */
public static Iterator<Advancement> advancementIterator() {
    return server.advancementIterator();
}
 
Example #14
Source File: Bukkit.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the advancement specified by this key.
 *
 * @param key unique advancement key
 * @return advancement or null if not exists
 */
public static Advancement getAdvancement(NamespacedKey key) {
    return server.getAdvancement(key);
}
 
Example #15
Source File: Player.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Return the player's progression on the specified advancement.
 *
 * @param advancement advancement
 * @return object detailing the player's progress
 */
public AdvancementProgress getAdvancementProgress(Advancement advancement);
 
Example #16
Source File: PlayerAdvancementCriterionGrantEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the advancement which has been affected.
 *
 * @return affected advancement
 */
public Advancement getAdvancement() {
    return advancement;
}
 
Example #17
Source File: UnsafeValues.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Load an advancement represented by the specified string into the server.
 * The advancement format is governed by Minecraft and has no specified
 * layout.
 * <br>
 * It is currently a JSON object, as described by the Minecraft Wiki:
 * http://minecraft.gamepedia.com/Advancements
 * <br>
 * Loaded advancements will be stored and persisted across server restarts
 * and reloads.
 * <br>
 * Callers should be prepared for {@link Exception} to be thrown.
 *
 * @param key         the unique advancement key
 * @param advancement representation of the advancement
 * @return the loaded advancement or null if an error occurred
 */
Advancement loadAdvancement(NamespacedKey key, String advancement);
 
Example #18
Source File: PlayerAdvancementDoneEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the advancement which has been completed.
 *
 * @return completed advancement
 */
public Advancement getAdvancement() {
    return advancement;
}
 
Example #19
Source File: Server.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get an iterator through all advancements. Advancements cannot be removed
 * from this iterator,
 *
 * @return an advancement iterator
 */
Iterator<Advancement> advancementIterator();
 
Example #20
Source File: Server.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the advancement specified by this key.
 *
 * @param key unique advancement key
 * @return advancement or null if not exists
 */
Advancement getAdvancement(NamespacedKey key);