From b0d91abe61acbbfc2028d3477d72cc64f71e2454 Mon Sep 17 00:00:00 2001 From: mcmonkey4eva Date: Sun, 19 Oct 2014 21:20:14 -0700 Subject: [PATCH] Make list.contains take a list basically a list.contains_all --- .../net/aufdemrand/denizen/objects/dList.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/objects/dList.java b/src/main/java/net/aufdemrand/denizen/objects/dList.java index 81d1f1619d..7a4ebc20fe 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dList.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dList.java @@ -1094,24 +1094,26 @@ else if (res > 0) } // <--[tag] - // @attribute ]> + // @attribute |...]> // @returns Element(Boolean) // @description - // returns whether the list contains a given element. + // returns whether the list contains all of the given elements. // --> - if (attribute.matches("contains")) { - if (attribute.hasContext(1)) { - boolean state = false; + if (attribute.matches("contains") + && attribute.hasContext(1)) { + dList needed = dList.valueOf(attribute.getContext(1)); + int gotten = 0; + for (String check: needed) { for (String element : this) { - if (element.equalsIgnoreCase(attribute.getContext(1))) { - state = true; + if (element.equalsIgnoreCase(check)) { + gotten++; break; } } - - return new Element(state).getAttribute(attribute.fulfill(1)); } + + return new Element(gotten == needed.size()).getAttribute(attribute.fulfill(1)); } if (attribute.startsWith("prefix"))