Update FF Event Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
e24970f947
Commit
e8fa5ead91
@ -440,8 +440,9 @@ SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eTNTExplode §8-§7 x, y, z
|
|||||||
SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eTNTExplodeInBuild §8-§7 x, y, z
|
SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eTNTExplodeInBuild §8-§7 x, y, z
|
||||||
SCRIPT_GUI_CUSTOM_EVENTS_LORE_18 = §eSelfJoin §8-§7 x, y, z, playerName
|
SCRIPT_GUI_CUSTOM_EVENTS_LORE_18 = §eSelfJoin §8-§7 x, y, z, playerName
|
||||||
SCRIPT_GUI_CUSTOM_EVENTS_LORE_19 = §eSelfLeave §8-§7 x, y, z, playerName
|
SCRIPT_GUI_CUSTOM_EVENTS_LORE_19 = §eSelfLeave §8-§7 x, y, z, playerName
|
||||||
|
SCRIPT_GUI_CUSTOM_EVENTS_LORE_20 = §eDropItem §8-§7 material, x, y, z
|
||||||
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Alles in den Klammern ist nur gesetzt,
|
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Alles in den Klammern ist nur gesetzt,
|
||||||
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_2 = §7wenn die Variable dafür gesetzt ist.
|
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_2 = §7wenn die Variable davor auf §etrue§7 gesetzt ist.
|
||||||
|
|
||||||
SCRIPT_GUI_OTHER = §eOther
|
SCRIPT_GUI_OTHER = §eOther
|
||||||
SCRIPT_GUI_OTHER_LORE_1 = §7Kommentare fangen mit §e#§7 an.
|
SCRIPT_GUI_OTHER_LORE_1 = §7Kommentare fangen mit §e#§7 an.
|
||||||
|
@ -21,15 +21,13 @@ package de.steamwar.bausystem.features.script;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.features.script.variables.Value;
|
import de.steamwar.bausystem.features.script.variables.Value;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -40,17 +38,13 @@ public enum EventType {
|
|||||||
FF(PlayerSwapHandItemsEvent.class, event -> null),
|
FF(PlayerSwapHandItemsEvent.class, event -> null),
|
||||||
PlaceBlock(BlockPlaceEvent.class, event -> {
|
PlaceBlock(BlockPlaceEvent.class, event -> {
|
||||||
Map<String, Value> valueMap = new HashMap<>();
|
Map<String, Value> valueMap = new HashMap<>();
|
||||||
valueMap.put("blockX", new Value.LongValue(event.getBlockPlaced().getX()));
|
addBlockXYZ(valueMap, event.getBlockPlaced().getLocation());
|
||||||
valueMap.put("blockY", new Value.LongValue(event.getBlockPlaced().getY()));
|
|
||||||
valueMap.put("blockZ", new Value.LongValue(event.getBlockPlaced().getZ()));
|
|
||||||
valueMap.put("blockType", new Value.StringValue(event.getBlockPlaced().getType().name()));
|
valueMap.put("blockType", new Value.StringValue(event.getBlockPlaced().getType().name()));
|
||||||
return valueMap;
|
return valueMap;
|
||||||
}),
|
}),
|
||||||
BreakBlock(BlockBreakEvent.class, event -> {
|
BreakBlock(BlockBreakEvent.class, event -> {
|
||||||
Map<String, Value> valueMap = new HashMap<>();
|
Map<String, Value> valueMap = new HashMap<>();
|
||||||
valueMap.put("blockX", new Value.LongValue(event.getBlock().getX()));
|
addBlockXYZ(valueMap, event.getBlock().getLocation());
|
||||||
valueMap.put("blockY", new Value.LongValue(event.getBlock().getY()));
|
|
||||||
valueMap.put("blockZ", new Value.LongValue(event.getBlock().getZ()));
|
|
||||||
valueMap.put("blockType", new Value.StringValue(event.getBlock().getType().name()));
|
valueMap.put("blockType", new Value.StringValue(event.getBlock().getType().name()));
|
||||||
return valueMap;
|
return valueMap;
|
||||||
}),
|
}),
|
||||||
@ -61,9 +55,7 @@ public enum EventType {
|
|||||||
valueMap.put("handType", new Value.StringValue(event.getMaterial().name()));
|
valueMap.put("handType", new Value.StringValue(event.getMaterial().name()));
|
||||||
valueMap.put("hasBlock", new Value.BooleanValue(event.hasBlock()));
|
valueMap.put("hasBlock", new Value.BooleanValue(event.hasBlock()));
|
||||||
if (event.hasBlock()) {
|
if (event.hasBlock()) {
|
||||||
valueMap.put("blockX", new Value.LongValue(event.getClickedBlock().getX()));
|
addBlockXYZ(valueMap, event.getClickedBlock().getLocation());
|
||||||
valueMap.put("blockY", new Value.LongValue(event.getClickedBlock().getY()));
|
|
||||||
valueMap.put("blockZ", new Value.LongValue(event.getClickedBlock().getZ()));
|
|
||||||
valueMap.put("blockFace", new Value.StringValue(event.getBlockFace().name()));
|
valueMap.put("blockFace", new Value.StringValue(event.getBlockFace().name()));
|
||||||
}
|
}
|
||||||
return valueMap;
|
return valueMap;
|
||||||
@ -75,9 +67,7 @@ public enum EventType {
|
|||||||
valueMap.put("handType", new Value.StringValue(event.getMaterial().name()));
|
valueMap.put("handType", new Value.StringValue(event.getMaterial().name()));
|
||||||
valueMap.put("hasBlock", new Value.BooleanValue(event.hasBlock()));
|
valueMap.put("hasBlock", new Value.BooleanValue(event.hasBlock()));
|
||||||
if (event.hasBlock()) {
|
if (event.hasBlock()) {
|
||||||
valueMap.put("blockX", new Value.LongValue(event.getClickedBlock().getX()));
|
addBlockXYZ(valueMap, event.getClickedBlock().getLocation());
|
||||||
valueMap.put("blockY", new Value.LongValue(event.getClickedBlock().getY()));
|
|
||||||
valueMap.put("blockZ", new Value.LongValue(event.getClickedBlock().getZ()));
|
|
||||||
valueMap.put("blockFace", new Value.StringValue(event.getBlockFace().name()));
|
valueMap.put("blockFace", new Value.StringValue(event.getBlockFace().name()));
|
||||||
}
|
}
|
||||||
return valueMap;
|
return valueMap;
|
||||||
@ -85,33 +75,43 @@ public enum EventType {
|
|||||||
TNTSpawn(EntitySpawnEvent.class, event -> null),
|
TNTSpawn(EntitySpawnEvent.class, event -> null),
|
||||||
TNTExplode(EntityExplodeEvent.class, event -> {
|
TNTExplode(EntityExplodeEvent.class, event -> {
|
||||||
Map<String, Value> valueMap = new HashMap<>();
|
Map<String, Value> valueMap = new HashMap<>();
|
||||||
valueMap.put("x", new Value.DoubleValue(event.getLocation().getX()));
|
addXYZ(valueMap, event.getLocation());
|
||||||
valueMap.put("y", new Value.DoubleValue(event.getLocation().getY()));
|
|
||||||
valueMap.put("z", new Value.DoubleValue(event.getLocation().getZ()));
|
|
||||||
return valueMap;
|
return valueMap;
|
||||||
}),
|
}),
|
||||||
TNTExplodeInBuild(EntityExplodeEvent.class, event -> {
|
TNTExplodeInBuild(EntityExplodeEvent.class, event -> {
|
||||||
Map<String, Value> valueMap = new HashMap<>();
|
Map<String, Value> valueMap = new HashMap<>();
|
||||||
valueMap.put("x", new Value.DoubleValue(event.getLocation().getX()));
|
addXYZ(valueMap, event.getLocation());
|
||||||
valueMap.put("y", new Value.DoubleValue(event.getLocation().getY()));
|
|
||||||
valueMap.put("z", new Value.DoubleValue(event.getLocation().getZ()));
|
|
||||||
return valueMap;
|
return valueMap;
|
||||||
}),
|
}),
|
||||||
SelfJoin(PlayerJoinEvent.class, event -> {
|
SelfJoin(PlayerJoinEvent.class, event -> {
|
||||||
Map<String, Value> valueMap = new HashMap<>();
|
Map<String, Value> valueMap = new HashMap<>();
|
||||||
valueMap.put("x", new Value.DoubleValue(event.getPlayer().getLocation().getX()));
|
addXYZ(valueMap, event.getPlayer().getLocation());
|
||||||
valueMap.put("y", new Value.DoubleValue(event.getPlayer().getLocation().getY()));
|
|
||||||
valueMap.put("z", new Value.DoubleValue(event.getPlayer().getLocation().getZ()));
|
|
||||||
return valueMap;
|
return valueMap;
|
||||||
}),
|
}),
|
||||||
SelfLeave(PlayerQuitEvent.class, event -> {
|
SelfLeave(PlayerQuitEvent.class, event -> {
|
||||||
Map<String, Value> valueMap = new HashMap<>();
|
Map<String, Value> valueMap = new HashMap<>();
|
||||||
valueMap.put("x", new Value.DoubleValue(event.getPlayer().getLocation().getX()));
|
addXYZ(valueMap, event.getPlayer().getLocation());
|
||||||
valueMap.put("y", new Value.DoubleValue(event.getPlayer().getLocation().getY()));
|
return valueMap;
|
||||||
valueMap.put("z", new Value.DoubleValue(event.getPlayer().getLocation().getZ()));
|
}),
|
||||||
|
DropItem(PlayerDropItemEvent.class, event -> {
|
||||||
|
Map<String, Value> valueMap = new HashMap<>();
|
||||||
|
valueMap.put("material", new Value.StringValue(event.getItemDrop().getItemStack().getType().name()));
|
||||||
|
addXYZ(valueMap, event.getItemDrop().getLocation());
|
||||||
return valueMap;
|
return valueMap;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private static void addXYZ(Map<String, Value> valueMap, Location location) {
|
||||||
|
valueMap.put("x", new Value.DoubleValue(location.getX()));
|
||||||
|
valueMap.put("y", new Value.DoubleValue(location.getY()));
|
||||||
|
valueMap.put("z", new Value.DoubleValue(location.getZ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addBlockXYZ(Map<String, Value> valueMap, Location location) {
|
||||||
|
valueMap.put("blockX", new Value.LongValue(location.getBlockX()));
|
||||||
|
valueMap.put("blockY", new Value.LongValue(location.getBlockY()));
|
||||||
|
valueMap.put("blockZ", new Value.LongValue(location.getBlockZ()));
|
||||||
|
}
|
||||||
|
|
||||||
private Class<? extends Event> eventType;
|
private Class<? extends Event> eventType;
|
||||||
private Function<Event, Map<String, Value>> eventValues;
|
private Function<Event, Map<String, Value>> eventValues;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class ScriptCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_COMMANDS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_", 1, 13), false, clickType -> {
|
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_COMMANDS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_", 1, 13), false, clickType -> {
|
||||||
}), null));
|
}), null));
|
||||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_EVENTS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_", 1, 19, loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_", 1, 2)), false, clickType -> {
|
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_EVENTS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_", 1, 20, loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_", 1, 2)), false, clickType -> {
|
||||||
}), null));
|
}), null));
|
||||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_OTHER", p), loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_", 1, 9), false, clickType -> {
|
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_OTHER", p), loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_", 1, 9), false, clickType -> {
|
||||||
}), null));
|
}), null));
|
||||||
|
@ -36,13 +36,10 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Map;
|
||||||
|
|
||||||
@Linked(LinkageType.LISTENER)
|
@Linked(LinkageType.LISTENER)
|
||||||
public class ScriptEventListener implements Listener {
|
public class ScriptEventListener implements Listener {
|
||||||
@ -50,10 +47,12 @@ public class ScriptEventListener implements Listener {
|
|||||||
@LinkedInstance
|
@LinkedInstance
|
||||||
private CustomScriptManager customScriptManager;
|
private CustomScriptManager customScriptManager;
|
||||||
|
|
||||||
private static final Set<Player> LAST_FS = new HashSet<>();
|
private static final Map<Player, Long> LAST_FS = new HashMap<>();
|
||||||
|
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), LAST_FS::clear, 20, 20);
|
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
|
LAST_FS.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() > 200);
|
||||||
|
}, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -68,10 +67,10 @@ public class ScriptEventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
||||||
if (LAST_FS.contains(event.getPlayer())) {
|
if (LAST_FS.containsKey(event.getPlayer())) {
|
||||||
customScriptManager.callEvent(EventType.FF, event.getPlayer(), event);
|
customScriptManager.callEvent(EventType.FF, event.getPlayer(), event);
|
||||||
} else {
|
} else {
|
||||||
LAST_FS.add(event.getPlayer());
|
LAST_FS.put(event.getPlayer(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,4 +121,9 @@ public class ScriptEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
customScriptManager.callEvent(EventType.DropItem, event.getPlayer(), event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren