Skip to content

Commit

Permalink
add note that list_flags tags are for debug/testing only
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 30, 2020
1 parent e01a35e commit 48a8318
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Expand Up @@ -17,13 +17,17 @@
import com.denizenscript.denizencore.scripts.ScriptEntry;
import com.denizenscript.denizencore.tags.TagContext;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.debugging.SlowWarning;
import com.denizenscript.denizencore.utilities.debugging.Warning;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemorySection;

import java.util.*;

public class FlagManager {

public static Warning listFlagsTagWarning = new SlowWarning("The list_flags tag is meant for testing/debugging only. Do not use it in scripts (ignore this warning if using for testing reasons).");

// Valid flag actions
public enum Action {
SET_VALUE, SET_BOOLEAN, INCREASE, DECREASE, MULTIPLY,
Expand Down
Expand Up @@ -1320,10 +1320,11 @@ public static void registerTags() {
// @attribute <EntityTag.list_flags[(regex:)<search>]>
// @returns ListTag
// @description
// Returns a list of an entity's flag names, with an optional search for
// names containing a certain pattern.
// Returns a list of an entity's flag names, with an optional search for names containing a certain pattern.
// Note that this is exclusively for debug/testing reasons, and should never be used in a real script.
// -->
registerSpawnedOnlyTag("list_flags", (attribute, object) -> {
FlagManager.listFlagsTagWarning.warn(attribute.context);
ListTag allFlags = new ListTag(DenizenAPI.getCurrentInstance().flagManager().listEntityFlags(object));
ListTag searchFlags = null;
if (!allFlags.isEmpty() && attribute.hasContext(1)) {
Expand Down
Expand Up @@ -676,10 +676,11 @@ else if (attribute.startsWith("list", 2)) {
// @attribute <NPCTag.list_flags[(regex:)<search>]>
// @returns ListTag
// @description
// Returns a list of an NPC's flag names, with an optional search for
// names containing a certain pattern.
// Returns a list of an NPC's flag names, with an optional search for names containing a certain pattern.
// Note that this is exclusively for debug/testing reasons, and should never be used in a real script.
// -->
registerTag("list_flags", (attribute, object) -> {
FlagManager.listFlagsTagWarning.warn(attribute.context);
ListTag allFlags = new ListTag(DenizenAPI.getCurrentInstance().flagManager().listNPCFlags(object.getId()));
ListTag searchFlags = null;
if (!allFlags.isEmpty() && attribute.hasContext(1)) {
Expand Down
Expand Up @@ -744,11 +744,12 @@ public static void registerTags() {
// @attribute <PlayerTag.list_flags[(regex:)<search>]>
// @returns ListTag
// @description
// Returns a list of a player's flag names, with an optional search for
// names containing a certain pattern.
// Returns a list of a player's flag names, with an optional search for names containing a certain pattern.
// Works with offline players.
// Note that this is exclusively for debug/testing reasons, and should never be used in a real script.
// -->
registerTag("list_flags", (attribute, object) -> {
FlagManager.listFlagsTagWarning.warn(attribute.context);
ListTag allFlags = new ListTag(DenizenAPI.getCurrentInstance().flagManager().listPlayerFlags(object));
ListTag searchFlags = null;
if (!allFlags.isEmpty() && attribute.hasContext(1)) {
Expand Down
Expand Up @@ -825,10 +825,11 @@ else if (recipe instanceof CookingRecipe<?>) {
// @attribute <server.list_flags[(regex:)<search>]>
// @returns ListTag
// @description
// Returns a list of the server's flag names, with an optional search for
// names containing a certain pattern.
// Returns a list of the server's flag names, with an optional search for names containing a certain pattern.
// Note that this is exclusively for debug/testing reasons, and should never be used in a real script.
// -->
if (attribute.startsWith("list_flags")) {
FlagManager.listFlagsTagWarning.warn(attribute.context);
ListTag allFlags = new ListTag(DenizenAPI.getCurrentInstance().flagManager().listGlobalFlags());
ListTag searchFlags = null;
if (!allFlags.isEmpty() && attribute.hasContext(1)) {
Expand Down

0 comments on commit 48a8318

Please sign in to comment.