Update AutostartListener
Update Countingwand Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
3e74d53934
Commit
7abdaa4b3e
@ -27,6 +27,7 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
@ -47,7 +48,9 @@ import java.util.Map;
|
||||
public class AutostartListener implements Listener {
|
||||
|
||||
public static ItemStack getWandItem(Player player) {
|
||||
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("AUTOSTART_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("AUTOSTART_ITEM_LORE", player)), false, null).getItemStack();
|
||||
ItemStack itemStack = new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("AUTOSTART_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("AUTOSTART_ITEM_LORE", player)), false, null).getItemStack();
|
||||
ItemUtils.setItem(itemStack, "autostart");
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ -55,7 +58,7 @@ public class AutostartListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!AutostartListener.getWandItem(event.getPlayer()).isSimilar(event.getItem())) {
|
||||
if (!ItemUtils.isItem(event.getItem(), "autostart")) {
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock() == null) {
|
||||
|
@ -20,30 +20,33 @@
|
||||
package de.steamwar.bausystem.features.countingwand;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.config.ColorConfig;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import java.util.*;
|
||||
|
||||
import de.steamwar.message.Message;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@UtilityClass
|
||||
public class Countingwand {
|
||||
|
||||
public static ItemStack getWandItem(Player player) {
|
||||
return new SWItem(Material.STICK, BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE1", player), BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE2", player)), false, null).getItemStack();
|
||||
ItemStack itemStack = new SWItem(Material.STICK, BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE1", player), BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE2", player)), false, null).getItemStack();
|
||||
ItemUtils.setItem(itemStack, "countingwand");
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
private final Map<String, Pair<Point, Point>> selections = new HashMap<>();
|
||||
|
||||
public boolean isCountingwand(Player player, ItemStack itemStack) {
|
||||
return getWandItem(player).isSimilar(itemStack);
|
||||
public boolean isCountingwand(ItemStack itemStack) {
|
||||
return ItemUtils.isItem(itemStack, "countingwand");
|
||||
}
|
||||
|
||||
public void checkSelection(final Point point, final boolean pos1, final Player p) {
|
||||
|
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.countingwand;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import java.util.Objects;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
@ -30,13 +29,15 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@Linked(LinkageType.LISTENER)
|
||||
public class CountingwandListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(final BlockBreakEvent event) {
|
||||
if (!Countingwand.isCountingwand(event.getPlayer(), event.getPlayer().getInventory().getItemInMainHand())) {
|
||||
if (!Countingwand.isCountingwand(event.getPlayer().getInventory().getItemInMainHand())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ public class CountingwandListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
if (!Countingwand.isCountingwand(event.getPlayer(), event.getItem())) {
|
||||
if (!Countingwand.isCountingwand(event.getItem())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren