Archiviert
13
0

lobby-update #16

Geschlossen
YoyoNow möchte 8 Commits von lobby-update nach master mergen
4 geänderte Dateien mit 98 neuen und 24 gelöschten Zeilen
Nur Änderungen aus Commit 631436d064 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -19,12 +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.utils.LobbyParticle;
import de.steamwar.lobby.particle.CustomParticle;
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;
@ -37,6 +37,16 @@ import java.util.Random;
public class ParticleListener implements Listener {
Review

Der Import ist noch da

Der Import ist noch da
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) {
@ -51,21 +61,10 @@ public class ParticleListener implements Listener {
public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
LobbyParticle lobbyParticle = lobbyPlayer.getLobbyParticle();
Particle particle = lobbyParticle.getParticle();
CustomParticle 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 (lobbyParticle.isCustomVelocity()) {
player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5, lobbyParticle.getParticle_vx(), lobbyParticle.getParticle_vy(), lobbyParticle.getParticle_vz(), lobbyParticle.getParticle_time());
} else {
player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5);
}
particle.particle(player.getWorld(), player, deg);
}

Datei anzeigen

@ -0,0 +1,69 @@
package de.steamwar.lobby.particle;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.lobby.utils.LobbyParticle;
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 sun.awt.image.OffScreenImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public abstract class CustomParticle {
private static final List<String> emptyLore = new ArrayList<>();
private static Random random = new Random();
protected final Color randomColor() {
return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256));
}
protected final float randomSize() {
return random.nextFloat() / 2 + 1;
}
protected final Particle.DustOptions getParticleDust() {
return new Particle.DustOptions(randomColor(), randomSize());
}
protected final Particle.DustOptions getParticleDust(float size) {
return new Particle.DustOptions(randomColor(), size);
}
protected final Particle.DustOptions getParticleDust(int r, int g, int b) {
return new Particle.DustOptions(Color.fromRGB(r, g, b), randomSize());
}
protected final Particle.DustOptions getParticleDust(int r, int g, int b, float size) {
return new Particle.DustOptions(Color.fromRGB(r, g, b), size);
}
private Material material;
private String name;
private List<String> lore;
public CustomParticle(Material material, String name, List<String> lore) {
if (lore == null) {
lore = emptyLore;
}
this.material = material;
this.name = name;
this.lore = lore;
}
public final void add(SWInventory swInventory, int pos, LobbyPlayer lobbyPlayer) {
SWItem swItem = new SWItem(material, name, lore, false, clickType -> {
lobbyPlayer.setParticle(this);
});
swInventory.setItem(pos, swItem);
}
public abstract void particle(World world, Player player, int deg);
}

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.lobby.utils;
import java.util.ArrayList;
Review

Unused Import

Unused Import
import java.util.List;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -62,7 +63,7 @@ public class ItemBuilder {
return this;
}
public ItemBuilder addLore(ArrayList<String> lore) {
public ItemBuilder addLore(List<String> lore) {
meta.setLore(lore);
return this;
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.lobby.utils;
import de.steamwar.lobby.particle.CustomParticle;
import org.bukkit.entity.Player;
import java.util.HashMap;
@ -29,18 +30,14 @@ public class LobbyPlayer {
private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
private LobbyParticle lobbyParticle;
private CustomParticle customParticle;
private boolean enderPearlUsed;
private boolean fly;
private LobbyPlayer(UUID uuid) {
cache.put(uuid, this);
lobbyParticle = new LobbyParticle();
}
public LobbyParticle getLobbyParticle() {
return lobbyParticle;
customParticle = null;
}
public boolean isFly() {
@ -59,6 +56,14 @@ public class LobbyPlayer {
this.enderPearlUsed = enderPearlUsed;
}
public CustomParticle getParticle() {
return customParticle;
}
public void setParticle(CustomParticle customParticle) {
this.customParticle = customParticle;
}
public static LobbyPlayer getLobbyPlayer(UUID uuid) {
LobbyPlayer lobbyPlayer = cache.get(uuid);
return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer;