Polish lobby particle slots

Count the real particle amount of reward designs, set slot budgets to
30 particles per tick (60 for the server team), let requirements test
only against an UnlockContext, and drop requirements and messages the
old particle menu used.
This commit is contained in:
2026-10-26 09:48:05 +01:00
parent c95901bc42
commit 98f04451a4
6 changed files with 38 additions and 211 deletions
@@ -39,11 +39,7 @@ public interface ParticleRequirement {
String getRequirementName(Player player);
boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig);
default boolean test(UnlockContext context) {
return test(context.getUser(), context.getEvents(), context.getEggHuntConfig());
}
boolean test(UnlockContext context);
ParticleRequirement SERVER_TEAM = new ParticleRequirement() {
@Override
@@ -51,11 +47,6 @@ public interface ParticleRequirement {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SERVER_TEAM", player);
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.hasPerm(UserPerm.TEAM);
}
@Override
public boolean test(UnlockContext context) {
return context.getUser().hasPerm(UserPerm.TEAM);
@@ -68,56 +59,24 @@ public interface ParticleRequirement {
return null;
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return true;
}
@Override
public boolean test(UnlockContext context) {
return true;
}
};
// Unlike HAS_TEAM this does not also pass for the server team
// Does not also pass for the server team
ParticleRequirement TEAM_MEMBER = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_TEAM", player);
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getTeam() != 0;
}
@Override
public boolean test(UnlockContext context) {
return context.getUser().getTeam() != 0;
}
};
ParticleRequirement HAS_TEAM = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_TEAM", player);
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getTeam() != 0;
}
}.or(SERVER_TEAM);
ParticleRequirement EVENT_PARTICIPATION = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EVENT", player);
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return !eventTeilname.isEmpty();
}
}.or(SERVER_TEAM);
ParticleRequirement EGG_HUNT_EASY = _easterEggHuntDifficulty(EggDifficulty.EASY);
ParticleRequirement EGG_HUNT_MEDIUM = _easterEggHuntDifficulty(EggDifficulty.MEDIUM);
ParticleRequirement EGG_HUNT_HARD = _easterEggHuntDifficulty(EggDifficulty.HARD);
@@ -130,7 +89,8 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
public boolean test(UnlockContext context) {
String eggHuntConfig = context.getEggHuntConfig();
if (eggHuntConfig == null) return false;
int count = 0;
for (int i = 0; i < eggHuntConfig.length(); i++) {
@@ -152,8 +112,8 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getTeam() == teamId;
public boolean test(UnlockContext context) {
return context.getUser().getTeam() == teamId;
}
}.or(SERVER_TEAM);
}
@@ -167,8 +127,8 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return eventTeilname.contains(eventId);
public boolean test(UnlockContext context) {
return context.getEvents().contains(eventId);
}
}.or(SERVER_TEAM);
}
@@ -184,9 +144,9 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
if (!eventTeilname.contains(eventId)) return false;
return teams.contains(user.getTeam());
public boolean test(UnlockContext context) {
if (!teams.contains(context.getUser().getTeam())) return false;
return context.getEvents().contains(eventId);
}
}.or(SERVER_TEAM);
}
@@ -213,7 +173,8 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
public boolean test(UnlockContext context) {
String eggHuntConfig = context.getEggHuntConfig();
if (eggHuntConfig == null) return false;
return eggs.stream().allMatch(id -> eggHuntConfig.length() > id && eggHuntConfig.charAt(id) == '1');
}
@@ -229,8 +190,8 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getId() == userId;
public boolean test(UnlockContext context) {
return context.getUser().getId() == userId;
}
}.or(SERVER_TEAM);
}
@@ -244,8 +205,8 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getId() == userId;
public boolean test(UnlockContext context) {
return context.getUser().getId() == userId;
}
}.or(SERVER_TEAM);
}
@@ -260,12 +221,13 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getTeam() == teamId;
public boolean test(UnlockContext context) {
return context.getUser().getTeam() == teamId;
}
}.or(SERVER_TEAM);
}
// The alternative is checked first, as it is usually the cheap server team check
default ParticleRequirement or(ParticleRequirement particleRequirement) {
return new ParticleRequirement() {
@Override
@@ -274,8 +236,8 @@ public interface ParticleRequirement {
}
@Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return ParticleRequirement.this.test(user, eventTeilname, eggHuntConfig) || particleRequirement.test(user, eventTeilname, eggHuntConfig);
public boolean test(UnlockContext context) {
return particleRequirement.test(context) || ParticleRequirement.this.test(context);
}
};
}
@@ -47,19 +47,19 @@ public class RewardDesigns {
.set(GLIDING, Gliding.NOT_GLIDING);
public final ParticleDesign EVENT_PLACEMENT_WARGEAR_SEASON = new FixedDesign("event_placement_wargear_season", Material.ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING",
ParticleRequirement.eventPlacement(22, 12, 285, 54), 1, MOVE,
ParticleRequirement.eventPlacement(22, 12, 285, 54), 5, MOVE,
() -> new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01), 0, 1.1, 0))));
public final ParticleDesign EVENT_PLACEMENT_AIRSHIP = new FixedDesign("event_placement_airship", Material.SNOWBALL, "PARTICLE_EVENT_CLOUD",
ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), 1, MOVE,
ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), 5, MOVE,
() -> new Circle(new LocationMutator(new SimpleParticle(Particle.CLOUD, 0, 0, 0, 0.01), 0, 2.2, 0)));
public final ParticleDesign EVENT_PLACEMENT_HELLS_BELLS = new FixedDesign("event_placement_hells_bells", Material.TNT_MINECART, "PARTICLE_EVENT_SMOKE",
ParticleRequirement.eventPlacement(28, 205, 9, 11), 1, MOVE,
ParticleRequirement.eventPlacement(28, 205, 9, 11), 5, MOVE,
() -> new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), 0, 2.2, 0))));
public final ParticleDesign EVENT_PLACEMENT_UNDERWATER = new FixedDesign("event_placement_underwater", Material.PRISMARINE_SHARD, "PARTICLE_EVENT_WATER",
ParticleRequirement.eventPlacement(31, 9, 210, 520), 1, MOVE,
ParticleRequirement.eventPlacement(31, 9, 210, 520), 5, MOVE,
() -> new Cloud(new SimpleParticle(Particle.DRIPPING_WATER)));
public final ParticleDesign EVENT_PLACEMENT_ADVENT_WAR_SHIP = new FixedDesign("event_placement_advent_war_ship", Material.PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER",
ParticleRequirement.eventPlacement(32, 9, 205, 210), 2, ALWAYS,
ParticleRequirement.eventPlacement(32, 9, 205, 210), 10, ALWAYS,
() -> new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIPPING_WATER), new SimpleParticle(Particle.UNDERWATER, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0));
public final ParticleDesign EVENT_PLACEMENT_MINI_WARGEAR_LIGA = wings("event_placement_mini_wargear_liga", Material.IRON_SWORD, "PARTICLE_EVENT_WINGS",
ParticleRequirement.eventPlacement(33, 9, 34, 205), Particle.UNDERWATER, 0.15, WingDesign.MWGL);
@@ -73,25 +73,25 @@ public class RewardDesigns {
ParticleRequirement.eventPlacement(38, 210, 158, 167, 286), Particle.CRIT, 0.1, WingDesign.SWORD_CROSSED);
public final ParticleDesign EVENT_PARTICIPATION_WARGEAR_SEASON = new FixedDesign("event_participation_wargear_season", Material.BOOK, "PARTICLE_EVENT_ENCHANTING",
ParticleRequirement.eventParticipation(22), 1, MOVE,
ParticleRequirement.eventParticipation(22), 5, MOVE,
() -> new SimpleParticle(Particle.ENCHANT));
public final ParticleDesign EVENT_PARTICIPATION_AIRSHIP = new FixedDesign("event_participation_airship", Material.SNOW_BLOCK, "PARTICLE_EVENT_CLOUD",
ParticleRequirement.eventParticipation(26), 1, MOVE,
ParticleRequirement.eventParticipation(26), 5, MOVE,
() -> new SimpleParticle(Particle.CLOUD));
public final ParticleDesign EVENT_PARTICIPATION_HELLS_BELLS = new FixedDesign("event_participation_hells_bells", Material.TNT, "PARTICLE_EVENT_SMOKE",
ParticleRequirement.eventParticipation(28), 1, MOVE,
ParticleRequirement.eventParticipation(28), 5, MOVE,
() -> new Circle(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01)));
public final ParticleDesign EVENT_PARTICIPATION_UNDERWATER = new FixedDesign("event_participation_underwater", Material.PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER",
ParticleRequirement.eventParticipation(31), 1, MOVE,
ParticleRequirement.eventParticipation(31), 5, MOVE,
() -> new SimpleParticle(Particle.DRIPPING_WATER));
public final ParticleDesign EVENT_PARTICIPATION_ADVENT_WAR_SHIP = new FixedDesign("event_participation_advent_war_ship", Material.PRISMARINE_WALL, "PARTICLE_EVENT_WATER",
ParticleRequirement.eventParticipation(32), 2, MOVE,
ParticleRequirement.eventParticipation(32), 10, MOVE,
() -> new Group(new SimpleParticle(Particle.DRIPPING_WATER), new SimpleParticle(Particle.UNDERWATER, 0.2F, 0.2F, 0.2F, 0.01)));
public final ParticleDesign EVENT_PARTICIPATION_MINI_WARGEAR_LIGA = new FixedDesign("event_participation_mini_wargear_liga", Material.PRISMARINE_SLAB, "PARTICLE_EVENT_WATER",
ParticleRequirement.eventParticipation(33), 1, MOVE,
ParticleRequirement.eventParticipation(33), 5, MOVE,
() -> new Circle(new SimpleParticle(Particle.UNDERWATER, 0, 0, 0, 0)));
public final ParticleDesign EVENT_PARTICIPATION_UNDERWATER_MWG = new FixedDesign("event_participation_underwater_mwg", Material.BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD",
ParticleRequirement.eventParticipation(35), 3, ALWAYS,
ParticleRequirement.eventParticipation(35), 15, ALWAYS,
() -> new RandomParticle(
rainCloud(Particle.RAIN, Particle.DRIPPING_WATER, 5),
rainCloud(null, Particle.DRIPPING_LAVA, 5),
@@ -113,7 +113,7 @@ public class RewardDesigns {
ParticleRequirement.EGG_HUNT_EASY, 1, ALWAYS,
() -> new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM, 0.5F, 0.1f, 0.5F, 1, 1), 0, 2.2, 0));
public final ParticleDesign EGG_HUNT_MEDIUM = new FixedDesign("egg_hunt_medium", Material.YELLOW_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_MEDIUM",
ParticleRequirement.EGG_HUNT_MEDIUM, 1, ALWAYS.andThen(values -> values.set(GROUND, Ground.ON_GROUND).set(SNEAK, Sneak.SNEAKING)),
ParticleRequirement.EGG_HUNT_MEDIUM, 5, ALWAYS.andThen(values -> values.set(GROUND, Ground.ON_GROUND).set(SNEAK, Sneak.SNEAKING)),
() -> new SimpleParticle(Particle.GLOW_SQUID_INK, 0.4F, 0.9F, 0.4F, 0.01));
public final ParticleDesign EGG_HUNT_HARD = new FixedDesign("egg_hunt_hard", Material.RED_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HARD",
ParticleRequirement.EGG_HUNT_HARD, 2, ALWAYS,
@@ -133,7 +133,7 @@ public class RewardDesigns {
), 0, -0.2, 0));
// Hearts above the head while sneaking on the ground, a heart cloud ring while in the air
public final ParticleDesign EGG_HUNT_HALF = new FixedDesign("egg_hunt_half", Material.EGG, "PARTICLE_EGG_HUNT_HALF",
ParticleRequirement.EGG_HUNT_FOUND_HALF, 1, ALWAYS,
ParticleRequirement.EGG_HUNT_FOUND_HALF, 5, ALWAYS,
() -> new Group(
new Sneaking(new Floor(new LocationMutator(new SimpleParticle(Particle.HEART, 0, 0, 0, 0.01), 0, 1.7, 0))),
new NonFloor(new NonFlying(new LocationMutator(new Cloud(new Circle(new SimpleParticle(Particle.HEART, 0, 0, 0, 0.01))), 0, 0.5, 0)))
@@ -36,9 +36,9 @@ public class ParticleSlots {
public final int MAX_ENTRIES = 10;
private final String KEY_PREFIX = "lobby-particle-slot-";
// Particle positions per tick a slot may spawn
// Particles per tick a slot may spawn. A default entry costs 5; the largest preset costs 38.
public double maxCost(SteamwarUser user) {
return user.hasPerm(UserPerm.TEAM) ? 80 : 40;
return user.hasPerm(UserPerm.TEAM) ? 60 : 30;
}
// Slots 1-3 for everyone, 4-5 for team members, 6-7 for the server team