Add EventParticle #29
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.*;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
|
||||||
|
public enum EventParticle {
|
||||||
|
|
||||||
|
WarGearSeason(22, new int[]{12, 285, 54}, new CloudCircleParticle(Material.ENCHANTING_TABLE, "§cVerzaubert", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "WarGearSeason Event 1., 2. oder 3. Platz"), Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0)), new SimpleParticle(Material.BOOK, "§5Verzaubert", ParticleInventory.loreBuilder(new String[0], "WarGearSeason Event"), Particle.ENCHANTMENT_TABLE)),
|
||||||
|
AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(Material.SNOWBALL, "§fCloud", ParticleInventory.loreBuilder(new String[]{"Ring"}, "AirshipEvent Event 1., 2. oder 3. Platz"), Particle.CLOUD, null, location -> location.add(0, 2.2, 0)), new SimpleParticle(Material.SNOW_BLOCK, "§fCloud", ParticleInventory.loreBuilder(new String[0], "AirshipEvent Event"), Particle.CLOUD)),
|
||||||
|
HellsBellsWs(28, new int[]{205, 9, 11}, new CloudCircleParticle(Material.TNT_MINECART, "§7Smoke", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "HellsBells Event 1., 2. oder 3. Platz"), Particle.CAMPFIRE_COSY_SMOKE, location -> location.add(0, 2.2, 0)), new CircleParticle(Material.TNT, "§8Smoke", ParticleInventory.loreBuilder(new String[]{"Ring"}, "HellsBells Event"), Particle.CAMPFIRE_COSY_SMOKE, null, location -> location, 0, 0, 0, 0.01)),
|
||||||
|
Underwater(31, new int[]{9, 210, 520}, 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(int event, int[] placementTeams, SpecialParticle placementParticle, SpecialParticle participationParticles) {
|
||||||
|
this.event = event;
|
||||||
|
this.placementTeams = placementTeams;
|
||||||
|
this.placementParticle = placementParticle;
|
||||||
|
this.participationParticles = participationParticles;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int event;
|
||||||
|
public final int[] placementTeams;
|
||||||
|
public final SpecialParticle placementParticle;
|
||||||
|
public final SpecialParticle participationParticles;
|
||||||
|
}
|
@ -20,17 +20,17 @@
|
|||||||
package de.steamwar.lobby.inventories;
|
package de.steamwar.lobby.inventories;
|
||||||
|
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.lobby.particle.*;
|
import de.steamwar.lobby.particle.*;
|
||||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.*;
|
||||||
import de.steamwar.sql.UserGroup;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ParticleInventory {
|
public class ParticleInventory {
|
||||||
|
|
||||||
@ -120,19 +120,45 @@ public class ParticleInventory {
|
|||||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||||
|
|
||||||
SWListInv<SpecialParticle> particleSWListInv;
|
List<SWListInv.SWListEntry<SpecialParticle>> particleList;
|
||||||
if (userGroup == UserGroup.Member) {
|
if (userGroup == UserGroup.Member) {
|
||||||
if (steamwarUser.getTeam() != 0) {
|
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 {
|
} else {
|
||||||
if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) {
|
if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) {
|
||||||
lobbyPlayer.setParticle(null);
|
lobbyPlayer.setParticle(null);
|
||||||
}
|
}
|
||||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, PLAYER_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
particleList = new ArrayList<>(PLAYER_PARTICLES_ENTRIES);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
particleSWListInv = new SWListInv<>(player, "§6Partikel", false, SERVERTEAM_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle));
|
particleList = new ArrayList<>(SERVERTEAM_PARTICLES_ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(), eventParticle.placementParticle));
|
||||||
|
} else {
|
||||||
|
SWItem swItem = eventParticle.placementParticle.getItem();
|
||||||
|
swItem.setName(swItem.getItemMeta().getDisplayName() + " §8- §c§lGesperrt");
|
||||||
|
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(), eventParticle.participationParticles));
|
||||||
|
} else {
|
||||||
|
SWItem swItem = eventParticle.participationParticles.getItem();
|
||||||
|
swItem.setName(swItem.getItemMeta().getDisplayName() + " §8- §c§lGesperrt");
|
||||||
|
particleList.add(new SWListInv.SWListEntry<>(swItem, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SWListInv<SpecialParticle> particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> {
|
||||||
|
if (particle == null) return;
|
||||||
|
lobbyPlayer.setParticle(particle);
|
||||||
|
});
|
||||||
particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> {
|
particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> {
|
||||||
lobbyPlayer.setParticle(null);
|
lobbyPlayer.setParticle(null);
|
||||||
});
|
});
|
||||||
@ -140,11 +166,18 @@ public class ParticleInventory {
|
|||||||
return particleSWListInv;
|
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) {
|
public static void openParticleInventory(Player player) {
|
||||||
createInventory(player).open();
|
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<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add("");
|
lore.add("");
|
||||||
if (attribute != null && attribute.length > 0) {
|
if (attribute != null && attribute.length > 0) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren