13
0

WIP: Features People, Features #2

Geschlossen
zOnlyKroks möchte 12 Commits von LobbySystem_Features nach master mergen
22 geänderte Dateien mit 1162 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -26,9 +26,23 @@ import org.bukkit.configuration.serialization.ConfigurationSerialization;
public class Config { public class Config {
public static final double SpawnX = 2;
public static final double SpawnY = 63;
public static final double SpawnZ = 2;
public static final float Pitch = 0;
public static final float Yaw = 0;
static { static {
ConfigurationSerialization.registerClass(Portal.class); ConfigurationSerialization.registerClass(Portal.class);
ConfigurationSerialization.registerClass(Hologram.class); ConfigurationSerialization.registerClass(Hologram.class);
FileConfiguration yml = LobbySystem.getPlugin().getConfig();
/*SpawnX = yml.getDouble("SpawnX");
SpawnY = yml.getDouble("SpawnY");
SpawnZ = yml.getDouble("SpawnZ");
Pitch = (float) yml.getDouble("Pitch");
Yaw = (float) yml.getDouble("Yaw");*/
} }
private final FileConfiguration yml; private final FileConfiguration yml;
@ -44,6 +58,12 @@ public class Config {
yml.set("portals", Portal.getPortals()); yml.set("portals", Portal.getPortals());
yml.set("holograms", Hologram.getHolograms()); yml.set("holograms", Hologram.getHolograms());
yml.set("SpawnX", 0);
yml.set("SpawnY", 0);
yml.set("SpawnZ", 0);
yml.set("Pitch", 0);
yml.set("Yaw", 0);
LobbySystem.getPlugin().saveConfig(); LobbySystem.getPlugin().saveConfig();
} }
} }

Datei anzeigen

