package eu.univento.teamvento; import eu.univento.core.api.Config; import eu.univento.core.api.server.ServerSettings; import eu.univento.teamvento.commands.*; import eu.univento.teamvento.listener.*; import eu.univento.teamvento.utils.PlotManager; import eu.univento.teamvento.utils.VoidGenerator; import org.bukkit.*; 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; import java.util.logging.Level; import java.util.logging.Logger; /** * @author joethei * @version 0.1 */ public class TeamVento extends JavaPlugin { private static File file = new File("plugins/Core", "worlds.yml"); private static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); public static File getConfigFile() { return file; } public static FileConfiguration getCfg() { return cfg; } private static TeamVento instance; public static TeamVento getInstance() { return instance; } private static Logger logger = Bukkit.getLogger(); private static void log(Level level, String string) { logger.log(level, "[" + getInstance().getDescription().getName() + "] " + string); } @Override public void onEnable() { instance = this; PluginManager pm = Bukkit.getPluginManager(); pm.registerEvents(new JoinQuit(), this); pm.registerEvents(new Events(), this); pm.registerEvents(new PositionSetter(), this); pm.registerEvents(new SignInteract(), this); pm.registerEvents(new MenuEvents(), this); new Setloc(this, "setloc" , "sets locations"); new WorldTP(this, "worldtp", "teleports players to other worlds", "wtp"); new WorldCreate(this, "worldcreate", "creates new worlds", "wc"); new WorldImport(this, "worldimport", "imports worlds", "wi"); new Set(this, "set", "sets the material of selected blocks"); new Sel(this, "sel", "removes block selection"); new WorldList(this, "worldlist", "lists all worlds", "wl"); new PlotInfo(this, "plotinfo", "info about a plot", "pi"); new Pack(this, "pack", "sets resource pack"); for(String world : getCfg().getKeys(true)) { String generator = getCfg().getString(world); WorldCreator creator = new WorldCreator(world); creator.generateStructures(false); if(generator.equals("normal")) { creator.environment(World.Environment.NORMAL); creator.type(WorldType.NORMAL); } if(generator.equals("flat")) { creator.environment(World.Environment.NORMAL); creator.type(WorldType.FLAT); creator.generateStructures(false); } if(generator.equals("void")) { creator.generator(new VoidGenerator()); creator.type(WorldType.CUSTOMIZED); creator.generateStructures(false); } Bukkit.createWorld(creator); World loadedWorld = Bukkit.getWorld(world); loadedWorld.setDifficulty(Difficulty.PEACEFUL); loadedWorld.setPVP(false); loadedWorld.setAnimalSpawnLimit(0); } ServerSettings.setGameMode(GameMode.CREATIVE); ServerSettings.setBuild(true); PlotManager.update(); PlotManager.setLastPlot(PlotManager.getPlotByOwner(Config.readString("lastPlot"))); log(Level.INFO, "Plugin ver." + getDescription().getVersion() + " gestartet"); 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("lastPlot", PlotManager.getLastPlot().getOwner().toString()); Bukkit.getWorld("plots").getLivingEntities().forEach(Entity::remove); log(Level.INFO, "Plugin beendet"); } }