Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* */ package io.github.rushy.Rushy;
- /* */
- /* */ import com.bugsnag.Bugsnag;
- /* */ import com.bugsnag.Report;
- /* */ import com.bugsnag.callbacks.Callback;
- /* */ import com.google.common.collect.ImmutableMap;
- /* */ import io.github.rushy.Rushy.Commands.AddGameCommand;
- /* */ import io.github.rushy.Rushy.Commands.AddTeamCommand;
- /* */ import io.github.rushy.Rushy.Commands.AddTeamJoinCommand;
- /* */ import io.github.rushy.Rushy.Commands.BaseCommand;
- /* */ import io.github.rushy.Rushy.Commands.DebugPasteCommand;
- /* */ import io.github.rushy.Rushy.Commands.GameTimeCommand;
- /* */ import io.github.rushy.Rushy.Commands.HelpCommand;
- /* */ import io.github.rushy.Rushy.Commands.JoinGameCommand;
- /* */ import io.github.rushy.Rushy.Commands.KickCommand;
- /* */ import io.github.rushy.Rushy.Commands.LeaveGameCommand;
- /* */ import io.github.rushy.Rushy.Commands.ListGamesCommand;
- /* */ import io.github.rushy.Rushy.Commands.RegionNameCommand;
- /* */ import io.github.rushy.Rushy.Commands.ReloadCommand;
- /* */ import io.github.rushy.Rushy.Commands.RemoveGameCommand;
- /* */ import io.github.rushy.Rushy.Commands.RemoveHoloCommand;
- /* */ import io.github.rushy.Rushy.Commands.RemoveTeamCommand;
- /* */ import io.github.rushy.Rushy.Commands.SaveGameCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetAutobalanceCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetBedCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetGameBlockCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetLobbyCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetMainLobbyCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetMinPlayersCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetRegionCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetSpawnCommand;
- /* */ import io.github.rushy.Rushy.Commands.SetSpawnerCommand;
- /* */ import io.github.rushy.Rushy.Commands.StartGameCommand;
- /* */ import io.github.rushy.Rushy.Commands.StopGameCommand;
- /* */ import io.github.rushy.Rushy.Database.DatabaseManager;
- /* */ import io.github.rushy.Rushy.Game.Game;
- /* */ import io.github.rushy.Rushy.Game.GameManager;
- /* */ import io.github.rushy.Rushy.Game.GameState;
- /* */ import io.github.rushy.Rushy.Game.Region;
- /* */ import io.github.rushy.Rushy.Game.RessourceSpawner;
- /* */ import io.github.rushy.Rushy.Game.Team;
- /* */ import io.github.rushy.Rushy.Listener.BlockListener;
- /* */ import io.github.rushy.Rushy.Listener.ChunkListener;
- /* */ import io.github.rushy.Rushy.Listener.EntityListener;
- /* */ import io.github.rushy.Rushy.Listener.Player19Listener;
- /* */ import io.github.rushy.Rushy.Listener.PlayerListener;
- /* */ import io.github.rushy.Rushy.Listener.PlayerSpigotListener;
- /* */ import io.github.rushy.Rushy.Listener.ServerListener;
- /* */ import io.github.rushy.Rushy.Listener.SignListener;
- /* */ import io.github.rushy.Rushy.Listener.WeatherListener;
- /* */ import io.github.rushy.Rushy.Localization.LocalizationConfig;
- /* */ import io.github.rushy.Rushy.Statistics.PlayerStatisticManager;
- /* */ import io.github.rushy.Rushy.Statistics.StorageType;
- /* */ import io.github.rushy.Rushy.Updater.ConfigUpdater;
- /* */ import io.github.rushy.Rushy.Updater.DatabaseUpdater;
- /* */ import io.github.rushy.Rushy.Updater.PluginUpdater;
- /* */ import io.github.rushy.Rushy.Updater.PluginUpdater.UpdateCallback;
- /* */ import io.github.rushy.Rushy.Updater.PluginUpdater.UpdateResult;
- /* */ import io.github.rushy.Rushy.Updater.PluginUpdater.UpdateType;
- /* */ import io.github.rushy.Rushy.Utils.BedwarsCommandExecutor;
- /* */ import io.github.rushy.Rushy.Utils.ChatWriter;
- /* */ import io.github.rushy.Rushy.Utils.SupportData;
- /* */ import io.github.rushy.Rushy.Utils.Utils;
- /* */ import java.io.BufferedReader;
- /* */ import java.io.File;
- /* */ import java.io.FileInputStream;
- /* */ import java.io.FileOutputStream;
- /* */ import java.io.InputStreamReader;
- /* */ import java.io.OutputStreamWriter;
- /* */ import java.util.ArrayList;
- /* */ import java.util.Iterator;
- /* */ import java.util.List;
- /* */ import java.util.Map;
- /* */ import java.util.Map.Entry;
- /* */ import org.bukkit.Bukkit;
- /* */ import org.bukkit.ChatColor;
- /* */ import org.bukkit.Location;
- /* */ import org.bukkit.Material;
- /* */ import org.bukkit.Server;
- /* */ import org.bukkit.World;
- /* */ import org.bukkit.command.ConsoleCommandSender;
- /* */ import org.bukkit.command.PluginCommand;
- /* */ import org.bukkit.configuration.file.FileConfiguration;
- /* */ import org.bukkit.configuration.file.FileConfigurationOptions;
- /* */ import org.bukkit.configuration.file.YamlConfiguration;
- /* */ import org.bukkit.configuration.serialization.ConfigurationSerialization;
- /* */ import org.bukkit.plugin.PluginDescriptionFile;
- /* */ import org.bukkit.plugin.PluginManager;
- /* */ import org.bukkit.plugin.java.JavaPlugin;
- /* */ import org.bukkit.plugin.messaging.Messenger;
- /* */ import org.bukkit.scheduler.BukkitRunnable;
- /* */ import org.bukkit.scheduler.BukkitScheduler;
- /* */ import org.bukkit.scheduler.BukkitTask;
- /* */ import org.bukkit.scoreboard.ScoreboardManager;
- /* */ import org.mcstats.Metrics;
- /* */
- /* */ public class Main extends JavaPlugin
- /* */ {
- /* 99 */ private static Main instance = null;
- /* */
- /* 101 */ public static int PROJECT_ID = 91743;
- /* */
- /* 103 */ private ArrayList<BaseCommand> commands = new ArrayList();
- /* 104 */ private BukkitTask timeTask = null;
- /* 105 */ private Package craftbukkit = null;
- /* 106 */ private Package minecraft = null;
- /* 107 */ private String version = null;
- /* 108 */ private LocalizationConfig localization = null;
- /* 109 */ private DatabaseManager dbManager = null;
- /* 110 */ private BukkitTask updateChecker = null;
- /* */
- /* 112 */ private List<Material> breakableTypes = null;
- /* 113 */ private YamlConfiguration shopConfig = null;
- /* */
- /* 115 */ private IHologramInteraction holographicInteraction = null;
- /* */
- /* 117 */ private boolean isSpigot = false;
- /* */
- /* 119 */ private static Boolean locationSerializable = null;
- /* */
- /* 121 */ private PlayerStatisticManager playerStatisticManager = null;
- /* */
- /* 123 */ private ScoreboardManager scoreboardManager = null;
- /* 124 */ private GameManager gameManager = null;
- /* 125 */ public Bugsnag getBugsnag() { return this.bugsnag; }
- /* */
- /* */
- /* */ public void onEnable()
- /* */ {
- /* 130 */ instance = this;
- /* */
- /* 132 */ registerBugsnag();
- /* */
- /* */
- /* 135 */ registerConfigurationClasses();
- /* */
- /* */
- /* 138 */ saveDefaultConfig();
- /* 139 */ loadConfigInUTF();
- /* */
- /* 141 */ getConfig().options().copyDefaults(true);
- /* 142 */ getConfig().options().copyHeader(true);
- /* */
- /* 144 */ this.craftbukkit = getCraftBukkit();
- /* 145 */ this.minecraft = getMinecraftPackage();
- /* 146 */ this.version = loadVersion();
- /* */
- /* 148 */ ConfigUpdater configUpdater = new ConfigUpdater();
- /* 149 */ configUpdater.addConfigs();
- /* 150 */ saveConfiguration();
- /* 151 */ loadConfigInUTF();
- /* */
- /* 153 */ if (getBooleanConfig("send-error-data", true)) {
- /* 154 */ enableBugsnag();
- /* */ } else {
- /* 156 */ disableBugsnag();
- /* */ }
- /* */
- /* 159 */ configUpdater.updateShop();
- /* 160 */ loadShop();
- /* */
- /* 162 */ this.isSpigot = getIsSpigot();
- /* 163 */ loadDatabase();
- /* */
- /* 165 */ registerCommands();
- /* 166 */ registerListener();
- /* */
- /* 168 */ this.gameManager = new GameManager();
- /* */
- /* */
- /* 171 */ if (getInstance().isBungee()) {
- /* 172 */ getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
- /* */ }
- /* */
- /* 175 */ loadStatistics();
- /* 176 */ this.localization = loadLocalization();
- /* */
- /* 178 */ checkUpdates();
- /* */
- /* */
- /* 181 */ this.scoreboardManager = Bukkit.getScoreboardManager();
- /* 182 */ this.gameManager.loadGames();
- /* 183 */ startTimeListener();
- /* 184 */ startMetricsIfEnabled();
- /* */
- /* */
- /* 187 */ if (isHologramsEnabled()) {
- /* 188 */ if (getServer().getPluginManager().isPluginEnabled("HologramAPI")) {
- /* 189 */ this.holographicInteraction = new HologramAPIInteraction();
- /* 190 */ } else if (getServer().getPluginManager().isPluginEnabled("HolographicDisplays")) {
- /* 191 */ this.holographicInteraction = new HolographicDisplaysInteraction();
- /* */ }
- /* 193 */ this.holographicInteraction.loadHolograms();
- /* */ }
- /* */ }
- /* */
- /* */ private void registerBugsnag() {
- /* 198 */ this.bugsnag = new Bugsnag("c23593c1e2f40fc0da36564af1bd00c6");
- /* 199 */ this.bugsnag.setAppVersion(SupportData.getPluginVersion());
- /* 200 */ this.bugsnag.setProjectPackages(new String[] { "io.github.bedwarsrel" });
- /* 201 */ this.bugsnag.setReleaseStage(SupportData.getPluginVersionType());
- /* */ }
- /* */
- /* */ private void enableBugsnag() {
- /* 205 */ this.bugsnag.addCallback(new Callback()
- /* */ {
- /* */ public void beforeNotify(Report report) {
- /* 208 */ Boolean shouldBeSent = Boolean.valueOf(false);
- /* 209 */ for (StackTraceElement stackTraceElement : report.getException().getStackTrace()) {
- /* 210 */ if (stackTraceElement.toString().contains("io.github.rushy.Rushy")) {
- /* 211 */ shouldBeSent = Boolean.valueOf(true);
- /* 212 */ break;
- /* */ }
- /* */ }
- /* 215 */ if (!shouldBeSent.booleanValue()) {
- /* 216 */ report.cancel();
- /* */ }
- /* */
- /* 219 */ report.setUserId(SupportData.getIdentifier());
- /* 220 */ if (!SupportData.getPluginVersionBuild().equalsIgnoreCase("unknown")) {
- /* 221 */ report.addToTab("Server", "Version Build", Main.getInstance().getDescription().getVersion() + " " + SupportData.getPluginVersionBuild());
- /* */ }
- /* */
- /* */
- /* 225 */ report.addToTab("Server", "Version", SupportData.getServerVersion());
- /* 226 */ report.addToTab("Server", "Version Bukkit", SupportData.getBukkitVersion());
- /* 227 */ report.addToTab("Server", "Server Mode", SupportData.getServerMode());
- /* 228 */ report.addToTab("Server", "Plugins", SupportData.getPlugins());
- /* */ }
- /* */ });
- /* */ }
- /* */
- /* */ private void disableBugsnag() {
- /* 234 */ this.bugsnag.addCallback(new Callback()
- /* */ {
- /* */ public void beforeNotify(Report report) {
- /* 237 */ report.cancel();
- /* */ }
- /* */ });
- /* */ }
- /* */
- /* */ public void onDisable()
- /* */ {
- /* 244 */ stopTimeListener();
- /* 245 */ this.gameManager.unloadGames();
- /* 246 */ cleanDatabase();
- /* */
- /* 248 */ if ((isHologramsEnabled()) && (this.holographicInteraction != null)) {
- /* 249 */ this.holographicInteraction.unloadHolograms();
- /* */ }
- /* */ }
- /* */
- /* */ public void loadConfigInUTF() {
- /* 254 */ File configFile = new File(getDataFolder(), "config.yml");
- /* 255 */ if (!configFile.exists()) {
- /* 256 */ return;
- /* */ }
- /* */ try
- /* */ {
- /* 260 */ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), "UTF-8"));
- /* */
- /* 262 */ getConfig().load(reader);
- /* */ } catch (Exception e) {
- /* 264 */ getInstance().getBugsnag().notify(e);
- /* 265 */ e.printStackTrace();
- /* */ }
- /* */
- /* 268 */ if (getConfig() == null) {
- /* 269 */ return;
- /* */ }
- /* */
- /* */
- /* 273 */ this.breakableTypes = new ArrayList();
- /* 274 */ for (String material : getConfig().getStringList("breakable-blocks.list"))
- /* 275 */ if (!material.equalsIgnoreCase("none"))
- /* */ {
- /* */
- /* */
- /* 279 */ Material mat = Utils.parseMaterial(material);
- /* 280 */ if ((mat != null) &&
- /* */
- /* */
- /* */
- /* 284 */ (!this.breakableTypes.contains(mat)))
- /* */ {
- /* */
- /* */
- /* 288 */ this.breakableTypes.add(mat); }
- /* */ }
- /* */ }
- /* */
- /* */ public void loadShop() {
- /* 293 */ File file = new File(getInstance().getDataFolder(), "shop.yml");
- /* 294 */ if (!file.exists())
- /* */ {
- /* 296 */ saveResource("shop.yml", false);
- /* */
- /* */ try
- /* */ {
- /* 300 */ Thread.sleep(100L);
- /* */ } catch (InterruptedException e) {
- /* 302 */ getInstance().getBugsnag().notify(e);
- /* 303 */ e.printStackTrace();
- /* */ }
- /* */ }
- /* */
- /* 307 */ this.shopConfig = new YamlConfiguration();
- /* */ try
- /* */ {
- /* 310 */ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
- /* */
- /* 312 */ this.shopConfig.load(reader);
- /* */ } catch (Exception e) {
- /* 314 */ getInstance().getBugsnag().notify(e);
- /* 315 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + "Couldn't load shop! Error in parsing shop!"));
- /* */
- /* 317 */ e.printStackTrace();
- /* */ }
- /* */ }
- /* */
- /* */ public void dispatchRewardCommands(List<String> commands, Map<String, String> replacements) {
- /* 322 */ for (String command : commands) {
- /* 323 */ command = command.trim();
- /* 324 */ if (!"".equals(command))
- /* */ {
- /* */
- /* */
- /* 328 */ if ("none".equalsIgnoreCase(command)) {
- /* */ break;
- /* */ }
- /* */
- /* 332 */ if (command.startsWith("/")) {
- /* 333 */ command = command.substring(1);
- /* */ }
- /* */
- /* 336 */ for (Map.Entry<String, String> entry : replacements.entrySet()) {
- /* 337 */ command = command.replace((CharSequence)entry.getKey(), (CharSequence)entry.getValue());
- /* */ }
- /* */
- /* 340 */ getInstance().getServer().dispatchCommand(getInstance().getServer().getConsoleSender(), command);
- /* */ }
- /* */ }
- /* */ }
- /* */
- /* */ public void saveConfiguration() {
- /* 346 */ File file = new File(getInstance().getDataFolder(), "config.yml");
- /* */ try {
- /* 348 */ file.mkdirs();
- /* */
- /* 350 */ String data = getYamlDump((YamlConfiguration)getConfig());
- /* */
- /* 352 */ FileOutputStream stream = new FileOutputStream(file);
- /* 353 */ OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8");
- /* */ try
- /* */ {
- /* 356 */ writer.write(data);
- /* */ } finally {
- /* 358 */ writer.close();
- /* 359 */ stream.close();
- /* */ }
- /* */ } catch (Exception ex) {
- /* 362 */ getInstance().getBugsnag().notify(ex);
- /* 363 */ ex.printStackTrace();
- /* */ }
- /* */ }
- /* */
- /* */ public Class<?> getVersionRelatedClass(String className) {
- /* */ try {
- /* 369 */ return Class.forName("io.github.rushy.Rushy.Com." + getCurrentVersion() + "." + className);
- /* */ }
- /* */ catch (Exception ex)
- /* */ {
- /* 373 */ getInstance().getBugsnag().notify(ex);
- /* 374 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + "Couldn't find version related class io.github.rushy.Rushy.Com." + getCurrentVersion() + "." + className));
- /* */ }
- /* */
- /* */
- /* */
- /* */
- /* 380 */ return null;
- /* */ }
- /* */
- /* */ public String getYamlDump(YamlConfiguration config) {
- /* */ try {
- /* 385 */ String fullstring = config.saveToString();
- /* 386 */ String endstring = fullstring;
- /* 387 */ return Utils.unescape_perl_string(fullstring);
- /* */ }
- /* */ catch (Exception ex)
- /* */ {
- /* 391 */ getInstance().getBugsnag().notify(ex);
- /* 392 */ ex.printStackTrace();
- /* */ }
- /* */
- /* 395 */ return null;
- /* */ }
- /* */
- /* */ public boolean isBreakableType(Material type) {
- /* 399 */ return ((getInstance().getConfig().getBoolean("breakable-blocks.use-as-blacklist")) && (!this.breakableTypes.contains(type))) || ((!getInstance().getConfig().getBoolean("breakable-blocks.use-as-blacklist")) && (this.breakableTypes.contains(type)));
- /* */ }
- /* */
- /* */
- /* */ public boolean isMineshafterPresent()
- /* */ {
- /* */ try
- /* */ {
- /* 407 */ Class.forName("mineshafter.MineServer");
- /* 408 */ return true;
- /* */ }
- /* */ catch (Exception e) {}
- /* 411 */ return false;
- /* */ }
- /* */
- /* */ public PlayerStatisticManager getPlayerStatisticManager()
- /* */ {
- /* 416 */ return this.playerStatisticManager;
- /* */ }
- /* */
- /* */ private void checkUpdates() {
- /* */ try {
- /* 421 */ if (getBooleanConfig("check-updates", true)) {
- /* 422 */ this.updateChecker = new BukkitRunnable()
- /* */ {
- /* */ public void run()
- /* */ {
- /* 426 */ final BukkitRunnable task = this;
- /* 427 */ PluginUpdater.UpdateCallback callback = new PluginUpdater.UpdateCallback()
- /* */ {
- /* */ public void onFinish(PluginUpdater updater)
- /* */ {
- /* 431 */ if (updater.getResult() == PluginUpdater.UpdateResult.SUCCESS) {
- /* 432 */ task.cancel();
- /* */ }
- /* */
- /* */ }
- /* 436 */ };
- /* 437 */ new PluginUpdater(Main.getInstance(), Main.PROJECT_ID, Main.getInstance().getFile(), PluginUpdater.UpdateType.DEFAULT, callback, Main.getInstance().getBooleanConfig("update-infos", true)); } }.runTaskTimerAsynchronously(getInstance(), 40L, 36000L);
- /* */ }
- /* */
- /* */
- /* */ }
- /* */ catch (Exception ex)
- /* */ {
- /* */
- /* 445 */ getInstance().getBugsnag().notify(ex);
- /* 446 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + "Check for updates not successful: Error!"));
- /* */ }
- /* */ }
- /* */
- /* */ private LocalizationConfig loadLocalization()
- /* */ {
- /* 452 */ LocalizationConfig config = new LocalizationConfig();
- /* 453 */ config.loadLocale(getConfig().getString("locale"), false);
- /* 454 */ return config;
- /* */ }
- /* */
- /* */ private void loadStatistics() {
- /* 458 */ this.playerStatisticManager = new PlayerStatisticManager();
- /* 459 */ this.playerStatisticManager.initialize();
- /* */ }
- /* */
- /* */ private void loadDatabase() {
- /* 463 */ if ((!getBooleanConfig("statistics.enabled", false)) || (!"database".equals(getStringConfig("statistics.storage", "yaml"))))
- /* */ {
- /* 465 */ return;
- /* */ }
- /* */
- /* 468 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.GREEN + "Initialize database ..."));
- /* */
- /* */
- /* 471 */ String host = getStringConfig("database.host", null);
- /* 472 */ int port = getIntConfig("database.port", 3306);
- /* 473 */ String user = getStringConfig("database.user", null);
- /* 474 */ String password = getStringConfig("database.password", null);
- /* 475 */ String db = getStringConfig("database.db", null);
- /* */
- /* 477 */ if ((host == null) || (user == null) || (password == null) || (db == null)) {
- /* 478 */ return;
- /* */ }
- /* */
- /* 481 */ this.dbManager = new DatabaseManager(host, port, user, password, db);
- /* 482 */ this.dbManager.initialize();
- /* */
- /* 484 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.GREEN + "Update database ..."));
- /* */
- /* 486 */ new DatabaseUpdater().execute();
- /* */
- /* 488 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.GREEN + "Done."));
- /* */ }
- /* */
- /* */ public StorageType getStatisticStorageType()
- /* */ {
- /* 493 */ String storage = getStringConfig("statistics.storage", "yaml");
- /* 494 */ return StorageType.getByName(storage);
- /* */ }
- /* */
- /* */ public boolean statisticsEnabled() {
- /* 498 */ return getBooleanConfig("statistics.enabled", false);
- /* */ }
- /* */
- /* */ private void cleanDatabase() {
- /* 502 */ if (this.dbManager != null) {
- /* 503 */ this.dbManager.cleanUp();
- /* */ }
- /* */ }
- /* */
- /* */ public DatabaseManager getDatabaseManager() {
- /* 508 */ return this.dbManager;
- /* */ }
- /* */
- /* */ public boolean isSpigot() {
- /* 512 */ return this.isSpigot;
- /* */ }
- /* */
- /* */ private boolean getIsSpigot() {
- /* */ try {
- /* 517 */ Package spigotPackage = Package.getPackage("org.spigotmc");
- /* 518 */ return spigotPackage != null;
- /* */ } catch (Exception e) {
- /* 520 */ getInstance().getBugsnag().notify(e);
- /* */ }
- /* */
- /* 523 */ return false;
- /* */ }
- /* */
- /* */ public int getIntConfig(String key, int defaultInt) {
- /* 527 */ FileConfiguration config = getConfig();
- /* 528 */ if ((config.contains(key)) && (config.isInt(key))) {
- /* 529 */ return config.getInt(key);
- /* */ }
- /* 531 */ return defaultInt;
- /* */ }
- /* */
- /* */ public String getStringConfig(String key, String defaultString) {
- /* 535 */ FileConfiguration config = getConfig();
- /* 536 */ if ((config.contains(key)) && (config.isString(key))) {
- /* 537 */ return config.getString(key);
- /* */ }
- /* 539 */ return defaultString;
- /* */ }
- /* */
- /* */ public boolean getBooleanConfig(String key, boolean defaultBool) {
- /* 543 */ FileConfiguration config = getConfig();
- /* 544 */ if ((config.contains(key)) && (config.isBoolean(key))) {
- /* 545 */ return config.getBoolean(key);
- /* */ }
- /* 547 */ return defaultBool;
- /* */ }
- /* */
- /* */ public LocalizationConfig getLocalization() {
- /* 551 */ return this.localization;
- /* */ }
- /* */
- /* */ private String loadVersion() {
- /* 555 */ String packName = Bukkit.getServer().getClass().getPackage().getName();
- /* 556 */ return packName.substring(packName.lastIndexOf('.') + 1);
- /* */ }
- /* */
- /* */ public String getCurrentVersion() {
- /* 560 */ return this.version;
- /* */ }
- /* */
- /* */ public boolean isBungee() {
- /* 564 */ return getConfig().getBoolean("bungeecord.enabled");
- /* */ }
- /* */
- /* */ public String getBungeeHub() {
- /* 568 */ if (getConfig().contains("bungeecord.hubserver")) {
- /* 569 */ return getConfig().getString("bungeecord.hubserver");
- /* */ }
- /* */
- /* 572 */ return null;
- /* */ }
- /* */
- /* */ public Package getCraftBukkit() {
- /* */ try {
- /* 577 */ if (this.craftbukkit == null) {
- /* 578 */ return Package.getPackage("org.bukkit.craftbukkit." + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]);
- /* */ }
- /* */
- /* 581 */ return this.craftbukkit;
- /* */ }
- /* */ catch (Exception ex) {
- /* 584 */ getInstance().getBugsnag().notify(ex);
- /* 585 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + _l("errors.packagenotfound", ImmutableMap.of("package", "craftbukkit"))));
- /* */ }
- /* 587 */ return null;
- /* */ }
- /* */
- /* */ public Package getMinecraftPackage()
- /* */ {
- /* */ try {
- /* 593 */ if (this.minecraft == null) {
- /* 594 */ return Package.getPackage("net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]);
- /* */ }
- /* */
- /* 597 */ return this.minecraft;
- /* */ }
- /* */ catch (Exception ex) {
- /* 600 */ getInstance().getBugsnag().notify(ex);
- /* 601 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + _l("errors.packagenotfound", ImmutableMap.of("package", "minecraft server"))));
- /* */ }
- /* 603 */ return null;
- /* */ }
- /* */
- /* */ public Class getCraftBukkitClass(String classname)
- /* */ {
- /* */ try
- /* */ {
- /* 610 */ if (this.craftbukkit == null) {
- /* 611 */ this.craftbukkit = getCraftBukkit();
- /* */ }
- /* */
- /* 614 */ return Class.forName(this.craftbukkit.getName() + "." + classname);
- /* */ } catch (Exception ex) {
- /* 616 */ getInstance().getBugsnag().notify(ex);
- /* 617 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + _l("errors.classnotfound", ImmutableMap.of("package", "craftbukkit", "class", classname))));
- /* */ }
- /* */
- /* 620 */ return null;
- /* */ }
- /* */
- /* */ public Class getMinecraftServerClass(String classname)
- /* */ {
- /* */ try
- /* */ {
- /* 627 */ if (this.minecraft == null) {
- /* 628 */ this.minecraft = getMinecraftPackage();
- /* */ }
- /* */
- /* 631 */ return Class.forName(this.minecraft.getName() + "." + classname);
- /* */ } catch (Exception ex) {
- /* 633 */ getInstance().getBugsnag().notify(ex);
- /* 634 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + _l("errors.classnotfound", ImmutableMap.of("package", "minecraft server", "class", classname))));
- /* */ }
- /* */
- /* 637 */ return null;
- /* */ }
- /* */
- /* */ public boolean metricsEnabled()
- /* */ {
- /* 642 */ if ((getConfig().contains("plugin-metrics")) && (getConfig().isBoolean("plugin-metrics")))
- /* */ {
- /* 644 */ return getConfig().getBoolean("plugin-metrics");
- /* */ }
- /* */
- /* 647 */ return false;
- /* */ }
- /* */
- /* */ public void startMetricsIfEnabled() {
- /* 651 */ if (metricsEnabled()) {
- /* */ try {
- /* 653 */ Metrics metrics = new Metrics(this);
- /* 654 */ metrics.start();
- /* */ } catch (Exception ex) {
- /* 656 */ getInstance().getBugsnag().notify(ex);
- /* 657 */ getServer().getConsoleSender().sendMessage(ChatWriter.pluginMessage(ChatColor.RED + "Metrics are enabled, but couldn't send data!"));
- /* */ }
- /* */ }
- /* */ }
- /* */
- /* */ public String getFallbackLocale()
- /* */ {
- /* 664 */ return "en_US";
- /* */ }
- /* */
- /* */ public boolean allPlayersBackToMainLobby() {
- /* 668 */ if ((getConfig().contains("endgame.all-players-to-mainlobby")) && (getConfig().isBoolean("endgame.all-players-to-mainlobby")))
- /* */ {
- /* 670 */ return getConfig().getBoolean("endgame.all-players-to-mainlobby");
- /* */ }
- /* */
- /* 673 */ return false;
- /* */ }
- /* */
- /* */ public List<String> getAllowedCommands()
- /* */ {
- /* 678 */ FileConfiguration config = getConfig();
- /* 679 */ if ((config.contains("allowed-commands")) && (config.isList("allowed-commands"))) {
- /* 680 */ return config.getStringList("allowed-commands");
- /* */ }
- /* */
- /* 683 */ return new ArrayList();
- /* */ }
- /* */
- /* */ public static Main getInstance() {
- /* 687 */ return instance;
- /* */ }
- /* */
- /* */ public ScoreboardManager getScoreboardManager() {
- /* 691 */ return this.scoreboardManager;
- /* */ }
- /* */
- /* */ private void registerListener() {
- /* 695 */ new WeatherListener();
- /* 696 */ new BlockListener();
- /* 697 */ new PlayerListener();
- /* 698 */ if ((getInstance().getCurrentVersion().startsWith("v1_9")) || (getInstance().getCurrentVersion().startsWith("v1_10")) || (getInstance().getCurrentVersion().startsWith("v1_11")))
- /* */ {
- /* */
- /* 701 */ new Player19Listener();
- /* */ }
- /* 703 */ new io.github.rushy.Rushy.Listener.HangingListener();
- /* 704 */ new EntityListener();
- /* 705 */ new ServerListener();
- /* 706 */ new SignListener();
- /* 707 */ new ChunkListener();
- /* */
- /* 709 */ if (isSpigot()) {
- /* 710 */ new PlayerSpigotListener();
- /* */ }
- /* */
- /* 713 */ io.github.rushy.Rushy.Shop.Specials.SpecialItem.loadSpecials();
- /* */ }
- /* */
- /* */ private void registerConfigurationClasses() {
- /* 717 */ ConfigurationSerialization.registerClass(RessourceSpawner.class, "RessourceSpawner");
- /* 718 */ ConfigurationSerialization.registerClass(Team.class, "Team");
- /* */ }
- /* */
- /* */ private void registerCommands() {
- /* 722 */ BedwarsCommandExecutor executor = new BedwarsCommandExecutor(this);
- /* */
- /* 724 */ this.commands.add(new HelpCommand(this));
- /* 725 */ this.commands.add(new SetSpawnerCommand(this));
- /* 726 */ this.commands.add(new AddGameCommand(this));
- /* 727 */ this.commands.add(new StartGameCommand(this));
- /* 728 */ this.commands.add(new StopGameCommand(this));
- /* 729 */ this.commands.add(new SetRegionCommand(this));
- /* 730 */ this.commands.add(new AddTeamCommand(this));
- /* 731 */ this.commands.add(new SaveGameCommand(this));
- /* 732 */ this.commands.add(new JoinGameCommand(this));
- /* 733 */ this.commands.add(new SetSpawnCommand(this));
- /* 734 */ this.commands.add(new SetLobbyCommand(this));
- /* 735 */ this.commands.add(new LeaveGameCommand(this));
- /* 736 */ this.commands.add(new io.github.rushy.Rushy.Commands.SetTargetCommand(this));
- /* 737 */ this.commands.add(new SetBedCommand(this));
- /* 738 */ this.commands.add(new ReloadCommand(this));
- /* 739 */ this.commands.add(new SetMainLobbyCommand(this));
- /* 740 */ this.commands.add(new ListGamesCommand(this));
- /* 741 */ this.commands.add(new RegionNameCommand(this));
- /* 742 */ this.commands.add(new RemoveTeamCommand(this));
- /* 743 */ this.commands.add(new RemoveGameCommand(this));
- /* 744 */ this.commands.add(new io.github.rushy.Rushy.Commands.ClearSpawnerCommand(this));
- /* 745 */ this.commands.add(new GameTimeCommand(this));
- /* 746 */ this.commands.add(new io.github.rushy.Rushy.Commands.StatsCommand(this));
- /* 747 */ this.commands.add(new SetMinPlayersCommand(this));
- /* 748 */ this.commands.add(new SetGameBlockCommand(this));
- /* 749 */ this.commands.add(new io.github.rushy.Rushy.Commands.SetBuilderCommand(this));
- /* 750 */ this.commands.add(new SetAutobalanceCommand(this));
- /* 751 */ this.commands.add(new KickCommand(this));
- /* 752 */ this.commands.add(new AddTeamJoinCommand(this));
- /* 753 */ this.commands.add(new io.github.rushy.Rushy.Commands.AddHoloCommand(this));
- /* 754 */ this.commands.add(new RemoveHoloCommand(this));
- /* 755 */ this.commands.add(new DebugPasteCommand(this));
- /* */
- /* 757 */ getCommand("rsh").setExecutor(executor);
- /* */ }
- /* */
- /* */ public ArrayList<BaseCommand> getCommands() {
- /* 761 */ return this.commands;
- /* */ }
- /* */
- /* */ private ArrayList<BaseCommand> filterCommandsByPermission(ArrayList<BaseCommand> commands, String permission)
- /* */ {
- /* 766 */ Iterator<BaseCommand> it = commands.iterator();
- /* */
- /* 768 */ while (it.hasNext()) {
- /* 769 */ BaseCommand command = (BaseCommand)it.next();
- /* 770 */ if (!command.getPermission().equals(permission)) {
- /* 771 */ it.remove();
- /* */ }
- /* */ }
- /* */
- /* 775 */ return commands;
- /* */ }
- /* */
- /* */ public ArrayList<BaseCommand> getBaseCommands()
- /* */ {
- /* 780 */ ArrayList<BaseCommand> commands = (ArrayList)this.commands.clone();
- /* 781 */ commands = filterCommandsByPermission(commands, "base");
- /* */
- /* 783 */ return commands;
- /* */ }
- /* */
- /* */ public ArrayList<BaseCommand> getSetupCommands()
- /* */ {
- /* 788 */ ArrayList<BaseCommand> commands = (ArrayList)this.commands.clone();
- /* 789 */ commands = filterCommandsByPermission(commands, "setup");
- /* */
- /* 791 */ return commands;
- /* */ }
- /* */
- /* */ public ArrayList<BaseCommand> getCommandsByPermission(String permission)
- /* */ {
- /* 796 */ ArrayList<BaseCommand> commands = (ArrayList)this.commands.clone();
- /* 797 */ commands = filterCommandsByPermission(commands, permission);
- /* */
- /* 799 */ return commands;
- /* */ }
- /* */
- /* */ public GameManager getGameManager() {
- /* 803 */ return this.gameManager;
- /* */ }
- /* */
- /* */ private void startTimeListener() {
- /* 807 */ this.timeTask = getServer().getScheduler().runTaskTimer(this, new Runnable()
- /* */ {
- /* */ public void run()
- /* */ {
- /* 811 */ for (Game g : Main.getInstance().getGameManager().getGames())
- /* 812 */ if (g.getState() == GameState.RUNNING)
- /* 813 */ g.getRegion().getWorld().setTime(g.getTime()); } }, 100L, 100L);
- /* */ }
- /* */
- /* */
- /* */
- /* */
- /* */ public static String _l(String localeKey, String singularValue, Map<String, String> params)
- /* */ {
- /* 821 */ if ("1".equals(params.get(singularValue))) {
- /* 822 */ return (String)getInstance().getLocalization().get(localeKey + "-one", params);
- /* */ }
- /* 824 */ return (String)getInstance().getLocalization().get(localeKey, params);
- /* */ }
- /* */
- /* */ public static String _l(String localeKey, Map<String, String> params) {
- /* 828 */ return (String)getInstance().getLocalization().get(localeKey, params);
- /* */ }
- /* */
- /* */ public static String _l(String localeKey) {
- /* 832 */ return (String)getInstance().getLocalization().get(localeKey);
- /* */ }
- /* */
- /* */ private void stopTimeListener() {
- /* */ try {
- /* 837 */ this.timeTask.cancel();
- /* */ }
- /* */ catch (Exception ex) {}
- /* */
- /* */ try
- /* */ {
- /* 843 */ this.updateChecker.cancel();
- /* */ }
- /* */ catch (Exception ex) {}
- /* */ }
- /* */
- /* */ public void reloadLocalization()
- /* */ {
- /* 850 */ this.localization.loadLocale(getConfig().getString("locale"), false);
- /* */ }
- /* */
- /* */ public boolean spectationEnabled() {
- /* 854 */ if ((getConfig().contains("spectation-enabled")) && (getConfig().isBoolean("spectation-enabled")))
- /* */ {
- /* 856 */ return getConfig().getBoolean("spectation-enabled");
- /* */ }
- /* 858 */ return true;
- /* */ }
- /* */
- /* */ public boolean toMainLobby() {
- /* 862 */ if (getConfig().contains("endgame.mainlobby-enabled")) {
- /* 863 */ return getConfig().getBoolean("endgame.mainlobby-enabled");
- /* */ }
- /* */
- /* 866 */ return false;
- /* */ }
- /* */
- /* */
- /* */
- /* */ private Bugsnag bugsnag;
- /* */
- /* */ public int getMaxLength()
- /* */ {
- /* 875 */ if ((getConfig().contains("gamelength")) && (getConfig().isInt("gamelength"))) {
- /* 876 */ return getConfig().getInt("gamelength") * 60;
- /* */ }
- /* */
- /* */
- /* 880 */ return 3600;
- /* */ }
- /* */
- /* */ public Integer getRespawnProtectionTime() {
- /* 884 */ FileConfiguration config = getConfig();
- /* 885 */ if ((config.contains("respawn-protection")) && (config.isInt("respawn-protection"))) {
- /* 886 */ return Integer.valueOf(config.getInt("respawn-protection"));
- /* */ }
- /* 888 */ return Integer.valueOf(0);
- /* */ }
- /* */
- /* */ public boolean isLocationSerializable() {
- /* 892 */ if (locationSerializable == null) {
- /* */ try {
- /* 894 */ Location.class.getMethod("serialize", new Class[0]);
- /* 895 */ locationSerializable = Boolean.valueOf(true);
- /* */ } catch (Exception ex) {
- /* 897 */ getInstance().getBugsnag().notify(ex);
- /* 898 */ locationSerializable = Boolean.valueOf(false);
- /* */ }
- /* */ }
- /* */
- /* 902 */ return locationSerializable.booleanValue();
- /* */ }
- /* */
- /* */ public FileConfiguration getShopConfig() {
- /* 906 */ return this.shopConfig;
- /* */ }
- /* */
- /* */ public boolean isHologramsEnabled() {
- /* 910 */ return ((getServer().getPluginManager().isPluginEnabled("HologramAPI")) && (getServer().getPluginManager().isPluginEnabled("PacketListenerApi"))) || ((getServer().getPluginManager().isPluginEnabled("HolographicDisplays")) && (getServer().getPluginManager().isPluginEnabled("ProtocolLib")));
- /* */ }
- /* */
- /* */
- /* */
- /* */ public String getMissingHoloDependency()
- /* */ {
- /* 917 */ if (!getInstance().isHologramsEnabled()) {
- /* 918 */ String missingHoloDependency = null;
- /* 919 */ if ((getServer().getPluginManager().isPluginEnabled("HologramAPI")) || (getServer().getPluginManager().isPluginEnabled("HolographicDisplays")))
- /* */ {
- /* 921 */ if (getServer().getPluginManager().isPluginEnabled("HologramAPI")) {
- /* 922 */ missingHoloDependency = "PacketListenerApi";
- /* 923 */ return missingHoloDependency;
- /* */ }
- /* 925 */ if (getServer().getPluginManager().isPluginEnabled("HolographicDisplays")) {
- /* 926 */ missingHoloDependency = "ProtocolLib";
- /* 927 */ return missingHoloDependency;
- /* */ }
- /* */ } else {
- /* 930 */ missingHoloDependency = "HolographicDisplays and ProtocolLib";
- /* 931 */ return missingHoloDependency;
- /* */ }
- /* */ }
- /* 934 */ return null;
- /* */ }
- /* */
- /* */ public IHologramInteraction getHolographicInteractor() {
- return this.holographicInteraction;
- }
- / }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement