lobby-update #16
@ -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());
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
54
src/de/steamwar/lobby/commands/FlyCommand.java
Normale Datei
@ -0,0 +1,54 @@
|
||||
/*
|
||||
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) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
Chaoscaot
hat
Klammer können weg Klammer können weg
|
||||
|
||||
Player player = (Player) sender;
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
if (userGroup == UserGroup.Member) {
|
||||
player.sendMessage("§cUnbekannter Befehl.");
|
||||
return false;
|
||||
}
|
||||
Lixfel
hat
Wenn dann einheitlich: Unbekannter Befehl. Wenn dann einheitlich: Unbekannter Befehl.
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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()
|
||||
|
@ -20,7 +20,9 @@
|
||||
package de.steamwar.lobby.inventories;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.lobby.particle.FunctionalParticle;
|
||||
import de.steamwar.lobby.particle.SimpleParticle;
|
||||
import de.steamwar.lobby.particle.SpecialParticle;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
@ -33,70 +35,67 @@ import java.util.List;
|
||||
|
||||
public class ParticleInventory {
|
||||
|
||||
private ParticleInventory() {}
|
||||
private ParticleInventory() {
|
||||
}
|
||||
|
||||
private static List<String> lore = Arrays.asList("§aKlicken zum Auswählen");
|
||||
private static final List<String> lore = Arrays.asList("§aKlicken zum Auswählen");
|
||||
|
||||
private static final SpecialParticle SNEEZE = new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01);
|
||||
Chaoscaot
hat
Könnte alles Final sein Könnte alles Final sein
|
||||
private static final SpecialParticle SMOKE = new SimpleParticle(Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01);
|
||||
private static final SpecialParticle FLAME = new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA);
|
||||
private static final SpecialParticle WATER = new SimpleParticle(Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER);
|
||||
private static final SpecialParticle HEART = new FunctionalParticle(Material.RED_DYE, "§cHerzen", lore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5));
|
||||
private static final SpecialParticle NOTES = new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", lore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5));
|
||||
private static final SpecialParticle NAUTILIS = new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01);
|
||||
|
||||
private static final SpecialParticle SNOWBALL = new SimpleParticle(Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01);
|
||||
private static final SpecialParticle EFFECT = new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01);
|
||||
private static final SpecialParticle CAMPFIRE = new SimpleParticle(Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01);
|
||||
private static final SpecialParticle MAGIC = new SimpleParticle(Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01);
|
||||
private static final SpecialParticle RAGE = new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01);
|
||||
private static final SpecialParticle SLIME = new SimpleParticle(Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME);
|
||||
private static final SpecialParticle MOB = new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB);
|
||||
|
||||
private static final SpecialParticle DAMAGE = new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01);
|
||||
private static final SpecialParticle WITCH = new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH);
|
||||
private static final SpecialParticle ENCHANTING = new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE);
|
||||
private static final SpecialParticle FRIEND = new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01);
|
||||
private static final SpecialParticle FIRE = new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01);
|
||||
private static final SpecialParticle TOTEM = new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01);
|
||||
private static final SpecialParticle END = new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01);
|
||||
|
||||
private static final SpecialParticle[] row_1 = new SpecialParticle[]{SNEEZE, SMOKE, FLAME, WATER, HEART, NOTES, NAUTILIS};
|
||||
private static final SpecialParticle[] row_2 = new SpecialParticle[]{SNOWBALL, EFFECT, CAMPFIRE, MAGIC, RAGE, SLIME, MOB};
|
||||
private static final SpecialParticle[] row_3 = new SpecialParticle[]{DAMAGE, WITCH, ENCHANTING, FRIEND, FIRE, TOTEM, END};
|
||||
|
||||
private static SWInventory createInventory(Player player) {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
SWInventory swInventory;
|
||||
if (userGroup == UserGroup.Member) {
|
||||
swInventory = new SWInventory(player, 9*5, "§6Partikel");
|
||||
} else {
|
||||
swInventory = new SWInventory(player, 9*6, "§6Partikel");
|
||||
}
|
||||
SWInventory swInventory = new SWInventory(player, 9 * (userGroup == UserGroup.Member ? 5 : 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.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, row_1, 10, lobbyPlayer);
|
||||
Chaoscaot
hat
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, row_2, 19, lobbyPlayer);
|
||||
|
||||
if (userGroup == UserGroup.Member) {
|
||||
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyPlayer);
|
||||
swInventory.setItem(31, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> {
|
||||
lobbyPlayer.setParticle(null);
|
||||
});
|
||||
} 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.BARRIER, "§8Keine Partikel", lore, null, 40, player, lobbyPlayer);
|
||||
add(swInventory, row_3, 28, lobbyPlayer);
|
||||
swInventory.setItem(40, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> {
|
||||
lobbyPlayer.setParticle(null);
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
SWItem swItem = new SWItem(material, name, lore, false, clickType -> {
|
||||
lobbyPlayer.setParticle(particle, customVelocity);
|
||||
lobbyPlayer.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) {
|
||||
SWItem swItem = new SWItem(material, name, lore, false, clickType -> {
|
||||
lobbyPlayer.setParticle(particle);
|
||||
player.closeInventory();
|
||||
});
|
||||
swInventory.setItem(slot, swItem);
|
||||
private static void add(SWInventory swInventory, SpecialParticle[] specialParticles, int index, LobbyPlayer lobbyPlayer) {
|
||||
for (int i = 0; i < specialParticles.length; i++) {
|
||||
specialParticles[i].add(swInventory, i + index, lobbyPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openParticleInventory(Player player) {
|
||||
|
@ -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()) {
|
||||
Chaoscaot
hat
Klammern weg Klammern weg
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
player.setAllowFlight(false);
|
||||
@ -65,8 +69,8 @@ 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)
|
||||
return;
|
||||
if (player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR) return;
|
||||
if (LobbyPlayer.getLobbyPlayer(player).isFly()) return;
|
||||
|
||||
player.setAllowFlight(true);
|
||||
Chaoscaot
hat
Same Same
|
||||
if (player.getGameMode() == GameMode.ADVENTURE || player.getGameMode() == GameMode.SURVIVAL) {
|
||||
|
@ -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);
|
||||
|
@ -19,11 +19,12 @@
|
||||
|
||||
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.SpecialParticle;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -31,17 +32,23 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ParticleListener implements Listener {
|
||||
|
||||
private static Random random = new Random();
|
||||
Chaoscaot
hat
Der Import ist noch da Der Import ist noch da
|
||||
private static int deg = 0;
|
||||
|
||||
public ParticleListener() {
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
|
||||
deg++;
|
||||
if (deg > 360) {
|
||||
deg = 0;
|
||||
}
|
||||
}, 0, 1);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(event.getMaterial() != LobbyInventory.PARTICLE)
|
||||
return;
|
||||
if (event.getMaterial() != LobbyInventory.PARTICLE) return;
|
||||
|
||||
ParticleInventory.openParticleInventory(player);
|
||||
}
|
||||
@ -49,21 +56,11 @@ 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);
|
||||
SpecialParticle particle = lobbyPlayer.getParticle();
|
||||
|
||||
if (particle == null) return;
|
||||
|
||||
if (particle == Particle.REDSTONE) {
|
||||
Particle.DustOptions dust = new Particle.DustOptions(Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)), random.nextFloat() / 2 + 1);
|
||||
player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5, dust);
|
||||
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());
|
||||
} else {
|
||||
player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5);
|
||||
}
|
||||
particle.particle(player.getWorld(), player, deg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
@ -29,36 +28,15 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class PlayerMoveListener implements Listener {
|
||||
|
||||
private static final Vector borderMinVector = new Vector(Config.BorderMinX, Config.BorderMinY, Config.BorderMinZ);
|
||||
private static final Vector borderMaxVector = new Vector(Config.BorderMaxX, Config.BorderMaxY, Config.BorderMaxZ);
|
||||
|
||||
@EventHandler
|
||||
public void handleWorldBorder(PlayerMoveEvent event) {
|
||||
Location to = event.getTo();
|
||||
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));
|
||||
}
|
||||
|
||||
private boolean isInRegion(Vector minPoint, Vector maxPoint, Vector location) {
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
||||
if(x >= minPoint.getBlockX()
|
||||
&& x <= maxPoint.getBlockX()
|
||||
&& y >= minPoint.getBlockY()
|
||||
&& y <= maxPoint.getBlockY()
|
||||
&& z >= minPoint.getBlockZ()
|
||||
&& z <= maxPoint.getBlockZ()) {
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
if (!to.toVector().isInAABB(borderMinVector, borderMaxVector)) {
|
||||
event.getPlayer().teleport(event.getFrom());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
130
src/de/steamwar/lobby/listener/PlayerSeatListener.java
Normale Datei
@ -0,0 +1,130 @@
|
||||
/*
|
||||
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 org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
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;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class PlayerSeatListener implements Listener {
|
||||
|
||||
private static class SeatLocation {
|
||||
Chaoscaot
hat
Warum hierfür eine eigene Klasse und kein Vektor, Block, Location? Warum hierfür eine eigene Klasse und kein Vektor, Block, Location?
YoyoNow
hat
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
Lixfel
hat
Sr, YoyoNow, aber da gibt es keinen Memoryleak. Sr, YoyoNow, aber da gibt es keinen Memoryleak.
YoyoNow
hat
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.
Lixfel
hat
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.
YoyoNow
hat
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.
Lixfel
hat
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.
YoyoNow
hat
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.
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public SeatLocation(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof SeatLocation)) return false;
|
||||
SeatLocation that = (SeatLocation) o;
|
||||
return x == that.x &&
|
||||
y == that.y &&
|
||||
z == that.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Set<SeatLocation> seats = new HashSet<>();
|
||||
|
||||
@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;
|
||||
|
||||
Location location = event.getClickedBlock().getLocation();
|
||||
SeatLocation seatLocation = getSeatLocation(location);
|
||||
if (seats.contains(seatLocation))
|
||||
return;
|
||||
seats.add(seatLocation);
|
||||
|
||||
Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(location.add(0.5, 0, 0.5), EntityType.ARROW);
|
||||
arrow.setGravity(false);
|
||||
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
|
||||
arrow.addPassenger(event.getPlayer());
|
||||
arrow.setPersistent(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDismount(EntityDismountEvent event) {
|
||||
Chaoscaot
hat
Was ist, wenn man von einem Sitz auf eine Enderperle geht? Was ist, wenn man von einem Sitz auf eine Enderperle geht?
|
||||
seats.remove(getSeatLocation(event.getDismounted().getLocation()));
|
||||
|
||||
if (event.getEntityType() != EntityType.PLAYER)
|
||||
return;
|
||||
|
||||
event.getDismounted().remove();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (event.getPlayer().isInsideVehicle())
|
||||
event.getPlayer().getVehicle().remove();
|
||||
}
|
||||
|
||||
public SeatLocation getSeatLocation(Location location) {
|
||||
return new SeatLocation(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
}
|
@ -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) {
|
||||
Chaoscaot
hat
Warum ein Fuchs? Warum ein Fuchs?
YoyoNow
hat
Wegen dem Meme des Fuchses aus der WGL Arena Wegen dem Meme des Fuchses aus der WGL Arena
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
44
src/de/steamwar/lobby/particle/FunctionalParticle.java
Normale Datei
@ -0,0 +1,44 @@
|
||||
/*
|
||||
*
|
||||
* 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.particle;
|
||||
|
||||
import org.bukkit.Material;
|
||||
Lixfel
hat
Bitte wenn du schon einen mehrfachconsumer benötigst, nicht unbedingt den Consumer aus log4j verwenden, sondern eher einen aus dem Java-Core (falls vorhanden) Bitte wenn du schon einen mehrfachconsumer benötigst, nicht unbedingt den Consumer aus log4j verwenden, sondern eher einen aus dem Java-Core (falls vorhanden)
YoyoNow
hat
Dort ist keiner vorhanden deswegen. Dort ist keiner vorhanden deswegen.
YoyoNow
hat
Hab ich behoben Hab ich behoben
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FunctionalParticle extends SpecialParticle {
|
||||
|
||||
private ParticleFunction particleFunction;
|
||||
|
||||
public FunctionalParticle(Material material, String name, List<String> lore, ParticleFunction particleFunction) {
|
||||
super(material, name, lore);
|
||||
this.particleFunction = particleFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void particle(World world, Player player, int deg) {
|
||||
particleFunction.accept(world, player, deg);
|
||||
}
|
||||
|
||||
}
|
30
src/de/steamwar/lobby/particle/ParticleFunction.java
Normale Datei
@ -0,0 +1,30 @@
|
||||
/*
|
||||
*
|
||||
* 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.particle;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ParticleFunction {
|
||||
void accept(World world, Player player, Integer time);
|
||||
Chaoscaot
hat
Warum brach der die Welt? Es ist doch alles auf einer Welt? Warum nicht einfach Bukkit.getWorlds().get(0)? Und sonst ist die welt auch noch im Spieler drin. Warum brach der die Welt? Es ist doch alles auf einer Welt? Warum nicht einfach Bukkit.getWorlds().get(0)? Und sonst ist die welt auch noch im Spieler drin.
YoyoNow
hat
'Bukkit.getWorlds().get(0)' ist unnütz, und dauert nur lang als call. Ich reiche das rein um es einfacher zu haben! 'Bukkit.getWorlds().get(0)' ist unnütz, und dauert nur lang als call. Ich reiche das rein um es einfacher zu haben!
|
||||
}
|
68
src/de/steamwar/lobby/particle/SimpleParticle.java
Normale Datei
@ -0,0 +1,68 @@
|
||||
/*
|
||||
*
|
||||
* 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.particle;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleParticle extends SpecialParticle {
|
||||
|
||||
private Particle particle;
|
||||
private boolean customVelocity = false;
|
||||
private float vx;
|
||||
private float vy;
|
||||
private float vz;
|
||||
private double time;
|
||||
|
||||
public SimpleParticle(Material material, String name, List<String> lore, Particle particle) {
|
||||
super(material, name, lore);
|
||||
this.particle = particle;
|
||||
}
|
||||
|
||||
public SimpleParticle(Material material, String name, List<String> lore, Particle particle, float vx, float vy, float vz, double time) {
|
||||
super(material, name, lore);
|
||||
this.particle = particle;
|
||||
customVelocity = true;
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
this.vz = vz;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void particle(World world, Player player, int deg) {
|
||||
Location location = player.getLocation().add(0.0, 0.2, 0.0);
|
||||
if (particle == Particle.REDSTONE) {
|
||||
world.spawnParticle(particle, location, 5, getParticleDust());
|
||||
return;
|
||||
}
|
||||
|
||||
if (customVelocity) {
|
||||
world.spawnParticle(particle, location, 5, vx, vy, vz, time);
|
||||
} else {
|
||||
world.spawnParticle(particle, location, 5);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
77
src/de/steamwar/lobby/particle/SpecialParticle.java
Normale Datei
@ -0,0 +1,77 @@
|
||||
/*
|
||||
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.particle;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
Chaoscaot
hat
Unused Import Unused Import
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class SpecialParticle {
|
||||
|
||||
private static final List<String> emptyLore = new ArrayList<>();
|
||||
private static Random random = new Random();
|
||||
|
||||
protected static Color randomColor() {
|
||||
return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256));
|
||||
Chaoscaot
hat
Können diese Methoden nicht static sein? Können diese Methoden nicht static sein?
|
||||
}
|
||||
|
||||
protected static float randomSize() {
|
||||
return random.nextFloat() / 2 + 1;
|
||||
}
|
||||
|
||||
protected static Particle.DustOptions getParticleDust() {
|
||||
return new Particle.DustOptions(randomColor(), randomSize());
|
||||
}
|
||||
|
||||
private Material material;
|
||||
private String name;
|
||||
Chaoscaot
hat
Drei ungenutzte Methoden Drei ungenutzte Methoden
|
||||
private List<String> lore;
|
||||
|
||||
public SpecialParticle(Material material, String name, List<String> lore) {
|
||||
if (lore == null) {
|
||||
lore = emptyLore;
|
||||
}
|
||||
this.material = material;
|
||||
this.name = name;
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
public final SWItem getItem(LobbyPlayer lobbyPlayer) {
|
||||
return new SWItem(material, name, lore, false, clickType -> {
|
||||
lobbyPlayer.setParticle(this);
|
||||
});
|
||||
}
|
||||
|
||||
public final void add(SWInventory swInventory, int pos, LobbyPlayer lobbyPlayer) {
|
||||
swInventory.setItem(pos, getItem(lobbyPlayer));
|
||||
}
|
||||
|
||||
public abstract void particle(World world, Player player, int deg);
|
||||
|
||||
}
|
@ -19,14 +19,14 @@
|
||||
|
||||
package de.steamwar.lobby.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
Chaoscaot
hat
Unused Import Unused Import
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBuilder {
|
||||
|
||||
private ItemStack item;
|
||||
@ -62,7 +62,7 @@ public class ItemBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addLore(ArrayList<String> lore) {
|
||||
public ItemBuilder addLore(List<String> lore) {
|
||||
meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
package de.steamwar.lobby.utils;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
import de.steamwar.lobby.particle.SpecialParticle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -29,71 +30,22 @@ 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 SpecialParticle specialParticle;
|
||||
|
||||
private boolean enderPearlUsed;
|
||||
private boolean fly;
|
||||
|
||||
private LobbyPlayer(UUID uuid) {
|
||||
this.hiderState = PlayerHiderState.SHOW_ALL;
|
||||
cache.put(uuid, this);
|
||||
specialParticle = null;
|
||||
}
|
||||
|
||||
public PlayerHiderState getHiderState() {
|
||||
return hiderState;
|
||||
public boolean isFly() {
|
||||
return fly;
|
||||
}
|
||||
|
||||
public void setHiderState(PlayerHiderState hiderState) {
|
||||
this.hiderState = hiderState;
|
||||
}
|
||||
|
||||
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 +56,21 @@ 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 SpecialParticle getParticle() {
|
||||
return specialParticle;
|
||||
}
|
||||
|
||||
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 void setParticle(SpecialParticle specialParticle) {
|
||||
this.specialParticle = specialParticle;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,4 +4,7 @@ author: Yaruma3341
|
||||
depend:
|
||||
- SpigotCore
|
||||
main: de.steamwar.lobby.LobbySystem
|
||||
api-version: "1.13"
|
||||
api-version: "1.13"
|
||||
|
||||
commands:
|
||||
fly:
|
Ich bin gegen fly-Command, weil es da mehrfach zu Beschwerden aus Userseite gab, würde hacken. Macht meiner Meinung nach mehr Komplikationen.
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.
Nein, nicht nur Leute, die sich nicht auskennen. Es verwirrt die User (auch MICH hat /fly schon verwirrt).
Ich glaube trotzdem, da es auch nur auf der Lobby ist, dass dieser Befehl wichtig ist.
Ich glaube die Abstimmung ist für wieder einführen.
Sehe da nix, welche Abstimmung von wann und wo?
Im
SteamWar Verwaltung
Discord#allgemein
am20.11.2020
wegen dem/fly
BefehlDas habe ich oben zu einem Screenshot gemacht. 8 sind dafür 4 dagegen