Search in sources :

Example 6 with NamespacedKey

use of org.bukkit.NamespacedKey in project Glowstone by GlowstoneMC.

the class NamespacedKeyTest method testFromStringWithoutKey.

@Test
public void testFromStringWithoutKey() {
    String keyRaw = "abc";
    NamespacedKey key = new NamespacedKey(NamespacedKey.MINECRAFT, keyRaw);
    assertThat(key.toString(), equalTo("minecraft:" + keyRaw));
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) Test(org.junit.jupiter.api.Test)

Example 7 with NamespacedKey

use of org.bukkit.NamespacedKey in project Glowstone by GlowstoneMC.

the class NamespacedKeyTest method testFromStringWithKey.

@Test
public void testFromStringWithKey() {
    String keyRaw = "minecraft:abc";
    NamespacedKey key = new NamespacedKey(keyRaw.substring(0, keyRaw.indexOf(':')), keyRaw.substring(keyRaw.indexOf(':') + 1, keyRaw.length()));
    assertThat(key.toString(), equalTo(keyRaw));
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) Test(org.junit.jupiter.api.Test)

Example 8 with NamespacedKey

use of org.bukkit.NamespacedKey in project Glowstone by GlowstoneMC.

the class GlowParticle method registerParticle.

private static void registerParticle(String name) {
    NamespacedKey key = NamespacedKey.minecraft(name);
    PARTICLES_BY_NAME.put(key, new GlowParticle(key));
}
Also used : NamespacedKey(org.bukkit.NamespacedKey)

Example 9 with NamespacedKey

use of org.bukkit.NamespacedKey in project Denizen-For-Bukkit by DenizenScript.

the class ToastCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) {
    ElementTag text = scriptEntry.getElement("text");
    ElementTag frame = scriptEntry.getElement("frame");
    ItemTag icon = scriptEntry.getObjectTag("icon");
    final List<PlayerTag> targets = (List<PlayerTag>) scriptEntry.getObject("targets");
    if (scriptEntry.dbCallShouldDebug()) {
        Debug.report(scriptEntry, name, text, frame, icon, db("targets", targets));
    }
    final Advancement advancement = new Advancement(true, new NamespacedKey(Denizen.getInstance(), UUID.randomUUID().toString()), null, icon.getItemStack(), text.asString(), "", null, Advancement.Frame.valueOf(frame.asString().toUpperCase()), true, false, true, 0, 0, 1);
    final AdvancementHelper advancementHelper = NMSHandler.getAdvancementHelper();
    for (PlayerTag target : targets) {
        Player player = target.getPlayerEntity();
        if (player != null) {
            advancementHelper.grant(advancement, player);
            advancementHelper.revoke(advancement, player);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) AdvancementHelper(com.denizenscript.denizen.nms.interfaces.AdvancementHelper) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) NamespacedKey(org.bukkit.NamespacedKey) List(java.util.List) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ItemTag(com.denizenscript.denizen.objects.ItemTag) Advancement(com.denizenscript.denizen.nms.util.Advancement)

Example 10 with NamespacedKey

use of org.bukkit.NamespacedKey in project Denizen-For-Bukkit by DenizenScript.

the class DataPersistenceFlagTracker method doTotalClean.

public void doTotalClean() {
    if (MapTagBasedFlagTracker.skipAllCleanings) {
        return;
    }
    if (!holder.getPersistentDataContainer().has(expireNeededKey, PersistentDataType.STRING)) {
        return;
    }
    boolean containsAnyToCheck = false;
    for (NamespacedKey key : holder.getPersistentDataContainer().getKeys()) {
        if (!key.getNamespace().equals("denizen") || !key.getKey().startsWith("flag_")) {
            continue;
        }
        ObjectTag map = DataPersistenceHelper.getDenizenKey(holder, key.getKey());
        if (!(map instanceof MapTag)) {
            continue;
        }
        if (isExpired(((MapTag) map).map.get(expirationString))) {
            holder.getPersistentDataContainer().remove(key);
            containsAnyToCheck = true;
            continue;
        }
        ObjectTag subValue = ((MapTag) map).map.get(valueString);
        if (subValue instanceof MapTag) {
            if (doClean((MapTag) subValue)) {
                holder.getPersistentDataContainer().set(key, DataPersistenceHelper.PERSISTER_TYPE, map);
            }
            containsAnyToCheck = true;
        }
    }
    if (!containsAnyToCheck) {
        holder.getPersistentDataContainer().remove(expireNeededKey);
    }
}
Also used : ObjectTag(com.denizenscript.denizencore.objects.ObjectTag) NamespacedKey(org.bukkit.NamespacedKey) MapTag(com.denizenscript.denizencore.objects.core.MapTag)

Aggregations

NamespacedKey (org.bukkit.NamespacedKey)24 Enchantment (org.bukkit.enchantments.Enchantment)4 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)3 ListTag (com.denizenscript.denizencore.objects.core.ListTag)3 ItemStack (org.bukkit.inventory.ItemStack)3 Test (org.junit.jupiter.api.Test)3 AdvancementHelper (com.denizenscript.denizen.nms.interfaces.AdvancementHelper)2 Advancement (com.denizenscript.denizen.nms.util.Advancement)2 ItemTag (com.denizenscript.denizen.objects.ItemTag)2 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)2 List (java.util.List)2 ResourceLocation (net.minecraft.resources.ResourceLocation)2 DamageSource (net.minecraft.world.damagesource.DamageSource)2 Entity (net.minecraft.world.entity.Entity)2 EquipmentSlot (net.minecraft.world.entity.EquipmentSlot)2 LivingEntity (net.minecraft.world.entity.LivingEntity)2 MobType (net.minecraft.world.entity.MobType)2 Location (org.bukkit.Location)2 KeyedBossBar (org.bukkit.boss.KeyedBossBar)2 Player (org.bukkit.entity.Player)2