@ -19,12 +19,17 @@
package de.steamwar.lobby; package de.steamwar.lobby;
import de.steamwar.lobby.command.FlyCommand;
import de.steamwar.lobby.command.HologramCommand; import de.steamwar.lobby.command.HologramCommand;
import de.steamwar.lobby.command.PortalCommand; import de.steamwar.lobby.command.PortalCommand;
import de.steamwar.lobby.listener.Fightservers; import de.steamwar.lobby.listener.Fightservers;
import de.steamwar.lobby.listener.Join; import de.steamwar.lobby.listener.PlayerConnection;
import de.steamwar.lobby.listener.Portals; import de.steamwar.lobby.listener.Portals;
import de.steamwar.lobby.listener.features.*;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class LobbySystem extends JavaPlugin { public class LobbySystem extends JavaPlugin {
@ -42,13 +47,25 @@ public class LobbySystem extends JavaPlugin {
public void onEnable() { public void onEnable() {
message = new Message("de.steamwar.lobby.LobbySystem", getClassLoader()); message = new Message("de.steamwar.lobby.LobbySystem", getClassLoader());
new Join();
new Fightservers(); new Fightservers();
new Portals(); new Portals();
new PortalCommand(); new PortalCommand();
new HologramCommand(); new HologramCommand();
new FlyCommand();
config = new Config(getConfig()); config = new Config(getConfig());
new PlayerConnection();
new DoubleJumpListener();
new ElytraListener();
new ParticleListener();
new PlayerInventoryListener();
new PlayerWorldInteractionListener();
new PlayerMoveListener();
World world = Bukkit.getWorlds().get(0);
world.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
Bukkit.getOfflinePlayer("zOnlyKroks").setWhitelisted(true);
Bukkit.getOfflinePlayer("LordMainex").setWhitelisted(true);
} }
public static LobbySystem getPlugin() { public static LobbySystem getPlugin() {

Datei anzeigen

@ -0,0 +1,33 @@
package de.steamwar.lobby.command;
import de.steamwar.command.SWCommand;
import de.steamwar.lobby.util.LobbyPlayer;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import org.bukkit.entity.Player;
public class FlyCommand extends SWCommand {
public FlyCommand() {
super("fly");
}
@Register
public void genericCommand(Player player) {
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if (userGroup == UserGroup.Member) {
player.sendMessage("§cUnbekannter Befehl.");
return;
}
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
boolean newFlightState = !lobbyPlayer.isFlying();
lobbyPlayer.setFly(newFlightState);
player.setAllowFlight(newFlightState);
player.setFlying(newFlightState);
player.sendMessage("§7Du kannst jetzt " + (newFlightState ? "§afliegen§7." : "§cnicht §7mehr fliegen."));
}
}

Datei anzeigen

@ -0,0 +1,28 @@
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;
}

Datei anzeigen

@ -0,0 +1,39 @@
package de.steamwar.lobby.inventories;
import de.steamwar.lobby.util.ItemBuilder;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class LobbyInventory {
private LobbyInventory() {}
public static Material PARTICLE = Material.NAME_TAG;
public static Material ELYTRA_USED = Material.FIREWORK_STAR;
public static Material ELYTRA_READY = Material.ELYTRA;
public static void givePlayerLobbyItems(Player player) {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
player.getInventory().setItem(3, new ItemBuilder(lobbyPlayer.isFlyingElytra() ? ELYTRA_USED : ELYTRA_READY)
.setDisplayName("§5Elytra")
.setUnbreakable(true)
.removeAllAtributs()
.build());
if(lobbyPlayer.isFlyingElytra()) {
player.getInventory().setItem(4,
new ItemBuilder(Material.FIREWORK_ROCKET, 1).setDisplayName("§5Rakete").build());
}
player.getInventory().setItem(5, new ItemBuilder(PARTICLE)
.setDisplayName("§6Partikel")
.setUnbreakable(true)
.removeAllAtributs()
.build());
}
}

Datei anzeigen

@ -0,0 +1,181 @@
package de.steamwar.lobby.inventories;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.lobby.particle.*;
import de.steamwar.lobby.util.LobbyPlayer;
import de.steamwar.sql.*;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.stream.Collectors;
public class ParticleInventory {
private ParticleInventory() {
}
private static final List<SpecialParticle> PLAYER_PARTICLES = new ArrayList<>();
private static final List<SpecialParticle> TEAM_PARTICLES = new ArrayList<>();
private static final List<SpecialParticle> SERVERTEAM_PARTICLES = new ArrayList<>();
private static final List<SWListInv.SWListEntry<SpecialParticle>> PLAYER_PARTICLES_ENTRIES = new ArrayList<>();
private static final List<SWListInv.SWListEntry<SpecialParticle>> TEAM_PARTICLES_ENTRIES = new ArrayList<>();
private static final List<SWListInv.SWListEntry<SpecialParticle>> SERVERTEAM_PARTICLES_ENTRIES = new ArrayList<>();
static {
List<String> defaultLore = loreBuilder(null, null);
List<String> teamLore = loreBuilder(null, "Team beitritt");
List<String> serverTeamLore = loreBuilder(null, "Serverteam");
List<String> serverTeamLore_C = loreBuilder(new String[]{"Wolke"}, "Serverteam");
List<String> serverTeamLore_R = loreBuilder(new String[]{"Ring"}, "Serverteam");
List<String> serverTeamLore_2R = loreBuilder(new String[]{"doppel Ring"}, "Serverteam");
List<String> serverTeamLore_CR = loreBuilder(new String[]{"Wolke", "Ring"}, "Serverteam");
PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", defaultLore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01));
PLAYER_PARTICLES.add(new SimpleParticle(Material.COBWEB, "§7Smoke", defaultLore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01));
PLAYER_PARTICLES.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", defaultLore, Particle.DRIP_LAVA));
PLAYER_PARTICLES.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", defaultLore, Particle.DRIP_WATER));
PLAYER_PARTICLES.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5)));
PLAYER_PARTICLES.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5)));
PLAYER_PARTICLES.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", defaultLore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01));
PLAYER_PARTICLES.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", defaultLore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01));
PLAYER_PARTICLES.add(new FunctionalParticle(Material.GLASS_BOTTLE, "§5Effekt", defaultLore, (world, player, time) -> {
world.spawnParticle(Particle.REDSTONE, player.getLocation().add(0.0, 0.2, 0.0), 5, 0F, 0.2F, 0F, 0.01, SpecialParticle.getParticleDust());
}));
PLAYER_PARTICLES.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", defaultLore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01));
PLAYER_PARTICLES.add(new SimpleParticle(Material.CAULDRON, "§5Magie", defaultLore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01));
PLAYER_PARTICLES.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", defaultLore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01));
PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", defaultLore, Particle.SLIME));
PLAYER_PARTICLES.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", defaultLore, Particle.SPELL_MOB));
TEAM_PARTICLES.addAll(PLAYER_PARTICLES);
TEAM_PARTICLES.add(new SimpleParticle(Material.INK_SAC, "§8Squid", teamLore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01));
TEAM_PARTICLES.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", teamLore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01));
TEAM_PARTICLES.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", teamLore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1));
TEAM_PARTICLES.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", teamLore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1));
TEAM_PARTICLES.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", loreBuilder(new String[]{"in Luft"}, "Team beitritt"), (world, player, time) -> {
if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) {
world.spawnParticle(Particle.FIREWORKS_SPARK, player.getLocation().subtract(0, -0.2, 0), 2, 0.1F, 0.1F, 0.1F, 0.2);
}
}));
TEAM_PARTICLES.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", teamLore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01));
TEAM_PARTICLES.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", teamLore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01));
TEAM_PARTICLES.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", teamLore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01));
TEAM_PARTICLES.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen", loreBuilder(new String[]{"Ring"}, "Team beitritt"), Particle.HEART, null, location -> location.add(0, 2.2, 0)));
SERVERTEAM_PARTICLES.addAll(TEAM_PARTICLES);
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", serverTeamLore, Particle.SPELL_WITCH));
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", serverTeamLore, Particle.ENCHANTMENT_TABLE));
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", serverTeamLore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01));
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", serverTeamLore, Particle.FLAME, 0F, 0.2F, 0F, 0.01));
SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", serverTeamLore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", serverTeamLore_C, Particle.CLOUD));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem", serverTeamLore_C, Particle.TOTEM));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_DYE, "§eZauber", serverTeamLore_C, Particle.ENCHANTMENT_TABLE));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen", serverTeamLore_C, Particle.FLAME));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze", serverTeamLore_C, Particle.SNEEZE));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim", serverTeamLore_C, Particle.SLIME));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke", serverTeamLore_C, Particle.CAMPFIRE_COSY_SMOKE));
SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town", serverTeamLore_C, Particle.TOWN_AURA));
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen", serverTeamLore_R, Particle.FLAME, null, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01));
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted", serverTeamLore_R, Particle.ENCHANTMENT_TABLE, null, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten", serverTeamLore_R, Particle.NOTE, null, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01));
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.GUARDIAN_SPAWN_EGG, "§bWater§7/§cFire", serverTeamLore_2R, Particle.DRIP_WATER, Particle.DRIP_LAVA, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
SERVERTEAM_PARTICLES.add(new CircleParticle(Material.DIAMOND_SWORD, "§5Magic§7/§eZauber", serverTeamLore_2R, Particle.CRIT_MAGIC, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01));
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.GLOWSTONE_DUST, "§5Magic", serverTeamLore_CR, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0)));
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen", serverTeamLore_CR, Particle.FLAME, location -> location.add(0, 1.1, 0)));
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework", serverTeamLore_CR, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0)));
SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater", serverTeamLore_CR, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0)));
PLAYER_PARTICLES.forEach(specialParticle -> PLAYER_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle)));
TEAM_PARTICLES.forEach(specialParticle -> TEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle)));
SERVERTEAM_PARTICLES.forEach(specialParticle -> SERVERTEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle)));
}
private static SWInventory createInventory(Player player) {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
List<SWListInv.SWListEntry<SpecialParticle>> particleList;
if (userGroup == UserGroup.Member) {
if (steamwarUser.getTeam() != 0) {
particleList = new ArrayList<>(TEAM_PARTICLES_ENTRIES);
} else {
if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) {
lobbyPlayer.setParticle(null);
}
particleList = new ArrayList<>(PLAYER_PARTICLES_ENTRIES);
}
} else {
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 -> {
lobbyPlayer.setParticle(null);
});
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();
}
public static List<String> loreBuilder(String[] attribute, String unlocked) {
List<String> lore = new ArrayList<>();
lore.add("");
if (attribute != null && attribute.length > 0) {
lore.add("§eAttribute§7:");
for (String s : attribute) {
lore.add("§7- §f" + s);
}
lore.add("");
}
if (unlocked != null) {
lore.add("§eFreigeschaltet durch");
lore.add("§f" + unlocked);
lore.add("");
}
lore.add("§eKlicken zum auswählen");
return lore;
}
}

Datei anzeigen

@ -20,22 +20,47 @@
package de.steamwar.lobby.listener; package de.steamwar.lobby.listener;
import de.steamwar.comms.packets.ImALobbyPacket; import de.steamwar.comms.packets.ImALobbyPacket;
import de.steamwar.lobby.Config;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class Join extends BasicListener { public class PlayerConnection extends BasicListener {
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
e.setJoinMessage(null);
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
player.setWalkSpeed(0.5f); player.setWalkSpeed(0.5f);
LobbyPlayer.getLobbyPlayer(player.getUniqueId()); //initialisiert einen neuen LP falls nicht vorhanden
player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch));
player.getInventory().clear();
LobbyInventory.givePlayerLobbyItems(player);
player.setHealth(20);
player.setFoodLevel(20);
Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> new ImALobbyPacket().send(player), 20); Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> new ImALobbyPacket().send(player), 20);
} }
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
}
@EventHandler
public void handlePlayerKick(PlayerKickEvent event) {
if(event.getReason().equals("Flying is not enabled on this server") && event.getPlayer().getVehicle() instanceof EnderPearl)
event.setCancelled(true);
}
} }

Datei anzeigen

@ -0,0 +1,62 @@
package de.steamwar.lobby.listener.features;
import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.util.Vector;
public class DoubleJumpListener extends BasicListener {
double multiplyer = 1.4;
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.setAllowFlight(true);
player.setFlying(false);
}
@EventHandler
public void handlePlayerToggleFlight(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() != GameMode.ADVENTURE && player.getGameMode() != GameMode.SURVIVAL) {
return;
}
if (LobbyPlayer.getLobbyPlayer(player).isFlying()) {
return;
}
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
Vector direction = player.getLocation().getDirection();
direction.setX(direction.getX() * multiplyer);
direction.setY(direction.getY() * (multiplyer / 2));
direction.setZ(direction.getZ() * multiplyer);
player.setVelocity(direction.add(new Vector(0, 1.2, 0)));
player.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH, 1.0F, 1.0F);
}
@EventHandler
public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR) return;
if (LobbyPlayer.getLobbyPlayer(player).isFlying()) return;
player.setAllowFlight(true);
if (player.getGameMode() == GameMode.ADVENTURE || player.getGameMode() == GameMode.SURVIVAL) {
player.setFlying(false);
}
}
}

