/* * Copyright (c) 2018 univento.eu - All rights reserved * You are not allowed to use, distribute or modify this code */ package eu.univento.teamvento; import eu.univento.commons.server.ServerType; import eu.univento.core.api.Config; import eu.univento.core.api.command.CommandFramework; import eu.univento.core.api.server.ServerSettings; import eu.univento.teamvento.commands.PlotInfo; import eu.univento.teamvento.commands.WorldCommands; import eu.univento.teamvento.generator.GeneratorManager; import eu.univento.teamvento.listener.Events; import eu.univento.teamvento.listener.JoinQuit; import eu.univento.teamvento.listener.MenuEvents; import eu.univento.teamvento.listener.SignInteract; import eu.univento.teamvento.plot.PlotManager; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Difficulty; import org.bukkit.GameMode; import org.bukkit.World; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import java.io.File; /** * @author joethei * @version 1.0 */ public class TeamVento extends JavaPlugin { @Getter private static final File configFile = new File("plugins/Core", "worlds.yml"); @Getter private static final FileConfiguration cfg = YamlConfiguration.loadConfiguration(configFile); @Getter private static TeamVento instance; @Override public void onEnable() { instance = this; CommandFramework commandFramework = new CommandFramework(this); commandFramework.registerCommands(new WorldCommands()); PluginManager pm = Bukkit.getPluginManager(); pm.registerEvents(new JoinQuit(), this); pm.registerEvents(new SignInteract(), this); pm.registerEvents(new MenuEvents(), this); pm.registerEvents(new Events(), this); new PlotInfo(this, "plotinfo", "info about a plot", "pi"); for(String world : getCfg().getKeys(true)) { World loadedWorld = Bukkit.createWorld(GeneratorManager.getWorldCreator(world, getCfg().getString(world))); loadedWorld.setDifficulty(Difficulty.HARD); loadedWorld.setPVP(false); loadedWorld.setAnimalSpawnLimit(0); } ServerSettings.setup(ServerType.TEAM_BUILD, GameMode.CREATIVE); PlotManager.update(); //Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Bukkit.getWorlds().stream().filter(world -> world.getTime() > 7698).forEach(world -> world.setTime(0)), 100 * 20L, 20L); Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Events.redstone = 0, 1L, 10 * 20L); } @Override public void onDisable() { Config.write(PlotManager.getLastPlot().getOwner().toString()); Bukkit.getWorld("plots").getLivingEntities().forEach(Entity::remove); } }