Skip to content

Commit

Permalink
Add new keywords to define game days
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSerpskiStalker committed Oct 31, 2024
1 parent 280233f commit 4f01d5f
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -961,24 +986,130 @@ 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);

if (world != null)
{
long currentDay = world.getWorldTime() / 24000;
Log.writeDataToLogFile(0, "cDay: " + currentDay);
return currentDay == (Integer)targetDay;
return currentDay % interval == 0;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,19 @@ public static class CommonKeyWorlds

public static final AttributeKey<Integer> GET_MOON_PHASE = AttributeKey.create(AttributeType.INTEGER, "moon_phase");

public static final AttributeKey<Integer> GET_CURRENT_GAME_DAY = AttributeKey.create(AttributeType.INTEGER, "current_day");
//-' '='
public static final AttributeKey<Long> GET_CURRENT_GAME_DAY_EQUAL = AttributeKey.create(AttributeType.LONG, "current_day_equal");
//-' '>'
public static final AttributeKey<Long> GET_CURRENT_GAME_DAY_GREATER = AttributeKey.create(AttributeType.LONG, "current_day_greater");
//-' '<'
public static final AttributeKey<Long> GET_CURRENT_GAME_DAY_LESS = AttributeKey.create(AttributeType.LONG, "current_day_less");
//-' '>='
public static final AttributeKey<Long> GET_CURRENT_GAME_DAY_GREATER_OR_EQUAL = AttributeKey.create(AttributeType.LONG, "current_day_greater_or_equal");
//-' '<='
public static final AttributeKey<Long> GET_CURRENT_GAME_DAY_LESS_OR_EQUAL = AttributeKey.create(AttributeType.LONG, "current_day_less_or_equal");

//-' currentDay % value == 0 -> true
public static final AttributeKey<Long> GET_CURRENT_GAME_DAY_INTERVAL = AttributeKey.create(AttributeType.LONG, "current_day_interval");

public static final AttributeKey<String> MOB = AttributeKey.create(AttributeType.STRING, "mob");

Expand Down

0 comments on commit 4f01d5f

Please sign in to comment.