Archiviert
13
0

lobby-update #16

Geschlossen
YoyoNow möchte 8 Commits von lobby-update nach master mergen
16 geänderte Dateien mit 273 neuen und 248 gelöschten Zeilen
Nur Änderungen aus Commit 7e40a439ad werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.lobby;
import de.steamwar.lobby.commands.FlyCommand;
import de.steamwar.lobby.listener.*;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
@ -32,6 +33,8 @@ public class LobbySystem extends JavaPlugin {
public void onEnable() {
instance = this;
getCommand("fly").setExecutor(new FlyCommand());
Review

Ich bin gegen fly-Command, weil es da mehrfach zu Beschwerden aus Userseite gab, würde hacken. Macht meiner Meinung nach mehr Komplikationen.

Ich bin gegen fly-Command, weil es da mehrfach zu Beschwerden aus Userseite gab, <Teammitglied XY> würde hacken. Macht meiner Meinung nach mehr Komplikationen.
Review

Ich glaube, dass die Leute, die sowas sagen sich einfach nicht auskennen oder so. Ich glaube besonders für YouTuber aufnahmen ist sowas sinnvoll und wichtig.

Ich glaube, dass die Leute, die sowas sagen sich einfach nicht auskennen oder so. Ich glaube besonders für YouTuber aufnahmen ist sowas sinnvoll und wichtig.
Review

Nein, nicht nur Leute, die sich nicht auskennen. Es verwirrt die User (auch MICH hat /fly schon verwirrt).

Nein, nicht nur Leute, die sich nicht auskennen. Es verwirrt die User (auch MICH hat /fly schon verwirrt).
Review

Ich glaube trotzdem, da es auch nur auf der Lobby ist, dass dieser Befehl wichtig ist.

Ich glaube trotzdem, da es auch nur auf der Lobby ist, dass dieser Befehl wichtig ist.
Review

Bildschirmfoto 2020-11-28 um 08.07.35
Ich glaube die Abstimmung ist für wieder einführen.

![Bildschirmfoto 2020-11-28 um 08.07.35](/devlabs/attachments/fcade1ca-9804-4229-87cf-f703df9ada76) Ich glaube die Abstimmung ist für wieder einführen.
Review

Sehe da nix, welche Abstimmung von wann und wo?

Sehe da nix, welche Abstimmung von wann und wo?
Review

Im SteamWar Verwaltung Discord #allgemein am 20.11.2020 wegen dem /fly Befehl

Im `SteamWar Verwaltung` Discord `#allgemein` am `20.11.2020` wegen dem `/fly` Befehl
Review

Das habe ich oben zu einem Screenshot gemacht. 8 sind dafür 4 dagegen

Das habe ich oben zu einem Screenshot gemacht. 8 sind dafür 4 dagegen
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerMoveListener(), instance);
@ -40,7 +43,7 @@ public class LobbySystem extends JavaPlugin {
pm.registerEvents(new PlayerWorldInteractionListener(), instance);
pm.registerEvents(new DoubleJumpListener(), instance);
pm.registerEvents(new ParticleListener(), instance);
pm.registerEvents(new PlayerHiderListener(), instance);
pm.registerEvents(new PlayerSeatListener(), instance);
pm.registerEvents(new EnderPearlListener(), instance);
}

Datei anzeigen

@ -0,0 +1,56 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.commands;
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 FlyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Veraltet
Review

Klammer können weg

Klammer können weg
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if (userGroup == UserGroup.Member) {
player.sendMessage("§cDu verfügst nicht über die benötigten Rechte!");
Veraltet
Review

Wenn dann einheitlich: Unbekannter Befehl.

Wenn dann einheitlich: Unbekannter Befehl.
return false;
}
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
boolean newFlightState = !lobbyPlayer.isFly();
lobbyPlayer.setFly(newFlightState);
player.setAllowFlight(newFlightState);
player.setFlying(newFlightState);
player.sendMessage("§7Du kannst jetzt " + (newFlightState ? "§afliegen§7." : "§cnicht §7mehr fliegen."));
return false;
}
}

Datei anzeigen

@ -28,28 +28,22 @@ public class LobbyInventory {
private LobbyInventory() {}
public static Material PLAYER_HIDER = Material.BLAZE_ROD;
public static Material PARTICLE = Material.NAME_TAG;
public static Material ENDERPEARL_USED = Material.FIREWORK_STAR;
public static Material ENDERPEARL_READY = Material.ENDER_PEARL;
public static Material SHIELD = Material.SHIELD;
public static void givePlayerLobbyItems(Player player) {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
player.getInventory().setItem(2, new ItemBuilder(PLAYER_HIDER)
.setDisplayName(lobbyPlayer.getHiderState().getName())
.setUnbreakable(true)
.removeAllAtributs()
.build());
// 2, 4, 6
player.getInventory().setItem(4, new ItemBuilder(lobbyPlayer.isEnderPearlUsed() ? ENDERPEARL_USED : ENDERPEARL_READY)
player.getInventory().setItem(3, new ItemBuilder(lobbyPlayer.isEnderPearlUsed() ? ENDERPEARL_USED : ENDERPEARL_READY)
.setDisplayName("§5Enderperle")
.setUnbreakable(true)
.removeAllAtributs()
.build());
player.getInventory().setItem(6, new ItemBuilder(PARTICLE)
player.getInventory().setItem(5, new ItemBuilder(PARTICLE)
.setDisplayName("§6Partikel")
.setUnbreakable(true)
.removeAllAtributs()

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.lobby.inventories;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.lobby.utils.LobbyParticle;
import de.steamwar.lobby.utils.LobbyPlayer;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
@ -38,9 +39,10 @@ public class ParticleInventory {
private static List<String> lore = Arrays.asList("§aKlicken zum Auswählen");
private static SWInventory createInventory(Player player) {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
Veraltet
Review

Könnte alles Final sein

Könnte alles Final sein
UserGroup userGroup = steamwarUser.getUserGroup();
LobbyParticle lobbyParticle = lobbyPlayer.getLobbyParticle();
SWInventory swInventory;
if (userGroup == UserGroup.Member) {
@ -49,51 +51,51 @@ public class ParticleInventory {
swInventory = new SWInventory(player, 9*6, "§6Partikel");
}
add(swInventory, Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 10, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 11, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA, 12, player, lobbyPlayer);
add(swInventory, Material.RED_DYE, "§cHerzen", lore, Particle.HEART, 13, player, lobbyPlayer);
add(swInventory, Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER, 14, player, lobbyPlayer);
add(swInventory, Material.NOTE_BLOCK, "§eNoten", lore, Particle.NOTE, 15, player, lobbyPlayer);
add(swInventory, Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 16, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 10, player, lobbyParticle, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 11, player, lobbyParticle, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA, 12, player, lobbyParticle);
add(swInventory, Material.RED_DYE, "§cHerzen", lore, Particle.HEART, 13, player, lobbyParticle);
add(swInventory, Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER, 14, player, lobbyParticle);
add(swInventory, Material.NOTE_BLOCK, "§eNoten", lore, Particle.NOTE, 15, player, lobbyParticle);
add(swInventory, Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 16, player, lobbyParticle, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 19, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 20, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 21, player, lobbyPlayer, true, 0F, 0.2F, 0F, 0.01);
add(swInventory, Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 22, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 23, player, lobbyPlayer, true, 0.2F, 0.02F, 0.2F, 0.01);
add(swInventory, Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME, 24, player, lobbyPlayer);
add(swInventory, Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB, 25, player, lobbyPlayer);
add(swInventory, Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 19, player, lobbyParticle, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 20, player, lobbyParticle, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 21, player, lobbyParticle, true, 0F, 0.2F, 0F, 0.01);
add(swInventory, Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 22, player, lobbyParticle, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 23, player, lobbyParticle, true, 0.2F, 0.02F, 0.2F, 0.01);
add(swInventory, Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME, 24, player, lobbyParticle);
add(swInventory, Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB, 25, player, lobbyParticle);
if (userGroup == UserGroup.Member) {
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyPlayer);
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyParticle);
} else {
add(swInventory, Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 28, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH, 29, player, lobbyPlayer);
add(swInventory, Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE, 30, player, lobbyPlayer);
add(swInventory, Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 31, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 32, player, lobbyPlayer, true, 0F, 0.2F, 0F, 0.01);
add(swInventory, Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 33, player, lobbyPlayer, true, 0F, 0.2F, 0F, 0.2);
add(swInventory, Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 34, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 28, player, lobbyParticle, true, 0.2F, 0F, 0.2F, 0.01);
add(swInventory, Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH, 29, player, lobbyParticle);
add(swInventory, Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE, 30, player, lobbyParticle);
add(swInventory, Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 31, player, lobbyParticle, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 32, player, lobbyParticle, true, 0F, 0.2F, 0F, 0.01);
add(swInventory, Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 33, player, lobbyParticle, true, 0F, 0.2F, 0F, 0.2);
Veraltet
Review

SWInventory swInventory = new SWInventory(player, 9 * (userGroup == UserGroup.Member?5:6), "§6Partikel");?

SWInventory swInventory = new SWInventory(player, 9 * (userGroup == UserGroup.Member?5:6), "§6Partikel");?
add(swInventory, Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 34, player, lobbyParticle, true, 0.2F, 0.2F, 0.2F, 0.01);
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 40, player, lobbyPlayer);
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 40, player, lobbyParticle);
}
return swInventory;
}
private static void add(SWInventory swInventory, Material material, String name, List<String> lore, Particle particle, int slot, Player player, LobbyPlayer lobbyPlayer, boolean customVelocity, float vx, float vy, float vz, double time) {
private static void add(SWInventory swInventory, Material material, String name, List<String> lore, Particle particle, int slot, Player player, LobbyParticle lobbyParticle, boolean customVelocity, float vx, float vy, float vz, double time) {
SWItem swItem = new SWItem(material, name, lore, false, clickType -> {
lobbyPlayer.setParticle(particle, customVelocity);
lobbyPlayer.setParticle(vx, vy, vz, time);
lobbyParticle.setParticle(particle, customVelocity);
lobbyParticle.setParticle(vx, vy, vz, time);
player.closeInventory();
});
swInventory.setItem(slot, swItem);
}
private static void add(SWInventory swInventory, Material material, String name, List<String> lore, Particle particle, int slot, Player player, LobbyPlayer lobbyPlayer) {
private static void add(SWInventory swInventory, Material material, String name, List<String> lore, Particle particle, int slot, Player player, LobbyParticle lobbyParticle) {
SWItem swItem = new SWItem(material, name, lore, false, clickType -> {
lobbyPlayer.setParticle(particle);
lobbyParticle.setParticle(particle);
player.closeInventory();
});
swInventory.setItem(slot, swItem);

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.lobby.listener;
import de.steamwar.lobby.utils.LobbyPlayer;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -47,6 +48,9 @@ public class DoubleJumpListener implements Listener {
if (player.getGameMode() != GameMode.ADVENTURE && player.getGameMode() != GameMode.SURVIVAL) {
return;
}
if (LobbyPlayer.getLobbyPlayer(player).isFly()) {
Review

Klammern weg

Klammern weg
return;
}
event.setCancelled(true);
player.setAllowFlight(false);
@ -65,8 +69,12 @@ public class DoubleJumpListener implements Listener {
public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR)
if(player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR) {
return;
}
if (LobbyPlayer.getLobbyPlayer(player).isFly()) {
Veraltet
Review

Same

Same
return;
}
player.setAllowFlight(true);
if (player.getGameMode() == GameMode.ADVENTURE || player.getGameMode() == GameMode.SURVIVAL) {

Datei anzeigen

@ -45,7 +45,7 @@ public class EnderPearlListener implements Listener {
event.setCancelled(true);
Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
lobbyPlayer.setEnderPearlUsed(true);
EnderPearl enderPearl = player.launchProjectile(EnderPearl.class);
@ -67,7 +67,7 @@ public class EnderPearlListener implements Listener {
if(!(event.getExited() instanceof Player))
return;
Player player = (Player) event.getExited();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
lobbyPlayer.setEnderPearlUsed(false);
LobbyInventory.givePlayerLobbyItems(player);

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.lobby.listener;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.inventories.ParticleInventory;
import de.steamwar.lobby.utils.LobbyParticle;
import de.steamwar.lobby.utils.LobbyPlayer;
import org.bukkit.Color;
import org.bukkit.Particle;
@ -49,8 +50,9 @@ public class ParticleListener implements Listener {
@EventHandler
public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
Particle particle = lobbyPlayer.getParticle();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
LobbyParticle lobbyParticle = lobbyPlayer.getLobbyParticle();
Particle particle = lobbyParticle.getParticle();
if (particle == null) return;
if (particle == Particle.REDSTONE) {
@ -59,8 +61,8 @@ public class ParticleListener implements Listener {
return;
}
if (lobbyPlayer.isCustomVelocity()) {
player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5, lobbyPlayer.getParticle_vx(), lobbyPlayer.getParticle_vy(), lobbyPlayer.getParticle_vz(), lobbyPlayer.getParticle_time());
if (lobbyParticle.isCustomVelocity()) {
player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5, lobbyParticle.getParticle_vx(), lobbyParticle.getParticle_vy(), lobbyParticle.getParticle_vz(), lobbyParticle.getParticle_time());
} else {
player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5);
}

Datei anzeigen

@ -41,14 +41,15 @@ public class PlayerConnectionListener implements Listener {
event.setJoinMessage(null);
Player player = event.getPlayer();
LobbyPlayer.getLobbyPlayer(player.getUniqueId()); //initialisiert einen neuen LP falls nicht vorhanden
LobbyPlayer.getLobbyPlayer(player); //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();
LobbyInventory.givePlayerLobbyItems(player);
player.setGameMode(GameMode.ADVENTURE);
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
LobbyInventory.givePlayerLobbyItems(player);
}
@EventHandler(priority = EventPriority.HIGH)

Datei anzeigen

@ -1,96 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.listener;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.utils.LobbyPlayer;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerHiderListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void handlePlayerInteract(PlayerInteractEvent event) {
Material material = event.getMaterial();
if(material != LobbyInventory.PLAYER_HIDER)
return;
Player player = event.getPlayer();
LobbyPlayer.getLobbyPlayer(player.getUniqueId()).nexthHiderState();
updateHider(player);
LobbyInventory.givePlayerLobbyItems(event.getPlayer());
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
updateHider(event.getPlayer());
}
private void updateHider(Player player) {
LobbyPlayer.PlayerHiderState hiderState = LobbyPlayer.getLobbyPlayer(player.getUniqueId()).getHiderState();
Bukkit.getServer().getOnlinePlayers().forEach(currentPlayer -> {
if(currentPlayer.getUniqueId().equals(player.getUniqueId())) return;
switch (hiderState) {
case SHOW_ALL:
player.showPlayer(currentPlayer);
break;
case SHOW_TEAM:
UserGroup userGroup = SteamwarUser.get(currentPlayer.getUniqueId()).getUserGroup();
if(userGroup == UserGroup.Member)
player.hidePlayer(currentPlayer);
else
player.showPlayer(currentPlayer);
break;
case SHOW_NOBODY:
player.hidePlayer(currentPlayer);
break;
}
LobbyPlayer.PlayerHiderState cpHiderState = LobbyPlayer.getLobbyPlayer(currentPlayer.getUniqueId()).getHiderState();
switch (cpHiderState) {
case SHOW_ALL:
currentPlayer.showPlayer(player);
break;
case SHOW_TEAM:
UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup();
if(userGroup == UserGroup.Member)
currentPlayer.hidePlayer(player);
else
currentPlayer.showPlayer(player);
break;
case SHOW_NOBODY:
currentPlayer.hidePlayer(player);
break;
}
});
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.lobby.listener;
import de.steamwar.lobby.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -32,17 +31,12 @@ public class PlayerMoveListener implements Listener {
@EventHandler
public void handleWorldBorder(PlayerMoveEvent event) {
Location to = event.getTo();
if(!isInRegion(
if (!isInRegion(
new Vector(Config.BorderMinX, Config.BorderMinY, Config.BorderMinZ),
new Vector(Config.BorderMaxX, Config.BorderMaxY, Config.BorderMaxZ),
to.toVector()))
event.getPlayer().teleport(new Location(
Bukkit.getWorlds().get(0),
Config.SpawnX,
Config.SpawnY,
Config.SpawnZ,
Config.Yaw,
Config.Pitch));
to.toVector())) {
event.getPlayer().teleport(event.getFrom());
}
}
private boolean isInRegion(Vector minPoint, Vector maxPoint, Vector location) {
@ -50,15 +44,16 @@ public class PlayerMoveListener implements Listener {
int y = location.getBlockY();
int z = location.getBlockZ();
if(x >= minPoint.getBlockX()
if (x >= minPoint.getBlockX()
Review

return location.inAABB(minPoint, maxPoint);?

return location.inAABB(minPoint, maxPoint);?
&& x <= maxPoint.getBlockX()
&& y >= minPoint.getBlockY()
&& y <= maxPoint.getBlockY()
&& z >= minPoint.getBlockZ()
&& z <= maxPoint.getBlockZ()) {
return true;
} else
} else {
return false;
}
}

Datei anzeigen

@ -0,0 +1,66 @@
package de.steamwar.lobby.listener;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.type.Stairs;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.spigotmc.event.entity.EntityDismountEvent;
public class PlayerSeatListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (!event.getClickedBlock().getType().name().toLowerCase().contains("stairs"))
return;
if (event.getPlayer().getGameMode() != GameMode.ADVENTURE && event.getPlayer().getGameMode() != GameMode.SURVIVAL)
return;
if (((Stairs) event.getClickedBlock().getBlockData()).getHalf() != Bisected.Half.BOTTOM)
return;
if (((Stairs) event.getClickedBlock().getBlockData()).getShape() != Stairs.Shape.STRAIGHT)
return;
if (event.getPlayer().isInsideVehicle())
event.getPlayer().getVehicle().remove();
if (event.getClickedBlock().getRelative(0, 1, 0).getType() != Material.AIR)
return;
Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(event.getClickedBlock().getLocation().add(0.5, 0, 0.5), EntityType.ARROW);
arrow.setGravity(false);
Review

Warum hierfür eine eigene Klasse und kein Vektor, Block, Location?

Warum hierfür eine eigene Klasse und kein Vektor, Block, Location?
Review

Weil ich nur Int block precision brauche und keine Doubles, Außerdem will ich kein memory leak, wenn ich einen Block oder eine Location verwende

Weil ich nur Int block precision brauche und keine Doubles, Außerdem will ich kein memory leak, wenn ich einen Block oder eine Location verwende
Review

Sr, YoyoNow, aber da gibt es keinen Memoryleak.

Sr, YoyoNow, aber da gibt es keinen Memoryleak.
Review

Gut dann gibt es kein memory leak. Einen Block kann ich nicht in ein Set speichern, weil es kein Dashcode hat. Außerdem glaube ich, dass eine Location für diesen Anwendungfalls zu groß ist Memory mäßig und ich nicht ordentlich auf den block vergleichen kann, da diese einen double intern speichert und dieser verglichen wird, womit es auch nicht die gleiche location sein muss. Das gleiche gilt für Vector, deswegen habe ich eine eigene Klasse dafür geschrieben.

Gut dann gibt es kein memory leak. Einen Block kann ich nicht in ein Set speichern, weil es kein Dashcode hat. Außerdem glaube ich, dass eine Location für diesen Anwendungfalls zu groß ist Memory mäßig und ich nicht ordentlich auf den block vergleichen kann, da diese einen double intern speichert und dieser verglichen wird, womit es auch nicht die gleiche location sein muss. Das gleiche gilt für Vector, deswegen habe ich eine eigene Klasse dafür geschrieben.
Review

Wozu musst du dir überhaupt die SeatLocations speichern? Und warum sind das dann so viele, dass da der Memoryverbrauch von Bedeutung wäre? Der Seatpositionsdetector aus dem SpectateSystem ist doch gut genug.

Wozu musst du dir überhaupt die SeatLocations speichern? Und warum sind das dann so viele, dass da der Memoryverbrauch von Bedeutung wäre? Der Seatpositionsdetector aus dem SpectateSystem ist doch gut genug.
Review

Ich Speicher sie mit deswegen, damit nicht zwei Personen auf ein und der selben Treppe sitzen, was ich etwas komisch finde, deswegen habe ich dies eingebaut um einfach es realistischer zu machen.

Ich Speicher sie mit deswegen, damit nicht zwei Personen auf ein und der selben Treppe sitzen, was ich etwas komisch finde, deswegen habe ich dies eingebaut um einfach es realistischer zu machen.
Review

Ja ok, wie viele Leute sitzen zeitgleich. 10-20? Da musst du nicht extra auf RAM achten.

Ja ok, wie viele Leute sitzen zeitgleich. 10-20? Da musst du nicht extra auf RAM achten.
Review

Dann sage ich aber immer noch, dass das vergleichen bzw 'hashCode()' von Location auch wenn es der gleiche block ist nicht der selbe sein muss, da dieser intern immer noch double als precision hat und nicht int.

Dann sage ich aber immer noch, dass das vergleichen bzw 'hashCode()' von Location auch wenn es der gleiche block ist nicht der selbe sein muss, da dieser intern immer noch double als precision hat und nicht int.
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
arrow.addPassenger(event.getPlayer());
arrow.setPersistent(true);
}
@EventHandler
public void onEntityDismount(EntityDismountEvent event) {
if (event.getDismounted().getType() != EntityType.ARROW)
return;
if (event.getEntityType() != EntityType.PLAYER)
return;
event.getDismounted().remove();
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer().isInsideVehicle())
event.getPlayer().getVehicle().remove();
}
}

Datei anzeigen

@ -37,8 +37,9 @@ public class PlayerWorldInteractionListener implements Listener {
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(event.getEntityType() != EntityType.PLAYER) return;
event.setCancelled(true);
if (event.getEntityType() == EntityType.FOX || event.getEntityType() == EntityType.PLAYER) {
Review

Warum ein Fuchs?

Warum ein Fuchs?
Review

Wegen dem Meme des Fuchses aus der WGL Arena

Wegen dem Meme des Fuchses aus der WGL Arena
event.setCancelled(true);
}
}
@EventHandler

Datei anzeigen

@ -71,15 +71,15 @@ public class ItemBuilder {
meta.addEnchant(enchantment, level, true);
return this;
}
public ItemStack build() {
item.setItemMeta(meta);
return item;
}
public ItemBuilder setUnbreakable(boolean unbreakable) {
meta.setUnbreakable(unbreakable);
return this;
}
public ItemStack build() {
item.setItemMeta(meta);
return item;
}
}

Datei anzeigen

@ -0,0 +1,57 @@
package de.steamwar.lobby.utils;
import org.bukkit.Particle;
public class LobbyParticle {
private Particle particle;
private boolean customVelocity = false;
private float particle_vx = 0;
private float particle_vy = 0;
private float particle_vz = 0;
private double particle_time = 0.001;
public Particle getParticle() {
return particle;
}
public boolean isCustomVelocity() {
return customVelocity;
}
public float getParticle_vx() {
return particle_vx;
}
public float getParticle_vy() {
return particle_vy;
}
public float getParticle_vz() {
return particle_vz;
}
public double getParticle_time() {
return particle_time;
}
public void setParticle(Particle particle) {
this.particle = particle;
this.customVelocity = false;
setParticle(0, 0, 0, 0.001);
}
public void setParticle(Particle particle, boolean customVelocity) {
this.particle = particle;
this.customVelocity = customVelocity;
setParticle(0, 0, 0, 0.001);
}
public void setParticle(float vx, float vy, float vz, double time) {
this.particle_vx = vx;
this.particle_vy = vy;
this.particle_vz = vz;
this.particle_time = time;
}
}

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.lobby.utils;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
@ -29,71 +29,26 @@ public class LobbyPlayer {
private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
private PlayerHiderState hiderState;
private Particle particle;
private boolean customVelocity = false;
private float particle_vx = 0;
private float particle_vy = 0;
private float particle_vz = 0;
private double particle_time = 0.001;
private LobbyParticle lobbyParticle;
private boolean enderPearlUsed;
private boolean fly;
private LobbyPlayer(UUID uuid) {
this.hiderState = PlayerHiderState.SHOW_ALL;
cache.put(uuid, this);
lobbyParticle = new LobbyParticle();
}
public PlayerHiderState getHiderState() {
return hiderState;
public LobbyParticle getLobbyParticle() {
return lobbyParticle;
}
public void setHiderState(PlayerHiderState hiderState) {
this.hiderState = hiderState;
public boolean isFly() {
return fly;
}
public Particle getParticle() {
return particle;
}
public boolean isCustomVelocity() {
return customVelocity;
}
public float getParticle_vx() {
return particle_vx;
}
public float getParticle_vy() {
return particle_vy;
}
public float getParticle_vz() {
return particle_vz;
}
public double getParticle_time() {
return particle_time;
}
public void setParticle(Particle particle) {
this.particle = particle;
this.customVelocity = false;
setParticle(0, 0, 0, 0.001);
}
public void setParticle(Particle particle, boolean customVelocity) {
this.particle = particle;
this.customVelocity = customVelocity;
setParticle(0, 0, 0, 0.001);
}
public void setParticle(float vx, float vy, float vz, double time) {
this.particle_vx = vx;
this.particle_vy = vy;
this.particle_vz = vz;
this.particle_time = time;
public void setFly(boolean fly) {
this.fly = fly;
}
public boolean isEnderPearlUsed() {
@ -104,35 +59,13 @@ public class LobbyPlayer {
this.enderPearlUsed = enderPearlUsed;
}
public void nexthHiderState() {
if(this.hiderState == PlayerHiderState.SHOW_ALL) {
this.hiderState = PlayerHiderState.SHOW_TEAM;
}
else if(this.hiderState == PlayerHiderState.SHOW_TEAM) {
this.hiderState = PlayerHiderState.SHOW_NOBODY;
}
else
this.hiderState = PlayerHiderState.SHOW_ALL;
}
public enum PlayerHiderState {
SHOW_ALL("§aAlle Spieler"),
SHOW_TEAM("§6Nur Teammitglieder"),
SHOW_NOBODY("§cKeine Spieler");
private String name;
private PlayerHiderState(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public static LobbyPlayer getLobbyPlayer(UUID uuid) {
LobbyPlayer lobbyPlayer = cache.get(uuid);
return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer;
}
public static LobbyPlayer getLobbyPlayer(Player player) {
return getLobbyPlayer(player.getUniqueId());
}
}

Datei anzeigen

@ -4,4 +4,7 @@ author: Yaruma3341
depend:
- SpigotCore
main: de.steamwar.lobby.LobbySystem
api-version: "1.13"
api-version: "1.13"
commands:
fly: