Archiviert
13
0

Implement new ParticleInventory

Dieser Commit ist enthalten in:
jojo 2021-01-03 15:36:23 +01:00
Ursprung 6f04d2b811
Commit 3d6c9b267f
7 geänderte Dateien mit 74 neuen und 69 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.lobby.inventories;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWListInv;
import de.steamwar.lobby.particle.CircleParticle;
import de.steamwar.lobby.particle.FunctionalParticle;
import de.steamwar.lobby.particle.SimpleParticle;
@ -29,9 +30,9 @@ import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.data.type.Fire;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -42,65 +43,60 @@ public class ParticleInventory {
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 List<SpecialParticle> playerParticles = new ArrayList<>();
private static final List<SpecialParticle> teamParticles = new ArrayList<>();
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 List<SWListInv.SWListEntry<SpecialParticle>> playerParticlesEntries = new ArrayList<>();
private static final List<SWListInv.SWListEntry<SpecialParticle>> teamParticlesEntries = new ArrayList<>();
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);
static {
playerParticles.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01));
playerParticles.add(new SimpleParticle(Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01));
playerParticles.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA));
playerParticles.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER));
playerParticles.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", lore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5)));
playerParticles.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", lore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5)));
playerParticles.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01));
playerParticles.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01));
playerParticles.add(new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01));
playerParticles.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01));
playerParticles.add(new SimpleParticle(Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01));
playerParticles.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01));
playerParticles.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME));
playerParticles.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB));
private static final SpecialParticle FIRE_RING = new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0));
teamParticles.addAll(playerParticles);
teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01));
teamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH));
teamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE));
teamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01));
teamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01));
teamParticles.add(new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01));
teamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01));
teamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01));
teamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted Ring", lore, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
teamParticles.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten Ring", lore, Particle.NOTE, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 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 final SpecialParticle[] row_4 = new SpecialParticle[]{FIRE_RING};
playerParticles.forEach(specialParticle -> playerParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle)));
teamParticles.forEach(specialParticle -> teamParticlesEntries.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 = new SWInventory(player, 9 * (userGroup == UserGroup.Member ? 5 : 6), "§6Partikel");
add(swInventory, row_1, 10, lobbyPlayer);
add(swInventory, row_2, 19, lobbyPlayer);
SWListInv<SpecialParticle> particleSWListInv;
if (userGroup == UserGroup.Member) {
swInventory.setItem(31, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> {
lobbyPlayer.setParticle(null);
});
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, playerParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle));
} else {
add(swInventory, row_3, 28, lobbyPlayer);
swInventory.setItem(40, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> {
lobbyPlayer.setParticle(null);
});
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, teamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle));
}
particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> {
lobbyPlayer.setParticle(null);
});
return swInventory;
}
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);
}
return particleSWListInv;
}
public static void openParticleInventory(Player player) {

Datei anzeigen

@ -34,14 +34,12 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class ParticleListener implements Listener {
private static int deg = 0;
private static double deg = 0;
public ParticleListener() {
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
deg++;
if (deg > 360) {
deg = 0;
}
deg += 0.1;
if (deg > 360) deg = 0;
}, 0, 1);
}

Datei anzeigen

@ -30,12 +30,16 @@ import org.bukkit.util.Vector;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
public class CircleParticle extends SpecialParticle {
private Particle particle;
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, Function<Location, Location> locationShift) {
super(material, name, lore);
@ -43,11 +47,26 @@ public class CircleParticle extends SpecialParticle {
this.locationShift = locationShift;
}
public CircleParticle(Material material, String name, List<String> lore, Particle particle, Function<Location, Location> locationShift, float vx, float vy, float vz, double time) {
super(material, name, lore);
this.particle = particle;
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, int deg) {
public void particle(World world, Player player, double deg) {
Vector vector = new Vector(1, 0, 0);
vector.rotateAroundY(deg);
world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 5);
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);
}
}
}

Datei anzeigen

@ -37,7 +37,7 @@ public class FunctionalParticle extends SpecialParticle {
}
@Override
public void particle(World world, Player player, int deg) {
public void particle(World world, Player player, double deg) {
particleFunction.accept(world, player, deg);
}

Datei anzeigen

@ -26,5 +26,5 @@ import org.bukkit.entity.Player;
@FunctionalInterface
public interface ParticleFunction {
void accept(World world, Player player, Integer time);
void accept(World world, Player player, double time);
}

Datei anzeigen

@ -33,7 +33,7 @@ public class SimpleParticle extends SpecialParticle {
private float vx;
private float vy;
private float vz;
private double time;
private double time = 1;
public SimpleParticle(Material material, String name, List<String> lore, Particle particle) {
super(material, name, lore);
@ -51,7 +51,7 @@ public class SimpleParticle extends SpecialParticle {
}
@Override
public void particle(World world, Player player, int deg) {
public void particle(World world, Player player, double deg) {
Location location = player.getLocation().add(0.0, 0.2, 0.0);
if (particle == Particle.REDSTONE) {
world.spawnParticle(particle, location, 5, getParticleDust());

Datei anzeigen

@ -19,9 +19,7 @@
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;
@ -62,16 +60,10 @@ public abstract class SpecialParticle {
this.lore = lore;
}
public final SWItem getItem(LobbyPlayer lobbyPlayer) {
return new SWItem(material, name, lore, false, clickType -> {
lobbyPlayer.setParticle(this);
});
public final SWItem getItem() {
return new SWItem(material, name, lore, false, clickType -> {});
}
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);
public abstract void particle(World world, Player player, double deg);
}