public void onDisable() { db.close(); lang.saveLang(); Shops.saveShops(); log("Plugin disabled. - By TruDan"); }
public void onEnable() { this.getConfig().options().copyDefaults(true); this.saveConfig(); DwDShopPlugin.logger = Logger.getLogger("Minecraft"); DwDShopPlugin.plugin = this; DwDShopPlugin.pluginName = this.getDescription().getName(); DwDShopPlugin.pluginVersion = this.getDescription().getVersion(); DwDShopPlugin.lang = new Lang(this); if (getServer().getPluginManager().getPlugin("Vault") != null) { setupPermissions(); setupEconomy(); } else { log(ChatColor.RED + "Missing dependency: Vault. Please install this for the plugin to work."); getServer().getPluginManager().disablePlugin(plugin); return; } // Create shops folder File theDir = new File(this.getDataFolder() + "/shops/" + File.separatorChar); // if the directory does not exist, create it if (!theDir.exists()) { boolean result = theDir.mkdir(); if (result) { log("Shops folder created."); } } setupCommands(); DwDShopPlugin.db = new MySQL( logger, "[" + pluginName + " v" + pluginVersion + "]", getConfig().getString("mysql.hostname"), getConfig().getString("mysql.port"), getConfig().getString("mysql.database"), getConfig().getString("mysql.username"), getConfig().getString("mysql.password")); try { db.open(); } catch (Exception e) { e.printStackTrace(); } PluginManager pm = getServer().getPluginManager(); Listener events = new Events(this); pm.registerEvents(events, this); Shops.loadShops(); log("Plugin enabled. - By TruDan"); }
/** * méthode permettant d'acheter un item dans le Shop choisi * * @param deguisement le Shop choisi */ @Override public void buyDeguisements(Shops deguisement) { String indice; deguisement.showDeguisements(deguisement); Scanner input = new Scanner(System.in); indice = input.nextLine(); switch (indice) { case "0": Deguisements princessDress = deguisement.getListOfDeguisements().get(Integer.parseInt(indice)); if (checkSize(princessDress)) { try { manageWallet(princessDress); } catch (NoMoneyException e) { System.out.println(e.getMessage()); youLoose(); } try { howFunny(princessDress); } catch (NegativeFunException e) { System.out.println(e.getMessage()); } bag.addItem(princessDress); } break; case "1": Deguisements cowBoyHat = deguisement.getListOfDeguisements().get(Integer.parseInt(indice)); if (checkSize(cowBoyHat)) { try { manageWallet(cowBoyHat); } catch (NoMoneyException e) { System.out.println(e.getMessage()); youLoose(); } try { howFunny(cowBoyHat); } catch (NegativeFunException e) { System.out.println(e.getMessage()); } bag.addItem(cowBoyHat); } break; case "2": Deguisements mickeyEars = deguisement.getListOfDeguisements().get(Integer.parseInt(indice)); if (checkSize(mickeyEars)) { try { manageWallet(mickeyEars); } catch (NoMoneyException e) { System.out.println(e.getMessage()); youLoose(); } try { howFunny(mickeyEars); } catch (NegativeFunException e) { System.out.println(e.getMessage()); } bag.addItem(mickeyEars); } break; default: System.out.println("\nVotre réponse ne correspond pas aux réponses proposées..."); buyGifts(deguisement); } }
/** * méthode permettant d'acheter un item dans le Shop choisi * * @param gift le Shop choisi */ @Override public void buyGifts(Shops gift) { String indice; gift.showGifts(gift); Scanner input = new Scanner(System.in); indice = input.nextLine(); switch (indice) { case "0": Gifts picture = gift.getListOfGifts().get(Integer.parseInt(indice)); try { manageWallet(picture); } catch (NoMoneyException e) { System.out.println(e.getMessage()); youLoose(); } try { howFunny(picture); } catch (NegativeFunException e) { System.out.println(e.getMessage()); } bag.addItem(picture); break; case "1": Gifts mug = gift.getListOfGifts().get(Integer.parseInt(indice)); try { manageWallet(mug); } catch (NoMoneyException e) { System.out.println(e.getMessage()); youLoose(); } try { howFunny(mug); } catch (NegativeFunException e) { System.out.println(e.getMessage()); } bag.addItem(mug); break; case "2": Gifts plush = gift.getListOfGifts().get(Integer.parseInt(indice)); try { manageWallet(plush); } catch (NoMoneyException e) { System.out.println(e.getMessage()); youLoose(); } try { howFunny(plush); } catch (NegativeFunException e) { System.out.println(e.getMessage()); } bag.addItem(plush); break; case "3": Gifts snowGlobe = gift.getListOfGifts().get(Integer.parseInt(indice)); try { manageWallet(snowGlobe); } catch (NoMoneyException e) { System.out.println(e.getMessage()); youLoose(); } try { howFunny(snowGlobe); } catch (NegativeFunException e) { System.out.println(e.getMessage()); } bag.addItem(snowGlobe); break; default: System.out.println("\nVotre réponse ne correspond pas aux réponses proposées..."); buyGifts(gift); } }