From f1e19126a991e4f1c7a1b0242f72e84439c7bd46 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 19 Dec 2020 13:04:49 +0100 Subject: [PATCH] Improve Code Complexity --- .../misslewars/scripts/RunnableScript.java | 4 +++ .../scripts/RunnableScriptEvent.java | 5 +--- .../misslewars/scripts/ScriptFunction.java | 26 ------------------- .../scripts/implemented/FilterScript.java | 1 - .../scripts/implemented/LaunchScript.java | 1 - .../scripts/implemented/LocationScript.java | 1 - .../scripts/implemented/SummonScript.java | 1 - 7 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 src/de/steamwar/misslewars/scripts/ScriptFunction.java diff --git a/src/de/steamwar/misslewars/scripts/RunnableScript.java b/src/de/steamwar/misslewars/scripts/RunnableScript.java index a5d784d..4f9f688 100644 --- a/src/de/steamwar/misslewars/scripts/RunnableScript.java +++ b/src/de/steamwar/misslewars/scripts/RunnableScript.java @@ -21,4 +21,8 @@ package de.steamwar.misslewars.scripts; public interface RunnableScript { boolean execute(RunnableScriptEvent runnableScriptEvent); + + interface ScriptFunction { + boolean execute(RunnableScriptEvent runnableScriptEvent, double... doubles); + } } diff --git a/src/de/steamwar/misslewars/scripts/RunnableScriptEvent.java b/src/de/steamwar/misslewars/scripts/RunnableScriptEvent.java index 38d1bd4..8758835 100644 --- a/src/de/steamwar/misslewars/scripts/RunnableScriptEvent.java +++ b/src/de/steamwar/misslewars/scripts/RunnableScriptEvent.java @@ -52,10 +52,7 @@ public class RunnableScriptEvent { if (locationType == LocationType.STATIC) return location; // Dynamic Location if entity is not null - if (locationType == LocationType.DYNAMIC) { - if (entity != null) return entity.getLocation(); - return location; - } + if (locationType == LocationType.DYNAMIC) return entity != null ? entity.getLocation() : location; // Default Location is static if EventType is onClick otherwise dynamic if (eventType == ScriptedItem.EventType.onClick) return location; diff --git a/src/de/steamwar/misslewars/scripts/ScriptFunction.java b/src/de/steamwar/misslewars/scripts/ScriptFunction.java deleted file mode 100644 index 18685f8..0000000 --- a/src/de/steamwar/misslewars/scripts/ScriptFunction.java +++ /dev/null @@ -1,26 +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 . - * / - */ - -package de.steamwar.misslewars.scripts; - -public interface ScriptFunction { - boolean execute(RunnableScriptEvent runnableScriptEvent, double... doubles); -} diff --git a/src/de/steamwar/misslewars/scripts/implemented/FilterScript.java b/src/de/steamwar/misslewars/scripts/implemented/FilterScript.java index a65ba13..85a6de2 100644 --- a/src/de/steamwar/misslewars/scripts/implemented/FilterScript.java +++ b/src/de/steamwar/misslewars/scripts/implemented/FilterScript.java @@ -23,7 +23,6 @@ import com.google.gson.JsonObject; import de.steamwar.misslewars.MissileWars; import de.steamwar.misslewars.scripts.RunnableScript; import de.steamwar.misslewars.scripts.RunnableScriptEvent; -import de.steamwar.misslewars.scripts.ScriptFunction; import org.bukkit.Location; import java.util.HashMap; diff --git a/src/de/steamwar/misslewars/scripts/implemented/LaunchScript.java b/src/de/steamwar/misslewars/scripts/implemented/LaunchScript.java index 6e29ad1..24481a0 100644 --- a/src/de/steamwar/misslewars/scripts/implemented/LaunchScript.java +++ b/src/de/steamwar/misslewars/scripts/implemented/LaunchScript.java @@ -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 de.steamwar.misslewars.scripts.ScriptFunction; import de.steamwar.misslewars.scripts.utils.EntityUtils; import de.steamwar.misslewars.scripts.utils.EntityUtils.ScriptShortcut; import org.bukkit.entity.Projectile; diff --git a/src/de/steamwar/misslewars/scripts/implemented/LocationScript.java b/src/de/steamwar/misslewars/scripts/implemented/LocationScript.java index aad7ea5..af2dfaa 100644 --- a/src/de/steamwar/misslewars/scripts/implemented/LocationScript.java +++ b/src/de/steamwar/misslewars/scripts/implemented/LocationScript.java @@ -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.RunnableScriptEvent.LocationType; -import de.steamwar.misslewars.scripts.ScriptFunction; import org.bukkit.Location; import java.util.HashMap; diff --git a/src/de/steamwar/misslewars/scripts/implemented/SummonScript.java b/src/de/steamwar/misslewars/scripts/implemented/SummonScript.java index f2db2be..84cbe13 100644 --- a/src/de/steamwar/misslewars/scripts/implemented/SummonScript.java +++ b/src/de/steamwar/misslewars/scripts/implemented/SummonScript.java @@ -22,7 +22,6 @@ package de.steamwar.misslewars.scripts.implemented; import com.google.gson.JsonObject; import de.steamwar.misslewars.scripts.RunnableScript; import de.steamwar.misslewars.scripts.RunnableScriptEvent; -import de.steamwar.misslewars.scripts.ScriptFunction; import de.steamwar.misslewars.scripts.utils.EntityUtils; import de.steamwar.misslewars.scripts.utils.EntityUtils.ScriptShortcut; import org.bukkit.entity.Entity;