Add EventParticle
Dieser Commit ist enthalten in:
Ursprung
189de4161f
Commit
3eb9c2fa6c
49
src/de/steamwar/lobby/inventories/EventParticle.java
Normale Datei
49
src/de/steamwar/lobby/inventories/EventParticle.java
Normale Datei
@ -0,0 +1,49 @@
|
||||
/*
|
||||
*
|
||||
* 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.inventories;
|
||||
|
||||
|
||||
import de.steamwar.lobby.particle.CloudParticle;
|
||||
import de.steamwar.lobby.particle.SimpleParticle;
|
||||
import de.steamwar.lobby.particle.SpecialParticle;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public enum EventParticle {
|
||||
|
||||
Underwater("Underwater", new int[0], new CloudParticle(Material.PRISMARINE_CRYSTALS, "§bWasser", ParticleInventory.loreBuilder(new String[]{"Wolke"}, "Underwater Event 1., 2. oder 3. Platz"), Particle.DRIP_WATER), new SimpleParticle(Material.PRISMARINE_BRICKS, "§bWasser", ParticleInventory.loreBuilder(new String[0], "Underwater Event"), Particle.DRIP_WATER));
|
||||
|
||||
public static EventParticle[] eventParticles = values();
|
||||
|
||||
EventParticle(String event, int[] placementTeams, SpecialParticle placementParticle, SpecialParticle participationParticles) {
|
||||
this.event = event;
|
||||
this.placementTeams = placementTeams;
|
||||
this.placementParticle = placementParticle;
|
||||
this.participationParticles = participationParticles;
|
||||
|
||||
}
|
||||
|
||||
public final String event;
|
||||
public final int[] placementTeams;
|
||||
public final SpecialParticle placementParticle;
|
||||
public final SpecialParticle participationParticles;
|
||||
}
|
@ -23,13 +23,16 @@ import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.lobby.particle.*;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleInventory {
|
||||
@ -120,19 +123,35 @@ public class ParticleInventory {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
SWListInv<SpecialParticle> particleSWListInv;
|
||||
List<SWListInv.SWListEntry<SpecialParticle>> particleList;
|
||||
if (userGroup == UserGroup.Member) {
|
||||
if (steamwarUser.getTeam() != 0) {
|
||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, TEAM_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
||||
particleList = new ArrayList<>(TEAM_PARTICLES_ENTRIES);
|
||||
} else {
|
||||
if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) {
|
||||
lobbyPlayer.setParticle(null);
|
||||
}
|
||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, PLAYER_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
||||
particleList = new ArrayList<>(PLAYER_PARTICLES_ENTRIES);
|
||||
}
|
||||
} else {
|
||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, SERVERTEAM_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
||||
particleList = new ArrayList<>(SERVERTEAM_PARTICLES_ENTRIES);
|
||||
}
|
||||
|
||||
if (steamwarUser.getTeam() != 0 && !userGroup.isTeamGroup()) {
|
||||
for (EventParticle eventParticle : EventParticle.eventParticles) {
|
||||
if (contains(eventParticle.placementTeams, steamwarUser.getTeam())) {
|
||||
particleList.add(new SWListInv.SWListEntry<>(eventParticle.placementParticle.getItem(), eventParticle.placementParticle));
|
||||
}
|
||||
}
|
||||
// TODO: Team team = Team.get(steamwarUser.getTeam()); participation fehlt!, wofür 'TeamTeilnahme' im SpigotCore fehlt.
|
||||
} else if (userGroup.isTeamGroup()) {
|
||||
for (EventParticle eventParticle : EventParticle.eventParticles) {
|
||||
particleList.add(new SWListInv.SWListEntry<>(eventParticle.placementParticle.getItem(), eventParticle.placementParticle));
|
||||
particleList.add(new SWListInv.SWListEntry<>(eventParticle.participationParticles.getItem(), eventParticle.participationParticles));
|
||||
}
|
||||
}
|
||||
|
||||
SWListInv<SpecialParticle> particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
||||
particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> {
|
||||
lobbyPlayer.setParticle(null);
|
||||
});
|
||||
@ -140,11 +159,18 @@ public class ParticleInventory {
|
||||
return particleSWListInv;
|
||||
}
|
||||
|
||||
private static boolean contains(int[] ints, int element) {
|
||||
for (int i : ints) {
|
||||
if (i == element) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void openParticleInventory(Player player) {
|
||||
createInventory(player).open();
|
||||
}
|
||||
|
||||
private static List<String> loreBuilder(String[] attribute, String unlocked) {
|
||||
public static List<String> loreBuilder(String[] attribute, String unlocked) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
if (attribute != null && attribute.length > 0) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren