예제 #1
0
  public static void load(Plugin plugin) {
    primary = getColor(plugin.getConfig().getString("color.primary"));
    secondary = getColor(plugin.getConfig().getString("color.secondary"));

    ConfigurationSection cfg = plugin.getConfig().getConfigurationSection("kick-colors");
    regular = getColor(cfg.getString("regular"));
    banner = getColor(cfg.getString("banner"));
    reason = getColor(cfg.getString("reason"));
    time = getColor(cfg.getString("time"));
  }
예제 #2
0
 public Nuke(Plugin plugin) {
   super(
       plugin,
       "Nuke",
       plugin.getConfig().getString("Blocks.Textures.URL.Nuke"),
       plugin.getConfig().getInt("Blocks.Textures.Size.Nuke"));
   this.plugin = plugin;
 }
 public static void init(Plugin plugin) throws IOException, InvalidConfigurationException {
   config = plugin.getConfig();
   if (!file.exists()) {
     file.getAbsoluteFile().getParentFile().mkdirs();
     file.createNewFile();
   }
   config.load(file);
 }
예제 #4
0
 public void onNeighborBlockChange(World world, int x, int y, int z, int changedId) {
   Location location = new Location(world, x, y, z);
   SpoutBlock block = (SpoutBlock) location.getBlock();
   if (block.isBlockPowered()) {
     block
         .getWorld()
         .createExplosion(
             block.getLocation(), plugin.getConfig().getInt("Blocks.Explosives.Sizes.Nuke"));
   }
 }
 private List<String> getSupportedPlugins() {
   Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
   List<String> supportedPlugins = new Vector<>();
   for (Plugin p : plugins)
     try {
       if (p.getConfig().getBoolean("upm")) supportedPlugins.add(p.getName());
     } catch (Exception e) {
     }
   return supportedPlugins;
 }
 public CrackedStoneBrickSlab(Plugin plugin, Texture texture) {
   super(
       plugin,
       plugin.getConfig().getString("stonebrick.cracked.name.normal", "Cracked Stone Brick Slab"),
       44,
       new GenericCuboidBlockDesign(
           plugin, texture, new int[] {1, 0, 0, 0, 0, 1}, 0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F));
   this.setStepSound(MaterialData.crackedStoneBricks.getStepSound());
   this.setHardness(MaterialData.crackedStoneBricks.getHardness());
   this.setFriction(MaterialData.crackedStoneBricks.getFriction());
   this.setLightLevel(MaterialData.crackedStoneBricks.getLightLevel());
 }
  public Settings(Plugin plugin) {
    // super(new File(Settings.PLUGIN_FOLDER + "/config.yml"), this.plugin);
    this.file = new File(plugin.getDataFolder(), "config.yml");

    this.plugin = plugin;

    // options().indent(4);
    // Override to always indent 4 spaces
    if (exists()) {
      load();
    } else {
      loadDefaults(file.getName());
      load();
    }

    configFile = (YamlConfiguration) plugin.getConfig();

    // saveDefaults();

  }
  @Override
  public void executeTyped(Listener listener, PlayerChangedWorldEvent event) throws EventException {

    boolean saveRequired = false;
    String fromName = event.getFrom().getName();
    String toName = event.getPlayer().getWorld().getName();

    logger.finer("Player change from " + fromName + " to " + toName);

    try {

      // Save old game mode if required
      String fromWorldMode = plugin.getConfig().getString("worlds." + fromName + ".mode");
      if (fromWorldMode != null) {
        ModeOptions fromMode = ModeOptions.valueOf(fromWorldMode);
        if (fromMode == ModeOptions.REMEMBER) {
          GameMode fromGameMode =
              GameMode.valueOf(plugin.getConfig().getString("worlds." + fromName + ".gamemode"));
          String rememberWorldString =
              plugin
                  .getConfig()
                  .getString(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + fromName);
          { // transition code
            String rememberWorldStringOld =
                plugin
                    .getConfig()
                    .getString("players." + event.getPlayer().getName() + "." + fromName);
            if (rememberWorldStringOld != null) {
              rememberWorldString = rememberWorldStringOld;
              plugin
                  .getConfig()
                  .set(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + fromName,
                      rememberWorldString);
              plugin
                  .getConfig()
                  .set("players." + event.getPlayer().getName() + "." + fromName, null);
              saveRequired = true;
            }
          }
          if (event.getPlayer().getGameMode() != fromGameMode) {
            if (rememberWorldString == null
                || GameMode.valueOf(rememberWorldString) != event.getPlayer().getGameMode()) {
              logger.info("The player has a gamemode different to default. Saving");
              plugin
                  .getConfig()
                  .set(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + fromName,
                      event.getPlayer().getGameMode().toString());
              saveRequired = true;
            }
          }
          if (rememberWorldString != null && event.getPlayer().getGameMode() == fromGameMode) {
            logger.info("The player used to have a unique gamemode but now it is the default");
            plugin.getConfig().set("players." + event.getPlayer().getName(), null);
            saveRequired = true;
          }
        }
      }

      // Change to new gamemode
      String newWorldMode = plugin.getConfig().getString("worlds." + toName + ".mode");
      if (newWorldMode != null) {
        ModeOptions toMode = ModeOptions.valueOf(newWorldMode);
        GameMode toGameMode =
            GameMode.valueOf(plugin.getConfig().getString("worlds." + toName + ".gamemode"));

        if (toMode == ModeOptions.REMEMBER) {
          String rememberWorldString =
              plugin
                  .getConfig()
                  .getString(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + toName);
          { // transition code
            String rememberWorldStringOld =
                plugin
                    .getConfig()
                    .getString("players." + event.getPlayer().getName() + "." + toName);
            if (rememberWorldStringOld != null) {
              rememberWorldString = rememberWorldStringOld;
              plugin
                  .getConfig()
                  .set(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + toName,
                      rememberWorldString);
              plugin.getConfig().set("players." + event.getPlayer().getName() + "." + toName, null);
              saveRequired = true;
            }
          }
          if (rememberWorldString != null) {
            toGameMode = GameMode.valueOf(rememberWorldString);
          }
        }
        if (event.getPlayer().getGameMode() != toGameMode) {
          logger.finer("Changing game mode to " + toGameMode);
          event.getPlayer().setGameMode(toGameMode);
        }
      } else {
        logger.fine("There is no setting for " + toName);
      }
    } finally {
      if (saveRequired) {
        plugin.saveConfig();
      }
    }
  }
  @Override
  public boolean onCommand(CommandSender cmdsender, Command cmd, String label, String[] args) {
    if (cmdsender instanceof Player) {
      Player player = (Player) cmdsender;
      if (!cmd.getName().equalsIgnoreCase("upm")) {
        return false;
      } else if (args.length == 0) {
        player.sendMessage(
            ChatColor.LIGHT_PURPLE + "Usage: " + ChatColor.GOLD + "/UPM <password> ");
      } else if (!locked) {
        if (args[0].equals(parentconfig.getString("password"))
            && (player.hasPermission("upm.limited")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          this.player = player;
          this.playerID = player.getUniqueId();
          cm.disableChat(player);
          locked = true;
          cm.sendMessage(ChatColor.LIGHT_PURPLE + "UPM Mode enabled");
        } else {
          player.sendMessage(ChatColor.RED + "Wrong password or no permission for this command!");
        }
      } else if (player.getUniqueId() == playerID) {
        if (args[0].equalsIgnoreCase("exit")) {
          locked = false;
          changed = false;
          loaded = false;
          cm.sendMessage(ChatColor.LIGHT_PURPLE + "UPM Mode disabled");
          cm.enableChat();
        } else if (args[0].equalsIgnoreCase("list")
            && (player.hasPermission("upm.limited")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          cm.sendMessage(ChatColor.LIGHT_PURPLE + "Supported Plugins:\n------------");
          for (String s : getSupportedPlugins()) cm.sendMessage(ChatColor.LIGHT_PURPLE + s);
        } else if (args[0].equalsIgnoreCase("load-cfg")
            && (player.hasPermission("upm.config.show")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (args.length > 1 && args[1] != null) {
            if (getSupportedPlugins().contains(args[1])) {
              pl = Bukkit.getPluginManager().getPlugin(args[1]);
              if (changed) {
                cm.sendMessage(
                    ChatColor.RED
                        + "There are unsafed changes in the loaded config."
                        + " "
                        + "You really want to load another config?\n"
                        + "To confirm "
                        + "type: "
                        + ChatColor.GOLD
                        + "YES");
                cm.requestConfirmation(1);
              } else loadCFG();
            } else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "Plugin "
                      + ChatColor.GOLD
                      + args[1]
                      + ChatColor.LIGHT_PURPLE
                      + " does not exist or isnt supported!");

          } else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/upm load-cfg "
                    + "<pluginname>");

        } else if (args[0].equalsIgnoreCase("save-cfg")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (loaded)
            if (changed)
              if (getSupportedPlugins().contains(loadedplugin)) {
                pl = Bukkit.getPluginManager().getPlugin(loadedplugin);
                try {
                  saveExternalPluginConfig(pl);
                  cm.sendMessage(ChatColor.LIGHT_PURPLE + "Config saved successfull");
                  this.changed = false;
                  this.loaded = false;
                } catch (IOException e) {
                  cm.sendMessage(ChatColor.RED + "Error while saving config!");
                }
              } else
                cm.sendMessage(
                    ChatColor.LIGHT_PURPLE
                        + "Plugin "
                        + ChatColor.GOLD
                        + loadedplugin
                        + ChatColor.LIGHT_PURPLE
                        + " does not exist or isnt supported!");
            else cm.sendMessage(ChatColor.LIGHT_PURPLE + "Nothing to save, config isnt changed!");
          else cm.sendMessage(ChatColor.LIGHT_PURPLE + "Nothing to save, config isnt loaded!");
        } else if (args[0].equalsIgnoreCase("update")
            && (player.hasPermission("upm.update")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (args.length > 1 && args[1] != null) {
            if (getSupportedPlugins().contains(args[1])) {
              pl = Bukkit.getPluginManager().getPlugin(args[1]);
              try {
                String updateURL = pl.getConfig().getString("upm_update");
                updatePlugin(updateURL, pl);
                cm.sendMessage(
                    ChatColor.LIGHT_PURPLE + "Plugin updated successfull. Restart needed.");
              } catch (Exception e) {
                cm.sendMessage(ChatColor.RED + "Error while updating!");
              }
            } else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "Plugin "
                      + ChatColor.GOLD
                      + args[1]
                      + ChatColor.LIGHT_PURPLE
                      + " does not exist or isnt supported!");

          } else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/upm update "
                    + "<pluginname>");
        } else if (args[0].equalsIgnoreCase("check-updates")
            && (player.hasPermission("upm.limited")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          cm.sendMessage(
              ChatColor.LIGHT_PURPLE
                  + "Name || Installed Version || Newest Version || Latest "
                  + "Changes");
          for (String s : getSupportedPlugins()) {
            pl = Bukkit.getPluginManager().getPlugin(s);
            String name = pl.getName();
            String installedVersion = pl.getDescription().getVersion();
            String updateURL = pl.getConfig().getString("upm_update");
            String[] information = getLatestPluginInformation(updateURL);
            if (information != null && !(installedVersion.equals(information[0])))
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + name
                      + " || "
                      + installedVersion
                      + " || "
                      + information[0]
                      + " || "
                      + ChatColor.GREEN
                      + information[1]);
          }
        } else if (args[0].equalsIgnoreCase("set-cfg")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (args.length > 2 && args[1] != null && args[2] != null)
            if (loaded) {
              try {
                String type = pluginconfig.getString("upm_configtype." + args[1]);
                if (pluginconfig.get("upm_configtype." + args[1]) != null) {
                  if (type.equals("list")) {
                    List<String> list = (List<String>) pluginconfig.getList(args[1]);
                    if (list == null) list = new Vector<>();
                    if (args[2].equalsIgnoreCase("add") && args.length > 3) {
                      cm.sendMessage(ChatColor.LIGHT_PURPLE + "Adding " + args[3] + " to list");
                      cm.sendMessage(ChatColor.RED + "To Confirm type " + ChatColor.GOLD + "YES");
                      templist = list;
                      tempargs = args;
                      temptype = type;
                      cm.requestConfirmation(2);
                    } else if (args[2].equalsIgnoreCase("remove") && args.length > 3) {
                      cm.sendMessage(ChatColor.LIGHT_PURPLE + "Removing " + args[3] + " from list");
                      cm.sendMessage(ChatColor.RED + "To Confirm type " + ChatColor.GOLD + "YES");
                      templist = list;
                      tempargs = args;
                      temptype = type;
                      cm.requestConfirmation(2);

                    } else if (args[2].equalsIgnoreCase("show")) {
                      cm.sendMessage(ChatColor.LIGHT_PURPLE + "Current List values:");
                      for (String s : list) cm.sendMessage("- " + s);
                    } else
                      cm.sendMessage(
                          ChatColor.LIGHT_PURPLE
                              + "Usage:"
                              + ChatColor.GOLD
                              + "/UPM "
                              + "set-cfg <path> <add/remove/show> (value)");
                  } else {
                    cm.sendMessage(
                        ChatColor.LIGHT_PURPLE
                            + "Current Value of "
                            + args[1]
                            + ":"
                            + ChatColor.GOLD
                            + pluginconfig.getString(args[1])
                            + " ("
                            + type
                            + ")");
                    cm.sendMessage(
                        ChatColor.LIGHT_PURPLE
                            + "New Value of "
                            + args[1]
                            + ":"
                            + ChatColor.GOLD
                            + args[2]);
                    cm.sendMessage(ChatColor.RED + "To Confirm type " + ChatColor.GOLD + "YES");
                    tempargs = args;
                    temptype = type;
                    cm.requestConfirmation(2);
                  }
                } else {
                  cm.sendMessage(
                      ChatColor.LIGHT_PURPLE
                          + "Path not found! Use /upm add-path to create "
                          + "it.");
                }
              } catch (Exception e) {
                cm.sendMessage(e.getLocalizedMessage());
                cm.sendMessage(e.getMessage());
                e.printStackTrace();
              }
            } else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "No Plugin loaded! Use "
                      + ChatColor.GOLD
                      + "/UPM "
                      + "load-cfg <pluginname> "
                      + ChatColor.LIGHT_PURPLE
                      + " to load a "
                      + "Config"
                      + ".");
          else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/UPM set-cfg <path> "
                    + "<value> ");
        } else if (args[0].equalsIgnoreCase("add-path")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (loaded)
            if (args.length > 2 && args[1] != null && args[2] != null)
              if (args[2].equalsIgnoreCase("string")) {
                tempargs = new String[3];
                // add upm path
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "string";
                changeValue();
              } else if (args[2].equalsIgnoreCase("int")) {
                tempargs = new String[3];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "int";
                changeValue();
              } else if (args[2].equalsIgnoreCase("double")) {
                tempargs = new String[3];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "double";
                changeValue();
              } else if (args[2].equalsIgnoreCase("boolean")) {
                tempargs = new String[3];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "boolean";
                changeValue();
              } else if (args[2].equalsIgnoreCase("list")) {
                tempargs = new String[4];
                // add upm path
                temptype = "string";
                tempargs[1] = "upm_configtype." + args[1];
                tempargs[2] = "list";
                changeValue();
              } else {
                cm.sendMessage(ChatColor.RED + "Value type " + args[2] + " isnt supported!");
              }
            else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE
                      + "Usage: "
                      + ChatColor.GOLD
                      + "/UPM add-path <path> "
                      + "<type>");
          else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "No Plugin loaded! Use "
                    + ChatColor.GOLD
                    + "/UPM "
                    + "load-cfg <pluginname> "
                    + ChatColor.LIGHT_PURPLE
                    + " to load a "
                    + "Config"
                    + ".");
        } else if (args[0].equalsIgnoreCase("show-cfg")
            && (player.hasPermission("upm.config.show")
                || player.isOp()
                || player.hasPermission("upm.admin"))) {
          if (loaded)
            if (args.length > 1 && args[1] != null)
              if (pluginconfig.get(args[1]) != null)
                cm.sendMessage(
                    ChatColor.LIGHT_PURPLE
                        + "Current Value of "
                        + args[1]
                        + ":"
                        + ChatColor.GOLD
                        + pluginconfig.getString(args[1]));
              else cm.sendMessage(ChatColor.LIGHT_PURPLE + "Config is not defined for " + args[1]);
            else
              cm.sendMessage(
                  ChatColor.LIGHT_PURPLE + "Usage: " + ChatColor.GOLD + "/UPM show-cfg <path> ");
          else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "No Plugin loaded! Use "
                    + ChatColor.GOLD
                    + "/UPM "
                    + "load-cfg <pluginname> "
                    + ChatColor.LIGHT_PURPLE
                    + " to load a "
                    + "Config"
                    + ".");
        } else if (args[0].equalsIgnoreCase("set-password")
            && (player.hasPermission("upm.config.edit")
                || player.isOp()
                || player.hasPermission("upm" + ".admin"))) {
          if (args.length > 2 && args[1] != null && args[2] != null) {
            if (args[1].equals(parentconfig.getString("password"))) {
              parentconfig.set("password", args[2]);
              UPM_IOManager.saveConfig(parentconfig);
              cm.sendMessage(ChatColor.GREEN + "Password successfull changed");
            } else cm.sendMessage(ChatColor.RED + "Wrong current Password");
          } else
            cm.sendMessage(
                ChatColor.LIGHT_PURPLE
                    + "Usage: "
                    + ChatColor.GOLD
                    + "/UPM set-password "
                    + "<current Password> <new Password>");
        } else
          cm.sendMessage(
              ChatColor.LIGHT_PURPLE
                  + "Help:\n"
                  + ChatColor.GOLD
                  + "/UPM exit"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Leaves UPM Mode, "
                  + "enables chat again\n"
                  + ChatColor.GOLD
                  + "/UPM check-updates"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Shows latest Updates for all supported Plugins\n"
                  + ChatColor.GOLD
                  + "/UPM update"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Updates a plugin to latest online version\n"
                  + ChatColor.GOLD
                  + "/UPM load-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Loads a config of a plugin\n"
                  + ChatColor.GOLD
                  + "/UPM save-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Saves the loaded config\n"
                  + ChatColor.GOLD
                  + "/UPM set-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Sets a value for a config path\n"
                  + ChatColor.GOLD
                  + "/UPM show-cfg"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Shows a value of a config path\n"
                  + ChatColor.GOLD
                  + "/UPM set-password"
                  + ChatColor.GRAY
                  + " - "
                  + ChatColor.LIGHT_PURPLE
                  + "Changes UPM password");

      } else {
        player.sendMessage(
            ChatColor.LIGHT_PURPLE
                + "UPM is currently used by "
                + ChatColor.GOLD
                + this.player.getName());
      }
    }
    return true;
  }
