- Add the ability to customize game rules per world in config

- Add gamerules argument to /debug
This commit is contained in:
Taah
2022-02-25 01:54:11 -08:00
parent 1b856db297
commit 1333f06dad
6 changed files with 117 additions and 78 deletions

View File

@ -1,11 +1,18 @@
package dev.plex.services.impl;
import dev.plex.Plex;
import dev.plex.services.AbstractService;
import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.World;
import java.util.Locale;
public class GameRuleService extends AbstractService
{
public GameRuleService()
@ -18,28 +25,12 @@ public class GameRuleService extends AbstractService
{
for (World world : Bukkit.getWorlds())
{
commitGameRules(world);
PlexUtils.commitGameRules(world);
PlexLog.debug("Set gamerules for world: " + world.getName());
}
}
private void commitGameRules(World world)
{
world.setGameRule(GameRule.DO_MOB_SPAWNING, false);
world.setGameRule(GameRule.DO_FIRE_TICK, false);
world.setGameRule(GameRule.KEEP_INVENTORY, true);
world.setGameRule(GameRule.DO_MOB_LOOT, false);
world.setGameRule(GameRule.MOB_GRIEFING, false);
world.setGameRule(GameRule.DO_TILE_DROPS, false);
world.setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
world.setGameRule(GameRule.NATURAL_REGENERATION, true);
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
world.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
world.setGameRule(GameRule.SHOW_DEATH_MESSAGES, false);
world.setGameRule(GameRule.SEND_COMMAND_FEEDBACK, false);
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
}
@Override
public int repeatInSeconds()