use of pl.plajer.villagedefense3.handlers.ShopManager in project Village_Defense by Plajer.
the class Main method onEnable.
@Override
public void onEnable() {
version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
new ConfigurationManager(this);
LanguageManager.init(this);
if (!(getVersion().equalsIgnoreCase("v1_8_R3") || getVersion().equalsIgnoreCase("v1_9_R1") || getVersion().equalsIgnoreCase("v1_11_R1") || getVersion().equalsIgnoreCase("v1_12_R1"))) {
BigTextUtils.thisVersionIsNotSupported();
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Your server version is not supported by Village Defense!");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Sadly, we must shut off. Maybe you consider changing your server version?");
forceDisable = true;
getServer().getPluginManager().disablePlugin(this);
return;
}
try {
Class.forName("org.spigotmc.SpigotConfig");
} catch (Exception e) {
BigTextUtils.thisVersionIsNotSupported();
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Your server software is not supported by Village Defense!");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "We support only Spigot and Spigot forks only! Shutting off...");
forceDisable = true;
getServer().getPluginManager().disablePlugin(this);
return;
}
// check if using releases before 2.1.0
if (LanguageManager.getLanguageFile().isSet("STATS-AboveLine") && LanguageManager.getLanguageFile().isSet("SCOREBOARD-Zombies")) {
migrateToNewFormat();
}
// check if using releases 2.1.0+
if (LanguageManager.getLanguageFile().isSet("File-Version") && getConfig().isSet("Config-Version")) {
migrateToNewFormat();
}
LanguageManager.saveDefaultLanguageFile();
saveDefaultConfig();
debug = getConfig().getBoolean("Debug");
if (Main.isDebugged()) {
System.out.println("[Village Debugger] Village Defense setup started!");
}
setupFiles();
debugChecker();
LanguageMigrator.languageFileUpdate();
setupLocale();
initializeClasses();
String currentVersion = "v" + Bukkit.getPluginManager().getPlugin("VillageDefense").getDescription().getVersion();
if (getConfig().getBoolean("Update-Notifier.Enabled")) {
try {
UpdateChecker.checkUpdate(currentVersion);
String latestVersion = UpdateChecker.getLatestVersion();
if (latestVersion != null) {
latestVersion = "v" + latestVersion;
if (latestVersion.contains("b")) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[VillageDefense] Your software is ready for update! However it's a BETA VERSION. Proceed with caution.");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[VillageDefense] Current version %old%, latest version %new%".replaceAll("%old%", currentVersion).replaceAll("%new%", latestVersion));
} else {
BigTextUtils.updateIsHere();
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Your Village Defense plugin is up to date! Download it to keep with latest changes and fixes.");
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Disable this option in config.yml if you wish.");
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "Current version: " + ChatColor.RED + currentVersion + ChatColor.YELLOW + " Latest version: " + ChatColor.GREEN + latestVersion);
}
}
} catch (Exception ex) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[VillageDefense] An error occured while checking for update!");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Please check internet connection or check for update via WWW site directly!");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "WWW site https://www.spigotmc.org/resources/minigame-village-defence-1-12-and-1-8-8.41869/");
}
}
STARTING_TIMER_TIME = getConfig().getInt("Starting-Waiting-Time");
MINI_ZOMBIE_SPEED = (float) getConfig().getDouble("Mini-Zombie-Speed");
ZOMBIE_SPEED = (float) getConfig().getDouble("Zombie-Speed");
databaseActivated = getConfig().getBoolean("DatabaseActivated");
inventoryManagerEnabled = getConfig().getBoolean("InventoryManager");
if (databaseActivated) {
database = new MySQLDatabase(this);
} else {
fileStats = new FileStats(this);
}
bossbarEnabled = getConfig().getBoolean("Bossbar-Enabled");
if (is1_8_R3()) {
bossbarEnabled = false;
}
getServer().getPluginManager().registerEvents(this, this);
BreakFenceListener listener = new BreakFenceListener();
listener.runTaskTimer(this, 1L, 20L);
setupGameKits();
SpecialItem.loadAll();
registerArenas();
new ShopManager();
// we must start it after instances load!
signManager = new SignManager(this);
chatFormat = getConfig().getBoolean("ChatFormat-Enabled");
ConfigurationSection cs = getConfig().getConfigurationSection("CustomPermissions");
for (String key : cs.getKeys(false)) {
customPermissions.put(key, getConfig().getInt("CustomPermissions." + key));
if (isDebugged()) {
System.out.println("[Village Debugger] Loaded custom permission " + key + "!");
}
}
for (Player p : Bukkit.getOnlinePlayers()) {
UserManager.registerUser(p.getUniqueId());
}
if (databaseActivated) {
for (Player p : Bukkit.getOnlinePlayers()) {
MySQLConnectionUtils.loadPlayerStats(p, this);
}
} else {
fileStats.loadStatsForPlayersOnline();
}
StatsStorage.plugin = this;
setupPermissions();
}
use of pl.plajer.villagedefense3.handlers.ShopManager in project Village_Defense by Plajer.
the class Main method registerArenas.
public void registerArenas() {
if (ArenaRegistry.getArenas() != null) {
if (ArenaRegistry.getArenas().size() > 0) {
for (Arena arena : ArenaRegistry.getArenas()) {
arena.clearZombies();
arena.clearVillagers();
arena.clearWolfs();
arena.clearGolems();
}
}
}
ArenaRegistry.getArenas().clear();
if (!ConfigurationManager.getConfig("arenas").contains("instances")) {
Bukkit.getConsoleSender().sendMessage(ChatManager.colorMessage("Validator.No-Instances-Created"));
return;
}
for (String ID : ConfigurationManager.getConfig("arenas").getConfigurationSection("instances").getKeys(false)) {
Arena arena;
String s = "instances." + ID + ".";
if (s.contains("default"))
continue;
if (is1_8_R3()) {
arena = new ArenaInitializer1_8_R3(ID, this);
} else if (is1_9_R1()) {
arena = new ArenaInitializer1_9_R1(ID, this);
} else if (is1_11_R1()) {
arena = new ArenaInitializer1_11_R1(ID, this);
} else {
arena = new ArenaInitializer1_12_R1(ID, this);
}
arena.setMinimumPlayers(ConfigurationManager.getConfig("arenas").getInt(s + "minimumplayers"));
arena.setMaximumPlayers(ConfigurationManager.getConfig("arenas").getInt(s + "maximumplayers"));
arena.setMapName(ConfigurationManager.getConfig("arenas").getString(s + "mapname"));
arena.setLobbyLocation(Util.getLocation(false, ConfigurationManager.getConfig("arenas").getString(s + "lobbylocation")));
arena.setStartLocation(Util.getLocation(false, ConfigurationManager.getConfig("arenas").getString(s + "Startlocation")));
arena.setEndLocation(Util.getLocation(false, ConfigurationManager.getConfig("arenas").getString(s + "Endlocation")));
if (!ConfigurationManager.getConfig("arenas").getBoolean(s + "isdone")) {
Bukkit.getConsoleSender().sendMessage(ChatManager.colorMessage("Validator.Invalid-Arena-Configuration").replaceAll("%arena%", ID).replaceAll("%error%", "NOT VALIDATED"));
arena.setReady(false);
ArenaRegistry.registerArena(arena);
continue;
}
if (ConfigurationManager.getConfig("arenas").contains(s + "zombiespawns")) {
for (String string : ConfigurationManager.getConfig("arenas").getConfigurationSection(s + "zombiespawns").getKeys(false)) {
String path = s + "zombiespawns." + string;
arena.addZombieSpawn(Util.getLocation(false, ConfigurationManager.getConfig("arenas").getString(path)));
}
} else {
Bukkit.getConsoleSender().sendMessage(ChatManager.colorMessage("Validator.Invalid-Arena-Configuration").replaceAll("%arena%", ID).replaceAll("%error%", "ZOMBIE SPAWNS"));
arena.setReady(false);
ArenaRegistry.registerArena(arena);
continue;
}
if (ConfigurationManager.getConfig("arenas").contains(s + "villagerspawns")) {
for (String string : ConfigurationManager.getConfig("arenas").getConfigurationSection(s + "villagerspawns").getKeys(false)) {
String path = s + "villagerspawns." + string;
arena.addVillagerSpawn(Util.getLocation(false, ConfigurationManager.getConfig("arenas").getString(path)));
}
} else {
Bukkit.getConsoleSender().sendMessage(ChatManager.colorMessage("Validator.Invalid-Arena-Configuration").replaceAll("%arena%", ID).replaceAll("%error%", "VILLAGER SPAWNS"));
arena.setReady(false);
ArenaRegistry.registerArena(arena);
continue;
}
if (ConfigurationManager.getConfig("arenas").contains(s + "doors")) {
for (String string : ConfigurationManager.getConfig("arenas").getConfigurationSection(s + "doors").getKeys(false)) {
String path = s + "doors." + string + ".";
arena.addDoor(Util.getLocation(false, ConfigurationManager.getConfig("arenas").getString(path + "location")), (byte) ConfigurationManager.getConfig("arenas").getInt(path + "byte"));
}
} else {
Bukkit.getConsoleSender().sendMessage(ChatManager.colorMessage("Validator.Invalid-Arena-Configuration").replaceAll("%arena%", ID).replaceAll("%error%", "DOORS"));
arena.setReady(false);
ArenaRegistry.registerArena(arena);
continue;
}
ArenaRegistry.registerArena(arena);
arena.start();
Bukkit.getConsoleSender().sendMessage(ChatManager.colorMessage("Validator.Instance-Started").replaceAll("%arena%", ID));
}
new ShopManager();
}
Aggregations