Hey liebe Community,
Ich arbeite derzeit an einem Server Projekt und Entwickle Plugins....
Jetzt hab ich ein weiteres Feature eingebaut in einem Haupt Plugin, das den Spieler Effekte ermöglichen soll.
Das Problem.... Ich schaffe es nicht das es nur auf einem Item läuft das nen bestimmten Namen hat....
Gedacht ist zb: "railgun.firework" und erst dann soll es laufen....
Hier mal den Code:
Frage:
Wie kann ich jetzt überprüfen ob der Gegenstand diesen Namen hat?
Ich wäre für Links und Beispiel Codes sehr froh
Danke schon jetzt für die Hilfe
Ich arbeite derzeit an einem Server Projekt und Entwickle Plugins....
Jetzt hab ich ein weiteres Feature eingebaut in einem Haupt Plugin, das den Spieler Effekte ermöglichen soll.
Das Problem.... Ich schaffe es nicht das es nur auf einem Item läuft das nen bestimmten Namen hat....
Gedacht ist zb: "railgun.firework" und erst dann soll es laufen....
Hier mal den Code:
Code:
@EventHandler
public void railShot(PlayerInteractEvent event){
try {
if (event.getAction() != Action.RIGHT_CLICK_AIR) return;
Player p = event.getPlayer();
if (p.getItemInHand()==null) return;
if (p.getItemInHand().getType()!= Material.BLAZE_ROD) return;
if (p.hasPermission("brandnetz.effekte.railgun") && p.isOp()==true){
Location loc1 = p.getEyeLocation();
@SuppressWarnings("deprecation")
Location loc2 = p.getTargetBlock((HashSet<Byte>) null, 100).getLocation();
if (p.getItemInHand().getType().)
if (loc1 == null) return;
if (loc2 == null) return;
List<Location> line = Util.buildLine(loc1, loc2); // provided by PlayEffect
if (line.size()<=1) return;
line.remove(0);
for (Location l : line){
// PlayEffect: play firework effect to simulate railgun trails
String param = "loc:"+Util.locationToStrLoc(loc1)+" loc2:"+Util.locationToStrLoc(loc2)+" draw:line color:red type:ball";
PlayEffect.play(VisualEffect.FIREWORKS_SPARK, param);
for (Entity e : l.getChunk().getEntities()){
if (!(e instanceof LivingEntity)) continue;
LivingEntity le = (LivingEntity) e;
if (le.getLocation().distance(l)<=1.5) le.damage(le.getMaxHealth()*2);
}
}
} else {
p.sendMessage(plugin_manager + ChatColor.RED + "Du hast keinen Zugang zu diesem Feature!");
}
} catch (Exception e) {
e.printStackTrace();
p.sendMessage(plugin_manager + ChatColor.RESET + "Diesen Code bitte dem Techniker senden: " + ChatColor.RED + "0x00054E");
}
}
Frage:
Wie kann ich jetzt überprüfen ob der Gegenstand diesen Namen hat?
Ich wäre für Links und Beispiel Codes sehr froh
Danke schon jetzt für die Hilfe
Zuletzt bearbeitet von einem Moderator: