Dieser Commit ist enthalten in:
Ursprung
94c6fc934b
Commit
291b4b883a
@ -22,6 +22,7 @@ package de.steamwar.lobby.listener;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.particle.BaseParticle;
|
||||
import de.steamwar.lobby.particle.ParticleData;
|
||||
import de.steamwar.lobby.particle.ParticleEnum;
|
||||
import de.steamwar.lobby.particle.ParticleInventory;
|
||||
import de.steamwar.lobby.util.LobbyPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -41,10 +42,11 @@ public class ParticleListener extends BasicListener {
|
||||
if (deg > 360) deg = 0;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
BaseParticle particle = lobbyPlayer.getParticle();
|
||||
ParticleEnum particle = lobbyPlayer.getParticle();
|
||||
if (particle == null) return;
|
||||
if (particle.needsTick()) {
|
||||
particle.particle(new ParticleData(player.getWorld(), player, deg));
|
||||
BaseParticle baseParticle = particle.getParticle();
|
||||
if (baseParticle.needsTick()) {
|
||||
baseParticle.particle(new ParticleData(player.getWorld(), player, deg));
|
||||
}
|
||||
});
|
||||
}, 0, 1);
|
||||
@ -62,9 +64,10 @@ public class ParticleListener extends BasicListener {
|
||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
BaseParticle particle = lobbyPlayer.getParticle();
|
||||
|
||||
ParticleEnum particle = lobbyPlayer.getParticle();
|
||||
if (particle == null) return;
|
||||
particle.particle(new ParticleData(player.getWorld(), player, deg));
|
||||
|
||||
BaseParticle baseParticle = particle.getParticle();
|
||||
baseParticle.particle(new ParticleData(player.getWorld(), player, deg));
|
||||
}
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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 de.steamwar.lobby.particle.decorator.CircleParticle;
|
||||
import de.steamwar.lobby.particle.decorator.CloudParticle;
|
||||
import de.steamwar.lobby.particle.mutator.LocationParticleMutator;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
public enum EventParticle {
|
||||
|
||||
WarGearSeason(22, new int[]{12, 285, 54},
|
||||
new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), Particle.ENCHANTMENT_TABLE), location -> location.add(0, 1.1, 0)))),
|
||||
new SimpleParticle(new ParticleItem(BOOK, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS"), Particle.ENCHANTMENT_TABLE)
|
||||
),
|
||||
AirshipEvent(26, new int[]{205, 9, 54, 120, 292},
|
||||
new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), Particle.CLOUD), location -> location.add(0, 2.2, 0))),
|
||||
new SimpleParticle(new ParticleItem(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT"), Particle.CLOUD)
|
||||
),
|
||||
HellsBellsWs(28, new int[]{205, 9, 11},
|
||||
new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), Particle.CAMPFIRE_COSY_SMOKE), location -> location.add(0, 2.2, 0)))),
|
||||
new CircleParticle(new SimpleParticle(new ParticleItem(TNT, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS"), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))
|
||||
),
|
||||
Underwater(31, new int[]{9, 210, 520},
|
||||
new CloudParticle(new SimpleParticle(new ParticleItem(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT"), Particle.DRIP_WATER)),
|
||||
new SimpleParticle(new ParticleItem(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER"), Particle.DRIP_WATER)
|
||||
),
|
||||
;
|
||||
|
||||
public static EventParticle[] eventParticles = values();
|
||||
|
||||
EventParticle(int event, int[] placementTeams, BaseParticle placementParticle, BaseParticle participationParticles) {
|
||||
this.event = event;
|
||||
this.placementTeams = placementTeams;
|
||||
this.placementParticle = placementParticle;
|
||||
this.participationParticles = participationParticles;
|
||||
}
|
||||
|
||||
public final int event;
|
||||
public final int[] placementTeams;
|
||||
public final BaseParticle placementParticle;
|
||||
public final BaseParticle participationParticles;
|
||||
}
|
42
src/de/steamwar/lobby/particle/EventParticleParticipation.java
Normale Datei
42
src/de/steamwar/lobby/particle/EventParticleParticipation.java
Normale Datei
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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 de.steamwar.lobby.particle.decorator.CircleParticle;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EventParticleParticipation implements ParticleEnum {
|
||||
|
||||
WarGearSeason(22, new SimpleParticle(new ParticleItem(BOOK, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS"), Particle.ENCHANTMENT_TABLE)),
|
||||
AirshipEvent(26, new SimpleParticle(new ParticleItem(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT"), Particle.CLOUD)),
|
||||
HellsBellsWs(28, new CircleParticle(new SimpleParticle(new ParticleItem(TNT, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS"), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))),
|
||||
Underwater(31, new SimpleParticle(new ParticleItem(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER"), Particle.DRIP_WATER)),
|
||||
;
|
||||
public static EventParticleParticipation[] particles = values();
|
||||
|
||||
private int event;
|
||||
private BaseParticle particle;
|
||||
}
|
45
src/de/steamwar/lobby/particle/EventParticlePlacement.java
Normale Datei
45
src/de/steamwar/lobby/particle/EventParticlePlacement.java
Normale Datei
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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 de.steamwar.lobby.particle.decorator.CircleParticle;
|
||||
import de.steamwar.lobby.particle.decorator.CloudParticle;
|
||||
import de.steamwar.lobby.particle.mutator.LocationParticleMutator;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EventParticlePlacement implements ParticleEnum {
|
||||
|
||||
WarGearSeason(22, new int[]{12, 285, 54}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), Particle.ENCHANTMENT_TABLE), location -> location.add(0, 1.1, 0))))),
|
||||
AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), Particle.CLOUD), location -> location.add(0, 2.2, 0)))),
|
||||
HellsBellsWs(28, new int[]{205, 9, 11}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), Particle.CAMPFIRE_COSY_SMOKE), location -> location.add(0, 2.2, 0))))),
|
||||
Underwater(31, new int[]{9, 210, 520}, new CloudParticle(new SimpleParticle(new ParticleItem(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT"), Particle.DRIP_WATER))),
|
||||
;
|
||||
public static EventParticlePlacement[] particles = values();
|
||||
|
||||
private int event;
|
||||
private int[] placementTeams;
|
||||
private BaseParticle particle;
|
||||
}
|
@ -30,6 +30,7 @@ import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import sun.util.resources.ext.CalendarData_da;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -42,9 +43,9 @@ public class ParticleInventory {
|
||||
private ParticleInventory() {
|
||||
}
|
||||
|
||||
private static void calculateParticles(ParticleEnum[] particles, Player player, List<SWListInv.SWListEntry<BaseParticle>> particleList) {
|
||||
private static void calculateParticles(ParticleEnum[] particles, Player player, List<SWListInv.SWListEntry<ParticleEnum>> particleList) {
|
||||
for (ParticleEnum particle : particles) {
|
||||
particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle.getParticle()));
|
||||
particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle));
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +54,7 @@ public class ParticleInventory {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
List<SWListInv.SWListEntry<BaseParticle>> particleList = new ArrayList<>();
|
||||
List<SWListInv.SWListEntry<ParticleEnum>> particleList = new ArrayList<>();
|
||||
calculateParticles(PlayerParticle.particles, player, particleList);
|
||||
if (steamwarUser.getTeam() != 0 || userGroup != UserGroup.Member) {
|
||||
calculateParticles(TeamParticle.particles, player, particleList);
|
||||
@ -63,27 +64,18 @@ public class ParticleInventory {
|
||||
}
|
||||
|
||||
Set<Integer> events = steamwarUser.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(steamwarUser.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet());
|
||||
for (EventParticle eventParticle : EventParticle.eventParticles) {
|
||||
boolean clickablePlacement = userGroup.isTeamGroup();
|
||||
clickablePlacement |= (steamwarUser.getTeam() != 0 && contains(eventParticle.placementTeams, steamwarUser.getTeam()));
|
||||
if (clickablePlacement) {
|
||||
particleList.add(new SWListInv.SWListEntry<>(eventParticle.placementParticle.getItem().toSWItem(player), eventParticle.placementParticle));
|
||||
} else {
|
||||
SWItem swItem = eventParticle.placementParticle.getItem().toSWItem(player);
|
||||
swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName()));
|
||||
particleList.add(new SWListInv.SWListEntry<>(swItem, null));
|
||||
}
|
||||
|
||||
if (eventParticle.placementTeams.length != 0 && (userGroup.isTeamGroup() || events.contains(eventParticle.event))) {
|
||||
particleList.add(new SWListInv.SWListEntry<>(eventParticle.participationParticles.getItem().toSWItem(player), eventParticle.participationParticles));
|
||||
} else {
|
||||
SWItem swItem = eventParticle.participationParticles.getItem().toSWItem(player);
|
||||
swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName()));
|
||||
particleList.add(new SWListInv.SWListEntry<>(swItem, null));
|
||||
}
|
||||
for (EventParticlePlacement particle : EventParticlePlacement.particles) {
|
||||
boolean clickable = userGroup.isTeamGroup();
|
||||
clickable |= (steamwarUser.getTeam() != 0 && contains(particle.getPlacementTeams(), steamwarUser.getTeam()));
|
||||
addParticle(particleList, particle, clickable, player);
|
||||
}
|
||||
for (EventParticleParticipation particle : EventParticleParticipation.particles) {
|
||||
boolean clickable = userGroup.isTeamGroup();
|
||||
clickable |= events.contains(particle.getEvent());
|
||||
addParticle(particleList, particle, clickable, player);
|
||||
}
|
||||
|
||||
SWListInv<BaseParticle> particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> {
|
||||
SWListInv<ParticleEnum> particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> {
|
||||
if (particle == null) return;
|
||||
lobbyPlayer.setParticle(particle);
|
||||
player.closeInventory();
|
||||
@ -95,6 +87,16 @@ public class ParticleInventory {
|
||||
return particleSWListInv;
|
||||
}
|
||||
|
||||
private static void addParticle(List<SWListInv.SWListEntry<ParticleEnum>> particleList, ParticleEnum particle, boolean clickable, Player player) {
|
||||
if (clickable) {
|
||||
particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle));
|
||||
} else {
|
||||
SWItem swItem = particle.getParticle().getItem().toSWItem(player);
|
||||
swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName()));
|
||||
particleList.add(new SWListInv.SWListEntry<>(swItem, null));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean contains(int[] ints, int element) {
|
||||
for (int i : ints) {
|
||||
if (i == element) return true;
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.lobby.util;
|
||||
|
||||
import de.steamwar.lobby.particle.BaseParticle;
|
||||
import de.steamwar.lobby.particle.ParticleEnum;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -30,7 +31,7 @@ public class LobbyPlayer {
|
||||
|
||||
private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
|
||||
|
||||
private BaseParticle particle;
|
||||
private ParticleEnum particle;
|
||||
|
||||
private boolean fly;
|
||||
|
||||
@ -47,12 +48,12 @@ public class LobbyPlayer {
|
||||
this.fly = fly;
|
||||
}
|
||||
|
||||
public BaseParticle getParticle() {
|
||||
public ParticleEnum getParticle() {
|
||||
return particle;
|
||||
}
|
||||
|
||||
public void setParticle(BaseParticle specialParticle) {
|
||||
this.particle = specialParticle;
|
||||
public void setParticle(ParticleEnum particle) {
|
||||
this.particle = particle;
|
||||
}
|
||||
|
||||
public static LobbyPlayer getLobbyPlayer(UUID uuid) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren