Error

Discussion in 'Plugin Development' started by DeadInside, Dec 6, 2018.

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

    DeadInside

    Hey I get this error for every public void or if or { } Could anyone help?


    Code:
      Error:Error:line (137)java: class, interface, or enum expected
        Error:Error:line (140)java: class, interface, or enum expected
        Error:Error:line (141)java: class, interface, or enum expected
        Error:Error:line (146)java: class, interface, or enum expected
        Error:Error:line (148)java: class, interface, or enum expected
        Error:Error:line (152)java: class, interface, or enum expected
        Error:Error:line (154)java: class, interface, or enum expected
        Error:Error:line (156)java: class, interface, or enum expected
        Error:Error:line (157)java: class, interface, or enum expected
        Error:Error:line (160)java: class, interface, or enum expected
        Error:Error:line (163)java: class, interface, or enum expected
        Error:Error:line (164)java: class, interface, or enum expected
        Error:Error:line (167)java: class, interface, or enum expected
        Error:Error:line (168)java: class, interface, or enum expected
        Error:Error:line (176)java: class, interface, or enum expected
        Error:Error:line (179)java: class, interface, or enum expected
        Error:Error:line (180)java: class, interface, or enum expected
        Error:Error:line (181)java: class, interface, or enum expected
        Error:Error:line (182)java: class, interface, or enum expected
        Error:Error:line (183)java: class, interface, or enum expected
        Error:Error:line (184)java: class, interface, or enum expected
        Error:Error:line (185)java: class, interface, or enum expected
        Error:Error:line (186)java: class, interface, or enum expected
        Error:Error:line (187)java: class, interface, or enum expected
        Error:Error:line (189)java: class, interface, or enum expected
        Error:Error:line (190)java: class, interface, or enum expected
        Error:Error:line (191)java: class, interface, or enum expected
        Error:Error:line (192)java: class, interface, or enum expected

    Heres the code:


    Code:
    package classes;
    
    import org.bukkit.*;
    import org.bukkit.block.Block;
    import org.bukkit.block.Sign;
    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.Action;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.event.entity.FoodLevelChangeEvent;
    import org.bukkit.event.player.*;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    import java.util.List;
    
    public class Listeners implements Listener{
    
        private final main plugin;
        private PlayerMoveEvent event;
    
        public Listeners(main main) {
            this.plugin = main;
            this.plugin.getServer().getPluginManager().registerEvents((Listener) this, plugin);
        }
    
        @EventHandler
        public void onFeed(FoodLevelChangeEvent event) {
            if(event.getEntity() instanceof Player) {
                Player player = (Player) event.getEntity();
                if(plugin.inJump.contains(player.getName())) {
                    event.setCancelled(true);
                }
            }
        }
    
        @EventHandler
        public void onItemDrop(PlayerDropItemEvent event) {
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                event.setCancelled(true);
            }
        }
    
        @EventHandler
        public void onItemPickup(PlayerPickupItemEvent event) {
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                event.setCancelled(true);
            }
        }
    
        @EventHandler
        public void onCommandDeny(PlayerCommandPreprocessEvent event) {
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                if(!event.getMessage().contains("/Enojump")) {
                    event.setCancelled(true);
                    event.getPlayer().sendMessage(plugin.prefix + "§8Dieser Command ist nicht erlaubt in der Jump Arena! §c[" + event.getMessage() + "§c]");
                }
            }
        }
    
        @EventHandler
        public void onQuit(PlayerQuitEvent event) {
            if(plugin.inJump.contains(event.getPlayer().getName())) {
    
                plugin.leaveArena(event.getPlayer());
    
            }
        }
    
        @EventHandler
        public void onSignChange(SignChangeEvent e) {
            if(e.getPlayer().hasPermission("Enojump.sign")) {
                if(e.getLine(0).equalsIgnoreCase("[Enojump]")) {
                    e.setLine(0, "§b§oEnojump");
                    e.setLine(1, "§4§lZiel");
                }
            }
        }
    
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event) {
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                event.setCancelled(true);
            }
        }
    
        @EventHandler
        public void onBlockPlace(BlockPlaceEvent event) {
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                event.setCancelled(true);
            }
        }
    
        @EventHandler
        public void onSignInteract(PlayerInteractEvent event) {
            Player p = event.getPlayer();
            if(plugin.inJump.contains(p.getName())) {
                if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    if(event.getClickedBlock().getState() instanceof Sign) {
                        Sign s = (Sign) event.getClickedBlock().getState();
    
                        if(s.getLine(0).equalsIgnoreCase("§b§oEnojump")) {
                            if(s.getLine(1).equalsIgnoreCase("§4§lZiel")) {
    
                                plugin.inJump.remove(p.getName());
    
                                p.getInventory().clear();
                                ItemStack[] old = plugin.oldItems.get(p.getName());
                                p.getInventory().setContents(old);
                                p.updateInventory();
    
                                Location loc = plugin.oldLoc.get(p.getName());
                                p.teleport(loc);
    
                                p.sendMessage(plugin.prefix + "§8Du bekommst 2 Diamanten weil du es geschafft hast!");
                                p.getInventory().addItem(new ItemStack(Material.DIAMOND, 1));
    
                                List<String> materials = this.plugin.config.getStringList("materials");
                                List<String> amount = this.plugin.config.getStringList("amount");
                                if (ItemStack.getType(plugin.getConfig() || ItemStack.getType(Material) || !ItemStack.hasItemMeta(amount)))
                                    Bukkit.broadcastMessage("INVALID MATERIAL");
                                }
                            }
                        }
                    }
                }
            }
        }
    
        @EventHandler
        private void onDamage(EntityDamageEvent event) {
            if(event.getEntity() instanceof Player) {
                Player p = (Player) event.getEntity();
                if(plugin.inJump.contains(p.getName())) {
                    event.setCancelled(true); }
            }
        }
    
        @EventHandler
        private void onPlayerMove(PlayerMoveEvent event) {
            this.event = event;
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                Player player = event.getPlayer();
    
    
                Block block = (Block) player.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
    
                if(((org.bukkit.block.Block) block).getType() == Material.GOLD_BLOCK) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20*5, 3));
                    player.playSound(player.getLocation(), Sound.GHAST_SCREAM, 3, 2);
                }
                if(((org.bukkit.block.Block) block).getType() == Material.BEDROCK) {
                    teleportToSpawn(player);
                }
                if(((org.bukkit.block.Block) block).getType() == Material.IRON_BLOCK) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20*5, 3));
                    player.playSound(player.getLocation(), Sound.GHAST_DEATH, 3, 2);
                }
                if(((org.bukkit.block.Block) block).getType() == Material.DIAMOND_BLOCK) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20*5, 3));
                    player.playSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 3, 2);
                }
            }
        }
    
    
    
    
        @SuppressWarnings("deprecation")
        public void teleportToSpawn(Player p) {
            FileConfiguration cfg = plugin.getConfig();
    
            String world = cfg.getString("Spawn.World");
            double x = cfg.getDouble("Spawn.PosX");
            double y = cfg.getDouble("Spawn.PosY");
            double z = cfg.getDouble("Spawn.PosZ");
            double yaw = cfg.getDouble("Spawn.PosYam");
            double pitch = cfg.getDouble("Spawn.PosPitch");
            Location loc = new Location(Bukkit.getWorld(world), x, y, z);
            loc.setPitch((float) pitch);
            loc.setYaw((float) yaw);
    
            p.teleport(loc);
            p.sendMessage(plugin.prefix + "§8Neuer Versuch! ");
            p.playEffect(p.getLocation(), Effect.GHAST_SHOOT, 3);
        }
    }
    
     
  2. @DeadInside

    Which line is 137?
    You probably forgot some token somewhere near there, but I'm willing to look with you.
     
  3. Offline

    DeadInside

    @knokko

    Code:
            @EventHandler
            public void onDamage(EntityDamageEvent event) { <--- Thats line 137
                if(event.getEntity() instanceof Player) {
                    Player p = (Player) event.getEntity();
                    if(plugin.inJump.contains(p.getName())) {
                        event.setCancelled(true);
                    }
                }
            }
    
        @EventHandler
        private void onPlayerMove(PlayerMoveEvent event) {
            this.event = event;
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                Player player = event.getPlayer();
    
    
                Block block = (Block) player.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
    
                if(((Block) block).getType() == Material.GOLD_BLOCK) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20*5, 3));
                    player.playSound(player.getLocation(), Sound.GHAST_SCREAM, 3, 2);
                }
                if(((Block) block).getType() == Material.BEDROCK) {
                    teleportToSpawn(player);  <--- Thats red marked
                }
                if(((Block) block).getType() == Material.IRON_BLOCK) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20*5, 3));
                    player.playSound(player.getLocation(), Sound.GHAST_DEATH, 3, 2);
                }
                if(((Block) block).getType() == Material.DIAMOND_BLOCK) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 5, 3));
                    player.playSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 3, 2);
                }
    now getEntity and teleportToSpawn is red when I try to export
     
  4. Offline

    KarimAKL

    @knokko I copy and pasted the code into Notepad++, line 137 should be
    Code:Java
    1. private void onDamage(EntityDamageEvent event) {
     
  5. Offline

    DeadInside

    Now I get a list of this errors

    Code:
    Information:java: Errors occurred while compiling module 'jumpnrun'
    Information:javac 1.8.0_191 was used to compile java sources
    Information:07.12.2018 14:41 - Compilation completed with 13 errors and 0 warnings in 1 s 744 ms
    C:\Users\Sweezy\Documents\Plugins\JumpNRun\jumpnrun\src\classes\Listeners.java
        Error:Error:line (137)java: ';' expected
        Error:Error:line (137)java: ';' expected
        Error:Error:line (147)java: ';' expected
        Error:Error:line (147)java: ';' expected
        Error:Error:line (175)java: ';' expected
        Error:Error:line (175)java: ';' expected
        Error:Error:line (194)java: illegal start of expression
        Error:Error:line (194)java: illegal start of expression
        Error:Error:line (194)java: ';' expected
        Error:Error:line (197)java: illegal start of expression
        Error:Error:line (197)java: illegal start of expression
        Error:Error:line (197)java: ';' expected
        Error:Error:line (198)java: reached end of file while parsing
     
  6. @DeadInside

    I think I found it

    Code:
    if (ItemStack.getType(plugin.getConfig() || ItemStack.getType(Material) || !ItemStack.hasItemMeta(amount)))
                                    Bukkit.broadcastMessage("INVALID MATERIAL");
                                }
    You are missing the opening { at the end of the if line.

    (In your onSignInteract method)
     
  7. Offline

    DeadInside

    @knokko

    I think he didnt got it onto code theres one so thats not the problem. :D
     
  8. @DeadInside

    It doesn't matter that that part of the code is not being executed.
    The java compiler can't use any of the code in your Listeners class because it can't understand what is in the file. (In this case, the computer thinks that the rest of the Listeners class is inside the onSignInteract.)
    I think adding a { at the end of the line:
    if (ItemStack.getType(plugin.getConfig() || ItemStack.getType(Material) || !ItemStack.hasItemMeta(amount)))
    will solve a part of your problem.
    But also, the rest of that line is invalid java. What are you even trying to do there?
     
  9. Offline

    DeadInside


    So like I have a jump plugin that like teleport you into an Arena and clear your inventory so when you get back youll get it back, but the problem is like I need to make a config so the amount and material can be changed in the config but like I dont get it how to I watched multiple videos and tried everything.
     
  10. @DeadInside

    Most of your code looks okay, but these 2 lines of code:
    Code:
    if (ItemStack.getType(plugin.getConfig() || ItemStack.getType(Material) || !ItemStack.hasItemMeta(amount)))
                                    Bukkit.broadcastMessage("INVALID MATERIAL");
    }
    are complete nonsense. I was wondering what these 2 lines are supposed to do because I have no clue. I think you should remove those lines for now and I might be able to give you the correct lines if you can tell me what it is supposed to do.
     
Thread Status:
Not open for further replies.

Share This Page