13
0

Fix double firework and no firework
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-03-25 13:33:02 +01:00
Ursprung 65f6789c95
Commit 08d1ebfb12
2 geänderte Dateien mit 29 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -19,17 +19,37 @@
package de.steamwar.lobby.listener; package de.steamwar.lobby.listener;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.command.ModifyCommand; import de.steamwar.lobby.command.ModifyCommand;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class InventoryInteraction extends BasicListener { public class InventoryInteraction extends BasicListener {
{
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
Bukkit.getOnlinePlayers().forEach(player -> {
ItemStack itemStack = player.getInventory().getItem(PlayerSpawn.FIREWORK_SLOT);
if (itemStack == null || itemStack.getType() == Material.AIR) {
player.getInventory().setItem(PlayerSpawn.FIREWORK_SLOT, PlayerSpawn.FIREWORK);
return;
}
if (itemStack.getAmount() > 1) {
player.getInventory().setItem(PlayerSpawn.FIREWORK_SLOT, PlayerSpawn.FIREWORK);
}
});
}, 0L, 1L);
}
@EventHandler @EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) { public void handlePlayerInteract(PlayerInteractEvent event) {
ItemStack item = event.getItem(); ItemStack item = event.getItem();

Datei anzeigen

@ -36,6 +36,12 @@ import org.bukkit.inventory.PlayerInventory;
public class PlayerSpawn extends BasicListener { public class PlayerSpawn extends BasicListener {
public static final int FIREWORK_SLOT = 3;
public static final ItemStack FIREWORK = new ItemBuilder(Material.FIREWORK_ROCKET, 1).setDisplayName("§5Rakete").build();
public static final int PARTICLE_SLOT = 5;
public static final ItemStack PARTICLE = new ItemBuilder(Material.NAME_TAG).setDisplayName("§6Partikel").setUnbreakable(true).removeAllAttributes().build();
private static final ItemStack ELYTRA = new ItemBuilder(Material.ELYTRA).setDisplayName("§5Elytra").setUnbreakable(true).removeAllAttributes().build();
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
@ -52,17 +58,14 @@ public class PlayerSpawn extends BasicListener {
Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> new ImALobbyPacket().send(player), 20); Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> new ImALobbyPacket().send(player), 20);
} }
private static final ItemStack ELYTRA = new ItemBuilder(Material.ELYTRA).setDisplayName("§5Elytra").setUnbreakable(true).removeAllAttributes().build();
public static final ItemStack PARTICLE = new ItemBuilder(Material.NAME_TAG).setDisplayName("§6Partikel").setUnbreakable(true).removeAllAttributes().build();
private void giveItems(Player player) { private void giveItems(Player player) {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
inventory.setItem(EquipmentSlot.CHEST, ELYTRA); inventory.setItem(EquipmentSlot.CHEST, ELYTRA);
player.getInventory().setItem(3, new ItemBuilder(Material.FIREWORK_ROCKET, 1).setDisplayName("§5Rakete").build()); player.getInventory().setItem(FIREWORK_SLOT, FIREWORK);
player.getInventory().setItem(5, PARTICLE); player.getInventory().setItem(PARTICLE_SLOT, PARTICLE);
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)