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));
}
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));
}
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));
}
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);
}
}
}
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);
}
}
Aggregations