Skip to content

Commit

Permalink
remove legacy ItemTag notes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 19, 2021
1 parent bff3159 commit 775f250
Showing 1 changed file with 2 additions and 63 deletions.
Expand Up @@ -14,20 +14,16 @@
import com.denizenscript.denizencore.objects.*;
import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.util.jnbt.StringTag;
import com.denizenscript.denizen.objects.notable.NotableManager;
import com.denizenscript.denizen.tags.BukkitTagContext;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.objects.notable.Notable;
import com.denizenscript.denizencore.objects.notable.Note;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.scripts.ScriptRegistry;
import com.denizenscript.denizencore.tags.Attribute;
import com.denizenscript.denizencore.tags.ObjectTagProcessor;
import com.denizenscript.denizencore.tags.TagContext;
import com.denizenscript.denizencore.tags.TagRunnable;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.Deprecations;
import com.denizenscript.denizencore.utilities.debugging.Debuggable;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
Expand All @@ -42,7 +38,7 @@

import java.util.Map;

public class ItemTag implements ObjectTag, Notable, Adjustable, FlaggableObject {
public class ItemTag implements ObjectTag, Adjustable, FlaggableObject {

// <--[ObjectType]
// @name ItemTag
Expand Down Expand Up @@ -100,11 +96,6 @@ public static ItemTag valueOf(String string, TagContext context) {
if (ObjectFetcher.isObjectWithProperties(string)) {
return ObjectFetcher.getObjectFromWithProperties(ItemTag.class, string, context);
}
Notable noted = NotableManager.getSavedObject(string);
if (noted instanceof ItemTag) {
Deprecations.notableItems.warn();
return (ItemTag) noted;
}
if (string.startsWith("i@")) {
string = string.substring("i@".length());
}
Expand Down Expand Up @@ -456,11 +447,6 @@ public String identify() {
if (item == null || item.getType() == Material.AIR) {
return "i@air";
}
// If saved item, return that
if (isUnique()) {
Deprecations.notableItems.warn();
return "i@" + NotableManager.getSavedId(this) + PropertyParser.getPropertiesString(this);
}
return "i@" + getMaterial().identifyNoPropertiesNoIdentifier().replace("m@", "") + PropertyParser.getPropertiesString(this);
}

Expand All @@ -469,22 +455,11 @@ public String identifySimple() {
if (item == null) {
return "null";
}

if (item.getType() != Material.AIR) {

// If saved item, return that
if (isUnique()) {
Deprecations.notableItems.warn();
return "i@" + NotableManager.getSavedId(this);
}

// If not a saved item, but is a custom item, return the script id
else if (isItemscript()) {
if (isItemscript()) {
return "i@" + getScriptName();
}
}

// Else, return the material name
return "i@" + identifyMaterial().replace("m@", "");
}

Expand All @@ -499,31 +474,9 @@ public String toString() {

@Override
public boolean isUnique() {
if (NotableManager.isSaved(this)) {
Deprecations.notableItems.warn();
return true;
}
return false;
}

@Override
@Note("Items")
public String getSaveObject() {
return identify();
}

@Override
public void makeUnique(String id) {
Deprecations.notableItems.warn();
NotableManager.saveAs(this, id);
}

@Override
public void forget() {
Deprecations.notableItems.warn();
NotableManager.remove(this);
}

@Override
public boolean isTruthy() {
return !getBukkitMaterial().isAir();
Expand Down Expand Up @@ -726,15 +679,6 @@ else if (container != null) {
return list;
});

registerTag("notable_name", (attribute, object) -> {
Deprecations.notableItems.warn();
String noteName = NotableManager.getSavedId(object);
if (noteName == null) {
return null;
}
return new ElementTag(noteName);
});

// <--[tag]
// @attribute <ItemTag.formatted>
// @returns ElementTag
Expand Down Expand Up @@ -825,11 +769,6 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
}

public void applyProperty(Mechanism mechanism) {
if (NotableManager.isExactSavedObject(this)) {
Deprecations.notableItems.warn();
Debug.echoError("Cannot apply properties to noted objects.");
return;
}
adjust(mechanism);
}

Expand Down

0 comments on commit 775f250

Please sign in to comment.