forked from SteamWar/SteamWar
Add MissileWars module
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
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.scripts.implemented;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import de.steamwar.misslewars.Config;
|
||||
import de.steamwar.misslewars.MissileWars;
|
||||
import de.steamwar.misslewars.scripts.RunnableScript;
|
||||
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DelayScript implements RunnableScript {
|
||||
|
||||
private static final Map<String, Integer> delayMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
delayMap.put("config.mineflytime", Config.ShieldFlyTime);
|
||||
delayMap.put("config.shieldflytime", Config.ShieldFlyTime);
|
||||
delayMap.put("config.endtime", Config.EndTime);
|
||||
delayMap.put("config.waitingtime", Config.WaitingTime);
|
||||
delayMap.put("config.itemtime", Config.ItemTime);
|
||||
delayMap.put("config.platformtime", Config.PlatformTime);
|
||||
|
||||
delayMap.put("config.tick", 1);
|
||||
}
|
||||
|
||||
private int delayTime = 0;
|
||||
|
||||
public DelayScript(JsonObject delay) {
|
||||
JsonPrimitive jsonPrimitive = delay.getAsJsonPrimitive("time");
|
||||
if (jsonPrimitive.isString()) delayTime = delayMap.getOrDefault(jsonPrimitive.getAsString().toLowerCase(), 0);
|
||||
else if (jsonPrimitive.isNumber()) delayTime = jsonPrimitive.getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), runnableScriptEvent::resumeScriptExecution, delayTime);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user