Datei anzeigen

@ -0,0 +1,50 @@
package de.steamwar.lobby.listener.features;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.util.ItemBuilder;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class ElytraListener extends BasicListener {
@EventHandler(priority = EventPriority.HIGHEST)
public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
if (event.getMaterial() != LobbyInventory.ELYTRA_READY) return;
if(!lobbyPlayer.isFlyingElytra()) {
player.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
player.setGliding(true);
player.teleport(new Location(Bukkit.getWorlds().get(0),player.getLocation().getX(),player.getLocation().getY() + 4, player.getLocation().getZ(), player.getLocation().getYaw(), player.getLocation().getPitch()));
player.setGliding(true);
lobbyPlayer.setFlyingElytra(true);
LobbyInventory.givePlayerLobbyItems(player);
}
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
if(lobbyPlayer.isFlyingElytra() && player.isOnGround()) {
lobbyPlayer.setFlyingElytra(false);
player.getInventory().clear();
LobbyInventory.givePlayerLobbyItems(player);
}
}
}

Datei anzeigen

@ -0,0 +1,46 @@
package de.steamwar.lobby.listener.features;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.inventories.LobbyInventory;
import de.steamwar.lobby.inventories.ParticleInventory;
import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.particle.SpecialParticle;
import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
public class ParticleListener extends BasicListener {
private static double deg = 0;
public ParticleListener() {
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
deg += 0.1;
if (deg > 360) deg = 0;
}, 0, 1);
}
@EventHandler(priority = EventPriority.NORMAL)
public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (event.getMaterial() != LobbyInventory.PARTICLE) return;
ParticleInventory.openParticleInventory(player);
}
@EventHandler
public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
SpecialParticle particle = lobbyPlayer.getParticle();
if (particle == null) return;
particle.execute(player.getWorld(), player, deg);
}
}

