TeamVento/src/main/java/eu/univento/teamvento/TeamVento.java

78 lines
2.9 KiB
Java
Raw Normal View History

2018-01-15 12:27:22 +01:00
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
2016-04-30 07:36:43 +02:00
package eu.univento.teamvento;
2017-06-04 13:47:12 +02:00
import eu.univento.commons.server.ServerType;
2016-07-09 13:19:56 +02:00
import eu.univento.core.api.Config;
2017-06-04 13:47:12 +02:00
import eu.univento.core.api.command.CommandFramework;
2016-04-30 07:36:43 +02:00
import eu.univento.core.api.server.ServerSettings;
2018-01-15 12:27:22 +01:00
import eu.univento.teamvento.commands.PlotInfo;
2017-06-04 13:47:12 +02:00
import eu.univento.teamvento.commands.WorldCommands;
2018-01-15 12:27:22 +01:00
import eu.univento.teamvento.generator.GeneratorManager;
2017-06-04 13:47:12 +02:00
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;
2018-01-15 12:27:22 +01:00
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.World;
2016-04-30 07:36:43 +02:00
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
2016-07-09 13:19:56 +02:00
import org.bukkit.entity.Entity;
2016-04-30 07:36:43 +02:00
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
/**
* @author joethei
2016-11-24 20:00:03 +01:00
* @version 1.0
2016-04-30 07:36:43 +02:00
*/
2016-11-24 20:00:03 +01:00
2016-04-30 07:36:43 +02:00
public class TeamVento extends JavaPlugin {
2018-01-15 12:27:22 +01:00
@Getter private static final File configFile = new File("plugins/Core", "worlds.yml");
@Getter private static final FileConfiguration cfg = YamlConfiguration.loadConfiguration(configFile);
2016-04-30 07:36:43 +02:00
2018-01-15 12:27:22 +01:00
@Getter private static TeamVento instance;
2017-06-04 13:47:12 +02:00
2016-04-30 07:36:43 +02:00
@Override
public void onEnable() {
instance = this;
2017-06-04 13:47:12 +02:00
CommandFramework commandFramework = new CommandFramework(this);
commandFramework.registerCommands(new WorldCommands());
2016-04-30 07:36:43 +02:00
PluginManager pm = Bukkit.getPluginManager();
2018-01-15 12:27:22 +01:00
pm.registerEvents(new JoinQuit(), this);
pm.registerEvents(new SignInteract(), this);
pm.registerEvents(new MenuEvents(), this);
pm.registerEvents(new Events(), this);
2017-06-04 13:47:12 +02:00
2018-01-15 12:27:22 +01:00
new PlotInfo(this, "plotinfo", "info about a plot", "pi");
2016-07-09 13:19:56 +02:00
for(String world : getCfg().getKeys(true)) {
2017-06-04 13:47:12 +02:00
World loadedWorld = Bukkit.createWorld(GeneratorManager.getWorldCreator(world, getCfg().getString(world)));
loadedWorld.setDifficulty(Difficulty.HARD);
2016-04-30 07:36:43 +02:00
loadedWorld.setPVP(false);
2016-07-09 13:19:56 +02:00
loadedWorld.setAnimalSpawnLimit(0);
2016-04-30 07:36:43 +02:00
}
2018-01-15 12:27:22 +01:00
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);
2016-07-09 13:19:56 +02:00
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Events.redstone = 0, 1L, 10 * 20L);
2016-04-30 07:36:43 +02:00
}
@Override
public void onDisable() {
2016-08-03 00:28:53 +02:00
Config.write(PlotManager.getLastPlot().getOwner().toString());
2016-07-09 13:19:56 +02:00
Bukkit.getWorld("plots").getLivingEntities().forEach(Entity::remove);
2016-04-30 07:36:43 +02:00
}
}