Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pink.zakshearman.lobby;
- import org.bukkit.configuration.InvalidConfigurationException;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.plugin.java.JavaPlugin;
- import pink.zakshearman.lobby.commands.BroadcastCommand;
- import pink.zakshearman.lobby.commands.HelpCommand;
- import pink.zakshearman.lobby.commands.SpawnCommand;
- import pink.zakshearman.lobby.modules.*;
- import pink.zakshearman.lobby.modules.maxplayers.MaxLoginEvent;
- import pink.zakshearman.lobby.modules.maxplayers.MaxServerPing;
- import pink.zakshearman.lobby.modules.maxplayers.MaxSlotsCommand;
- import java.io.File;
- import java.io.IOException;
- import java.util.Arrays;
- public final class Lobby extends JavaPlugin {
- private File languageConfigFile;
- public FileConfiguration languageFile;
- public FileConfiguration config;
- @Override
- public void onEnable() {
- createLanguageFile();
- this.saveDefaultConfig();
- Arrays.stream(Config.values()).forEach(value -> value.cache(config));
- Arrays.stream(Language.values()).forEach(value -> value.cache(languageFile));
- config = this.getConfig();
- getServer().getPluginManager().registerEvents(new BlockBreak(), this);
- getServer().getPluginManager().registerEvents(new BlockChat(), this);
- getServer().getPluginManager().registerEvents(new BlockCommands(), this);
- getServer().getPluginManager().registerEvents(new BlockPlace(), this);
- getServer().getPluginManager().registerEvents(new DisableHunger(), this);
- getServer().getPluginManager().registerEvents(new JoinMessages(this), this);
- getServer().getPluginManager().registerEvents(new BlockDamage(), this);
- getCommand("help").setExecutor(new HelpCommand());
- getCommand("spawn").setExecutor(new SpawnCommand());
- getCommand("broadcast").setExecutor(new BroadcastCommand());
- //MaxPlayers
- getServer().getPluginManager().registerEvents(new MaxLoginEvent(), this);
- getServer().getPluginManager().registerEvents(new MaxServerPing(), this);
- getCommand("slots").setExecutor(new MaxSlotsCommand());
- VoidFall vf = new VoidFall(this);
- vf.runCheck();
- }
- @Override
- public void onDisable() {
- Arrays.stream(Config.values()).forEach(value -> this.config.set(value.getSection(), value.getValue()));
- this.saveConfig();
- }
- private void createLanguageFile() {
- languageConfigFile = new File(getDataFolder(), "language.yml");
- if(!languageConfigFile.exists()) {
- //noinspection ResultOfMethodCallIgnored
- languageConfigFile.getParentFile().mkdirs();
- saveResource("language.yml", false);
- }
- languageFile = new YamlConfiguration();
- try {
- languageFile.load(languageConfigFile);
- } catch (IOException | InvalidConfigurationException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement