Update2.0 #22
@ -21,6 +21,7 @@ package de.steamwar.misslewars.scripts;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RunnableScriptEvent {
|
||||
|
||||
@ -74,4 +75,8 @@ public class RunnableScriptEvent {
|
||||
this.customLocation = new Location(location.getWorld(), x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return (Player) entity;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,16 +39,14 @@ public class LaunchScript extends RunnableScript {
|
||||
switch (launch.getAsJsonPrimitive("entity").getAsString().toLowerCase()) {
|
||||
case "fireball":
|
||||
this.launch = runnableScriptEvent -> {
|
||||
Player player = (Player) runnableScriptEvent.entity;
|
||||
Fireball fireball = player.launchProjectile(Fireball.class);
|
||||
Fireball fireball = runnableScriptEvent.getPlayer().launchProjectile(Fireball.class);
|
||||
setFireballOptions(fireball, launch);
|
||||
fireball.setDirection(runnableScriptEvent.getLocation().getDirection());
|
||||
};
|
||||
break;
|
||||
case "arrow":
|
||||
this.launch = runnableScriptEvent -> {
|
||||
Player player = (Player) runnableScriptEvent.entity;
|
||||
Arrow arrow = player.launchProjectile(Arrow.class);
|
||||
Arrow arrow = runnableScriptEvent.getPlayer().launchProjectile(Arrow.class);
|
||||
setProjectileOptions(arrow, launch);
|
||||
};
|
||||
break;
|
||||
|
@ -23,7 +23,6 @@ import com.google.gson.JsonObject;
|
||||
import de.steamwar.misslewars.scripts.RunnableScript;
|
||||
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
|
||||
import de.steamwar.misslewars.scripts.ScriptedItem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@ -52,8 +51,7 @@ public class PotionScript extends RunnableScript {
|
||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||
if (potionEffect == null) return false;
|
||||
if (runnableScriptEvent.eventType != ScriptedItem.EventType.onClick) return true;
|
||||
Player player = (Player) runnableScriptEvent.entity;
|
||||
player.addPotionEffect(potionEffect);
|
||||
runnableScriptEvent.getPlayer().addPotionEffect(potionEffect);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class SoundScript extends RunnableScript {
|
||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||
if (sound == null) return false;
|
||||
if (runnableScriptEvent.eventType != ScriptedItem.EventType.onClick) return true;
|
||||
Player player = (Player) runnableScriptEvent.entity;
|
||||
Player player = runnableScriptEvent.getPlayer();
|
||||
player.playSound(player.getLocation(), sound, volume, pitch);
|
||||
return true;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren