i have problem

Discussion in 'Plugin Development' started by TheQurekPL, Jan 9, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    TheQurekPL

    plis me help
     

    Attached Files:

    • fg.PNG
      fg.PNG
      File size:
      66.3 KB
      Views:
      8
    • fg.PNG
      fg.PNG
      File size:
      66.3 KB
      Views:
      8
    • fg.PNG
      fg.PNG
      File size:
      66.3 KB
      Views:
      7
    • fg.PNG
      fg.PNG
      File size:
      66.3 KB
      Views:
      7
  2. Online

    timtower Ninja on the waves Moderator

  3. Offline

    TheQurekPL

    ?

    java 8

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 9, 2019
  4. Online

    timtower Ninja on the waves Moderator

  5. Offline

    TheQurekPL

  6. Online

    timtower Ninja on the waves Moderator

    @TheQurekPL Split line 64 into multiple lines please, you don't need to assign anything there.
     
  7. Offline

    TheQurekPL

    WHATTT

    it did not help

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 9, 2019
  8. Offline

    TheQurekPL

    @Zombie_Striker all or on this folder from package(My english is bad because i from poland)
     
  9. Online

    timtower Ninja on the waves Moderator

    This class.
     
  10. Offline

    TheQurekPL

  11. Online

    timtower Ninja on the waves Moderator

    [code]<code here>[/code] in the post.
     
  12. Offline

    TheQurekPL

    Code:
    
    package pl.qurek.Case.listeners;
    
    import java.util.Iterator;
    import java.util.List;
    import java.util.Random;
    import pl.qurek.Case.managers.*;
    import pl.qurek.Case.objects.*;
    import pl.qurek.Case.utils.*;
    import org.bukkit.Material;
    import org.bukkit.Server;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class CaseListener
      implements Listener
    {
      private JavaPlugin plugin;
      public CaseListener(JavaPlugin plugin)
      {
        this.plugin = plugin;
        this.plugin.getServer().getPluginManager().registerEvents(this, this.plugin);
      }
      @EventHandler
      public void onPlace(final BlockPlaceEvent e) {
          if (e.isCancelled()) {
              return;
          }
          final Player p = e.getPlayer();
          final ItemStack item = e.getPlayer().getItemInHand();
          if (item.getType() != Material.CHEST) {
              return;
          }
          if (!item.hasItemMeta()) {
              return;
          }
          if (!item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatUtil.fixColor(this.plugin.getConfig().getString("itemstack-premiumcase.name")))) {
              return;
          }
          e.setCancelled(true);
          final ItemStack isp = p.getItemInHand().clone();
          isp.setAmount(1);
          p.getInventory().removeItem(new ItemStack[] { isp });
          final Random rand = new Random();
          final Drop drop = DropsManager.drops.get(rand.nextInt(DropsManager.drops.size()));
          for (final ItemStack is : drop.getItems()) {
              e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), is);
          }
          if (this.plugin.getConfig().getBoolean("messages-enable.open-broadcast")) {
              for (String msg : drop.getMessage()) {
                  msg = msg.replace("{PLAYER}", p.getName());
                  Player[] onlinePlayers;
                  for (int length = (onlinePlayers = this.plugin.getServer().getOnlinePlayers()).length, i = 0; // error
                      i < length; ++i) {
                      final Player online = onlinePlayers[i];
                      online.sendMessage(ChatUtil.fixColor(msg));
                  }
              }
          }
          if (this.plugin.getConfig().getBoolean("messages-enable.open-msg")) {
              for (String msg : drop.getMessage()) {
                  msg = msg.replace("{PLAYER}", p.getName());
                  p.sendMessage(ChatUtil.fixColor(msg));
              }
          }
      }
    }
    [CODE]
     
  13. Online

    timtower Ninja on the waves Moderator

    @TheQurekPL Why so complicated in 1 line?
    Why not like this:
    Code:
    Player[] onlinePlayers = this.plugin.getServer().getOnlinePlayers();
    for(int i = 0; i<onlinePlayers.length;i++){
     
Thread Status:
Not open for further replies.

Share This Page