SteamWar/MissileWars
Archiviert
13
0

Update2.0 #22

Manuell gemergt
YoyoNow hat 32 Commits von Update2.0 nach master 2020-12-20 13:52:31 +01:00 zusammengeführt
4 geänderte Dateien mit 9 neuen und 8 gelöschten Zeilen
Nur Änderungen aus Commit 25f2b27406 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.misslewars.scripts;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class RunnableScriptEvent { public class RunnableScriptEvent {
@ -74,4 +75,8 @@ public class RunnableScriptEvent {
this.customLocation = new Location(location.getWorld(), x, y, z, yaw, pitch); this.customLocation = new Location(location.getWorld(), x, y, z, yaw, pitch);
} }
public Player getPlayer() {
return (Player) entity;
}
} }

Datei anzeigen

@ -39,16 +39,14 @@ public class LaunchScript extends RunnableScript {
switch (launch.getAsJsonPrimitive("entity").getAsString().toLowerCase()) { switch (launch.getAsJsonPrimitive("entity").getAsString().toLowerCase()) {
case "fireball": case "fireball":
this.launch = runnableScriptEvent -> { this.launch = runnableScriptEvent -> {
Player player = (Player) runnableScriptEvent.entity; Fireball fireball = runnableScriptEvent.getPlayer().launchProjectile(Fireball.class);
Fireball fireball = player.launchProjectile(Fireball.class);
setFireballOptions(fireball, launch); setFireballOptions(fireball, launch);
fireball.setDirection(runnableScriptEvent.getLocation().getDirection()); fireball.setDirection(runnableScriptEvent.getLocation().getDirection());
}; };
break; break;
case "arrow": case "arrow":
this.launch = runnableScriptEvent -> { this.launch = runnableScriptEvent -> {
Player player = (Player) runnableScriptEvent.entity; Arrow arrow = runnableScriptEvent.getPlayer().launchProjectile(Arrow.class);
Arrow arrow = player.launchProjectile(Arrow.class);
setProjectileOptions(arrow, launch); setProjectileOptions(arrow, launch);
}; };
break; break;

Datei anzeigen

@ -23,7 +23,6 @@ import com.google.gson.JsonObject;
import de.steamwar.misslewars.scripts.RunnableScript; import de.steamwar.misslewars.scripts.RunnableScript;
import de.steamwar.misslewars.scripts.RunnableScriptEvent; import de.steamwar.misslewars.scripts.RunnableScriptEvent;
import de.steamwar.misslewars.scripts.ScriptedItem; import de.steamwar.misslewars.scripts.ScriptedItem;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -52,8 +51,7 @@ public class PotionScript extends RunnableScript {
public boolean execute(RunnableScriptEvent runnableScriptEvent) { public boolean execute(RunnableScriptEvent runnableScriptEvent) {
if (potionEffect == null) return false; if (potionEffect == null) return false;
if (runnableScriptEvent.eventType != ScriptedItem.EventType.onClick) return true; if (runnableScriptEvent.eventType != ScriptedItem.EventType.onClick) return true;
Player player = (Player) runnableScriptEvent.entity; runnableScriptEvent.getPlayer().addPotionEffect(potionEffect);
player.addPotionEffect(potionEffect);
return true; return true;
} }

Datei anzeigen

@ -43,7 +43,7 @@ public class SoundScript extends RunnableScript {
public boolean execute(RunnableScriptEvent runnableScriptEvent) { public boolean execute(RunnableScriptEvent runnableScriptEvent) {
if (sound == null) return false; if (sound == null) return false;
if (runnableScriptEvent.eventType != ScriptedItem.EventType.onClick) return true; if (runnableScriptEvent.eventType != ScriptedItem.EventType.onClick) return true;
Player player = (Player) runnableScriptEvent.entity; Player player = runnableScriptEvent.getPlayer();
player.playSound(player.getLocation(), sound, volume, pitch); player.playSound(player.getLocation(), sound, volume, pitch);
return true; return true;
} }