예제 #10
0
  public static void shopGUI(
      Plugin plugin,
      Player player,
      Material shopType,
      short durability,
      int moneyPrice,
      int itemPrice,
      int sellNumber,
      int buyNumber,
      boolean itemSize,
      boolean moneySize) {
    itemPrice = itemPrice % 10000;
    moneyPrice = moneyPrice % 10000;
    if (itemPrice == 0) {
      itemPrice = 1;
    }
    if (moneyPrice == 0) {
      moneyPrice = 1;
    }

    sellNumber = sellNumber % 1000;
    buyNumber = buyNumber % 1000;
    if (sellNumber == 0) {
      sellNumber = 1;
    }
    if (buyNumber == 0) {
      buyNumber = 1;
    }
    Inventory menu = Bukkit.createInventory(null, 54, plugin.getConfig().getString("shop.name"));
    ItemStack[] itemStacks = menu.getContents();

    for (int i = 0; i < 4; i++) {
      itemStacks[12 - i] = ItemUtil.getNumberStack(itemPrice / (int) Math.pow(10, (double) i) % 10);
      itemStacks[17 - i] =
          ItemUtil.getNumberStack(moneyPrice / (int) Math.pow(10, (double) i) % 10);
      if (i != 3) {
        itemStacks[38 - i] =
            ItemUtil.getNumberStack(sellNumber / (int) Math.pow(10, (double) i) % 10);
        itemStacks[44 - i] =
            ItemUtil.getNumberStack(buyNumber / (int) Math.pow(10, (double) i) % 10);
      }
    }

    int[] upArrow = {0, 1, 2, 3, 5, 6, 7, 8, 27, 28, 29, 33, 34, 35};
    for (int i : upArrow) {
      itemStacks[i] = ItemUtil.getUpArrow();
    }

    int[] downArrow = {18, 19, 20, 21, 23, 24, 25, 26, 45, 46, 47, 51, 52, 53};
    for (int i : downArrow) {
      itemStacks[i] = ItemUtil.getDownArrow();
    }

    if (itemSize) {
      itemStacks[39] = new ItemStack(shopType, shopType.getMaxStackSize(), durability);
    } else {
      itemStacks[39] = new ItemStack(shopType, 1, durability);
    }

    if (moneySize) {
      itemStacks[41] =
          new ItemStack(ItemUtil.getCurrency(), ItemUtil.getCurrency().getMaxStackSize());
    } else {
      itemStacks[41] = new ItemStack(ItemUtil.getCurrency(), 1);
    }

    itemStacks[13] =
        ItemUtil.button(
            shopType,
            String.format(
                plugin.getConfig().getString("message.priceButton"),
                itemPrice,
                shopType.name(),
                moneyPrice));
    ItemMeta itemMeta13 = itemStacks[13].getItemMeta();
    List<String> list13 = new ArrayList<String>();
    list13.add(getLowest(plugin, shopType, durability));
    list13.add(getHighest(plugin, shopType, durability));
    itemMeta13.setLore(list13);
    itemStacks[13].setItemMeta(itemMeta13);
    itemStacks[13].setDurability(durability);

    itemStacks[40] =
        ItemUtil.getDetail(
            shopType.name(),
            durability,
            moneyPrice,
            itemPrice,
            sellNumber,
            buyNumber,
            itemSize,
            moneySize);

    if (itemSize) {
      sellNumber = sellNumber * shopType.getMaxStackSize();
    }
    if (moneySize) {
      buyNumber = buyNumber * ItemUtil.getCurrency().getMaxStackSize();
    }

    // 买卖键
    itemStacks[48] =
        ItemUtil.button(
            shopType,
            durability,
            String.format(
                plugin.getConfig().getString("message.sellButton"),
                sellNumber,
                shopType.name(),
                sellNumber * moneyPrice / itemPrice));
    itemStacks[50] =
        ItemUtil.button(
            ItemUtil.getCurrency(),
            String.format(
                plugin.getConfig().getString("message.buyButton"),
                shopType.name(),
                buyNumber,
                itemPrice,
                moneyPrice));

    // 库存显示
    itemStacks[30] =
        ItemUtil.button(
            Material.CHEST,
            String.format(
                plugin.getConfig().getString("message.itemOwned"),
                ItemUtil.getItemNumber(player, shopType, durability),
                shopType.name()));
    itemStacks[32] =
        ItemUtil.button(
            Material.TRAPPED_CHEST,
            String.format(
                plugin.getConfig().getString("message.moneyOwned"),
                ItemUtil.getItemNumber(player, ItemUtil.getCurrency())));

    //        // 最低卖价
    //        itemStacks[4] = getLowest(plugin, shopType);
    //
    //        // 最高售价
    //        itemStacks[22] = getHighest(plugin, shopType);

    menu.setContents(itemStacks);
    player.openInventory(menu);
  }
예제 #11
0
 public void setup(Plugin p) {
   config = p.getConfig();
   config.options().copyDefaults(true);
   cfile = new File(p.getDataFolder(), "config.yml");
 }
예제 #12
0
 /**
  * This will use your main configuration (config.yml). Use this in onEnable().
  *
  * @param plugin The instance of your plugins main class.
  * @throws Exception
  */
 public AutoUpdate(Plugin plugin) throws Exception {
   this(plugin, plugin.getConfig());
 }
예제 #13
0
 /**
  * This will overwrite the pre-saved configuration. use this after reloadConfig(), for example.
  * This will use your main configuration (config.yml). This will call {@link #restartMainTask()}
  * internally.
  *
  * @throws FileNotFoundException
  */
 public void resetConfig() throws FileNotFoundException {
   setConfig(plugin.getConfig());
 }
예제 #14
0
 public LockdownListener(Plugin plugin) {
   REJECTMSG = plugin.getConfig().getString("plugin.lockdown.rejectmsg");
   NOTIFICATIONMSG = plugin.getConfig().getString("plugin.lockdown.notificationmsg");
 }