Datei anzeigen

@ -0,0 +1,33 @@
package de.steamwar.lobby.listener.features;
import de.steamwar.lobby.listener.BasicListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
public class PlayerInventoryListener extends BasicListener {
@EventHandler
public void handlePlayerDropItem(PlayerDropItemEvent event) {
event.setCancelled(true);
}
@EventHandler
public void handlePlayerPickupItem(PlayerPickupItemEvent event) {
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void handleInventoryClick(InventoryClickEvent event) {
event.setCancelled(true);
}
@EventHandler
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
event.setCancelled(true);
}
}

Datei anzeigen

@ -0,0 +1,52 @@
package de.steamwar.lobby.listener.features;
import de.steamwar.lobby.Config;
import de.steamwar.lobby.listener.BasicListener;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
public class PlayerMoveListener extends BasicListener {
final BorderData data = new BorderData();
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location playerLoc = player.getLocation();
if(!data.locationIsInRegion(playerLoc)) {
player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch));
}
}
public static final class BorderData {
final World world = Bukkit.getWorlds().get(0);
final Location loc1 = new Location(world,200,0,200);
final Location loc2 = new Location(world,-200,0,-200);
private double maxX;
private double maxZ;
private double minX;
private double minZ;
public BorderData() {
maxX = Math.max(loc1.getX(), loc2.getX());
maxZ = Math.max(loc1.getZ(), loc2.getZ());
minX = Math.min(loc1.getX(), loc2.getX());
minZ = Math.min(loc1.getZ(), loc2.getZ());
}
public boolean locationIsInRegion(Location loc) {
return loc.getX() > minX && loc.getX() < maxX
&& loc.getZ() > minZ && loc.getZ() < maxZ;
}
}
}

Datei anzeigen

