Particle #21
@ -20,7 +20,8 @@
|
||||
package de.steamwar.lobby.inventories;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.lobby.particle.*;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
@ -28,80 +29,138 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
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<SpecialParticle> PLAYER_PARTICLES = new ArrayList<>();
|
||||
private static final List<SpecialParticle> TEAM_PARTICLES = new ArrayList<>();
|
||||
private static final List<SpecialParticle> SERVERTEAM_PARTICLES = new ArrayList<>();
|
||||
|
||||
private static final List<SWListInv.SWListEntry<SpecialParticle>> PLAYER_PARTICLES_ENTRIES = new ArrayList<>();
|
||||
private static final List<SWListInv.SWListEntry<SpecialParticle>> TEAM_PARTICLES_ENTRIES = new ArrayList<>();
|
||||
private static final List<SWListInv.SWListEntry<SpecialParticle>> SERVERTEAM_PARTICLES_ENTRIES = new ArrayList<>();
|
||||
|
||||
static {
|
||||
List<String> defaultLore = loreBuilder(null, null);
|
||||
List<String> teamLore = loreBuilder(null, "Team beitritt");
|
||||
List<String> serverTeamLore = loreBuilder(null, "Serverteam");
|
||||
List<String> serverTeamLore_C = loreBuilder(new String[]{"Wolke"}, "Serverteam");
|
||||
List<String> serverTeamLore_R = loreBuilder(new String[]{"Ring"}, "Serverteam");
|
||||
List<String> serverTeamLore_2R = loreBuilder(new String[]{"doppel Ring"}, "Serverteam");
|
||||
List<String> serverTeamLore_CR = loreBuilder(new String[]{"Wolke", "Ring"}, "Serverteam");
|
||||
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", defaultLore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.COBWEB, "§7Smoke", defaultLore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", defaultLore, Particle.DRIP_LAVA));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", defaultLore, Particle.DRIP_WATER));
|
||||
PLAYER_PARTICLES.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5)));
|
||||
PLAYER_PARTICLES.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5)));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", defaultLore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", defaultLore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01));
|
||||
PLAYER_PARTICLES.add(new FunctionalParticle(Material.GLASS_BOTTLE, "§5Effekt", defaultLore, (world, player, time) -> {
|
||||
world.spawnParticle(Particle.REDSTONE, player.getLocation().add(0.0, 0.2, 0.0), 5, 0F, 0.2F, 0F, 0.01, SpecialParticle.getParticleDust());
|
||||
}));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", defaultLore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.CAULDRON, "§5Magie", defaultLore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", defaultLore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", defaultLore, Particle.SLIME));
|
||||
PLAYER_PARTICLES.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", defaultLore, Particle.SPELL_MOB));
|
||||
|
||||
TEAM_PARTICLES.addAll(PLAYER_PARTICLES);
|
||||
TEAM_PARTICLES.add(new SimpleParticle(Material.INK_SAC, "§8Squid", teamLore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01));
|
||||
TEAM_PARTICLES.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", teamLore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01));
|
||||
TEAM_PARTICLES.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", teamLore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1));
|
||||
TEAM_PARTICLES.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", teamLore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1));
|
||||
TEAM_PARTICLES.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", loreBuilder(new String[]{"in Luft"}, "Team beitritt"), (world, player, time) -> {
|
||||
if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) {
|
||||
world.spawnParticle(Particle.FIREWORKS_SPARK, player.getLocation().subtract(0, -0.2, 0), 2, 0.1F, 0.1F, 0.1F, 0.2);
|
||||
}
|
||||
}));
|
||||
TEAM_PARTICLES.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", teamLore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01));
|
||||
TEAM_PARTICLES.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", teamLore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01));
|
||||
TEAM_PARTICLES.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", teamLore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01));
|
||||
TEAM_PARTICLES.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen", loreBuilder(new String[]{"Ring"}, "Team beitritt"), Particle.HEART, null, location -> location.add(0, 2.2, 0)));
|
||||
|
||||
SERVERTEAM_PARTICLES.addAll(TEAM_PARTICLES);
|
||||
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", serverTeamLore, Particle.SPELL_WITCH));
|
||||
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", serverTeamLore, Particle.ENCHANTMENT_TABLE));
|
||||
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", serverTeamLore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", serverTeamLore, Particle.FLAME, 0F, 0.2F, 0F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", serverTeamLore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", serverTeamLore_C, Particle.CLOUD));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem", serverTeamLore_C, Particle.TOTEM));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_DYE, "§eZauber", serverTeamLore_C, Particle.ENCHANTMENT_TABLE));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen", serverTeamLore_C, Particle.FLAME));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze", serverTeamLore_C, Particle.SNEEZE));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim", serverTeamLore_C, Particle.SLIME));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke", serverTeamLore_C, Particle.CAMPFIRE_COSY_SMOKE));
|
||||
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town", serverTeamLore_C, Particle.TOWN_AURA));
|
||||
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen", serverTeamLore_R, Particle.FLAME, null, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted", serverTeamLore_R, Particle.ENCHANTMENT_TABLE, null, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten", serverTeamLore_R, Particle.NOTE, null, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.GUARDIAN_SPAWN_EGG, "§bWater§7/§cFire", serverTeamLore_2R, Particle.DRIP_WATER, Particle.DRIP_LAVA, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.DIAMOND_SWORD, "§5Magic§7/§eZauber", serverTeamLore_2R, Particle.CRIT_MAGIC, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
|
||||
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.GLOWSTONE_DUST, "§5Magic", serverTeamLore_CR, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0)));
|
||||
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen", serverTeamLore_CR, Particle.FLAME, location -> location.add(0, 1.1, 0)));
|
||||
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework", serverTeamLore_CR, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0)));
|
||||
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater", serverTeamLore_CR, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0)));
|
||||
|
||||
PLAYER_PARTICLES.forEach(specialParticle -> PLAYER_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle)));
|
||||
TEAM_PARTICLES.forEach(specialParticle -> TEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle)));
|
||||
SERVERTEAM_PARTICLES.forEach(specialParticle -> SERVERTEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle)));
|
||||
}
|
||||
|
||||
private static SWInventory createInventory(Player player) {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
SWInventory swInventory;
|
||||
SWListInv<SpecialParticle> particleSWListInv;
|
||||
if (userGroup == UserGroup.Member) {
|
||||
swInventory = new SWInventory(player, 9*5, "§6Partikel");
|
||||
if (steamwarUser.getTeam() != 0) {
|
||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, TEAM_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
||||
} else {
|
||||
if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) {
|
||||
lobbyPlayer.setParticle(null);
|
||||
}
|
||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, PLAYER_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
||||
}
|
||||
} else {
|
||||
swInventory = new SWInventory(player, 9*6, "§6Partikel");
|
||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, SERVERTEAM_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (userGroup == UserGroup.Member) {
|
||||
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyPlayer);
|
||||
} 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);
|
||||
}
|
||||
|
||||
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();
|
||||
particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> {
|
||||
lobbyPlayer.setParticle(null);
|
||||
});
|
||||
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);
|
||||
return particleSWListInv;
|
||||
}
|
||||
|
||||
public static void openParticleInventory(Player player) {
|
||||
createInventory(player).open();
|
||||
}
|
||||
|
||||
private static List<String> loreBuilder(String[] attribute, String unlocked) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
if (attribute != null && attribute.length > 0) {
|
||||
lore.add("§eAttribute§7:");
|
||||
for (String s : attribute) {
|
||||
lore.add("§7- §f" + s);
|
||||
}
|
||||
lore.add("");
|
||||
}
|
||||
if (unlocked != null) {
|
||||
lore.add("§eFreigeschaltet durch");
|
||||
lore.add("§f" + unlocked);
|
||||
lore.add("");
|
||||
}
|
||||
lore.add("§eKlicken zum auswählen");
|
||||
return lore;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,21 @@ 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();
|
||||
private static double deg = 0;
|
||||
|
||||
public ParticleListener() {
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
|
||||
deg += 0.1;
|
||||
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);
|
||||
}
|
||||
@ -50,20 +55,10 @@ public class ParticleListener implements Listener {
|
||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
Particle particle = lobbyPlayer.getParticle();
|
||||
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.execute(player.getWorld(), player, deg);
|
||||
}
|
||||
|
||||
|
||||
|
87
src/de/steamwar/lobby/particle/CircleParticle.java
Normale Datei
87
src/de/steamwar/lobby/particle/CircleParticle.java
Normale Datei
@ -0,0 +1,87 @@
|
||||
/*
|
||||
*
|
||||
* 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.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class CircleParticle extends SpecialParticle {
|
||||
|
||||
private Particle particle;
|
||||
private Particle particle2;
|
||||
private Function<Location, Location> locationShift;
|
||||
private boolean customVelocity = false;
|
||||
private float vx;
|
||||
private float vy;
|
||||
private float vz;
|
||||
private double time = 1;
|
||||
|
||||
public CircleParticle(Material material, String name, List<String> lore, Particle particle, Particle particle2, UnaryOperator<Location> locationShift) {
|
||||
super(material, name, lore);
|
||||
this.particle = particle;
|
||||
this.particle2 = particle2;
|
||||
this.locationShift = locationShift;
|
||||
}
|
||||
|
||||
public CircleParticle(Material material, String name, List<String> lore, Particle particle, Particle particle2, UnaryOperator<Location> locationShift, float vx, float vy, float vz, double time) {
|
||||
super(material, name, lore);
|
||||
this.particle = particle;
|
||||
this.particle2 = particle2;
|
||||
this.locationShift = locationShift;
|
||||
customVelocity = true;
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
this.vz = vz;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void particle(World world, Player player, double deg) {
|
||||
Vector vector = new Vector(1, 0, 0);
|
||||
vector.rotateAroundY(deg);
|
||||
if (customVelocity) {
|
||||
world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time);
|
||||
} else {
|
||||
world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1);
|
||||
}
|
||||
|
||||
if (particle2 == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
vector.setX(-vector.getX());
|
||||
vector.setZ(-vector.getZ());
|
||||
if (customVelocity) {
|
||||
world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time);
|
||||
} else {
|
||||
world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
44
src/de/steamwar/lobby/particle/CloudCircleParticle.java
Normale Datei
44
src/de/steamwar/lobby/particle/CloudCircleParticle.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.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class CloudCircleParticle extends CircleParticle {
|
||||
|
||||
public CloudCircleParticle(Material material, String name, List<String> lore, Particle particle, UnaryOperator<Location> locationShift) {
|
||||
super(material, name, lore, particle, null, locationShift, 0.0F, 0.0F, 0.0F, 0.01);
|
||||
asCloud = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void particle(World world, Player player, double deg) {
|
||||
super.particle(world, player, deg);
|
||||
}
|
||||
|
||||
}
|
44
src/de/steamwar/lobby/particle/CloudParticle.java
Normale Datei
44
src/de/steamwar/lobby/particle/CloudParticle.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;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CloudParticle extends SpecialParticle {
|
||||
|
||||
private Particle particle;
|
||||
|
||||
public CloudParticle(Material material, String name, List<String> lore, Particle particle) {
|
||||
super(material, name, lore);
|
||||
asCloud = true;
|
||||
this.particle = particle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void particle(World world, Player player, double deg) {
|
||||
world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 5, 0.5F, 0.02F, 0.5F, 0.01);
|
||||
}
|
||||
}
|
43
src/de/steamwar/lobby/particle/FunctionalParticle.java
Normale Datei
43
src/de/steamwar/lobby/particle/FunctionalParticle.java
Normale Datei
@ -0,0 +1,43 @@
|
||||
/*
|
||||
*
|
||||
* 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;
|
||||
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, double deg) {
|
||||
particleFunction.accept(world, player, deg);
|
||||
}
|
||||
|
||||
}
|
29
src/de/steamwar/lobby/particle/ParticleFunction.java
Normale Datei
29
src/de/steamwar/lobby/particle/ParticleFunction.java
Normale Datei
@ -0,0 +1,29 @@
|
||||
/*
|
||||
*
|
||||
* 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, double time);
|
||||
}
|
62
src/de/steamwar/lobby/particle/SimpleParticle.java
Normale Datei
62
src/de/steamwar/lobby/particle/SimpleParticle.java
Normale Datei
@ -0,0 +1,62 @@
|
||||
/*
|
||||
*
|
||||
* 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 = 1;
|
||||
|
||||
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, double deg) {
|
||||
Location location = player.getLocation().add(0.0, 0.2, 0.0);
|
||||
if (customVelocity) {
|
||||
world.spawnParticle(particle, location, 5, vx, vy, vz, time);
|
||||
} else {
|
||||
world.spawnParticle(particle, location, 5);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
84
src/de/steamwar/lobby/particle/SpecialParticle.java
Normale Datei
84
src/de/steamwar/lobby/particle/SpecialParticle.java
Normale Datei
@ -0,0 +1,84 @@
|
||||
/*
|
||||
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.SWItem;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class SpecialParticle {
|
||||
|
||||
private static final List<String> EMPTY_LORE = new ArrayList<>();
|
||||
private static Random random = new Random();
|
||||
|
||||
public static Color randomColor() {
|
||||
return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256));
|
||||
}
|
||||
|
||||
public static float randomSize() {
|
||||
return random.nextFloat() / 2 + 1;
|
||||
}
|
||||
|
||||
public static Particle.DustOptions getParticleDust() {
|
||||
return new Particle.DustOptions(randomColor(), randomSize());
|
||||
}
|
||||
|
||||
private Material material;
|
||||
private String name;
|
||||
private List<String> lore;
|
||||
protected boolean asCloud = false;
|
||||
|
||||
protected SpecialParticle(Material material, String name, List<String> lore) {
|
||||
if (lore == null) {
|
||||
lore = EMPTY_LORE;
|
||||
}
|
||||
this.material = material;
|
||||
this.name = name;
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
public final SWItem getItem() {
|
||||
return new SWItem(material, name, lore, false, clickType -> {});
|
||||
}
|
||||
|
||||
public final void execute(World world, Player player, double deg) {
|
||||
if (asCloud) {
|
||||
if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false));
|
||||
} else {
|
||||
player.removePotionEffect(PotionEffectType.SLOW_FALLING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
particle(world, player, deg);
|
||||
}
|
||||
|
||||
public abstract void particle(World world, Player player, double deg);
|
||||
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.lobby.utils;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
import de.steamwar.lobby.particle.SpecialParticle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -30,18 +30,14 @@ public class LobbyPlayer {
|
||||
|
||||
private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
|
||||
|
||||
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) {
|
||||
cache.put(uuid, this);
|
||||
specialParticle = null;
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
@ -52,47 +48,12 @@ public class LobbyPlayer {
|
||||
this.fly = fly;
|
||||
}
|
||||
|
||||
public Particle getParticle() {
|
||||
return particle;
|
||||
public SpecialParticle getParticle() {
|
||||
return specialParticle;
|
||||
}
|
||||
|
||||
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 setParticle(SpecialParticle specialParticle) {
|
||||
this.specialParticle = specialParticle;
|
||||
}
|
||||
|
||||
public boolean isEnderPearlUsed() {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren