Dieser Commit ist enthalten in:
Ursprung
e2dc9bb587
Commit
e08982f594
@ -42,6 +42,7 @@ public class ItemListener extends BasicListener {
|
|||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
|
if (e.getPlayer().hasCooldown(item.getType())) return;
|
||||||
|
|
||||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_AIR)
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_AIR)
|
||||||
return;
|
return;
|
||||||
|
@ -2,9 +2,12 @@ package de.steamwar.misslewars.scripts.implemented;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
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 org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class CooldownScript implements RunnableScript {
|
public class CooldownScript implements RunnableScript {
|
||||||
|
|
||||||
@ -17,8 +20,12 @@ public class CooldownScript implements RunnableScript {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||||
if (runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType(), cooldown);
|
Material mainHand = runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType();
|
||||||
if (runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType(), cooldown);
|
Material offHand = runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType();
|
||||||
|
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> {
|
||||||
|
if (mainHand != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(mainHand, cooldown);
|
||||||
|
if (offHand != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(offHand, cooldown);
|
||||||
|
}, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren