use of com.denizenscript.denizencore.objects.notable.Notable in project Denizen-For-Bukkit by DenizenScript.
the class CuboidTag method valueOf.
@Fetchable("cu")
public static CuboidTag valueOf(String string, TagContext context) {
if (string == null) {
return null;
}
if (CoreUtilities.toLowerCase(string).startsWith("cu@")) {
string = string.substring("cu@".length());
}
Notable noted = NoteManager.getSavedObject(string);
if (noted instanceof CuboidTag) {
return (CuboidTag) noted;
}
if (CoreUtilities.contains(string, '@')) {
if (CoreUtilities.contains(string, '|') && string.contains("l@")) {
Debug.echoError("Warning: likely improperly constructed CuboidTag '" + string + "' - use to_cuboid");
} else {
return null;
}
}
if (CoreUtilities.contains(string, '|')) {
ListTag positions = ListTag.valueOf(string, context);
if (positions.size() > 1 && LocationTag.matches(positions.get(0)) && LocationTag.matches(positions.get(1))) {
if (positions.size() % 2 != 0) {
if (context == null || context.showErrors()) {
Debug.echoError("valueOf CuboidTag returning null (Uneven number of locations): '" + string + "'.");
}
return null;
}
CuboidTag toReturn = new CuboidTag();
for (int i = 0; i < positions.size(); i += 2) {
LocationTag pos_1 = LocationTag.valueOf(positions.get(i), context);
LocationTag pos_2 = LocationTag.valueOf(positions.get(i + 1), context);
if (pos_1 == null || pos_2 == null) {
if (context == null || context.showErrors()) {
Debug.echoError("valueOf in CuboidTag returning null (null locations): '" + string + "'.");
}
return null;
}
if (pos_1.getWorldName() == null || pos_2.getWorldName() == null) {
if (context == null || context.showErrors()) {
Debug.echoError("valueOf in CuboidTag returning null (null worlds): '" + string + "'.");
}
return null;
}
toReturn.addPair(pos_1, pos_2);
}
if (toReturn.pairs.size() > 0) {
return toReturn;
}
}
} else if (CoreUtilities.contains(string, ',')) {
List<String> subStrs = CoreUtilities.split(string, ',');
if (subStrs.size() < 7 || (subStrs.size() - 1) % 6 != 0) {
if (context == null || context.showErrors()) {
Debug.echoError("valueOf CuboidTag returning null (Improper number of commas): '" + string + "'.");
}
return null;
}
CuboidTag toReturn = new CuboidTag();
String worldName = subStrs.get(0);
if (worldName.startsWith("w@")) {
worldName = worldName.substring("w@".length());
}
try {
for (int i = 0; i < subStrs.size() - 1; i += 6) {
LocationTag locationOne = new LocationTag(parseRoundDouble(subStrs.get(i + 1)), parseRoundDouble(subStrs.get(i + 2)), parseRoundDouble(subStrs.get(i + 3)), worldName);
LocationTag locationTwo = new LocationTag(parseRoundDouble(subStrs.get(i + 4)), parseRoundDouble(subStrs.get(i + 5)), parseRoundDouble(subStrs.get(i + 6)), worldName);
toReturn.addPair(locationOne, locationTwo);
}
} catch (NumberFormatException ex) {
if (context == null || context.showErrors()) {
Debug.echoError("valueOf CuboidTag returning null (Improper number value inputs): '" + ex.getMessage() + "'.");
}
return null;
}
if (toReturn.pairs.size() > 0) {
return toReturn;
}
}
if (context == null || context.showErrors()) {
Debug.echoError("Minor: valueOf CuboidTag returning null: " + string);
}
return null;
}
use of com.denizenscript.denizencore.objects.notable.Notable in project Denizen-For-Bukkit by DenizenScript.
the class AreaEnterExitScriptEvent method processNewPosition.
public void processNewPosition(EntityTag entity, Location pos, Event eventCause) {
if (onlyTrackPlayers && !entity.isPlayer()) {
return;
}
HashSet<String> inAreas = entitiesInArea.get(entity.getUUID());
if (doTrackAll || matchers != null || flagTracked != null) {
for (CuboidTag cuboid : NoteManager.getAllType(CuboidTag.class)) {
if (anyMatch(cuboid.noteName, cuboid)) {
processSingle(cuboid, entity, inAreas, pos, eventCause);
}
}
for (EllipsoidTag ellipsoid : NoteManager.getAllType(EllipsoidTag.class)) {
if (anyMatch(ellipsoid.noteName, ellipsoid)) {
processSingle(ellipsoid, entity, inAreas, pos, eventCause);
}
}
for (PolygonTag polygon : NoteManager.getAllType(PolygonTag.class)) {
if (anyMatch(polygon.noteName, polygon)) {
processSingle(polygon, entity, inAreas, pos, eventCause);
}
}
} else {
for (String name : exactTracked) {
Notable obj = NoteManager.getSavedObject(name);
if (!(obj instanceof AreaContainmentObject)) {
Debug.echoError("Invalid area enter/exit event area '" + name + "'");
continue;
}
processSingle((AreaContainmentObject) obj, entity, inAreas, pos, eventCause);
}
}
if (inAreas != null && inAreas.isEmpty()) {
entitiesInArea.remove(entity.getUUID());
}
}
Aggregations