Archiviert
13
0

Simplify ParticleInventory

Dieser Commit ist enthalten in:
jojo 2021-02-23 11:37:54 +01:00
Ursprung e56da0ba68
Commit 687f498543
7 geänderte Dateien mit 55 neuen und 106 gelöschten Zeilen

Datei anzeigen

@ -82,7 +82,7 @@ public class ParticleInventory {
teamParticles.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", teamLore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01));
teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", teamLore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01));
teamParticles.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", teamLore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01));
teamParticles.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen", loreBuilder(new String[]{"Ring"}, "Team beitritt"), Particle.HEART, location -> location.add(0, 2.2, 0)));
teamParticles.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen", loreBuilder(new String[]{"Ring"}, "Team beitritt"), Particle.HEART, null, location -> location.add(0, 2.2, 0)));
serverteamParticles.addAll(teamParticles);
serverteamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", serverTeamLore, Particle.SPELL_WITCH));
@ -98,11 +98,11 @@ public class ParticleInventory {
serverteamParticles.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim", serverTeamLore_C, Particle.SLIME));
serverteamParticles.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke", serverTeamLore_C, Particle.CAMPFIRE_COSY_SMOKE));
serverteamParticles.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town", serverTeamLore_C, Particle.TOWN_AURA));
serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen", serverTeamLore_R, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01));
serverteamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted", serverTeamLore_R, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
serverteamParticles.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten", serverTeamLore_R, Particle.NOTE, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01));
serverteamParticles.add(new DoubleCircleParticle(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));
serverteamParticles.add(new DoubleCircleParticle(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));
serverteamParticles.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));
serverteamParticles.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));
serverteamParticles.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));
serverteamParticles.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));
serverteamParticles.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));
serverteamParticles.add(new CloudCircleParticle(Material.GLOWSTONE_DUST, "§5Magic", serverTeamLore_CR, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0)));
serverteamParticles.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen", serverTeamLore_CR, Particle.FLAME, location -> location.add(0, 1.1, 0)));
serverteamParticles.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework", serverTeamLore_CR, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0)));

Datei anzeigen

@ -58,7 +58,7 @@ public class ParticleListener implements Listener {
SpecialParticle particle = lobbyPlayer.getParticle();
if (particle == null) return;
particle.particle(player.getWorld(), player, deg);
particle.execute(player.getWorld(), player, deg);
}

Datei anzeigen

@ -35,6 +35,7 @@ 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;
@ -42,15 +43,17 @@ public class CircleParticle extends SpecialParticle {
private float vz;
private double time = 1;
public CircleParticle(Material material, String name, List<String> lore, Particle particle, UnaryOperator<Location> locationShift) {
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, UnaryOperator<Location> locationShift, float vx, float vy, float vz, double time) {
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;
@ -68,6 +71,18 @@ public class CircleParticle extends SpecialParticle {
} 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);
}
}
}

Datei anzeigen

@ -26,8 +26,6 @@ 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.List;
import java.util.function.UnaryOperator;
@ -35,17 +33,13 @@ 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, locationShift, 0.0F, 0.0F, 0.0F, 0.01);
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) {
if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false));
super.particle(world, player, deg);
} else {
player.removePotionEffect(PotionEffectType.SLOW_FALLING);
}
super.particle(world, player, deg);
}
}

Datei anzeigen

@ -23,22 +23,23 @@ package de.steamwar.lobby.particle;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.List;
public class CloudParticle extends FunctionalParticle {
public class CloudParticle extends SpecialParticle {
private Particle particle;
public CloudParticle(Material material, String name, List<String> lore, Particle particle) {
super(material, name, lore, (world, player, time) -> {
if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false));
world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 5, 0.5F, 0.02F, 0.5F, 0.01);
} else {
player.removePotionEffect(PotionEffectType.SLOW_FALLING);
}
});
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);
}
}

Datei anzeigen

@ -1,76 +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.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 DoubleCircleParticle extends SpecialParticle {
private Particle particle1;
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 DoubleCircleParticle(Material material, String name, List<String> lore, Particle particle1, Particle particle2, UnaryOperator<Location> locationShift, float vx, float vy, float vz, double time) {
super(material, name, lore);
this.particle1 = particle1;
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(particle1, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time);
} else {
world.spawnParticle(particle1, locationShift.apply(player.getLocation().add(vector)), 1);
}
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);
}
}
}

Datei anzeigen

@ -25,6 +25,8 @@ 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;
@ -50,8 +52,9 @@ public abstract class SpecialParticle {
private Material material;
private String name;
private List<String> lore;
protected boolean asCloud = false;
public SpecialParticle(Material material, String name, List<String> lore) {
protected SpecialParticle(Material material, String name, List<String> lore) {
if (lore == null) {
lore = emptyLore;
}
@ -64,6 +67,18 @@ public abstract class SpecialParticle {
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);
}