diff --git a/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/ListActionBinary.java b/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/ListActionBinary.java index ea5b7c4..cefc4df 100644 --- a/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/ListActionBinary.java +++ b/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/ListActionBinary.java @@ -208,9 +208,34 @@ public void CreateListActions(AttributeMap map) this.addCheckMoonPhase(map); } - if (map.has(GET_CURRENT_GAME_DAY)) + if (map.has(GET_CURRENT_GAME_DAY_EQUAL)) { - this.addCheckCurrentGameDay(map); + this.addCheckCurrentGameDayEqual(map); + } + + if (map.has(GET_CURRENT_GAME_DAY_GREATER)) + { + this.addCheckCurrentGameDayGreater(map); + } + + if (map.has(GET_CURRENT_GAME_DAY_LESS)) + { + this.addCheckCurrentGameDayLess(map); + } + + if (map.has(GET_CURRENT_GAME_DAY_GREATER_OR_EQUAL)) + { + this.addCheckCurrentGameDayGreaterOrEqual(map); + } + + if (map.has(GET_CURRENT_GAME_DAY_LESS_OR_EQUAL)) + { + this.addCheckCurrentGameDayLessOrEqual(map); + } + + if (map.has(GET_CURRENT_GAME_DAY_INTERVAL)) + { + this.addCheckCurrentGameDayInterval(map); } if (map.has(MOB)) @@ -961,15 +986,122 @@ private void addCheckMoonPhase(AttributeMap map) * * @param map */ - private void addCheckCurrentGameDay(AttributeMap map) + private void addCheckCurrentGameDayEqual(AttributeMap map) { - Object targetDay = map.get(GET_CURRENT_GAME_DAY); + Object targetDay = map.get(GET_CURRENT_GAME_DAY_EQUAL); - if (targetDay == null) + this.ARRAY_LIST.add((event, query) -> { - return; - } - + World world = query.getWorld(event); + + if (world != null) + { + long currentDay = world.getWorldTime() / 24000; + return currentDay == (Long)targetDay; + } + + return false; + }); + } + + /** + * + * @param map + */ + private void addCheckCurrentGameDayGreater(AttributeMap map) + { + Object targetDay = map.get(GET_CURRENT_GAME_DAY_GREATER); + + this.ARRAY_LIST.add((event, query) -> + { + World world = query.getWorld(event); + + if (world != null) + { + long currentDay = world.getWorldTime() / 24000; + return currentDay > (Long)targetDay; + } + + return false; + }); + } + + /** + * + * @param map + */ + private void addCheckCurrentGameDayLess(AttributeMap map) + { + Object targetDay = map.get(GET_CURRENT_GAME_DAY_LESS); + + this.ARRAY_LIST.add((event, query) -> + { + World world = query.getWorld(event); + + if (world != null) + { + long currentDay = world.getWorldTime() / 24000; + return currentDay < (Long)targetDay; + } + + return false; + }); + } + + /** + * + * @param map + */ + private void addCheckCurrentGameDayGreaterOrEqual(AttributeMap map) + { + Object targetDay = map.get(GET_CURRENT_GAME_DAY_GREATER_OR_EQUAL); + + this.ARRAY_LIST.add((event, query) -> + { + World world = query.getWorld(event); + + if (world != null) + { + long currentDay = world.getWorldTime() / 24000; + return currentDay >= (Long)targetDay; + } + + return false; + }); + } + + /** + * + * @param map + */ + private void addCheckCurrentGameDayLessOrEqual(AttributeMap map) + { + Object targetDay = map.get(GET_CURRENT_GAME_DAY_LESS_OR_EQUAL); + + this.ARRAY_LIST.add((event, query) -> + { + World world = query.getWorld(event); + + if (world != null) + { + long currentDay = world.getWorldTime() / 24000; + return currentDay <= (Long)targetDay; + } + + return false; + }); + } + + /** + * + * @param map + */ + private void addCheckCurrentGameDayInterval(AttributeMap map) + { + Object intervalObj = map.get(GET_CURRENT_GAME_DAY_INTERVAL); + + long interval = (Long) intervalObj; + this.ARRAY_LIST.add((event, query) -> { World world = query.getWorld(event); @@ -977,8 +1109,7 @@ private void addCheckCurrentGameDay(AttributeMap map) if (world != null) { long currentDay = world.getWorldTime() / 24000; - Log.writeDataToLogFile(0, "cDay: " + currentDay); - return currentDay == (Integer)targetDay; + return currentDay % interval == 0; } return false; diff --git a/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/MultipleKeyWord.java b/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/MultipleKeyWord.java index c0cb558..5c48e79 100644 --- a/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/MultipleKeyWord.java +++ b/dynamicspawncontrol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/customlibrary/MultipleKeyWord.java @@ -44,7 +44,19 @@ public static class CommonKeyWorlds public static final AttributeKey GET_MOON_PHASE = AttributeKey.create(AttributeType.INTEGER, "moon_phase"); - public static final AttributeKey GET_CURRENT_GAME_DAY = AttributeKey.create(AttributeType.INTEGER, "current_day"); + //-' '=' + public static final AttributeKey GET_CURRENT_GAME_DAY_EQUAL = AttributeKey.create(AttributeType.LONG, "current_day_equal"); + //-' '>' + public static final AttributeKey GET_CURRENT_GAME_DAY_GREATER = AttributeKey.create(AttributeType.LONG, "current_day_greater"); + //-' '<' + public static final AttributeKey GET_CURRENT_GAME_DAY_LESS = AttributeKey.create(AttributeType.LONG, "current_day_less"); + //-' '>=' + public static final AttributeKey GET_CURRENT_GAME_DAY_GREATER_OR_EQUAL = AttributeKey.create(AttributeType.LONG, "current_day_greater_or_equal"); + //-' '<=' + public static final AttributeKey GET_CURRENT_GAME_DAY_LESS_OR_EQUAL = AttributeKey.create(AttributeType.LONG, "current_day_less_or_equal"); + + //-' currentDay % value == 0 -> true + public static final AttributeKey GET_CURRENT_GAME_DAY_INTERVAL = AttributeKey.create(AttributeType.LONG, "current_day_interval"); public static final AttributeKey MOB = AttributeKey.create(AttributeType.STRING, "mob");