Implement World limitations at startup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bea 2022-11-12 04:44:35 +01:00
parent 09884f1646
commit 73bb8e4de2
3 changed files with 51 additions and 6 deletions

View File

@ -6,10 +6,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import wtf.beatrice.limbomanager.commands.Spawn;
import wtf.beatrice.limbomanager.listeners.CommandCanceller;
import wtf.beatrice.limbomanager.listeners.PlayerChecker;
import wtf.beatrice.limbomanager.listeners.PlayerTeleporter;
import wtf.beatrice.limbomanager.listeners.RiskyBlocksHandler;
import wtf.beatrice.limbomanager.listeners.*;
import wtf.beatrice.limbomanager.objects.LocationCheckRunnable;
import wtf.beatrice.limbomanager.utils.FileUtils;
@ -36,6 +33,7 @@ public class LimboManager extends JavaPlugin {
pluginManager.registerEvents(new PlayerTeleporter(), this);
pluginManager.registerEvents(new CommandCanceller(), this);
pluginManager.registerEvents(new RiskyBlocksHandler(), this);
pluginManager.registerEvents(new WorldLoadHandler(), this);
// no need to check if folder exists, it will just skip creation.
getDataFolder().mkdirs();

View File

@ -0,0 +1,46 @@
package wtf.beatrice.limbomanager.listeners;
import org.bukkit.Difficulty;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent;
public class WorldLoadHandler implements Listener
{
@EventHandler
public void onWorldLoad(WorldLoadEvent event)
{
World loaded = event.getWorld();
loaded.setDifficulty(Difficulty.PEACEFUL);
loaded.setAutoSave(false);
loaded.setFullTime(6000L);
loaded.setPVP(false);
loaded.setStorm(false);
loaded.setHardcore(false);
loaded.setGameRule(GameRule.DO_INSOMNIA, false);
loaded.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
loaded.setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
loaded.setGameRule(GameRule.DISABLE_RAIDS, true);
loaded.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
loaded.setGameRule(GameRule.DO_ENTITY_DROPS, false);
loaded.setGameRule(GameRule.DO_FIRE_TICK,false);
loaded.setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, true);
loaded.setGameRule(GameRule.DO_MOB_LOOT, false);
loaded.setGameRule(GameRule.DO_MOB_SPAWNING, false);
loaded.setGameRule(GameRule.DO_PATROL_SPAWNING, false);
loaded.setGameRule(GameRule.DO_TILE_DROPS, false);
loaded.setGameRule(GameRule.DO_TRADER_SPAWNING, false);
loaded.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
loaded.setGameRule(GameRule.DO_WARDEN_SPAWNING, false);
loaded.setGameRule(GameRule.FALL_DAMAGE, false);
loaded.setGameRule(GameRule.FIRE_DAMAGE, false);
loaded.setGameRule(GameRule.DROWNING_DAMAGE, false);
loaded.setGameRule(GameRule.FREEZE_DAMAGE, false);
loaded.setGameRule(GameRule.MOB_GRIEFING, false);
loaded.setGameRule(GameRule.NATURAL_REGENERATION, false);
loaded.setGameRule(GameRule.SHOW_DEATH_MESSAGES, false);
loaded.setGameRule(GameRule.KEEP_INVENTORY, false);
}
}

View File

@ -1,6 +1,7 @@
name: LimboManager
main: wtf.beatrice.limbomanager.LimboManager
version: 0.0.2
version: 0.0.3
load: STARTUP
description: Mix of tools to run a Limbo server
api-version: 1.19
author: astro_bea
@ -10,4 +11,4 @@ depend:
commands:
spawn:
usage: /<command>
description: teleport to player island spawn
description: teleport a player to their own island