コード例 #1
0
 public Particles(Main plugin) {
   super("particles.yml", plugin);
   this.plugin = plugin;
   Config pluginConfig = plugin.getBabies();
   this.enabled = this.config.getBoolean("Enabled");
   this.worldsBlacklist = this.config.getStringList("WorldsBlacklist");
   this.command = this.config.getString("Command");
   this.noPermissionMessage = this.config.getString("NoPermissionMessage");
   this.giveSound = Sound.valueOf(this.config.getString("GiveSound"));
   this.removeSound = Sound.valueOf(this.config.getString("RemoveSound"));
   this.updateInterval = this.config.getDouble("UpdateInterval");
   this.viewDistance = this.config.getInt("ViewDistance");
   this.guiName = this.config.getString("GUIName");
   this.guiSize = Parsing.parseInt(this.config.getString("GUISize"));
   this.noPermissionItem = Methods.getNoPermissionItem(this.config);
   this.noPermissionItem_Enabled = this.config.getBoolean("NoPermissionItem.Enabled");
   this.removeItem = Methods.getGuiItem(this.config, "RemoveItem");
   this.homeItem = Methods.getGuiItem(this.config, "HomeItem");
   this.previousItem = Methods.getGuiItem(this.config, "PreviousItem");
   this.nextItem = Methods.getGuiItem(this.config, "NextItem");
   this.particles = getParticlesInternal();
   this.maxPage = getMaxPageInternal();
   if (pluginConfig.getLoggingLevel() >= 2)
     General.sendColoredMessage(plugin, "Particles config successfully loaded!", ChatColor.GREEN);
 }
コード例 #2
0
 public static void open(Player p, int page) {
   Player p1 = p;
   Fireworks config = plugin.getFireworks();
   GUI gui =
       buildGui(
           config.getGuiName(),
           config.getGuiSize(),
           config.getHomeItem(),
           config.getPreviousItem(),
           config.getNextItem());
   for (FireworkStorage firework : config.getFireworks()) {
     int position = getRealPosition(firework.getPosition(), page, config.getGuiSize());
     if (position != -1) {
       ItemStack item = firework.getItem().clone();
       gui.setItem(position, item);
       if (config.isNoPermissionItemEnabled()
           && !Methods.hasPermission(p1, firework.getPermission())) {
         gui.setItem(position, config.getNoPermissionItem(firework));
       }
     }
   }
   PlayerOpenGuiEvent event = new PlayerOpenGuiEvent(p1, gui);
   Bukkit.getPluginManager().callEvent(event);
   if (event.isCancelled()) return;
   gui = event.getGui();
   p1 = event.getPlayer();
   PAGEMAP.put(p1.getName(), page);
   gui.open(p1);
 }
コード例 #3
0
 @Override
 protected void handleClick(GUI gui, Player p, ItemStack item) {
   Balloons config = plugin.getBalloons();
   if (gui.getName().equals(Placeholders.parse(config.getGuiName(), p))) {
     CosmeticsAPI api = plugin.getApi();
     if (config.getHomeItem().getItem().isSimilar(item)) {
       if (plugin.getBabies().getGuiClickSound() != null)
         Sounds.playSound(p, plugin.getBabies().getGuiClickSound());
       CosmeticsGuiHandler.open(p);
       return;
     }
     if (config.getRemoveItem().getItem().isSimilar(item)) {
       if (api.hasBalloon(p)) api.getBalloon(p).remove();
       Sounds.playSound(p, config.getRemoveSound());
       p.closeInventory();
       return;
     }
     if (Methods.isNoPermissionItem(config.getNoPermissionItem(), item)) {
       plugin.informPlayerNoPermission(p, config.getNoPermissionMessage());
       return;
     }
     if (config.getPreviousItem().getItem().isSimilar(item)) {
       if (plugin.getBabies().getGuiClickSound() != null)
         Sounds.playSound(p, plugin.getBabies().getGuiClickSound());
       int currPage = PAGEMAP.get(p.getName());
       if (currPage == 0) open(p, config.getMaxPage());
       else open(p, currPage - 1);
       return;
     }
     if (config.getNextItem().getItem().isSimilar(item)) {
       if (plugin.getBabies().getGuiClickSound() != null)
         Sounds.playSound(p, plugin.getBabies().getGuiClickSound());
       int currPage = PAGEMAP.get(p.getName());
       if (currPage == config.getMaxPage()) open(p, 0);
       else open(p, currPage + 1);
       return;
     }
     BalloonStorage balloon = api.getBalloonByItemStack(item);
     if (!Methods.hasPermission(p, balloon.getPermission())) {
       plugin.informPlayerNoPermission(p, config.getNoPermissionMessage());
       return;
     }
     new BalloonImpl(p, balloon).give();
     Sounds.playSound(p, config.getGiveSound());
     p.closeInventory();
   }
 }
コード例 #4
0
 public static void open(Player p, int page) {
   Player p1 = p;
   Balloons config = plugin.getBalloons();
   CosmeticsAPI api = plugin.getApi();
   GUI gui =
       buildGui(
           config.getGuiName(),
           config.getGuiSize(),
           config.getHomeItem(),
           config.getPreviousItem(),
           config.getNextItem());
   for (BalloonStorage balloon : config.getBalloons()) {
     int position = getRealPosition(balloon.getPosition(), page, config.getGuiSize());
     if (position != -1) {
       ItemStack item = balloon.getItem().clone();
       if (api.hasBalloon(p1)) {
         if (api.getBalloon(p1)
             .getBalloonStorage()
             .getIdentifier()
             .equals(balloon.getIdentifier())) item.addUnsafeEnchantment(glow, 1);
       }
       gui.setItem(position, item);
       if (config.isNoPermissionItemEnabled()
           && !Methods.hasPermission(p1, balloon.getPermission())) {
         gui.setItem(position, config.getNoPermissionItem(balloon));
       }
     }
   }
   gui.setItem(config.getRemoveItem());
   PlayerOpenGuiEvent event = new PlayerOpenGuiEvent(p1, gui);
   Bukkit.getPluginManager().callEvent(event);
   if (event.isCancelled()) return;
   gui = event.getGui();
   p1 = event.getPlayer();
   PAGEMAP.put(p1.getName(), page);
   gui.open(p1);
 }