Add Support Item softcoded
Dieser Commit ist enthalten in:
Ursprung
e8d3974b81
Commit
6f1ab2be8b
@ -60,7 +60,6 @@ public class MissileWars extends JavaPlugin {
|
|||||||
new PortalDestructListener();
|
new PortalDestructListener();
|
||||||
new WaitingListener();
|
new WaitingListener();
|
||||||
new FightListener();
|
new FightListener();
|
||||||
new ArrowListener();
|
|
||||||
new ChatListener();
|
new ChatListener();
|
||||||
getCommand("spectate").setExecutor(new CommandSpectate());
|
getCommand("spectate").setExecutor(new CommandSpectate());
|
||||||
|
|
||||||
|
@ -41,10 +41,13 @@ public class Item extends SpecialItem {
|
|||||||
public Item(File item) {
|
public Item(File item) {
|
||||||
try {
|
try {
|
||||||
JsonObject jsonObject = new JsonParser().parse(new FileReader(item)).getAsJsonObject();
|
JsonObject jsonObject = new JsonParser().parse(new FileReader(item)).getAsJsonObject();
|
||||||
|
System.out.println(jsonObject);
|
||||||
scriptedItem = new ScriptedItem(jsonObject);
|
scriptedItem = new ScriptedItem(jsonObject);
|
||||||
} catch (JsonSyntaxException e) {
|
} catch (JsonSyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
throw new SecurityException("Item JSON error");
|
throw new SecurityException("Item JSON error");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
throw new SecurityException("Corrupt Item");
|
throw new SecurityException("Corrupt Item");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,4 +83,8 @@ public class Item extends SpecialItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScriptedItem getScriptedItem() {
|
||||||
|
return scriptedItem;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,11 @@ public abstract class SpecialItem {
|
|||||||
if (this.isMissile()) {
|
if (this.isMissile()) {
|
||||||
missileItems.add(this);
|
missileItems.add(this);
|
||||||
} else {
|
} else {
|
||||||
materialName = getItem().getType().name().toLowerCase();
|
|
||||||
supportItems.add(this);
|
supportItems.add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String materialName = "";
|
private String materialName = null;
|
||||||
public abstract ItemStack getItem();
|
public abstract ItemStack getItem();
|
||||||
public abstract boolean handleUse(Player p);
|
public abstract boolean handleUse(Player p);
|
||||||
public void handleThrow(Entity e) {}
|
public void handleThrow(Entity e) {}
|
||||||
@ -88,6 +87,9 @@ public abstract class SpecialItem {
|
|||||||
public static void handleThrow(ProjectileLaunchEvent e) {
|
public static void handleThrow(ProjectileLaunchEvent e) {
|
||||||
String name = e.getEntity().getClass().getName().toLowerCase();
|
String name = e.getEntity().getClass().getName().toLowerCase();
|
||||||
for (SpecialItem specialItem : supportItems) {
|
for (SpecialItem specialItem : supportItems) {
|
||||||
|
if (specialItem.materialName == null) {
|
||||||
|
specialItem.materialName = specialItem.getItem().getType().name().toLowerCase();
|
||||||
|
}
|
||||||
if (name.contains(specialItem.materialName)) {
|
if (name.contains(specialItem.materialName)) {
|
||||||
specialItem.handleThrow(e.getEntity());
|
specialItem.handleThrow(e.getEntity());
|
||||||
}
|
}
|
||||||
@ -96,6 +98,7 @@ public abstract class SpecialItem {
|
|||||||
|
|
||||||
public static void handleHit(ProjectileHitEvent e) {
|
public static void handleHit(ProjectileHitEvent e) {
|
||||||
String name = e.getEntity().getClass().getName().toLowerCase();
|
String name = e.getEntity().getClass().getName().toLowerCase();
|
||||||
|
|
||||||
Location location = null;
|
Location location = null;
|
||||||
if (e.getHitEntity() != null) {
|
if (e.getHitEntity() != null) {
|
||||||
location = e.getHitEntity().getLocation();
|
location = e.getHitEntity().getLocation();
|
||||||
@ -103,8 +106,9 @@ public abstract class SpecialItem {
|
|||||||
location = e.getHitBlock().getLocation();
|
location = e.getHitBlock().getLocation();
|
||||||
}
|
}
|
||||||
if (location == null) return;
|
if (location == null) return;
|
||||||
|
|
||||||
for (SpecialItem specialItem : supportItems) {
|
for (SpecialItem specialItem : supportItems) {
|
||||||
if (name.contains(specialItem.materialName)) {
|
if (name.contains(((Item) specialItem).getScriptedItem().getEntityName())) {
|
||||||
specialItem.handleHit(e.getEntity(), location);
|
specialItem.handleHit(e.getEntity(), location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"type": "ARROW",
|
|
||||||
"name": "§ePfeil",
|
|
||||||
"lore": [],
|
|
||||||
"amount": 3,
|
|
||||||
"EVENT.onThrow": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"EVENT.onHit": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"EVENT.onClick": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SPECTRAL_ARROW",
|
|
||||||
"name": "§eExplodierender Pfeil",
|
|
||||||
"lore": [],
|
|
||||||
"amount": 1,
|
|
||||||
"EVENT.onHit": [
|
|
||||||
{"type": "summon", "entity": "TNTPrimed", "incendiary": false, "fuse": 0, "yield": 2.0}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIRE_CHARGE",
|
|
||||||
"name": "§eFeuerball",
|
|
||||||
"lore": [],
|
|
||||||
"amount": 1,
|
|
||||||
"EVENT.onClick": [
|
|
||||||
{"type": "launch", "entity": "Fireball", "incendiary": false, "bounce": false, "yield": 3.0, "velocity": 2},
|
|
||||||
{"type": "sound", "sound": "ITEM_FIRECHARGE_USE", "volume": 100, "pitch": 1}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SLIME_BALL",
|
|
||||||
"name": "§aLanding Pad",
|
|
||||||
"lore": [],
|
|
||||||
"amount": 1,
|
|
||||||
"EVENT.onClick": [
|
|
||||||
{"type": "potion", "potion": "SLOW_FALLING", "duration": 2, "amplifier": 1, "ambient": false, "particles": false, "icon": false},
|
|
||||||
{"type": "paste", "schem": "landingPad.schem", "centered": true, "offset": [0, -5, 0], "ignoreAir": true}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "EGG",
|
|
||||||
"name": "§eMine",
|
|
||||||
"lore": [],
|
|
||||||
"amount": 1,
|
|
||||||
"EVENT.onThrow": [
|
|
||||||
{"type": "delay", "time": "CONFIG.MineFlyTime"},
|
|
||||||
{"type": "filter", "filter": "nearPortal", "invert": true},
|
|
||||||
{"type": "paste", "schem": "mine.schem", "centered": true, "offset": [0, 0, 0], "ignoreAir": true}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SNOWBALL",
|
|
||||||
"name": "§aSchild",
|
|
||||||
"lore": [],
|
|
||||||
"amount": 1,
|
|
||||||
"EVENT.onThrow": [
|
|
||||||
{"type": "delay", "time": "CONFIG.ShieldFlyTime"},
|
|
||||||
{"type": "filter", "filter": "nearPortal", "invert": true},
|
|
||||||
{"type": "paste", "schem": "shield.schem", "centered": true, "offset": [0, 0, 0], "ignoreAir": true}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.misslewars.listener;
|
|
||||||
|
|
||||||
import de.steamwar.misslewars.FightState;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
public class ArrowListener extends BasicListener {
|
|
||||||
|
|
||||||
public ArrowListener() {
|
|
||||||
super(EnumSet.of(FightState.FIGHTING));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onHit(ProjectileHitEvent e) {
|
|
||||||
Projectile projectile = e.getEntity();
|
|
||||||
if (projectile.getType() != EntityType.SPECTRAL_ARROW) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location location = getLocation(e);
|
|
||||||
if (location == null) return;
|
|
||||||
|
|
||||||
TNTPrimed tnt = e.getEntity().getWorld().spawn(location, TNTPrimed.class);
|
|
||||||
tnt.setYield(2.0F);
|
|
||||||
tnt.setIsIncendiary(false);
|
|
||||||
tnt.setFuseTicks(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Location getLocation(ProjectileHitEvent e) {
|
|
||||||
if (e.getHitEntity() != null) {
|
|
||||||
return e.getHitEntity().getLocation();
|
|
||||||
}
|
|
||||||
if (e.getHitBlock() != null) {
|
|
||||||
return e.getHitBlock().getLocation();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -19,23 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars.listener;
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.FightState;
|
import de.steamwar.misslewars.FightState;
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import de.steamwar.misslewars.items.SpecialItem;
|
import de.steamwar.misslewars.items.SpecialItem;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Egg;
|
|
||||||
import org.bukkit.entity.Snowball;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
@ -43,40 +28,10 @@ import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class ItemListener extends BasicListener {
|
public class ItemListener extends BasicListener {
|
||||||
|
|
||||||
private static final File shield = new File(MissileWars.getPlugin().getDataFolder(), "shield.schem");
|
|
||||||
private static final File mine = new File(MissileWars.getPlugin().getDataFolder(), "mine.schem");
|
|
||||||
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
|
|
||||||
private static final Clipboard clipboardShield;
|
|
||||||
private static final BlockVector3 offsetShield;
|
|
||||||
|
|
||||||
private static final Clipboard clipboardMine;
|
|
||||||
private static final BlockVector3 offsetMine;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
clipboardShield = Objects.requireNonNull(ClipboardFormats.findByFile(shield)).getReader(new FileInputStream(shield)).read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException("Could not load shield", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
clipboardMine = Objects.requireNonNull(ClipboardFormats.findByFile(mine)).getReader(new FileInputStream(mine)).read();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException("Could not load mine", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
offsetShield = clipboardShield.getRegion().getMinimumPoint().subtract(clipboardShield.getOrigin()).add(clipboardShield.getDimensions().divide(2));
|
|
||||||
offsetMine = clipboardMine.getRegion().getMinimumPoint().subtract(clipboardMine.getOrigin()).add(clipboardMine.getDimensions().divide(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemListener() {
|
public ItemListener() {
|
||||||
super(EnumSet.of(FightState.FIGHTING));
|
super(EnumSet.of(FightState.FIGHTING));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public interface RunnableScript {
|
|||||||
|
|
||||||
public final ScriptedItem.EventType eventType;
|
public final ScriptedItem.EventType eventType;
|
||||||
public final Entity entity;
|
public final Entity entity;
|
||||||
public final Location location;
|
private final Location location;
|
||||||
|
|
||||||
public RunnableScriptEvent(ScriptedItem.EventType eventType, Entity entity, Location location) {
|
public RunnableScriptEvent(ScriptedItem.EventType eventType, Entity entity, Location location) {
|
||||||
this.eventType = eventType;
|
this.eventType = eventType;
|
||||||
@ -36,6 +36,14 @@ public interface RunnableScript {
|
|||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
if (eventType == ScriptedItem.EventType.onClick) return location;
|
||||||
|
if (entity != null) {
|
||||||
|
return entity.getLocation();
|
||||||
|
}
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean execute(RunnableScriptEvent runnableScriptEvent);
|
boolean execute(RunnableScriptEvent runnableScriptEvent);
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.misslewars.scripts;
|
package de.steamwar.misslewars.scripts;
|
||||||
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import de.steamwar.misslewars.scripts.implemented.DelayScript;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -30,20 +30,55 @@ public class Script {
|
|||||||
|
|
||||||
private List<RunnableScript> runnableScriptList = new ArrayList<>();
|
private List<RunnableScript> runnableScriptList = new ArrayList<>();
|
||||||
|
|
||||||
public void execute(RunnableScript.RunnableScriptEvent runnableScriptEvent) {
|
private class ScriptExecutor {
|
||||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> {
|
|
||||||
int i = 0;
|
private int index = 0;
|
||||||
while (i < runnableScriptList.size()) {
|
|
||||||
if (!runnableScriptList.get(i).execute(runnableScriptEvent)) {
|
private final RunnableScript.RunnableScriptEvent runnableScriptEvent;
|
||||||
|
|
||||||
|
public ScriptExecutor(RunnableScript.RunnableScriptEvent runnableScriptEvent) {
|
||||||
|
this.runnableScriptEvent = runnableScriptEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resume() {
|
||||||
|
while (index < runnableScriptList.size()) {
|
||||||
|
RunnableScript runnableScript = runnableScriptList.get(index);
|
||||||
|
if (runnableScript instanceof DelayScript) {
|
||||||
|
index++;
|
||||||
|
resumeLater(((DelayScript) runnableScript).getDelayTime());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
if (!runnableScript.execute(runnableScriptEvent)) {
|
||||||
|
index = runnableScriptList.size();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}, 0);
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resumeLater(int delayTime) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::resume, delayTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(RunnableScript.RunnableScriptEvent runnableScriptEvent) {
|
||||||
|
new ScriptExecutor(runnableScriptEvent).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(RunnableScript runnableScript) {
|
public void add(RunnableScript runnableScript) {
|
||||||
runnableScriptList.add(runnableScript);
|
runnableScriptList.add(runnableScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Script{" +
|
||||||
|
"runnableScriptList=" + runnableScriptList +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ public class ScriptParser {
|
|||||||
public static Script parseScript(JsonArray jsonArray) {
|
public static Script parseScript(JsonArray jsonArray) {
|
||||||
Script script = new Script();
|
Script script = new Script();
|
||||||
jsonArray.forEach(jsonElement -> {
|
jsonArray.forEach(jsonElement -> {
|
||||||
if (!jsonArray.isJsonObject()) return;
|
|
||||||
RunnableScript runnableScript = parseScriptSnippet((JsonObject) jsonElement);
|
RunnableScript runnableScript = parseScriptSnippet((JsonObject) jsonElement);
|
||||||
if (runnableScript == null) return;
|
if (runnableScript == null) return;
|
||||||
script.add(runnableScript);
|
script.add(runnableScript);
|
||||||
@ -46,6 +45,8 @@ public class ScriptParser {
|
|||||||
return new DelayScript(jsonObject);
|
return new DelayScript(jsonObject);
|
||||||
case "filter":
|
case "filter":
|
||||||
return new FilterScript(jsonObject);
|
return new FilterScript(jsonObject);
|
||||||
|
case "remove":
|
||||||
|
return new RemoveScript(jsonObject);
|
||||||
case "launch":
|
case "launch":
|
||||||
return new LaunchScript(jsonObject);
|
return new LaunchScript(jsonObject);
|
||||||
case "paste":
|
case "paste":
|
||||||
|
@ -53,12 +53,17 @@ public class ScriptedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<EventType, Script> scriptMap = new HashMap<>();
|
private Map<EventType, Script> scriptMap = new HashMap<>();
|
||||||
|
private String entityName = "---";
|
||||||
|
|
||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
|
|
||||||
public ScriptedItem(JsonObject jsonObject) {
|
public ScriptedItem(JsonObject jsonObject) {
|
||||||
itemStack = createItemStack(jsonObject);
|
itemStack = createItemStack(jsonObject);
|
||||||
|
|
||||||
|
if (jsonObject.has("entityName")) {
|
||||||
|
entityName = jsonObject.get("entityName").getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
for (EventType eventType : EventType.values()) {
|
for (EventType eventType : EventType.values()) {
|
||||||
String eventString = "EVENT." + eventType.name();
|
String eventString = "EVENT." + eventType.name();
|
||||||
if (!jsonObject.has(eventString)) continue;
|
if (!jsonObject.has(eventString)) continue;
|
||||||
@ -102,4 +107,8 @@ public class ScriptedItem {
|
|||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEntityName() {
|
||||||
|
return entityName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class DelayScript implements RunnableScript {
|
|||||||
if (jsonPrimitive.isString()) {
|
if (jsonPrimitive.isString()) {
|
||||||
switch (jsonPrimitive.getAsString().toLowerCase()) {
|
switch (jsonPrimitive.getAsString().toLowerCase()) {
|
||||||
case "config.mineflytime":
|
case "config.mineflytime":
|
||||||
case "config.shiledflytime":
|
case "config.shieldflytime":
|
||||||
delayTime = Config.ShieldFlyTime;
|
delayTime = Config.ShieldFlyTime;
|
||||||
break;
|
break;
|
||||||
case "config.endtime":
|
case "config.endtime":
|
||||||
@ -62,12 +62,11 @@ public class DelayScript implements RunnableScript {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||||
try {
|
|
||||||
Thread.sleep(delayTime);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDelayTime() {
|
||||||
|
return delayTime;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class FilterScript implements RunnableScript {
|
|||||||
switch (filter.getAsJsonPrimitive("filter").getAsString().toLowerCase()) {
|
switch (filter.getAsJsonPrimitive("filter").getAsString().toLowerCase()) {
|
||||||
case "nearportal":
|
case "nearportal":
|
||||||
this.filter = runnableScriptEvent -> {
|
this.filter = runnableScriptEvent -> {
|
||||||
Location location = runnableScriptEvent.location;
|
Location location = runnableScriptEvent.getLocation();
|
||||||
int bz = MissileWars.getBlueTeam().getPortalZ();
|
int bz = MissileWars.getBlueTeam().getPortalZ();
|
||||||
int rz = MissileWars.getRedTeam().getPortalZ();
|
int rz = MissileWars.getRedTeam().getPortalZ();
|
||||||
|
|
||||||
@ -47,13 +47,13 @@ public class FilterScript implements RunnableScript {
|
|||||||
|
|
||||||
int blockZ = location.getBlockZ();
|
int blockZ = location.getBlockZ();
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
if (blockZ > bz - offset) return false;
|
if (blockZ > bz - offset) return true;
|
||||||
if (blockZ < rz + offset) return false;
|
if (blockZ < rz + offset) return true;
|
||||||
} else {
|
} else {
|
||||||
if (blockZ < bz - offset) return false;
|
if (blockZ < bz - offset) return true;
|
||||||
if (blockZ > rz + offset) return false;
|
if (blockZ > rz + offset) return true;
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -50,7 +50,7 @@ public class LaunchScript implements RunnableScript {
|
|||||||
setGlowing(fireball, launch);
|
setGlowing(fireball, launch);
|
||||||
setGravity(fireball, launch);
|
setGravity(fireball, launch);
|
||||||
|
|
||||||
fireball.setDirection(runnableScriptEvent.location.getDirection());
|
fireball.setDirection(runnableScriptEvent.getLocation().getDirection());
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "arrow":
|
case "arrow":
|
||||||
|
@ -85,7 +85,7 @@ public class PasteScript implements RunnableScript {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||||
Location location = runnableScriptEvent.location;
|
Location location = runnableScriptEvent.getLocation();
|
||||||
BlockVector3 paste = BlockVector3.at(location.getX() + xOffset, location.getY() + yOffset, location.getZ() + zOffset);
|
BlockVector3 paste = BlockVector3.at(location.getX() + xOffset, location.getY() + yOffset, location.getZ() + zOffset);
|
||||||
if (centered) {
|
if (centered) {
|
||||||
paste = paste.subtract(centeredOffset);
|
paste = paste.subtract(centeredOffset);
|
||||||
|
20
src/de/steamwar/misslewars/scripts/implemented/RemoveScript.java
Normale Datei
20
src/de/steamwar/misslewars/scripts/implemented/RemoveScript.java
Normale Datei
@ -0,0 +1,20 @@
|
|||||||
|
package de.steamwar.misslewars.scripts.implemented;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import de.steamwar.misslewars.scripts.RunnableScript;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class RemoveScript implements RunnableScript {
|
||||||
|
|
||||||
|
public RemoveScript(JsonObject jsonObject) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||||
|
if (runnableScriptEvent.entity instanceof Player) return true;
|
||||||
|
runnableScriptEvent.entity.remove();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -39,7 +39,7 @@ public class SummonScript implements RunnableScript {
|
|||||||
switch (summon.getAsJsonPrimitive("entity").getAsString().toLowerCase()) {
|
switch (summon.getAsJsonPrimitive("entity").getAsString().toLowerCase()) {
|
||||||
case "tntprimed":
|
case "tntprimed":
|
||||||
this.summon = runnableScriptEvent -> {
|
this.summon = runnableScriptEvent -> {
|
||||||
TNTPrimed tnt = runnableScriptEvent.entity.getWorld().spawn(runnableScriptEvent.location, TNTPrimed.class);
|
TNTPrimed tnt = runnableScriptEvent.entity.getWorld().spawn(runnableScriptEvent.getLocation(), TNTPrimed.class);
|
||||||
|
|
||||||
setYield(tnt, summon);
|
setYield(tnt, summon);
|
||||||
setIncendiary(tnt, summon);
|
setIncendiary(tnt, summon);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren