13
0

Refactoring, spawning
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-03-10 14:21:53 +01:00
Ursprung 6947d920a7
Commit b0f0ffb9aa
12 geänderte Dateien mit 27 neuen und 73 gelöschten Zeilen

Datei anzeigen

@ -25,24 +25,9 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
public class Config {
public static final double SpawnX = 2;
public static final double SpawnY = 63;
public static final double SpawnZ = 2;
public static final float Pitch = 0;
public static final float Yaw = 0;
static {
ConfigurationSerialization.registerClass(Portal.class);
ConfigurationSerialization.registerClass(Hologram.class);
FileConfiguration yml = LobbySystem.getPlugin().getConfig();
/*SpawnX = yml.getDouble("SpawnX");
SpawnY = yml.getDouble("SpawnY");
SpawnZ = yml.getDouble("SpawnZ");
Pitch = (float) yml.getDouble("Pitch");
Yaw = (float) yml.getDouble("Yaw");*/
}
private final FileConfiguration yml;
@ -58,12 +43,6 @@ public class Config {
yml.set("portals", Portal.getPortals());
yml.set("holograms", Hologram.getHolograms());
yml.set("SpawnX", 0);
yml.set("SpawnY", 0);
yml.set("SpawnZ", 0);
yml.set("Pitch", 0);
yml.set("Yaw", 0);
LobbySystem.getPlugin().saveConfig();
}
}

Datei anzeigen

@ -17,12 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.listener;
package de.steamwar.lobby;
import de.steamwar.comms.BungeeReceiver;
import de.steamwar.comms.PacketIdManager;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.Fightserver;
import org.bukkit.Bukkit;
public class Fightservers {

Datei anzeigen

@ -23,10 +23,7 @@ import de.steamwar.lobby.command.DebugCommand;
import de.steamwar.lobby.command.FlyCommand;
import de.steamwar.lobby.command.HologramCommand;
import de.steamwar.lobby.command.PortalCommand;
import de.steamwar.lobby.listener.Fightservers;
import de.steamwar.lobby.listener.PlayerConnection;
import de.steamwar.lobby.listener.Portals;
import de.steamwar.lobby.listener.features.*;
import de.steamwar.lobby.listener.*;
import de.steamwar.message.Message;
import org.bukkit.plugin.java.JavaPlugin;
@ -53,13 +50,13 @@ public class LobbySystem extends JavaPlugin {
new DebugCommand();
config = new Config(getConfig());
new PlayerConnection();
new PlayerSpawn();
new DoubleJumpListener();
new ElytraListener();
new ParticleListener();
new PlayerInventoryListener();
new PlayerWorldInteractionListener();
new PlayerMoveListener();
new WorldBorder();
}

Datei anzeigen

@ -53,6 +53,7 @@ public class DebugCommand extends SWCommand implements Listener {
debugMode.add(player);
player.setGameMode(GameMode.CREATIVE);
player.setOp(true);
}
@EventHandler

Datei anzeigen

@ -28,9 +28,9 @@ public class LobbyInventory {
private LobbyInventory() {}
public static Material PARTICLE = Material.NAME_TAG;
public static Material ELYTRA_USED = Material.FIREWORK_STAR;
public static Material ELYTRA_READY = Material.ELYTRA;
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) {

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,9 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.listener.features;
package de.steamwar.lobby.listener;
import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.GameMode;
import org.bukkit.Material;

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,10 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.listener.features;
package de.steamwar.lobby.listener;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Location;

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,12 +17,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.listener.features;
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.listener.BasicListener;
import de.steamwar.lobby.particle.SpecialParticle;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit;

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,9 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.listener.features;
package de.steamwar.lobby.listener;
import de.steamwar.lobby.listener.BasicListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;

Datei anzeigen

@ -20,32 +20,27 @@
package de.steamwar.lobby.listener;
import de.steamwar.comms.packets.ImALobbyPacket;
import de.steamwar.lobby.Config;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.EnderPearl;
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.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerConnection extends BasicListener {
public class PlayerSpawn extends BasicListener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
e.setJoinMessage(null);
player.getInventory().clear();
player.setGameMode(GameMode.ADVENTURE);
player.setWalkSpeed(0.5f);
LobbyPlayer.getLobbyPlayer(player.getUniqueId()); //initialisiert einen neuen LP falls nicht vorhanden
player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch));
player.getInventory().clear();
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
LobbyInventory.givePlayerLobbyItems(player);
player.setHealth(20);
player.setFoodLevel(20);
@ -57,10 +52,4 @@ public class PlayerConnection extends BasicListener {
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
}
@EventHandler
public void handlePlayerKick(PlayerKickEvent event) {
if(event.getReason().equals("Flying is not enabled on this server") && event.getPlayer().getVehicle() instanceof EnderPearl)
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,11 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.listener.features;
package de.steamwar.lobby.listener;
import de.steamwar.lobby.listener.BasicListener;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
@ -42,7 +40,6 @@ public class PlayerWorldInteractionListener extends BasicListener {
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(event.getEntityType() != EntityType.PLAYER) return;
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,10 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.listener.features;
package de.steamwar.lobby.listener;
import de.steamwar.lobby.Config;
import de.steamwar.lobby.listener.BasicListener;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -28,17 +26,16 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
public class PlayerMoveListener extends BasicListener {
public class WorldBorder extends BasicListener {
final BorderData data = new BorderData();
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location playerLoc = event.getTo();
if(!data.locationIsInRegion(playerLoc)) {
player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch));
if(!data.locationIsInRegion(event.getTo())) {
player.teleport(event.getFrom());
}
}