Skip to content

Commit

Permalink
AdvancedTextImpl -> PaperAPITools
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 3, 2022
1 parent db29682 commit fa7d53b
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 68 deletions.
Expand Up @@ -10,9 +10,9 @@
import com.denizenscript.denizen.paper.events.*;
import com.denizenscript.denizen.paper.properties.*;
import com.denizenscript.denizen.paper.tags.PaperTagBase;
import com.denizenscript.denizen.paper.utilities.PaperAdvancedTextImpl;
import com.denizenscript.denizen.paper.utilities.PaperAPIToolsImpl;
import com.denizenscript.denizen.utilities.FormattedTextHelper;
import com.denizenscript.denizen.utilities.AdvancedTextImpl;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
Expand Down Expand Up @@ -80,7 +80,7 @@ public static void init() {

// Other helpers
Bukkit.getPluginManager().registerEvents(new PaperEventHelpers(), Denizen.getInstance());
AdvancedTextImpl.instance = new PaperAdvancedTextImpl();
PaperAPITools.instance = new PaperAPIToolsImpl();
}

public static Component parseFormattedText(String text, ChatColor baseColor) {
Expand Down
Expand Up @@ -4,7 +4,7 @@
import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.paper.PaperModule;
import com.denizenscript.denizen.utilities.AdvancedTextImpl;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizencore.DenizenCore;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.destroystokyo.paper.profile.PlayerProfile;
Expand All @@ -26,7 +26,7 @@

import java.util.*;

public class PaperAdvancedTextImpl extends AdvancedTextImpl {
public class PaperAPIToolsImpl extends PaperAPITools {

@Override
public Inventory createInventory(InventoryHolder holder, int slots, String title) {
Expand Down
Expand Up @@ -2,7 +2,7 @@

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.ItemTag;
import com.denizenscript.denizen.utilities.AdvancedTextImpl;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.*;
Expand Down Expand Up @@ -140,7 +140,7 @@ else if (Argument.valueOf(lower).matchesArgumentList(ItemTag.class)) {
return true;
}
else if (event instanceof PlayerDeathEvent) {
AdvancedTextImpl.instance.setDeathMessage((PlayerDeathEvent) event, determination);
PaperAPITools.instance.setDeathMessage((PlayerDeathEvent) event, determination);
return true;
}
else {
Expand All @@ -159,7 +159,7 @@ public ObjectTag getContext(String name) {
case "entity": return entity.getDenizenObject();
case "projectile": return projectile == null ? null : projectile.getDenizenObject();
case "damager": return damager == null ? null : damager.getDenizenObject();
case "message": return event instanceof PlayerDeathEvent ? new ElementTag(AdvancedTextImpl.instance.getDeathMessage((PlayerDeathEvent) event)) : null;
case "message": return event instanceof PlayerDeathEvent ? new ElementTag(PaperAPITools.instance.getDeathMessage((PlayerDeathEvent) event)) : null;
case "cause": return cause;
case "xp": return new ElementTag(event.getDroppedExp());
case "drops":
Expand Down
Expand Up @@ -4,7 +4,7 @@
import com.denizenscript.denizen.scripts.containers.core.InventoryScriptContainer;
import com.denizenscript.denizen.scripts.containers.core.InventoryScriptHelper;
import com.denizenscript.denizen.scripts.containers.core.ItemScriptHelper;
import com.denizenscript.denizen.utilities.AdvancedTextImpl;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.depends.Depends;
import com.denizenscript.denizen.utilities.inventory.InventoryTrackerSystem;
Expand Down Expand Up @@ -181,16 +181,16 @@ public void setInventory(Inventory inventory) {
public void makeUnique(String id) {
InventoryTag toNote = new InventoryTag(inventory, idType, idHolder);
toNote.uniquifier = null;
String title = AdvancedTextImpl.instance.getTitle(inventory);
String title = PaperAPITools.instance.getTitle(inventory);
if (title == null || title.startsWith("container.")) {
title = toNote.inventory.getType().getDefaultTitle();
}
ItemStack[] contents = toNote.inventory.getContents();
if (getInventoryType() == InventoryType.CHEST) {
toNote.inventory = AdvancedTextImpl.instance.createInventory(null, toNote.inventory.getSize(), title);
toNote.inventory = PaperAPITools.instance.createInventory(null, toNote.inventory.getSize(), title);
}
else {
toNote.inventory = AdvancedTextImpl.instance.createInventory(null, toNote.inventory.getType(), title);
toNote.inventory = PaperAPITools.instance.createInventory(null, toNote.inventory.getType(), title);
}
toNote.inventory.setContents(contents);
InventoryScriptHelper.notedInventories.put(toNote.inventory, toNote);
Expand Down Expand Up @@ -538,7 +538,7 @@ public InventoryTag(int size, String title) {
Debug.echoError("InventorySize must be multiple of 9, and greater than 0.");
return;
}
inventory = AdvancedTextImpl.instance.createInventory(null, size, title);
inventory = PaperAPITools.instance.createInventory(null, size, title);
idType = "generic";
idHolder = new ElementTag("chest");
}
Expand All @@ -550,7 +550,7 @@ public InventoryTag(InventoryType type) {
}

public InventoryTag(InventoryType type, String title) {
inventory = AdvancedTextImpl.instance.createInventory(null, type, title);
inventory = PaperAPITools.instance.createInventory(null, type, title);
idType = "generic";
idHolder = new ElementTag(CoreUtilities.toLowerCase(type.name()));
}
Expand Down Expand Up @@ -619,12 +619,12 @@ else if (inventory == null) {
else {
newContents = oldContents;
}
String title = AdvancedTextImpl.instance.getTitle(inventory);
String title = PaperAPITools.instance.getTitle(inventory);
if (title == null) {
setInventory(Bukkit.getServer().createInventory(null, size));
}
else {
setInventory(AdvancedTextImpl.instance.createInventory(null, size, title));
setInventory(PaperAPITools.instance.createInventory(null, size, title));
}
inventory.setContents(newContents);
trackTemporaryInventory(this);
Expand Down Expand Up @@ -1218,7 +1218,7 @@ public static void registerTags() {
}

InventoryType type = object.inventory.getType();
InventoryTag dummyInv = new InventoryTag(type == InventoryType.PLAYER ? InventoryType.CHEST : type, AdvancedTextImpl.instance.getTitle(object.inventory));
InventoryTag dummyInv = new InventoryTag(type == InventoryType.PLAYER ? InventoryType.CHEST : type, PaperAPITools.instance.getTitle(object.inventory));
ItemStack[] contents = object.getStorageContents();
if (dummyInv.getInventoryType() == InventoryType.CHEST) {
dummyInv.setSize(contents.length);
Expand Down Expand Up @@ -1285,7 +1285,7 @@ public static void registerTags() {
return null;
}
List<ItemTag> items = ListTag.getListFor(attribute.getParamObject(), attribute.context).filter(ItemTag.class, attribute.context);
InventoryTag dummyInv = new InventoryTag(object.inventory.getType(), AdvancedTextImpl.instance.getTitle(object.inventory));
InventoryTag dummyInv = new InventoryTag(object.inventory.getType(), PaperAPITools.instance.getTitle(object.inventory));
if (object.inventory.getType() == InventoryType.CHEST) {
dummyInv.setSize(object.inventory.getSize());
}
Expand Down Expand Up @@ -1329,7 +1329,7 @@ public static void registerTags() {
return null;
}
String matcher = attribute.getParam();
InventoryTag dummyInv = new InventoryTag(object.inventory.getType(), AdvancedTextImpl.instance.getTitle(object.inventory));
InventoryTag dummyInv = new InventoryTag(object.inventory.getType(), PaperAPITools.instance.getTitle(object.inventory));
if (object.inventory.getType() == InventoryType.CHEST) {
dummyInv.setSize(object.inventory.getSize());
}
Expand Down Expand Up @@ -1377,7 +1377,7 @@ public static void registerTags() {
return null;
}
List<ItemTag> items = ListTag.getListFor(attribute.getParamObject(), attribute.context).filter(ItemTag.class, attribute.context);
InventoryTag dummyInv = new InventoryTag(object.inventory.getType(), AdvancedTextImpl.instance.getTitle(object.inventory));
InventoryTag dummyInv = new InventoryTag(object.inventory.getType(), PaperAPITools.instance.getTitle(object.inventory));
if (object.inventory.getType() == InventoryType.CHEST) {
dummyInv.setSize(object.inventory.getSize());
}
Expand Down
Expand Up @@ -1333,7 +1333,7 @@ public static void registerTags() {
// -->
tagProcessor.registerTag(ListTag.class, "sign_contents", (attribute, object) -> {
if (object.getBlockStateForTag(attribute) instanceof Sign) {
return new ListTag(Arrays.asList(AdvancedTextImpl.instance.getSignLines(((Sign) object.getBlockStateForTag(attribute)))));
return new ListTag(Arrays.asList(PaperAPITools.instance.getSignLines(((Sign) object.getBlockStateForTag(attribute)))));
}
else {
return null;
Expand Down Expand Up @@ -4159,7 +4159,7 @@ else if (material.hasModernData() && material.getModernData() instanceof org.buk
// -->
tagProcessor.registerTag(ElementTag.class, "custom_name", (attribute, object) -> {
if (object.getBlockStateForTag(attribute) instanceof Nameable) {
return new ElementTag(AdvancedTextImpl.instance.getCustomName((Nameable) object.getBlockStateForTag(attribute)));
return new ElementTag(PaperAPITools.instance.getCustomName((Nameable) object.getBlockStateForTag(attribute)));
}
return null;
});
Expand Down Expand Up @@ -4642,7 +4642,7 @@ public void adjust(Mechanism mechanism) {
if (mechanism.matches("sign_contents") && getBlockState() instanceof Sign) {
Sign state = (Sign) getBlockState();
for (int i = 0; i < 4; i++) {
AdvancedTextImpl.instance.setSignLine(state, i, "");
PaperAPITools.instance.setSignLine(state, i, "");
}
ListTag list = mechanism.valueAsType(ListTag.class);
CoreUtilities.fixNewLinesToListSeparation(list);
Expand All @@ -4651,7 +4651,7 @@ public void adjust(Mechanism mechanism) {
}
else {
for (int i = 0; i < list.size(); i++) {
AdvancedTextImpl.instance.setSignLine(state, i, list.get(i));
PaperAPITools.instance.setSignLine(state, i, list.get(i));
}
}
state.update();
Expand Down Expand Up @@ -4802,7 +4802,7 @@ public void adjust(Mechanism mechanism) {
title = mechanism.getValue().asString();
}
BlockState state = getBlockState();
AdvancedTextImpl.instance.setCustomName((Nameable) state, title);
PaperAPITools.instance.setCustomName((Nameable) state, title);
state.update(true);
}
}
Expand Down
Expand Up @@ -11,7 +11,7 @@
import com.denizenscript.denizen.scripts.commands.player.SidebarCommand;
import com.denizenscript.denizen.scripts.commands.server.BossBarCommand;
import com.denizenscript.denizen.tags.core.PlayerTagBase;
import com.denizenscript.denizen.utilities.AdvancedTextImpl;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizen.utilities.BukkitImplDeprecations;
import com.denizenscript.denizen.utilities.FormattedTextHelper;
import com.denizenscript.denizen.utilities.ScoreboardHelper;
Expand Down Expand Up @@ -1397,7 +1397,7 @@ else if (obj instanceof EntityTag) {
// Returns the name of the player as shown in the player list.
// -->
registerOnlineOnlyTag(ElementTag.class, "list_name", (attribute, object) -> {
return new ElementTag(AdvancedTextImpl.instance.getPlayerListName(object.getPlayerEntity()), true);
return new ElementTag(PaperAPITools.instance.getPlayerListName(object.getPlayerEntity()), true);
});

// <--[tag]
Expand Down Expand Up @@ -3001,7 +3001,7 @@ public void adjust(Mechanism mechanism) {
// <PlayerTag.list_name>
// -->
if (mechanism.matches("player_list_name")) {
AdvancedTextImpl.instance.setPlayerListName(getPlayerEntity(), mechanism.getValue().asString());
PaperAPITools.instance.setPlayerListName(getPlayerEntity(), mechanism.getValue().asString());
}

// <--[mechanism]
Expand Down Expand Up @@ -3665,7 +3665,7 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) {
if (LocationTag.matches(split[0]) && split.length > 1) {
ListTag lines = ListTag.valueOf(split[1], mechanism.context);
LocationTag location = LocationTag.valueOf(split[0], mechanism.context);
AdvancedTextImpl.instance.sendSignUpdate(getPlayerEntity(), location, lines.toArray(new String[4]));
PaperAPITools.instance.sendSignUpdate(getPlayerEntity(), location, lines.toArray(new String[4]));
}
else {
Debug.echoError("Must specify a valid location and at least one sign line!");
Expand Down Expand Up @@ -3791,7 +3791,7 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) {
mechanism.echoError("Must specify a name with no more than 16 characters.");
return;
}
AdvancedTextImpl.instance.setSkin(getPlayerEntity(), name);
PaperAPITools.instance.setSkin(getPlayerEntity(), name);
}

// <--[mechanism]
Expand All @@ -3806,7 +3806,7 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) {
// <PlayerTag.skin_blob>
// -->
if (mechanism.matches("skin_blob") && mechanism.hasValue()) {
AdvancedTextImpl.instance.setSkinBlob(getPlayerEntity(), mechanism.getValue().asString());
PaperAPITools.instance.setSkinBlob(getPlayerEntity(), mechanism.getValue().asString());
}

// <--[mechanism]
Expand Down
@@ -1,7 +1,7 @@
package com.denizenscript.denizen.objects.properties.entity;

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.utilities.AdvancedTextImpl;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.ObjectTag;
Expand Down Expand Up @@ -36,7 +36,7 @@ private EntityCustomName(EntityTag ent) {

@Override
public String getPropertyString() {
return AdvancedTextImpl.instance.getCustomName(entity.getBukkitEntity());
return PaperAPITools.instance.getCustomName(entity.getBukkitEntity());
}

@Override
Expand All @@ -55,7 +55,7 @@ public static void registerTags() {
// Returns the entity's custom name (as set by plugin or name tag item), if any.
// -->
PropertyParser.registerTag(EntityCustomName.class, ElementTag.class, "custom_name", (attribute, object) -> {
String name = AdvancedTextImpl.instance.getCustomName(object.entity.getBukkitEntity());
String name = PaperAPITools.instance.getCustomName(object.entity.getBukkitEntity());
if (name == null) {
return null;
}
Expand All @@ -76,7 +76,7 @@ public void adjust(Mechanism mechanism) {
// <EntityTag.custom_name>
// -->
if (mechanism.matches("custom_name")) {
AdvancedTextImpl.instance.setCustomName(entity.getBukkitEntity(), CoreUtilities.clearNBSPs(mechanism.getValue().asString()));
PaperAPITools.instance.setCustomName(entity.getBukkitEntity(), CoreUtilities.clearNBSPs(mechanism.getValue().asString()));
}

}
Expand Down
Expand Up @@ -2,7 +2,7 @@

import com.denizenscript.denizen.objects.InventoryTag;
import com.denizenscript.denizen.scripts.containers.core.InventoryScriptHelper;
import com.denizenscript.denizen.utilities.AdvancedTextImpl;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.ObjectTag;
Expand Down Expand Up @@ -37,7 +37,7 @@ public InventoryTitle(InventoryTag inventory) {

public String getTitle() {
if (inventory.getInventory() != null) {
String title = AdvancedTextImpl.instance.getTitle(inventory.getInventory());
String title = PaperAPITools.instance.getTitle(inventory.getInventory());
if (title != null) {
if (!title.startsWith("container.")) {
return title;
Expand Down Expand Up @@ -100,21 +100,21 @@ public void adjust(Mechanism mechanism) {
inventory.customTitle = title;
return;
}
if (inventory.getInventory() != null && AdvancedTextImpl.instance.getTitle(inventory.getInventory()).equals(title)) {
if (inventory.getInventory() != null && PaperAPITools.instance.getTitle(inventory.getInventory()).equals(title)) {
return;
}
inventory.uniquifier = null;
if (inventory.getInventory() == null) {
inventory.setInventory(AdvancedTextImpl.instance.createInventory(null, InventoryTag.maxSlots, title));
inventory.setInventory(PaperAPITools.instance.createInventory(null, InventoryTag.maxSlots, title));
InventoryTag.trackTemporaryInventory(inventory);
return;
}
ItemStack[] contents = inventory.getContents();
if (inventory.getInventory().getType() == InventoryType.CHEST) {
inventory.setInventory(AdvancedTextImpl.instance.createInventory(null, inventory.getSize(), title));
inventory.setInventory(PaperAPITools.instance.createInventory(null, inventory.getSize(), title));
}
else {
inventory.setInventory(AdvancedTextImpl.instance.createInventory(null, inventory.getInventory().getType(), title));
inventory.setInventory(PaperAPITools.instance.createInventory(null, inventory.getInventory().getType(), title));
}
inventory.setContents(contents);
InventoryTag.trackTemporaryInventory(inventory);
Expand Down

0 comments on commit fa7d53b

Please sign in to comment.