Particle #21
@ -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);
|
||||
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());
|
||||
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);
|
||||
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,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();
|
||||
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);
|
||||
}
|
||||
@ -50,20 +57,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.particle(player.getWorld(), player, deg);
|
||||
}
|
||||
|
||||
|
||||
|
44
src/de/steamwar/lobby/particle/FunctionalParticle.java
Normale Datei
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;
|
||||
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
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);
|
||||
}
|
68
src/de/steamwar/lobby/particle/SimpleParticle.java
Normale Datei
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
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;
|
||||
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));
|
||||
}
|
||||
|
||||
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;
|
||||
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,7 +19,7 @@
|
||||
|
||||
package de.steamwar.lobby.utils;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
import de.steamwar.lobby.particle.SpecialParticle;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -29,60 +29,21 @@ 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 LobbyPlayer(UUID uuid) {
|
||||
cache.put(uuid, this);
|
||||
specialParticle = null;
|
||||
}
|
||||
|
||||
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