Add CooldownScript #45
@ -85,6 +85,8 @@ public class Script {
|
||||
return new SummonScript(jsonObject);
|
||||
case "slowmo":
|
||||
return new SlowMoScript(jsonObject);
|
||||
case "cooldown":
|
||||
return new CooldownScript(jsonObject);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
24
src/de/steamwar/misslewars/scripts/implemented/CooldownScript.java
Normale Datei
24
src/de/steamwar/misslewars/scripts/implemented/CooldownScript.java
Normale Datei
@ -0,0 +1,24 @@
|
||||
package de.steamwar.misslewars.scripts.implemented;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import de.steamwar.misslewars.scripts.RunnableScript;
|
||||
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class CooldownScript implements RunnableScript {
|
||||
|
||||
private int cooldown = 0;
|
||||
|
||||
public CooldownScript(JsonObject object) {
|
||||
JsonPrimitive primitive = object.getAsJsonPrimitive("cooldown");
|
||||
if(primitive.isNumber()) cooldown = primitive.getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||
if (runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType(), cooldown);
|
||||
if (runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType(), cooldown);
|
||||
return true;
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren