Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.hannezhd.citybuildsystem;
- import de.hannezhd.citybuildsystem.Backpack.BackpackCommand;
- import de.hannezhd.citybuildsystem.Backpack.BackpackManager;
- import de.hannezhd.citybuildsystem.Economy.PayCommand;
- import de.hannezhd.citybuildsystem.Economy.RiseCoins;
- import de.hannezhd.citybuildsystem.Economy.Risecoins2;
- import de.hannezhd.citybuildsystem.Scoreboard.ScoreboardBuilder;
- import de.hannezhd.citybuildsystem.TPA.*;
- import de.hannezhd.citybuildsystem.commands.*;
- import de.hannezhd.citybuildsystem.commands.AdminShop.AdminShopClickListener;
- import de.hannezhd.citybuildsystem.commands.AdminShop.AdminShopCommand;
- import de.hannezhd.citybuildsystem.commands.homes.DelHomeCommand;
- import de.hannezhd.citybuildsystem.commands.homes.HomeCommand;
- import de.hannezhd.citybuildsystem.commands.homes.SetHomeCommand;
- import de.hannezhd.citybuildsystem.commands.vote.CoinseeCommand;
- import de.hannezhd.citybuildsystem.commands.vote.VCShopListener;
- import de.hannezhd.citybuildsystem.commands.vote.coins;
- import de.hannezhd.citybuildsystem.commands.vote.vcshop;
- import de.hannezhd.citybuildsystem.commands.warps.DelWarpsCommand;
- import de.hannezhd.citybuildsystem.commands.warps.SetWarpsCommand;
- import de.hannezhd.citybuildsystem.commands.warps.WarpCommand;
- import de.hannezhd.citybuildsystem.commands.warps.WarpsCommand;
- import de.hannezhd.citybuildsystem.listener.InventoryListener;
- import de.hannezhd.citybuildsystem.listener.InvseeListener;
- import de.hannezhd.citybuildsystem.listener.Joinlistener;
- import de.hannezhd.citybuildsystem.listener.RangInfoListener;
- import java.io.File;
- import java.io.IOException;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import de.hannezhd.citybuildsystem.ränge.RangInfoCommand;
- import de.hannezhd.citybuildsystem.util.MYSQLManager;
- import de.hannezhd.citybuildsystem.util.RandGUISystem;
- import de.hannezhd.citybuildsystem.util.WallGUISystem;
- import org.bukkit.Bukkit;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.ConfigurationSection;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- public final class Citybuild_system extends JavaPlugin {
- public static String prefix = "§x§b§a§6§c§f§f§lR§x§a§6§6§7§f§f§li§x§9§2§6§2§f§f§ls§x§7§d§5§d§f§f§le§x§6§9§5§8§f§f§l-§x§5§5§5§3§f§f§lC§x§4§1§4§e§f§f§li§x§2§c§4§9§f§f§lt§x§1§8§4§4§f§f§ly§f ● ";
- public static String nopermission = prefix + "§cDazu hast du keine Rechte";
- private MYSQLManager mysqlManager;
- public static Citybuild_system plugin;
- private File file;
- private YamlConfiguration configuration;
- private File votecoinfile;
- private File risecoinfile;
- private File homefile;
- private File backpackfile;
- public YamlConfiguration votecoinconfiguration;
- public YamlConfiguration risecoinconfiguration;
- public YamlConfiguration homeconfiguration;
- public YamlConfiguration backpackconfiguration;
- private BackpackManager backpackManager;
- private static Citybuild_system instance;
- public void onEnable() {
- instance = this;
- this.file = new File("plugins/Citybuild-system", "warps.yml");
- this.configuration = YamlConfiguration.loadConfiguration(this.file);
- this.registerBukkit();
- this.votecoinfile = new File("plugins/Citybuild-system", "Votecoin.yml");
- this.votecoinconfiguration = YamlConfiguration.loadConfiguration(this.votecoinfile);
- this.risecoinfile = new File("plugins/Citybuild-system", "money.yml");
- this.risecoinconfiguration = YamlConfiguration.loadConfiguration(this.risecoinfile);
- this.homefile = new File("plugins/Citybuild-system", "homes.yml");
- this.homeconfiguration= YamlConfiguration.loadConfiguration(this.homefile);
- this.backpackfile = new File("plugins/Citybuild-system", "backpack.yml");
- this.backpackconfiguration = YamlConfiguration.loadConfiguration(this.backpackfile);
- this.registerBukkit();
- mysqlManager = new MYSQLManager(getDataFolder());
- mysqlManager.createTables();
- // Überprüfe den Verbindungsstatus
- try {
- if (mysqlManager.getConnection() != null && !mysqlManager.getConnection().isClosed()) {
- getLogger().info("Verbindung zur MySQL-Datenbank hergestellt.");
- } else {
- getLogger().severe("Verbindung zur MySQL-Datenbank fehlgeschlagen.");
- getServer().getPluginManager().disablePlugin(this);
- return;
- }
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- this.registerBukkit();
- this.getCommand("gm").setExecutor(new GmCommand());
- this.getCommand("website").setExecutor(new WebsiteCommand());
- this.getCommand("warp").setExecutor(new WarpCommand());
- this.getCommand("trash").setExecutor(new TrashCanCommand());
- this.getCommand("ranginfo").setExecutor(new RangInfoCommand());
- this.getCommand("wand").setExecutor(new WallCommand());
- this.getCommand("rand").setExecutor(new RandCommand());
- this.getCommand("adminshop").setExecutor(new AdminShopCommand(this));
- this.getCommand("enderchest").setExecutor(new EnderchestCommand());
- this.getCommand("heal").setExecutor(new HealCommand());
- this.getCommand("tpa").setExecutor(new TpaCommand());
- this.getCommand("tpaccept").setExecutor(new TpacceptCommand());
- this.getCommand("tpacancel").setExecutor(new TpaCancelCommand());
- this.getCommand("sethome").setExecutor(new SetHomeCommand(this));
- this.getCommand("delhome").setExecutor(new DelHomeCommand(this));
- this.getCommand("home").setExecutor(new HomeCommand(this));
- this.getCommand("tpahere").setExecutor(new TpahereCommand());
- this.getCommand("anvil").setExecutor(new AnvilCommand(this));
- this.getCommand("workbench").setExecutor(new WorkbenchCommand());
- this.getCommand("ptime").setExecutor(new PtimeCommand());
- this.getCommand("backpack").setExecutor(new BackpackCommand());
- this.getCommand("invsee").setExecutor(new InvseeCommand());
- this.getCommand("hat").setExecutor(new HatCommand());
- //TabCompleter
- this.getCommand("gm").setTabCompleter(this);
- this.getCommand("votecoins").setTabCompleter(this);
- this.getCommand("money").setTabCompleter(this);
- this.getCommand("pay").setTabCompleter(this);
- this.getCommand("home").setTabCompleter(this);
- this.getCommand("delhome").setTabCompleter(this);
- this.getCommand("ptime").setTabCompleter(this);
- this.getCommand("hat").setTabCompleter(this);
- PluginManager pluginManager = Bukkit.getPluginManager();
- pluginManager.registerEvents(new Joinlistener(this), this);
- pluginManager.registerEvents(new InventoryListener(), this);
- pluginManager.registerEvents(new RangInfoListener(), this);
- pluginManager.registerEvents(new WallGUISystem(), this);
- pluginManager.registerEvents(new RandGUISystem(), this);
- pluginManager.registerEvents(new AdminShopClickListener(this), this);
- pluginManager.registerEvents(new ScoreboardBuilder(this), this);
- pluginManager.registerEvents(new InvseeListener(), this);
- VCShopListener listener = new VCShopListener(this);
- pluginManager.registerEvents(listener, this);
- //Backpack
- backpackManager = new BackpackManager();
- System.out.println(" _____ _ _ ______ _ _ _ _____ _ ");
- System.out.println("/ __ \\(_)| | | ___ \\ (_)| | | | / ___| | | ");
- System.out.println("| / \\/ _ | |_ _ _ | |_/ / _ _ _ | | __| | ______ \\ `--. _ _ ___ | |_ ___ _ __ ___ ");
- System.out.println("| | | || __|| | | || ___ \\| | | || || | / _` ||______| `--. \\| | | |/ __|| __| / _ \\| '_ ` _ \\ \n");
- System.out.println("| \\__/\\| || |_ | |_| || |_/ /| |_| || || || (_| | /\\__/ /| |_| |\\__ \\| |_ | __/| | | | | |\n");
- System.out.println(" \\____/|_| \\__| \\__, |\\____/ \\__,_||_||_| \\__,_| \\____/ \\__, ||___/ \\__| \\___||_| |_| |_|\n");
- System.out.println(" __/ | __/ | \n");
- System.out.println(" |___/ |___/ \n");
- }
- private void registerBukkit() {
- this.getCommand("setwarps").setExecutor(new SetWarpsCommand(this));
- this.getCommand("warps").setExecutor(new WarpsCommand(this));
- this.getCommand("delwarps").setExecutor(new DelWarpsCommand(this));
- this.getCommand("votecoins").setExecutor(new coins(this));
- this.getCommand("votecoinssee").setExecutor(new CoinseeCommand(this));
- this.getCommand("vcshop").setExecutor(new vcshop(this));
- this.getCommand("money").setExecutor(new RiseCoins(this));
- this.getCommand("pay").setExecutor(new PayCommand(this));
- this.getCommand("money2").setExecutor(new Risecoins2());
- }
- //Tab Completer
- @Override
- public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
- if (cmd.getName().equalsIgnoreCase("gm")) {
- if (args.length == 1) {
- return Arrays.asList("0", "1", "2", "3");
- } else if (args.length == 2) {
- List<String> playerNames = new ArrayList<>();
- for (Player player : Bukkit.getOnlinePlayers()) {
- playerNames.add(player.getName());
- }
- return playerNames;
- }
- } else if (cmd.getName().equalsIgnoreCase("votecoins")) {
- if (args.length == 1) {
- return Arrays.asList("add", "set", "remove");
- } else if (args.length == 2) {
- List<String> playerNames = new ArrayList<>();
- for (Player player : Bukkit.getOnlinePlayers()) {
- playerNames.add(player.getName());
- }
- return playerNames;
- } else if (args.length == 3) {
- return Arrays.asList("1", "10", "100", "1000");
- }
- } else if (cmd.getName().equalsIgnoreCase("money")) {
- if (args.length == 1) {
- return Arrays.asList("add", "set", "remove", "see");
- } else if (args.length == 2) {
- List<String> playerNames = new ArrayList<>();
- for (Player player : Bukkit.getOnlinePlayers()) {
- playerNames.add(player.getName());
- playerNames.add("*");
- }
- return playerNames;
- } else if (args.length == 3) {
- return Arrays.asList("1", "10", "100", "1000");
- }
- } else if (cmd.getName().equalsIgnoreCase("pay")) {
- if (args.length == 2) {
- return Arrays.asList("1", "10", "100", "1000");
- }
- } else if (cmd.getName().equalsIgnoreCase("home")) {
- Player player = (Player) sender;
- if (args.length == 1) {
- YamlConfiguration cfg = this.getHomeconfiguration();
- ConfigurationSection section = cfg.getConfigurationSection(player.getUniqueId().toString());
- if (section != null) {
- List<String> homes = new ArrayList<>(section.getKeys(false));
- // Filtere Homes basierend auf den bisherigen Argumenten
- String partialHomeName = args[0];
- homes.removeIf(homeName -> !homeName.startsWith(partialHomeName));
- return homes;
- }
- }
- } else if (cmd.getName().equalsIgnoreCase("delhome")) {
- Player player = (Player) sender;
- if (args.length == 1) {
- YamlConfiguration cfg = this.getHomeconfiguration();
- ConfigurationSection section = cfg.getConfigurationSection(player.getUniqueId().toString());
- if (section != null) {
- List<String> homes = new ArrayList<>(section.getKeys(false));
- // Filtere Homes basierend auf den bisherigen Argumenten
- String partialHomeName = args[0];
- homes.removeIf(homeName -> !homeName.startsWith(partialHomeName));
- return homes;
- }
- }
- } else if (cmd.getName().equalsIgnoreCase("ptime")) {
- Player player = (Player) sender;
- if (args.length == 1) {
- return Arrays.asList("day","night","reset","get");
- }
- } else if (cmd.getName().equalsIgnoreCase("hat")) {
- Player player = (Player) sender;
- if (args.length == 1) {
- return Arrays.asList("remove", "off", "0");
- }
- }
- return null;
- }
- public static Citybuild_system getPlugin() {
- return instance;
- }
- public void onDisable() {
- // Trenne die Verbindung zur MySQL-Datenbank
- mysqlManager.disconnect();
- getLogger().info("Verbindung zur MySQL-Datenbank getrennt.");
- try {
- this.configuration.save(this.file);
- } catch (IOException var2) {
- throw new RuntimeException(var2);
- }
- backpackManager.save();
- try {
- this.configuration.save(this.file);
- this.votecoinconfiguration.save(this.votecoinfile);
- this.risecoinconfiguration.save(this.risecoinfile);
- this.homeconfiguration.save(this.homefile);
- this.backpackconfiguration.save(this.backpackfile);
- } catch (IOException var2) {
- throw new RuntimeException(var2);
- }
- }
- public YamlConfiguration getConfiguration() {
- return this.configuration;
- }
- public YamlConfiguration getVotecoinconfiguration() {
- return this.votecoinconfiguration;
- }
- public YamlConfiguration getRisecoinconfiguration() {
- return this.risecoinconfiguration;
- }
- public YamlConfiguration getHomeconfiguration() {
- return this.homeconfiguration;
- }
- public YamlConfiguration getBackpackconfiguration() {
- return this.backpackconfiguration;
- }
- public BackpackManager getBackpackManager() {
- return backpackManager;
- }
- public static Citybuild_system getInstance() {
- return instance;
- }
- public void saveConfiguration() {
- try {
- configuration.save(file);
- } catch (IOException e) {
- getLogger().severe("Fehler beim Speichern der Konfigurationsdatei: " + e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment