• Es freut uns dass du in unser Minecraft Forum gefunden hast. Hier kannst du mit über 130.000 Minecraft Fans über Minecraft diskutieren, Fragen stellen und anderen helfen. In diesem Minecraft Forum kannst du auch nach Teammitgliedern, Administratoren, Moderatoren , Supporter oder Sponsoren suchen. Gerne kannst du im Offtopic Bereich unseres Minecraft Forums auch über nicht Minecraft spezifische Themen reden. Wir hoffen dir gefällt es in unserem Minecraft Forum!

Wenn Player Blaze Rod rechtsclickt passiert nichts!

S

Scrumplex

Guest
Hi Community,
bin neu hier und wollte mmal fragen warum das was im Titel erwähnt wurde nicht geht?

Code:
	@EventHandler(priority=EventPriority.HIGH)
	public void onPlayerUse(PlayerInteractEvent event){
	    Player p = event.getPlayer();
	 
	    if(event.getAction().equals(Action.LEFT_CLICK_AIR)){
	        if(p.getItemInHand().getType() == Material.BLAZE_ROD){
                event.setCancelled(true);
                double Height = 5 / 15D;
                double Lenght = 16 / 8D;
                Player pe = event.getPlayer();
                pe.setVelocity(pe.getLocation().getDirection().setY(Height).multiply(Lenght));
                pe.playSound(pe.getLocation(), Sound.WITHER_SHOOT, 1F, 1F);	
                
	        
	        }
	    }
	    if(event.getAction().equals(Action.RIGHT_CLICK_AIR)){
	        if(p.getItemInHand().getType() == Material.BLAZE_ROD){
                event.setCancelled(true);
                double Height = 5 / 15D;
                double Lenght = 16 / 8D;
                Player pe = event.getPlayer();
                pe.setVelocity(pe.getLocation().getDirection().setY(Height).multiply(Lenght));
                pe.playSound(pe.getLocation(), Sound.WITHER_SHOOT, 1F, 1F);
	        }
	    }
	}

Bitte hilft mir!
 
S

Scrumplex

Guest
Einen Fehler bekomme ich nicht!

Die ganze Klasse:

Code:
package net.scrumplex.flappycraft;

import java.util.ArrayList;


import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

import net.scrumplex.flappycraft.Commands;;

public class Main extends JavaPlugin {
	ArrayList<String> jumped = new ArrayList<String>();
	public static String pluginName = "§4[Flappycraft]§b";
	public static ArrayList<String> inGamePlayers = new ArrayList<>();
	public static int PlayerAmount = 0;
	
	public void onEnable(){
		this.getCommand("fc").setExecutor(new Commands());
		this.getCommand("flappycraft").setExecutor(new Commands());
		System.out.println("[FlappyCraft "+this.getDescription().getVersion()+"] enabled");
	}
	
	public void onDisable(){
		
		System.out.println("[FlappyCraft "+this.getDescription().getVersion()+"] disabled");
	}
	
	
	
	public void loadConfig(){
		FileConfiguration cfg = this.getConfig();
		cfg.options().copyDefaults(true);
		
	}
	@EventHandler(priority=EventPriority.HIGH)
	public void onPlayerUse(PlayerInteractEvent event){
	    Player p = event.getPlayer();
	 
	    if(event.getAction().equals(Action.LEFT_CLICK_AIR)){
	        if(p.getItemInHand().getType() == Material.BLAZE_ROD){
                event.setCancelled(true);
                double Height = 5 / 15D;
                double Lenght = 16 / 8D;
                Player pe = event.getPlayer();
                pe.setVelocity(pe.getLocation().getDirection().setY(Height).multiply(Lenght));
                pe.playSound(pe.getLocation(), Sound.WITHER_SHOOT, 1F, 1F);	
                
	        
	        }
	    }
	    if(event.getAction().equals(Action.RIGHT_CLICK_AIR)){
	        if(p.getItemInHand().getType() == Material.BLAZE_ROD){
                event.setCancelled(true);
                double Height = 5 / 15D;
                double Lenght = 16 / 8D;
                Player pe = event.getPlayer();
                pe.setVelocity(pe.getLocation().getDirection().setY(Height).multiply(Lenght));
                pe.playSound(pe.getLocation(), Sound.WITHER_SHOOT, 1F, 1F);
	        }
	    }
	}
}
 

MiCrJonas

Threadripper
Registriert
29 Oktober 2012
Beiträge
1.064
Diamanten
0
In Deiner onEnable()-Methode fehlt folgende Anweisung:
Code:
getServer().getPluginManager().registerEvents(this, this);

Und die Methode loadConfig() wird scheinbar auch nicht aufgerufen, was damit aber nichts zu tun hat. Außerdem empfehel ich Dir, die Event-Methoden in eine andere Klasse zu packen.
 
Zuletzt bearbeitet:
Oben