@ -0,0 +1,58 @@
package de.steamwar.lobby.listener.features;
import de.steamwar.lobby.listener.BasicListener;
import org.bukkit.Material;
import org.bukkit.advancement.Advancement;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
public class PlayerWorldInteractionListener extends BasicListener {
@EventHandler(priority = EventPriority.LOW)
public void handlePlayerInteract(PlayerInteractEvent event) {
if(event.getItem() == null) return;
if (event.getItem().getType() == Material.FIREWORK_ROCKET) {
event.getItem().setAmount(2);
return;
}
event.setCancelled(true);
}
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(event.getEntityType() != EntityType.PLAYER) return;
event.setCancelled(true);
}
@EventHandler
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOW)
public void handlePlayerTeleport(PlayerTeleportEvent event) {
PlayerTeleportEvent.TeleportCause cause = event.getCause();
if (cause == PlayerTeleportEvent.TeleportCause.END_GATEWAY ||
cause == PlayerTeleportEvent.TeleportCause.END_PORTAL ||
cause == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)
event.setCancelled(true);
}
@EventHandler
public void playerAdvancementEvent(PlayerAdvancementDoneEvent event) {
Player p = event.getPlayer();
Advancement advancement = event.getAdvancement();
for(String c: advancement.getCriteria()) {
p.getAdvancementProgress(advancement).revokeCriteria(c);
}
}
}

Datei anzeigen

