getEntity() error and teleportToSpawn error

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

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

    DeadInside

    Heres my code

    Code:
            @EventHandler
            public 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(((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);
                }
                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);
                }
    
    Heres my main


    Code:
    package classes;
    
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.configuration.ConfigurationSection;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import java.awt.*;
    import java.util.ArrayList;
    import java.util.HashMap;
    
    public class main extends JavaPlugin {
    
        private main plugin;
    
        public ArrayList<String> inJump = new ArrayList<>();
        public HashMap<String, Location> oldLoc = new HashMap<>();
        public HashMap<String, ItemStack[]> oldItems = new HashMap<>();
        public String prefix = "§7[§bEnoJump§7] ";
        public String noperm = "§7[§bEnoJump§7] Du hast keine Permissions!";
        public String help = "§7[§bEnoJump§7] §6Help: /Enojump hilfe";
        public ConfigurationSection config;
    
        @Override
        public void onEnable() {
            getConfig().options().copyDefaults(true);
            saveConfig();
            this.reloadConfig();
            System.out.println("[EnoJump] Plugin version +!" + this.getDescription().getVersion() + " loaded!");
            new Listeners(this);
            getCommand("enojump").setExecutor(new Commands(this));
            Material mat = Material.DIAMOND;int amount = 1;
            ItemStack item = new ItemStack(Material.getMaterial(), 1);
        }
    
        @Override
        public void onDisable() {
            System.out.println("[EnoJump] Plugin deaktiviert!");
    
        }
    
    
    
        @SuppressWarnings("deprecation")
        public void leaveArena(Player player) {
            if(inJump.contains(player.getName())) {
    
                inJump.remove(player.getName());
    
                player.getInventory().clear();
                ItemStack[] old = oldItems.get(player.getName());
                player.getInventory().setContents(old);
                player.updateInventory();
    
                Location location = oldLoc.get(player.getName());
                player.teleport(location);
    
    
                player.sendMessage(prefix + "§cDu hast die Arena verlassen!");
    
            } else {
                player.sendMessage(prefix + "§cDu bist nicht in der Arena!");
            }
        }
    }
    
     
  2. What is the error? How do the teleportToSpawn method look like? Please post some more details about your problem
     
Thread Status:
Not open for further replies.

Share This Page