cleanup and hotfixes
Dieser Commit ist enthalten in:
Ursprung
216e467314
Commit
9853f41914
@ -1,9 +1,7 @@
|
||||
package de.steamwar.lobby;
|
||||
|
||||
import de.steamwar.lobby.commands.FlyCommand;
|
||||
import de.steamwar.lobby.commands.ShieldCommand;
|
||||
import de.steamwar.lobby.listener.*;
|
||||
import de.steamwar.lobby.utils.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -16,19 +14,16 @@ public class LobbySystem extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
if(Config.SpawnY == 0)
|
||||
shutdown(null);
|
||||
|
||||
init();
|
||||
|
||||
getCommand("fly").setExecutor(new FlyCommand());
|
||||
getCommand("schild").setExecutor(new ShieldCommand());
|
||||
}
|
||||
|
||||
public void init() {
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
|
||||
pm.registerEvents(new PlayerMoveListener(), instance);
|
||||
pm.registerEvents(new PlayerJoinListener(), instance);
|
||||
pm.registerEvents(new PlayerConnectionListener(), instance);
|
||||
pm.registerEvents(new PlayerInventoryListener(), instance);
|
||||
pm.registerEvents(new PlayerWorldInteractionListener(), instance);
|
||||
pm.registerEvents(new DoubleJumpListener(), instance);
|
||||
@ -38,11 +33,6 @@ public class LobbySystem extends JavaPlugin {
|
||||
pm.registerEvents(new ShieldListener(), instance);
|
||||
}
|
||||
|
||||
public void shutdown(final String reason) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer(reason));
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
|
||||
|
||||
public static LobbySystem getInstance() {
|
||||
return instance;
|
||||
|
@ -20,9 +20,11 @@ public class FlyCommand implements CommandExecutor {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
if(userGroup != UserGroup.Developer &&
|
||||
if(userGroup != UserGroup.Admin &&
|
||||
userGroup != UserGroup.Moderator &&
|
||||
userGroup != UserGroup.Admin &&
|
||||
userGroup != UserGroup.Developer &&
|
||||
userGroup != UserGroup.Supporter &&
|
||||
userGroup != UserGroup.Builder &&
|
||||
userGroup != UserGroup.Youtuber) {
|
||||
player.sendMessage("§cDu verfügst nicht über die benötigten Rechte!");
|
||||
return false;
|
||||
|
@ -1,39 +0,0 @@
|
||||
package de.steamwar.lobby.commands;
|
||||
|
||||
import de.steamwar.lobby.inventorys.LobbyInventory;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ShieldCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
|
||||
Player player = (Player) sender;
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
if(userGroup != UserGroup.Developer &&
|
||||
userGroup != UserGroup.Moderator &&
|
||||
userGroup != UserGroup.Admin &&
|
||||
userGroup != UserGroup.Youtuber) {
|
||||
player.sendMessage("§cDu verfügst nicht über die benötigten Rechte!");
|
||||
return false;
|
||||
}
|
||||
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
boolean newShieldState = !lobbyPlayer.isShield();
|
||||
|
||||
lobbyPlayer.setShield(newShieldState);
|
||||
LobbyInventory.givePlayerLobbyItems(player);
|
||||
player.sendMessage("§7Dein Schild ist jetzt " + (newShieldState ? "§aan" : "§caus") + "§7.");
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.steamwar.lobby.inventorys;
|
||||
package de.steamwar.lobby.inventories;
|
||||
|
||||
import de.steamwar.lobby.utils.ItemBuilder;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
@ -9,11 +9,13 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class LobbyInventory {
|
||||
|
||||
private LobbyInventory() {}
|
||||
|
||||
public static Material PLAYER_HIDER = Material.BLAZE_ROD;
|
||||
public static Material PARTIKEL = Material.NAME_TAG;
|
||||
public static Material PARTICLE = Material.NAME_TAG;
|
||||
public static Material ENDERPEARL_USED = Material.FIREWORK_CHARGE;
|
||||
public static Material ENDERPEARL_READY = Material.ENDER_PEARL;
|
||||
public static Material SCHILD = Material.SHIELD;
|
||||
public static Material SHIELD = Material.SHIELD;
|
||||
|
||||
public static void givePlayerLobbyItems(Player player) {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
@ -31,7 +33,7 @@ public class LobbyInventory {
|
||||
.removeAllAtributs()
|
||||
.build());
|
||||
|
||||
player.getInventory().setItem(6, new ItemBuilder(PARTIKEL)
|
||||
player.getInventory().setItem(6, new ItemBuilder(PARTICLE)
|
||||
.setDisplayName("§6Partikel")
|
||||
.setUnbreakable(true)
|
||||
.removeAllAtributs()
|
||||
@ -39,13 +41,15 @@ public class LobbyInventory {
|
||||
|
||||
|
||||
UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup();
|
||||
if(userGroup != UserGroup.Developer &&
|
||||
if(userGroup != UserGroup.Admin &&
|
||||
userGroup != UserGroup.Moderator &&
|
||||
userGroup != UserGroup.Admin &&
|
||||
userGroup != UserGroup.Developer &&
|
||||
userGroup != UserGroup.Supporter &&
|
||||
userGroup != UserGroup.Builder &&
|
||||
userGroup != UserGroup.Youtuber) {
|
||||
return;
|
||||
}
|
||||
player.getInventory().setItem(8, new ItemBuilder(SCHILD)
|
||||
player.getInventory().setItem(8, new ItemBuilder(SHIELD)
|
||||
.setDisplayName("§bSchild §8| " + (lobbyPlayer.isShield() ? "§aan" : "§caus"))
|
||||
.setUnbreakable(true)
|
||||
.removeAllAtributs()
|
@ -1,4 +1,4 @@
|
||||
package de.steamwar.lobby.inventorys;
|
||||
package de.steamwar.lobby.inventories;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -12,9 +12,10 @@ import java.util.List;
|
||||
|
||||
public class ParticleInventory {
|
||||
|
||||
private ParticleInventory() {}
|
||||
|
||||
public static void openParticleInventory(Player player) {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
if(lobbyPlayer == null) return;
|
||||
|
||||
SWInventory swInventory = new SWInventory(player, 9 * 1, "§6Partikel");
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.inventorys.LobbyInventory;
|
||||
import de.steamwar.lobby.inventories.LobbyInventory;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
@ -10,11 +10,9 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EnderPearlListener implements Listener {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.lobby.inventorys.LobbyInventory;
|
||||
import de.steamwar.lobby.inventorys.ParticleInventory;
|
||||
import de.steamwar.lobby.inventories.LobbyInventory;
|
||||
import de.steamwar.lobby.inventories.ParticleInventory;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -15,7 +15,7 @@ public class ParticleListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(event.getMaterial() != LobbyInventory.PARTIKEL)
|
||||
if(event.getMaterial() != LobbyInventory.PARTICLE)
|
||||
return;
|
||||
|
||||
ParticleInventory.openParticleInventory(player);
|
||||
@ -25,7 +25,7 @@ public class ParticleListener implements Listener {
|
||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
if(lobbyPlayer == null || lobbyPlayer.getParticle() == null) return;
|
||||
if(lobbyPlayer.getParticle() == null) return;
|
||||
|
||||
player.getWorld().playEffect(player.getLocation().add(0.0D, 0.2D, 0.0D), lobbyPlayer.getParticle(), 5);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.lobby.inventorys.LobbyInventory;
|
||||
import de.steamwar.lobby.inventories.LobbyInventory;
|
||||
import de.steamwar.lobby.utils.Config;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -10,15 +10,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
public class PlayerConnectionListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
event.setJoinMessage(null);
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(LobbyPlayer.getLobbyPlayer(player.getUniqueId()) == null)
|
||||
new LobbyPlayer(player.getUniqueId());
|
||||
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));
|
||||
LobbyInventory.givePlayerLobbyItems(player);
|
||||
@ -27,5 +28,10 @@ public class PlayerJoinListener implements Listener {
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
event.setQuitMessage(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.lobby.inventorys.LobbyInventory;
|
||||
import de.steamwar.lobby.inventories.LobbyInventory;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
|
@ -1,13 +1,10 @@
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.inventorys.LobbyInventory;
|
||||
import de.steamwar.lobby.inventories.LobbyInventory;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -82,7 +79,7 @@ public class ShieldListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
if(event.getMaterial() != LobbyInventory.SCHILD) return;
|
||||
if(event.getMaterial() != LobbyInventory.SHIELD) return;
|
||||
Action action = event.getAction();
|
||||
if(action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) return;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class Config {
|
||||
if(!new File(instance.getDataFolder(), "config.yml").exists()) {
|
||||
instance.saveDefaultConfig();
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Config fehlt!");
|
||||
instance.shutdown(null);
|
||||
throw new SecurityException();
|
||||
}
|
||||
FileConfiguration config = instance.getConfig();
|
||||
|
||||
|
@ -2,29 +2,21 @@ package de.steamwar.lobby.utils;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class LobbyPlayer {
|
||||
|
||||
private static List<LobbyPlayer> cache = new ArrayList<>();
|
||||
private static Map<UUID, LobbyPlayer> cache = new HashMap();
|
||||
|
||||
private UUID uuid;
|
||||
private PlayerHiderState hiderState;
|
||||
private Effect particle;
|
||||
private boolean fly;
|
||||
private boolean enderPearlUsed;
|
||||
private boolean shield;
|
||||
|
||||
public LobbyPlayer(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
private LobbyPlayer(UUID uuid) {
|
||||
this.hiderState = PlayerHiderState.SHOW_ALL;
|
||||
cache.add(this);
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
cache.put(uuid, this);
|
||||
}
|
||||
|
||||
public PlayerHiderState getHiderState() {
|
||||
@ -95,10 +87,7 @@ public class LobbyPlayer {
|
||||
}
|
||||
|
||||
public static LobbyPlayer getLobbyPlayer(UUID uuid) {
|
||||
for(LobbyPlayer current : cache) {
|
||||
if(current.getUuid().equals(uuid))
|
||||
return current;
|
||||
}
|
||||
return null;
|
||||
LobbyPlayer lobbyPlayer = cache.get(uuid);
|
||||
return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer;
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,3 @@ main: de.steamwar.lobby.LobbySystem
|
||||
|
||||
commands:
|
||||
fly:
|
||||
schild:
|
In neuem Issue referenzieren
Einen Benutzer sperren