13
0

Update and fix many particles
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-04-07 12:55:43 +02:00
Ursprung 27326b43de
Commit 7cbabc3348
5 geänderte Dateien mit 81 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -16,13 +16,19 @@ PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos
PORTAL_NO_WORLDEDIT_SELECTION = §cNo WorldEdit selection
# Particle
PARTICLE_INVENTORY = §6Particle
PARTICLE_INVENTORY = §0Particle
PARTICLE_DESELECT = §8No particle
PARTICLE_SHOW_HAS_ALL = §8You have all particles
PARTICLE_SHOW_ALL = §aShow all
PARTICLE_SHOW_UNLOCKED = §cShow unlocked
PARTICLE_UNLOCKED_BY = §eUnlocked by
PARTICLE_UNLOCKED_BY_TEAM = §fJoin a team
PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0}
PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM_EASTER = §fTeam {0} (Easter Egg Hunt)
PARTICLE_UNLOCKED_BY_SPECIFIC_USER = §fUser {0}
PARTICLE_UNLOCKED_BY_SPECIFIC_USER_EASTER = §fUser {0} (Easter Egg Hunt)
PARTICLE_UNLOCKED_BY_EVENT = §fEvent participation
PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team
PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. or 3. Place

Datei anzeigen

@ -16,13 +16,19 @@ PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos
PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection
# Particle
PARTICLE_INVENTORY = §6Partikel
PARTICLE_INVENTORY = §0Partikel
PARTICLE_DESELECT = §8Keine Partikel
PARTICLE_SHOW_HAS_ALL = §8Du hast alle Partikel
PARTICLE_SHOW_ALL = §aZeige alle
PARTICLE_SHOW_UNLOCKED = §cZeige freigeschaltete
PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch
PARTICLE_UNLOCKED_BY_TEAM = §fTeambeitritt
PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0}
PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM_EASTER = §fTeam {0} (Oster-Eierer-Suche)
PARTICLE_UNLOCKED_BY_SPECIFIC_USER = §fUser {0}
PARTICLE_UNLOCKED_BY_SPECIFIC_USER_EASTER = §fUser {0} (Oster-Eierer-Suche)
PARTICLE_UNLOCKED_BY_EVENT = §fEventteilnahme
PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServerteam
PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz

