13
0

Fix some stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-03-10 14:56:20 +01:00
Ursprung 00564a8b80
Commit d336893196
14 geänderte Dateien mit 107 neuen und 124 gelöschten Zeilen

Datei anzeigen

@ -54,8 +54,8 @@ public class LobbySystem extends JavaPlugin {
new DoubleJumpListener();
new ElytraListener();
new ParticleListener();
new PlayerInventoryListener();
new PlayerWorldInteractionListener();
new InventoryInteraction();
new WorldInteraction();
new WorldBorder();
}

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.lobby.LobbySystem;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -34,9 +35,9 @@ import java.util.Set;
public class DebugCommand extends SWCommand implements Listener {
private static final Set<Player> debugMode = new HashSet<>();
private static final Set<HumanEntity> debugMode = new HashSet<>();
public static boolean debugging(Player player) {
public static boolean debugging(HumanEntity player) {
return debugMode.contains(player);
}

Datei anzeigen

@ -1,57 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.inventories;
import de.steamwar.lobby.util.ItemBuilder;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class LobbyInventory {
private LobbyInventory() {}
public static final Material PARTICLE = Material.NAME_TAG;
public static final Material ELYTRA_USED = Material.FIREWORK_STAR;
public static final Material ELYTRA_READY = Material.ELYTRA;
public static void givePlayerLobbyItems(Player player) {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
player.getInventory().setItem(3, new ItemBuilder(lobbyPlayer.isFlyingElytra() ? ELYTRA_USED : ELYTRA_READY)
.setDisplayName("§5Elytra")
.setUnbreakable(true)
.removeAllAtributs()
.build());
if(lobbyPlayer.isFlyingElytra()) {
player.getInventory().setItem(4,
new ItemBuilder(Material.FIREWORK_ROCKET, 1).setDisplayName("§5Rakete").build());
}
player.getInventory().setItem(5, new ItemBuilder(PARTICLE)
.setDisplayName("§6Partikel")
.setUnbreakable(true)
.removeAllAtributs()
.build());
}
}

Datei anzeigen

@ -19,17 +19,12 @@
package de.steamwar.lobby.listener;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
public class ElytraListener extends BasicListener {
@ -38,7 +33,7 @@ public class ElytraListener extends BasicListener {
Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
if (event.getMaterial() != LobbyInventory.ELYTRA_READY) return;
/*if (event.getMaterial() != LobbyInventory.ELYTRA_READY) return;
if(!lobbyPlayer.isFlyingElytra()) {
player.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
@ -47,18 +42,18 @@ public class ElytraListener extends BasicListener {
player.setGliding(true);
lobbyPlayer.setFlyingElytra(true);
LobbyInventory.givePlayerLobbyItems(player);
}
}*/
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
/*Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
if(lobbyPlayer.isFlyingElytra() && player.isOnGround()) {
lobbyPlayer.setFlyingElytra(false);
player.getInventory().clear();
LobbyInventory.givePlayerLobbyItems(player);
}
}*/
}
}

Datei anzeigen

@ -19,14 +19,27 @@
package de.steamwar.lobby.listener;
import de.steamwar.lobby.command.DebugCommand;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
public class PlayerInventoryListener extends BasicListener {
public class InventoryInteraction extends BasicListener {
@EventHandler(priority = EventPriority.LOW)
public void handlePlayerInteract(PlayerInteractEvent event) {
if(event.getItem() == null) return;
if (event.getItem().getType() == Material.FIREWORK_ROCKET) {
event.getItem().setAmount(2);
return;
}
event.setCancelled(true);
}
@EventHandler
public void handlePlayerDropItem(PlayerDropItemEvent event) {
@ -40,11 +53,13 @@ public class PlayerInventoryListener extends BasicListener {
@EventHandler(priority = EventPriority.LOWEST)
public void handleInventoryClick(InventoryClickEvent event) {
if(!DebugCommand.debugging(event.getWhoClicked()))
event.setCancelled(true);
}
@EventHandler
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
if(!DebugCommand.debugging(event.getPlayer()))
event.setCancelled(true);
}

Datei anzeigen

@ -20,8 +20,7 @@
package de.steamwar.lobby.listener;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.inventories.ParticleInventory;
import de.steamwar.lobby.particle.ParticleInventory;
import de.steamwar.lobby.particle.SpecialParticle;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit;
@ -45,7 +44,7 @@ public class ParticleListener extends BasicListener {
@EventHandler(priority = EventPriority.NORMAL)
public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (event.getMaterial() != LobbyInventory.PARTICLE) return;
if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return;
ParticleInventory.openParticleInventory(player);
}

Datei anzeigen

@ -21,18 +21,22 @@ package de.steamwar.lobby.listener;
import de.steamwar.comms.packets.ImALobbyPacket;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.util.ItemBuilder;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
public class PlayerSpawn extends BasicListener {
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
e.setJoinMessage(null);
@ -41,13 +45,26 @@ public class PlayerSpawn extends BasicListener {
player.setGameMode(GameMode.ADVENTURE);
player.setWalkSpeed(0.5f);
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
LobbyInventory.givePlayerLobbyItems(player);
player.setHealth(20);
player.setFoodLevel(20);
giveItems(player);
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) {
PlayerInventory inventory = player.getInventory();
inventory.setItem(EquipmentSlot.CHEST, ELYTRA);
player.getInventory().setItem(4, new ItemBuilder(Material.FIREWORK_ROCKET, 1).setDisplayName("§5Rakete").build());
player.getInventory().setItem(5, PARTICLE);
}
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);

Datei anzeigen

@ -19,24 +19,16 @@
package de.steamwar.lobby.listener;
import org.bukkit.Material;
import de.steamwar.lobby.command.DebugCommand;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
public class PlayerWorldInteractionListener extends BasicListener {
@EventHandler(priority = EventPriority.LOW)
public void handlePlayerInteract(PlayerInteractEvent event) {
if(event.getItem() == null) return;
if (event.getItem().getType() == Material.FIREWORK_ROCKET) {
event.getItem().setAmount(2);
return;
}
event.setCancelled(true);
}
public class WorldInteraction extends BasicListener {
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
@ -47,5 +39,23 @@ public class PlayerWorldInteractionListener extends BasicListener {
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(true);
}
@EventHandler
public void handleBlockBreak(BlockBreakEvent event) {
if(!DebugCommand.debugging(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler
public void handleBlockPlace(BlockPlaceEvent event) {
if(!DebugCommand.debugging(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler
public void handleHangingBreak(HangingBreakByEntityEvent event) {
if(!DebugCommand.debugging((HumanEntity) event.getRemover()))
event.setCancelled(true);
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -17,18 +17,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.inventories;
package de.steamwar.lobby.particle;
import de.steamwar.lobby.particle.*;
import org.bukkit.Material;
import org.bukkit.Particle;
public enum EventParticle {
WarGearSeason(22, new int[]{12, 285, 54}, new CloudCircleParticle(Material.ENCHANTING_TABLE, "§cVerzaubert", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "WarGearSeason Event 1., 2. oder 3. Platz"), Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0)), new SimpleParticle(Material.BOOK, "§5Verzaubert", ParticleInventory.loreBuilder(new String[0], "WarGearSeason Event"), Particle.ENCHANTMENT_TABLE)),
AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(Material.SNOWBALL, "§fCloud", ParticleInventory.loreBuilder(new String[]{"Ring"}, "AirshipEvent Event 1., 2. oder 3. Platz"), Particle.CLOUD, null, location -> location.add(0, 2.2, 0)), new SimpleParticle(Material.SNOW_BLOCK, "§fCloud", ParticleInventory.loreBuilder(new String[0], "AirshipEvent Event"), Particle.CLOUD)),
HellsBellsWs(28, new int[]{205, 9, 11}, new CloudCircleParticle(Material.TNT_MINECART, "§7Smoke", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "HellsBells Event 1., 2. oder 3. Platz"), Particle.CAMPFIRE_COSY_SMOKE, location -> location.add(0, 2.2, 0)), new CircleParticle(Material.TNT, "§8Smoke", ParticleInventory.loreBuilder(new String[]{"Ring"}, "HellsBells Event"), Particle.CAMPFIRE_COSY_SMOKE, null, location -> location, 0, 0, 0, 0.01)),
Underwater(31, new int[]{9, 210, 520}, new CloudParticle(Material.PRISMARINE_CRYSTALS, "§bWasser", ParticleInventory.loreBuilder(new String[]{"Wolke"}, "Underwater Event 1., 2. oder 3. Platz"), Particle.DRIP_WATER), new SimpleParticle(Material.PRISMARINE_BRICKS, "§bWasser", ParticleInventory.loreBuilder(new String[0], "Underwater Event"), Particle.DRIP_WATER));
WarGearSeason(22, new int[]{12, 285, 54}, new CloudCircleParticle(Material.ENCHANTING_TABLE, "§cVerzaubert", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "WarGearSeason 1., 2. oder 3. Platz"), Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0)), new SimpleParticle(Material.BOOK, "§5Verzaubert", ParticleInventory.loreBuilder(new String[0], "WarGearSeason"), Particle.ENCHANTMENT_TABLE)),
AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(Material.SNOWBALL, "§fCloud", ParticleInventory.loreBuilder(new String[]{"Ring"}, "AirshipEvent 1., 2. oder 3. Platz"), Particle.CLOUD, null, location -> location.add(0, 2.2, 0)), new SimpleParticle(Material.SNOW_BLOCK, "§fCloud", ParticleInventory.loreBuilder(new String[0], "AirshipEvent"), Particle.CLOUD)),
HellsBellsWs(28, new int[]{205, 9, 11}, new CloudCircleParticle(Material.TNT_MINECART, "§7Smoke", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "HellsBells 1., 2. oder 3. Platz"), Particle.CAMPFIRE_COSY_SMOKE, location -> location.add(0, 2.2, 0)), new CircleParticle(Material.TNT, "§8Smoke", ParticleInventory.loreBuilder(new String[]{"Ring"}, "HellsBells"), Particle.CAMPFIRE_COSY_SMOKE, null, location -> location, 0, 0, 0, 0.01)),
Underwater(31, new int[]{9, 210, 520}, new CloudParticle(Material.PRISMARINE_CRYSTALS, "§bWasser", ParticleInventory.loreBuilder(new String[]{"Wolke"}, "Underwater 1., 2. oder 3. Platz"), Particle.DRIP_WATER), new SimpleParticle(Material.PRISMARINE_BRICKS, "§bWasser", ParticleInventory.loreBuilder(new String[0], "Underwater"), Particle.DRIP_WATER));
public static EventParticle[] eventParticles = values();

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -17,19 +17,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.inventories;
package de.steamwar.lobby.particle;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.lobby.particle.*;
import de.steamwar.lobby.util.LobbyPlayer;
import de.steamwar.sql.*;
import de.steamwar.sql.Event;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.TeamTeilnahme;
import de.steamwar.sql.UserGroup;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class ParticleInventory {
@ -158,6 +163,7 @@ public class ParticleInventory {
SWListInv<SpecialParticle> particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> {
if (particle == null) return;
lobbyPlayer.setParticle(particle);
player.closeInventory();
});
particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> {
lobbyPlayer.setParticle(null);

Datei anzeigen

@ -20,12 +20,14 @@
package de.steamwar.lobby.portal;
import de.steamwar.comms.packets.ExecuteCommandPacket;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.listener.Portals;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.Deque;
import java.util.Map;
import java.util.logging.Level;
public class CommandPortal implements PortalHandler {
@ -55,7 +57,8 @@ public class CommandPortal implements PortalHandler {
String[] pieces = new String[stackIds.length];
while (maxId > 0) {
if(stack.isEmpty()) {
player.sendMessage("Fehlende Stackinhalte für den command");
LobbySystem.getPlugin().getLogger().log(Level.WARNING, "Stackportal with missing elements: " + player.getName() + " /" + command);
player.sendMessage("§cEigentlich solltest du gerade gar nicht durch dieses Portal durchgehen können...");
return;
}

Datei anzeigen

@ -19,12 +19,15 @@
package de.steamwar.lobby.portal;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.command.DebugCommand;
import de.steamwar.lobby.listener.Portals;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.*;
import java.util.logging.Level;
public class TeleportPortal implements PortalHandler {
@ -65,9 +68,11 @@ public class TeleportPortal implements PortalHandler {
private void teleport(Player player, Location to, Portal target) {
if(target == null) {
player.sendMessage("teleport " + portal.getId() + " -> UNKNOWN");
LobbySystem.getPlugin().getLogger().log(Level.WARNING, "Portal with unknown target: " + portal.getId());
player.sendMessage("§cAus unbekannten Gründen führt dieses Portal zurzeit in den Limbus");
return;
}
if(DebugCommand.debugging(player))
player.sendMessage("teleport " + portal.getId() + " -> " + target.getId());
player.teleport(target.denormalize(portal.normalize(to)).toLocation(to.getWorld(), (float) (to.getYaw() - Math.toDegrees(target.getYrotation() - portal.getYrotation())), to.getPitch()), PlayerTeleportEvent.TeleportCause.PLUGIN);

Datei anzeigen

@ -25,12 +25,12 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class ItemBuilder {
private ItemStack item;
private ItemMeta meta;
private final ItemStack item;
private final ItemMeta meta;
public ItemBuilder(Material matrial) {
item = new ItemStack(matrial);
@ -42,12 +42,8 @@ public class ItemBuilder {
item = new ItemStack(matrial, amount);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, short subid) {
item = new ItemStack(matrial, 1, subid);
meta = item.getItemMeta();
}
public ItemBuilder removeAllAtributs() {
public ItemBuilder removeAllAttributes() {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
@ -62,7 +58,7 @@ public class ItemBuilder {
return this;
}
public ItemBuilder addLore(ArrayList<String> lore) {
public ItemBuilder addLore(List<String> lore) {
meta.setLore(lore);
return this;
}

Datei anzeigen

@ -20,8 +20,6 @@
package de.steamwar.lobby.util;
import de.steamwar.lobby.particle.SpecialParticle;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.Player;
import java.util.HashMap;
@ -34,10 +32,6 @@ public class LobbyPlayer {
private SpecialParticle specialParticle;
@Getter
@Setter
private boolean flyingElytra;
private boolean fly;
private LobbyPlayer(UUID uuid) {