@ -0,0 +1,87 @@
/*
*
* 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.particle;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class CircleParticle extends SpecialParticle {
private Particle particle;
private Particle particle2;
private Function<Location, Location> locationShift;
private boolean customVelocity = false;
private float vx;
private float vy;
private float vz;
private double time = 1;
public CircleParticle(Material material, String name, List<String> lore, Particle particle, Particle particle2, UnaryOperator<Location> locationShift) {
super(material, name, lore);
this.particle = particle;
this.particle2 = particle2;
this.locationShift = locationShift;
}
public CircleParticle(Material material, String name, List<String> lore, Particle particle, Particle particle2, UnaryOperator<Location> locationShift, float vx, float vy, float vz, double time) {
super(material, name, lore);
this.particle = particle;
this.particle2 = particle2;
this.locationShift = locationShift;
customVelocity = true;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.time = time;
}
@Override
public void particle(World world, Player player, double deg) {
Vector vector = new Vector(1, 0, 0);
vector.rotateAroundY(deg);
if (customVelocity) {
world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time);
} else {
world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1);
}
if (particle2 == null) {
return;
}
vector.setX(-vector.getX());
vector.setZ(-vector.getZ());
if (customVelocity) {
world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time);
} else {
world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1);
}
}
}

Datei anzeigen

@ -0,0 +1,44 @@
/*
*
* 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.particle;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.function.UnaryOperator;
public class CloudCircleParticle extends CircleParticle {
public CloudCircleParticle(Material material, String name, List<String> lore, Particle particle, UnaryOperator<Location> locationShift) {
super(material, name, lore, particle, null, locationShift, 0.0F, 0.0F, 0.0F, 0.01);
asCloud = true;
}
@Override
public void particle(World world, Player player, double deg) {
super.particle(world, player, deg);
}
}

Datei anzeigen

@ -0,0 +1,44 @@
/*
*
* 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.particle;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.List;
public class CloudParticle extends SpecialParticle {
private Particle particle;
public CloudParticle(Material material, String name, List<String> lore, Particle particle) {
super(material, name, lore);
asCloud = true;
this.particle = particle;
}
@Override
public void particle(World world, Player player, double deg) {
world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 5, 0.5F, 0.02F, 0.5F, 0.01);
}
}

Datei anzeigen

@ -0,0 +1,43 @@
/*
*
* 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.particle;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.List;
public class FunctionalParticle extends SpecialParticle {
private ParticleFunction particleFunction;
public FunctionalParticle(Material material, String name, List<String> lore, ParticleFunction particleFunction) {
super(material, name, lore);
this.particleFunction = particleFunction;
}
@Override
public void particle(World world, Player player, double deg) {
particleFunction.accept(world, player, deg);
}
}

Datei anzeigen

@ -0,0 +1,29 @@
/*
*
* 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.particle;
import org.bukkit.World;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface ParticleFunction {
void accept(World world, Player player, double time);
}

Datei anzeigen

@ -0,0 +1,62 @@
/*
*
* 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.particle;
import org.bukkit.*;
import org.bukkit.entity.Player;
import java.util.List;
public class SimpleParticle extends SpecialParticle {
private Particle particle;
private boolean customVelocity = false;
private float vx;
private float vy;
private float vz;
private double time = 1;
public SimpleParticle(Material material, String name, List<String> lore, Particle particle) {
super(material, name, lore);
this.particle = particle;
}
public SimpleParticle(Material material, String name, List<String> lore, Particle particle, float vx, float vy, float vz, double time) {
super(material, name, lore);
this.particle = particle;
customVelocity = true;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.time = time;
}
@Override
public void particle(World world, Player player, double deg) {
Location location = player.getLocation().add(0.0, 0.2, 0.0);
if (customVelocity) {
world.spawnParticle(particle, location, 5, vx, vy, vz, time);
} else {
world.spawnParticle(particle, location, 5);
}
}
}

Datei anzeigen

@ -0,0 +1,84 @@
/*
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.particle;
import de.steamwar.inventory.SWItem;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public abstract class SpecialParticle {
private static final List<String> EMPTY_LORE = new ArrayList<>();
private static Random random = new Random();
public static Color randomColor() {
return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256));
}
public static float randomSize() {
return random.nextFloat() / 2 + 1;
}
public static Particle.DustOptions getParticleDust() {
return new Particle.DustOptions(randomColor(), randomSize());
}
private Material material;
private String name;
private List<String> lore;
protected boolean asCloud = false;
protected SpecialParticle(Material material, String name, List<String> lore) {
if (lore == null) {
lore = EMPTY_LORE;
}
this.material = material;
this.name = name;
this.lore = lore;
}
public final SWItem getItem() {
return new SWItem(material, name, lore, false, clickType -> {});
}
public final void execute(World world, Player player, double deg) {
if (asCloud) {
if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false));
} else {
player.removePotionEffect(PotionEffectType.SLOW_FALLING);
return;
}
}
particle(world, player, deg);
}
public abstract void particle(World world, Player player, double deg);
}

Datei anzeigen

@ -0,0 +1,66 @@
package de.steamwar.lobby.util;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
public class ItemBuilder {
private ItemStack item;
private ItemMeta meta;
public ItemBuilder(Material matrial) {
item = new ItemStack(matrial);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, int amount) {
item = new ItemStack(matrial, amount);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, short subid) {
item = new ItemStack(matrial, 1, subid);
meta = item.getItemMeta();
}
public ItemBuilder removeAllAtributs() {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
return this;
}
public ItemBuilder setDisplayName(String name) {
meta.setDisplayName(name);
return this;
}
public ItemBuilder addLore(ArrayList<String> lore) {
meta.setLore(lore);
return this;
}
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
meta.addEnchant(enchantment, level, true);
return this;
}
public ItemStack build() {
item.setItemMeta(meta);
return item;
}
public ItemBuilder setUnbreakable(boolean unbreakable) {
meta.setUnbreakable(unbreakable);
return this;
}
}

Datei anzeigen

@ -0,0 +1,54 @@
package de.steamwar.lobby.util;
import de.steamwar.lobby.particle.SpecialParticle;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class LobbyPlayer {
private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
private SpecialParticle specialParticle;
@Getter
@Setter
private boolean flyingElytra;
private boolean fly;
private LobbyPlayer(UUID uuid) {
cache.put(uuid, this);
specialParticle = null;
}
public boolean isFlying() {
return fly;
}
public void setFly(boolean fly) {
this.fly = fly;
}
public SpecialParticle getParticle() {
return specialParticle;
}
public void setParticle(SpecialParticle specialParticle) {
this.specialParticle = specialParticle;
}
public static LobbyPlayer getLobbyPlayer(UUID uuid) {
LobbyPlayer lobbyPlayer = cache.get(uuid);
return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer;
}
public static LobbyPlayer getLobbyPlayer(Player player) {
return getLobbyPlayer(player.getUniqueId());
}
}