Datei anzeigen

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@UtilityClass
@ -63,16 +64,20 @@ public class ParticleInventory {
return null;
}
public void openInventory(Player player) {
public void openInventory(Player player, boolean onlyUnlocked) {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Set<Integer> events = user.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(user.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet());
String eggHuntConfig = UserConfig.getConfig(user.getId(), EggHunt.EGG_HUNT_CONFIG_KEY);
AtomicBoolean hasOneLocked = new AtomicBoolean(false);
List<SWListInv.SWListEntry<ParticleEnum>> particleList = new ArrayList<>();
for (Class<?> clazz : PARTICLES) {
addParticles(particleList, (ParticleEnum[]) clazz.getEnumConstants(), player, user, events, eggHuntConfig);
addParticles(particleList, (ParticleEnum[]) clazz.getEnumConstants(), player, onlyUnlocked, hasOneLocked, user, events, eggHuntConfig);
}
for (int i = 0; i < particleList.size() % 45; i++) {
particleList.add(new SWListInv.SWListEntry<>(new SWItem(Material.BLACK_STAINED_GLASS_PANE, " "), null));
}
SWListInv<ParticleEnum> particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> {
@ -80,21 +85,39 @@ public class ParticleInventory {
lobbyPlayer.setParticle(particle);
player.closeInventory();
});
particleSWListInv.setItem(49, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> {
particleSWListInv.setItem(48, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> {
lobbyPlayer.setParticle(null);
});
if (!hasOneLocked.get()) {
particleSWListInv.setItem(50, Material.GRAY_BANNER, LobbySystem.getMessage().parse("PARTICLE_SHOW_HAS_ALL", player), new ArrayList<>(), false, clickType -> {
});
} else if (onlyUnlocked) {
particleSWListInv.setItem(50, Material.LIME_BANNER, LobbySystem.getMessage().parse("PARTICLE_SHOW_ALL", player), new ArrayList<>(), false, clickType -> {
openInventory(player, false);
});
} else {
particleSWListInv.setItem(50, Material.RED_BANNER, LobbySystem.getMessage().parse("PARTICLE_SHOW_UNLOCKED", player), new ArrayList<>(), false, clickType -> {
openInventory(player, true);
});
}
particleSWListInv.open();
}
private void addParticles(List<SWListInv.SWListEntry<ParticleEnum>> particleList, ParticleEnum[] particleEnums, Player player, SteamwarUser user, Set<Integer> events, String eggHuntConfig) {
private void addParticles(List<SWListInv.SWListEntry<ParticleEnum>> particleList, ParticleEnum[] particleEnums, Player player, boolean onlyUnlocked, AtomicBoolean hasOneLocked, SteamwarUser user, Set<Integer> events, String eggHuntConfig) {
for (ParticleEnum particle : particleEnums) {
ParticleData particleData = particle.getParticle();
SWItem swItem = particleData.toSWItem(player, user, events, eggHuntConfig);
if (particleData.getRequirement().test(user, events, eggHuntConfig)) {
particleList.add(new SWListInv.SWListEntry<>(swItem, particle));
} else {
hasOneLocked.set(true);
if (!onlyUnlocked) {
particleList.add(new SWListInv.SWListEntry<>(swItem, null));
}
}
}
for (int i = 0; i < particleList.size() % 9; i++) {
particleList.add(new SWListInv.SWListEntry<>(new SWItem(Material.BLACK_STAINED_GLASS_PANE, " "), null));
}
}
}

Datei anzeigen

@ -33,8 +33,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;
public class ParticleListener extends BasicListener {
@ -42,12 +42,13 @@ public class ParticleListener extends BasicListener {
private static double deg = 0;
private static Set<Player> movingPlayers = new HashSet<>();
private static Map<Player, Integer> movingPlayers = new HashMap<>();
public ParticleListener() {
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
movingPlayers.replaceAll((player, integer) -> integer - 1);
movingPlayers.entrySet().removeIf(entry -> entry.getValue() <= 0);
if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) {
movingPlayers.clear();
return;
}
deg += 0.1;
@ -60,10 +61,9 @@ public class ParticleListener extends BasicListener {
ParticleData particleData = particle.getParticle();
ParticleElement particleElement = particleData.getParticleElement();
if (particleElement.tickType() == ParticleTickType.ALWAYS) {
particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, movingPlayers.contains(player)));
particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, movingPlayers.containsKey(player)));
}
});
movingPlayers.clear();
}, 0, 1);
}
@ -75,7 +75,7 @@ public class ParticleListener extends BasicListener {
if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return;
event.setCancelled(true);
ParticleInventory.openInventory(player);
ParticleInventory.openInventory(player, true);
}
@EventHandler
@ -93,7 +93,7 @@ public class ParticleListener extends BasicListener {
particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, true));
}
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getY() != event.getTo().getY() || event.getFrom().getZ() != event.getTo().getZ()) {
movingPlayers.add(player);
movingPlayers.put(player, 5);
}
}

Datei anzeigen

@ -183,6 +183,37 @@ public interface ParticleRequirement {
}.or(SERVER_TEAM);
}
static ParticleRequirement easterEventSpecificPlayer(int userId) {
String userName = SteamwarUser.get(userId).getUserName();
return new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SPECIFIC_USER_EASTER", player, userName);
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getId() == userId;
}
}.or(SERVER_TEAM);
}
static ParticleRequirement easterEventSpecificTeam(int teamId) {
if (teamId == 0) return NO_REQUIRMENT;
String teamKuerzel = Team.get(teamId).getTeamKuerzel();
return new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM_EASTER", player, teamKuerzel);
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getTeam() == teamId;
}
}.or(SERVER_TEAM);
}
default ParticleRequirement or(ParticleRequirement particleRequirement) {
return new ParticleRequirement() {
@Override