maps : observerEntityMap.rowMap().values()) {
- maps.remove(entityID);
- }
- }
-
- /**
- * Invoked when a player logs out.
- * @param player - the player that jused logged out.
- */
- protected void removePlayer(Player player) {
- // Cleanup
- observerEntityMap.rowMap().remove(player.getEntityId());
- }
-
- /**
- * Construct the Bukkit event listener.
- * @return Our listener.
- */
- private Listener constructBukkit() {
- return new Listener() {
- @EventHandler
- public void onEntityDeath(EntityDeathEvent e) {
- removeEntity(e.getEntity(), true);
- }
-
- @EventHandler
- public void onChunkUnload(ChunkUnloadEvent e) {
- for (Entity entity : e.getChunk().getEntities()) {
- removeEntity(entity, false);
- }
- }
-
- @EventHandler
- public void onPlayerQuit(PlayerQuitEvent e) {
- removePlayer(e.getPlayer());
- }
- };
- }
-
- /**
- * Construct the packet listener that will be used to intercept every entity-related packet.
- * @param plugin - the parent plugin.
- * @return The packet listener.
- */
- private PacketAdapter constructProtocol(Plugin plugin) {
- return new PacketAdapter(plugin, ENTITY_PACKETS) {
- @Override
- public void onPacketSending(PacketEvent event) {
- int entityID = event.getPacket().getIntegers().read(0);
-
- // See if this packet should be cancelled
- if (!isVisible(event.getPlayer(), entityID)) {
- event.setCancelled(true);
- }
- }
- };
- }
-
-// /**
-// * Toggle the visibility status of an entity for a player.
-// *
-// * If the entity is visible, it will be hidden. If it is hidden, it will become visible.
-// * @param observer - the player observer.
-// * @param entity - the entity to toggle.
-// * @return TRUE if the entity was visible before, FALSE otherwise.
-// */
-// public final boolean toggleEntity(Player observer, Entity entity) {
-// if (isVisible(observer, entity.getEntityId())) {
-// return hideEntity(observer, entity);
-// } else {
-// return !showEntity(observer, entity);
-// }
-// }
-
- /**
- * Allow the observer to see an entity that was previously hidden.
- * @param observer - the observer.
- * @param entity - the entity to show.
- * @return TRUE if the entity was hidden before, FALSE otherwise.
- */
- public final boolean showEntity(Player observer, Player entity) {
- observer.showPlayer(entity);
-
-// validate(observer, entity);
-// boolean hiddenBefore = !setVisibility(observer, entity.getEntityId(), true);
-//
-// // Resend packets
-// if (manager != null && hiddenBefore) {
-// manager.updateEntity(entity, Arrays.asList(observer));
-// }
-
- return true;
- }
-
- /**
- * Prevent the observer from seeing a given entity.
- * @param observer - the player observer.
- * @param entity - the entity to hide.
- * @return TRUE if the entity was previously visible, FALSE otherwise.
- */
- public final boolean hideEntity(Player observer, Player entity) {
- observer.hidePlayer(entity);
-
-// validate(observer, entity);
-// boolean visibleBefore = setVisibility(observer, entity.getEntityId(), false);
-//
-// if (visibleBefore) {
-// PacketContainer destroyEntity = new PacketContainer(ENTITY_DESTROY);
-// destroyEntity.getIntegerArrays().write(0, new int[] { entity.getEntityId() });
-//
-// // Make the entity disappear
-// try {
-// manager.sendServerPacket(observer, destroyEntity);
-// } catch (InvocationTargetException e) {
-// throw new RuntimeException("Cannot send server packet.", e);
-// }
-// }
-
- return true;
- }
-
- /**
- * Determine if the given entity has been hidden from an observer.
- *
- * Note that the entity may very well be occluded or out of range from the perspective
- * of the observer. This method simply checks if an entity has been completely hidden
- * for that observer.
- * @param observer - the observer.
- * @param entity - the entity that may be hidden.
- * @return TRUE if the player may see the entity, FALSE if the entity has been hidden.
- */
- public final boolean canSee(Player observer, Entity entity) {
- validate(observer, entity);
-
- return isVisible(observer, entity.getEntityId());
- }
-
- // For valdiating the input parameters
- private void validate(Player observer, Entity entity) {
- Preconditions.checkNotNull(observer, "observer cannot be NULL.");
- Preconditions.checkNotNull(entity, "entity cannot be NULL.");
- }
-
- /**
- * Retrieve the current visibility policy.
- * @return The current visibility policy.
- */
- public Policy getPolicy() {
- return policy;
- }
-
- public void close() {
- if (manager != null) {
- HandlerList.unregisterAll(bukkitListener);
- manager.removePacketListener(protocolListener);
- manager = null;
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/completion/AbstractDivisionPrizeHandler.java b/src/main/java/com/solexgames/practice/completion/AbstractDivisionPrizeHandler.java
deleted file mode 100644
index 52b43bc..0000000
--- a/src/main/java/com/solexgames/practice/completion/AbstractDivisionPrizeHandler.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.solexgames.practice.completion;
-
-import com.solexgames.practice.player.PlayerData;
-import org.bukkit.entity.Player;
-
-import java.util.function.BiConsumer;
-
-/**
- * @author GrowlyX
- * @since 8/12/2021
- */
-
-public abstract class AbstractDivisionPrizeHandler {
-
- public abstract BiConsumer getPrize();
-
-}
diff --git a/src/main/java/com/solexgames/practice/completion/impl/BronzeDivisionPrizeHandler.java b/src/main/java/com/solexgames/practice/completion/impl/BronzeDivisionPrizeHandler.java
deleted file mode 100644
index 9a6ea51..0000000
--- a/src/main/java/com/solexgames/practice/completion/impl/BronzeDivisionPrizeHandler.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.solexgames.practice.completion.impl;
-
-import com.solexgames.practice.completion.AbstractDivisionPrizeHandler;
-import com.solexgames.practice.player.PlayerData;
-import org.bukkit.entity.Player;
-
-import java.util.function.BiConsumer;
-
-/**
- * @author GrowlyX
- * @since 8/12/2021
- */
-
-public class BronzeDivisionPrizeHandler extends AbstractDivisionPrizeHandler {
-
- @Override
- public BiConsumer getPrize() {
- return (player, playerData) -> {
-
- };
- }
-}
diff --git a/src/main/java/com/solexgames/practice/completion/impl/DiamondDivisionPrizeHandler.java b/src/main/java/com/solexgames/practice/completion/impl/DiamondDivisionPrizeHandler.java
deleted file mode 100644
index 2c4fc52..0000000
--- a/src/main/java/com/solexgames/practice/completion/impl/DiamondDivisionPrizeHandler.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.solexgames.practice.completion.impl;
-
-import com.solexgames.practice.completion.AbstractDivisionPrizeHandler;
-import com.solexgames.practice.player.PlayerData;
-import org.bukkit.entity.Player;
-
-import java.util.function.BiConsumer;
-
-/**
- * @author GrowlyX
- * @since 8/12/2021
- */
-
-public class DiamondDivisionPrizeHandler extends AbstractDivisionPrizeHandler {
-
- @Override
- public BiConsumer getPrize() {
- return (player, playerData) -> {
-
- };
- }
-}
diff --git a/src/main/java/com/solexgames/practice/completion/impl/GoldDivisionPrizeHandler.java b/src/main/java/com/solexgames/practice/completion/impl/GoldDivisionPrizeHandler.java
deleted file mode 100644
index a41f0fd..0000000
--- a/src/main/java/com/solexgames/practice/completion/impl/GoldDivisionPrizeHandler.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.solexgames.practice.completion.impl;
-
-import com.solexgames.practice.completion.AbstractDivisionPrizeHandler;
-import com.solexgames.practice.player.PlayerData;
-import org.bukkit.entity.Player;
-
-import java.util.function.BiConsumer;
-
-/**
- * @author GrowlyX
- * @since 8/12/2021
- */
-
-public class GoldDivisionPrizeHandler extends AbstractDivisionPrizeHandler {
-
- @Override
- public BiConsumer getPrize() {
- return (player, playerData) -> {
-
- };
- }
-}
diff --git a/src/main/java/com/solexgames/practice/completion/impl/IronDivisionPrizeHandler.java b/src/main/java/com/solexgames/practice/completion/impl/IronDivisionPrizeHandler.java
deleted file mode 100644
index 0ad856c..0000000
--- a/src/main/java/com/solexgames/practice/completion/impl/IronDivisionPrizeHandler.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.solexgames.practice.completion.impl;
-
-import com.solexgames.practice.completion.AbstractDivisionPrizeHandler;
-import com.solexgames.practice.player.PlayerData;
-import org.bukkit.entity.Player;
-
-import java.util.function.BiConsumer;
-
-/**
- * @author GrowlyX
- * @since 8/12/2021
- */
-
-public class IronDivisionPrizeHandler extends AbstractDivisionPrizeHandler {
-
- @Override
- public BiConsumer getPrize() {
- return (player, playerData) -> {
-
- };
- }
-}
diff --git a/src/main/java/com/solexgames/practice/completion/impl/SilverDivisionPrizeHandler.java b/src/main/java/com/solexgames/practice/completion/impl/SilverDivisionPrizeHandler.java
deleted file mode 100644
index 7295198..0000000
--- a/src/main/java/com/solexgames/practice/completion/impl/SilverDivisionPrizeHandler.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.solexgames.practice.completion.impl;
-
-import com.solexgames.practice.completion.AbstractDivisionPrizeHandler;
-import com.solexgames.practice.player.PlayerData;
-import org.bukkit.entity.Player;
-
-import java.util.function.BiConsumer;
-
-/**
- * @author GrowlyX
- * @since 8/12/2021
- */
-
-public class SilverDivisionPrizeHandler extends AbstractDivisionPrizeHandler {
-
- @Override
- public BiConsumer getPrize() {
- return (player, playerData) -> {
-
- };
- }
-}
diff --git a/src/main/java/com/solexgames/practice/effects/DeathEffect.java b/src/main/java/com/solexgames/practice/effects/DeathEffect.java
deleted file mode 100644
index d13ea32..0000000
--- a/src/main/java/com/solexgames/practice/effects/DeathEffect.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.solexgames.practice.effects;
-
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-
-/**
- * @author GrowlyX
- * @since 5/23/2021
- */
-
-public interface DeathEffect {
-
- String getName();
-
- String getPermission();
-
- Material getIcon();
-
- void applyEffect(Player player, Player killer);
-
-}
diff --git a/src/main/java/com/solexgames/practice/effects/DeathEffects.java b/src/main/java/com/solexgames/practice/effects/DeathEffects.java
deleted file mode 100644
index aeb9f61..0000000
--- a/src/main/java/com/solexgames/practice/effects/DeathEffects.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.solexgames.practice.effects;
-
-import com.solexgames.practice.effects.impl.LightningDeathEffect;
-
-/**
- * @author GrowlyX
- * @since 7/7/2021
- */
-
-public class DeathEffects {
-
- public static final DeathEffect LIGHTNING = new LightningDeathEffect();
-
-}
diff --git a/src/main/java/com/solexgames/practice/effects/impl/BloodDeathEffect.java b/src/main/java/com/solexgames/practice/effects/impl/BloodDeathEffect.java
deleted file mode 100644
index 4f6b0fd..0000000
--- a/src/main/java/com/solexgames/practice/effects/impl/BloodDeathEffect.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.solexgames.practice.effects.impl;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.effects.DeathEffect;
-import lombok.RequiredArgsConstructor;
-import org.bukkit.Effect;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-
-import java.util.Arrays;
-
-/**
- * @author GrowlyX
- * @since 7/9/2021
- */
-
-public class BloodDeathEffect implements DeathEffect {
-
- @Override
- public String getName() {
- return "Blood";
- }
-
- @Override
- public String getPermission() {
- return "practice.effects.blood";
- }
-
- @Override
- public Material getIcon() {
- return Material.REDSTONE;
- }
-
- @Override
- public void applyEffect(Player player, Player killer) {
- new BloodEffectTask(player.getLocation()).runTaskTimer(Practice.getInstance(), 0L, 10L);
- }
-
- @RequiredArgsConstructor
- public static class BloodEffectTask extends BukkitRunnable {
-
- private final Location location;
-
- private int ticks = 0;
-
- @Override
- public void run() {
- this.ticks++;
-
- if (this.ticks >= 5) {
- this.cancel();
- return;
- }
-
- Arrays.asList(1.0D, 1.25D, 1.5D, 1.75D, 2.0D).forEach(aDouble -> {
- this.location.getWorld().playEffect(this.location.clone().add(0.0D, aDouble, 0.0D), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
- });
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/effects/impl/ExplosionDeathEffect.java b/src/main/java/com/solexgames/practice/effects/impl/ExplosionDeathEffect.java
deleted file mode 100644
index a10c5c2..0000000
--- a/src/main/java/com/solexgames/practice/effects/impl/ExplosionDeathEffect.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.solexgames.practice.effects.impl;
-
-import com.solexgames.practice.effects.DeathEffect;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
-import xyz.xenondevs.particle.ParticleEffect;
-
-/**
- * @author GrowlyX
- * @since 5/26/2021
- */
-
-public class ExplosionDeathEffect implements DeathEffect {
-
- @Override
- public String getName() {
- return "Explosion";
- }
-
- @Override
- public String getPermission() {
- return "practice.effects.explosion";
- }
-
- @Override
- public Material getIcon() {
- return Material.TNT;
- }
-
- @Override
- public void applyEffect(Player player, Player killer) {
- final Vector finalLoc = killer.getLocation().getDirection().multiply(2.5D).setY(1.1D);
- player.setVelocity(finalLoc);
-
- ParticleEffect.EXPLOSION_LARGE.display(player.getLocation());
- }
-}
diff --git a/src/main/java/com/solexgames/practice/effects/impl/LightningDeathEffect.java b/src/main/java/com/solexgames/practice/effects/impl/LightningDeathEffect.java
deleted file mode 100644
index 2b4989c..0000000
--- a/src/main/java/com/solexgames/practice/effects/impl/LightningDeathEffect.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.solexgames.practice.effects.impl;
-
-import com.solexgames.practice.effects.DeathEffect;
-import net.minecraft.server.v1_8_R3.EntityLightning;
-import net.minecraft.server.v1_8_R3.Packet;
-import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityWeather;
-import org.bukkit.Material;
-import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-/**
- * @author GrowlyX
- * @since 5/23/2021
- */
-
-public class LightningDeathEffect implements DeathEffect {
-
- @Override
- public String getName() {
- return "Lightning";
- }
-
- @Override
- public String getPermission() {
- return "practice.effects.lightning";
- }
-
- @Override
- public Material getIcon() {
- return Material.BLAZE_ROD;
- }
-
- @Override
- public void applyEffect(Player player, Player killer) {
- final Packet> packet = new PacketPlayOutSpawnEntityWeather(new EntityLightning(((CraftPlayer) player).getHandle().getWorld(), (player).getLocation().getX(), (player).getLocation().getY(), (player).getLocation().getZ(), false, false));
-
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- ((CraftPlayer) killer).getHandle().playerConnection.sendPacket(packet);
-
- player.setAllowFlight(true);
- player.setFlying(true);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/event/BaseEvent.java b/src/main/java/com/solexgames/practice/event/BaseEvent.java
deleted file mode 100644
index 75d20a8..0000000
--- a/src/main/java/com/solexgames/practice/event/BaseEvent.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.solexgames.practice.event;
-
-import org.bukkit.Bukkit;
-import org.bukkit.event.Cancellable;
-import org.bukkit.event.Event;
-import org.bukkit.event.HandlerList;
-
-public class BaseEvent extends Event {
-
- private static final HandlerList HANDLER_LIST = new HandlerList();
-
- @Override
- public HandlerList getHandlers() {
- return HANDLER_LIST;
- }
-
- public void call() {
- Bukkit.getServer().getPluginManager().callEvent(this);
-
- if (this instanceof Cancellable) {
- ((Cancellable) this).isCancelled();
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/event/match/MatchEndEvent.java b/src/main/java/com/solexgames/practice/event/match/MatchEndEvent.java
deleted file mode 100644
index 03d49e4..0000000
--- a/src/main/java/com/solexgames/practice/event/match/MatchEndEvent.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.solexgames.practice.event.match;
-
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.team.impl.MatchTeam;
-import lombok.Getter;
-
-@Getter
-public class MatchEndEvent extends MatchEvent {
-
- private final MatchTeam winningTeam;
- private final MatchTeam losingTeam;
-
- public MatchEndEvent(Match match, MatchTeam winningTeam, MatchTeam losingTeam) {
- super(match);
-
- this.winningTeam = winningTeam;
- this.losingTeam = losingTeam;
- }
-
-}
diff --git a/src/main/java/com/solexgames/practice/event/match/MatchEvent.java b/src/main/java/com/solexgames/practice/event/match/MatchEvent.java
deleted file mode 100644
index 2541650..0000000
--- a/src/main/java/com/solexgames/practice/event/match/MatchEvent.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.solexgames.practice.event.match;
-
-import com.solexgames.practice.match.Match;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.bukkit.event.Event;
-import org.bukkit.event.HandlerList;
-
-@Getter
-@RequiredArgsConstructor
-public class MatchEvent extends Event {
- private static final HandlerList HANDLERS = new HandlerList();
-
- private final Match match;
-
- public static HandlerList getHandlerList() {
- return HANDLERS;
- }
-
- @Override
- public HandlerList getHandlers() {
- return HANDLERS;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/event/match/MatchStartEvent.java b/src/main/java/com/solexgames/practice/event/match/MatchStartEvent.java
deleted file mode 100644
index 54c409f..0000000
--- a/src/main/java/com/solexgames/practice/event/match/MatchStartEvent.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.solexgames.practice.event.match;
-
-import com.solexgames.practice.match.Match;
-
-public class MatchStartEvent extends MatchEvent {
- public MatchStartEvent(Match match) {
- super(match);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/events/Event.java b/src/main/java/com/solexgames/practice/events/Event.java
deleted file mode 100644
index 1ed1062..0000000
--- a/src/main/java/com/solexgames/practice/events/Event.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package com.solexgames.practice.events;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.PlayerUtil;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.Setter;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import java.util.*;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-/**
- * @author GrowlyX
- * @since 8/14/2021
- */
-
-@Getter
-@Setter
-@RequiredArgsConstructor
-public abstract class Event {
-//
-// private final String name;
-//
-// private Player host;
-// private EventState state = EventState.UNANNOUNCED;
-//
-// private int limit = 64;
-//
-// public void startCountdown() {
-// if (this.getCountdownTask().isEnded()) {
-// this.getCountdownTask().setTimeUntilStart(this.getCountdownTask().getCountdownTime());
-// this.getCountdownTask().setEnded(false);
-// } else {
-// this.getCountdownTask().runTaskTimer(Practice.getInstance(), 20L, 20L);
-// }
-// }
-//
-// public void sendMessage(String message) {
-// this.getBukkitPlayers().forEach(player -> player.sendMessage(Color.translate(message)));
-// }
-//
-// public Set getBukkitPlayers() {
-// return getPlayers().keySet().stream()
-// .filter(uuid -> Practice.getInstance().getServer().getPlayer(uuid) != null)
-// .map(Practice.getInstance().getServer()::getPlayer)
-// .collect(Collectors.toSet());
-// }
-//
-// public void join(Player player) {
-// if (this.getPlayers().size() >= this.limit && !player.hasPermission("practice.event.full.bypass")) {
-// return;
-// }
-//
-// Practice.getInstance().getQueueManager().removePlayerFromQueue(player);
-//
-// final PlayerData playerData = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-// playerData.setPlayerState(PlayerState.EVENT);
-//
-// PlayerUtil.clearPlayer(player);
-//
-// if (this.onJoin() != null) {
-// this.onJoin().accept(player);
-// }
-//
-// if (this.getSpawnLocations().size() == 1) {
-// player.teleport(this.getSpawnLocations().get(0).toBukkitLocation());
-// } else {
-// final List asyncLocations = new ArrayList<>(this.getSpawnLocations());
-//
-// asyncLocations.get(ThreadLocalRandom.current().nextInt(asyncLocations.size())).teleport(player);
-// }
-//
-// Practice.getInstance().getPlayerManager().giveLobbyItems(player);
-//
-// this.getBukkitPlayers().forEach(other -> other.showPlayer(player));
-// this.getBukkitPlayers().forEach(player::showPlayer);
-//
-// this.sendMessage(CC.AQUA + player.getName() + CC.YELLOW + " has joined. " + CC.GREEN + "(" + this.getPlayers().size() + "/" + this.limit + ")");
-//
-// player.sendMessage(CC.YELLOW + "You've joined the " + CC.AQUA + this.name + CC.YELLOW + " event.");
-// }
-//
-// public void leave(Player player) {
-// if (this.onDeath() != null) {
-// this.onDeath().accept(player);
-// }
-//
-// this.getPlayers().remove(player.getUniqueId());
-//
-// player.sendMessage(CC.RED + "You've left the " + this.name + " event.");
-//
-// Practice.getInstance().getPlayerManager().sendToSpawnAndReset(player);
-// }
-//
-//// public void start() {
-// new EventStartEvent(this).call();
-//
-// this.setState(EventState.STARTED);
-// this.onStart();
-//
-// Practice.getInstance().getEventManager().setCooldown(0L);
-// }
-//
-// public void handleWin(Player winner) {
-// Bukkit.broadcastMessage("");
-// Bukkit.broadcastMessage(winner.getDisplayName() + CC.YELLOW + " has won the " + CC.AQUA + this.name + CC.YELLOW + " event!");
-// Bukkit.broadcastMessage("");
-// }
-//
-// public void end() {
-// Practice.getInstance().getEventManager().setCooldown(System.currentTimeMillis() + (60 * 3) * 1000L);
-//
-// this.getBukkitPlayers().forEach(player -> {
-// Practice.getInstance().getPlayerManager().sendToSpawnAndReset(player);
-// });
-//
-// if (this instanceof SumoEvent) {
-// SumoEvent sumoEvent = (SumoEvent) this;
-// sumoEvent.setRound(0);
-//
-// for (SumoPlayer sumoPlayer : sumoEvent.getPlayers().values()) {
-// if (sumoPlayer.getFightTask() != null) {
-// sumoPlayer.getFightTask().cancel();
-// }
-// }
-//
-// if (sumoEvent.getWaterCheckTask() != null) {
-// sumoEvent.getWaterCheckTask().cancel();
-// }
-// }
-//
-// this.getPlayers().clear();
-// this.setState(EventState.UNANNOUNCED);
-////
-//// final Iterator iterator = Practice.getInstance().getEventManager()
-//// .getSpectators().keySet().iterator();
-////
-//// while (iterator.hasNext()) {
-//// final UUID spectatorUUID = iterator.next();
-//// final Player spectator = Bukkit.getPlayer(spectatorUUID);
-////
-//// if (spectator != null) {
-//// Practice.getInstance().getServer().getScheduler().runTask(Practice.getInstance(), () -> Practice.getInstance().getPlayerManager().sendToSpawnAndReset(spectator));
-////
-//// iterator.remove();
-//// }
-//// }
-//
-//// Practice.getInstance().getEventManager().getSpectators().clear();
-//
-// this.getCountdownTask().setEnded(true);
-// }
-//
-// public K getPlayer(Player player) {
-// return this.getPlayer(player.getUniqueId());
-// }
-//
-// public K getPlayer(UUID uuid) {
-// return this.getPlayers().get(uuid);
-// }
-//
-// public abstract Map getPlayers();
-//
-// public abstract EventCountdownTask getCountdownTask();
-//
-// public abstract List getSpawnLocations();
-//
-// public abstract void onStart();
-//
-// public abstract Consumer onJoin();
-//
-// public abstract Consumer onDeath();
-
-}
diff --git a/src/main/java/com/solexgames/practice/events/EventCountdownTask.java b/src/main/java/com/solexgames/practice/events/EventCountdownTask.java
deleted file mode 100644
index 95b2db4..0000000
--- a/src/main/java/com/solexgames/practice/events/EventCountdownTask.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.solexgames.practice.events;
-
-import com.solexgames.core.util.clickable.Clickable;
-import com.solexgames.practice.util.CC;
-import lombok.Getter;
-import lombok.Setter;
-import net.md_5.bungee.api.chat.ClickEvent;
-import org.bukkit.Bukkit;
-import org.bukkit.scheduler.BukkitRunnable;
-
-@Setter
-@Getter
-public abstract class EventCountdownTask extends BukkitRunnable {
-
- private final Event> event;
- private final int countdownTime;
-
- private int timeUntilStart;
- private boolean ended;
-
- public EventCountdownTask(Event> event, int countdownTime) {
- this.event = event;
- this.countdownTime = countdownTime;
- this.timeUntilStart = countdownTime;
- }
-
- @Override
- public void run() {
- if (this.isEnded()) {
- return;
- }
-
- if (this.timeUntilStart <= 0) {
- if (this.canStart()) {
-// this.event.start();
- } else {
- this.onCancel();
- }
-
- this.ended = true;
- return;
- }
-
- if (shouldAnnounce(timeUntilStart)) {
-// final Clickable clickable = new Clickable(CC.YELLOW + "A " + CC.AQUA + this.event.getName() + CC.GRAY + " (1v1)" + CC.YELLOW + " event is starting soon. ");
-// clickable.add(CC.GREEN + CC.BOLD + "[Join]", CC.GREEN + "Click to join the " + CC.YELLOW + this.event.getName() + CC.GREEN + " event.", "/joinevent " + this.event.getName(), ClickEvent.Action.RUN_COMMAND);
-//
-// Bukkit.getOnlinePlayers().forEach(player -> {
-// player.spigot().sendMessage(clickable.asComponents());
-// });
- }
-
- this.timeUntilStart--;
- }
-
- public abstract boolean shouldAnnounce(int timeUntilStart);
-
- public abstract boolean canStart();
-
- public abstract void onCancel();
-
-}
diff --git a/src/main/java/com/solexgames/practice/events/EventPlayer.java b/src/main/java/com/solexgames/practice/events/EventPlayer.java
deleted file mode 100644
index bfb2f03..0000000
--- a/src/main/java/com/solexgames/practice/events/EventPlayer.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.solexgames.practice.events;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.UUID;
-
-@Getter
-@RequiredArgsConstructor
-public class EventPlayer {
-
- private final UUID uuid;
- private final Event> event;
-
-}
diff --git a/src/main/java/com/solexgames/practice/events/EventState.java b/src/main/java/com/solexgames/practice/events/EventState.java
deleted file mode 100644
index 7ec16a2..0000000
--- a/src/main/java/com/solexgames/practice/events/EventState.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.solexgames.practice.events;
-
-public enum EventState {
-
- UNANNOUNCED, // The event hasn't even been announced yet
- WAITING, // Waiting for players to join while the event counts down to start
- STARTED // The event has started and is in progress
-
-}
diff --git a/src/main/java/com/solexgames/practice/ffa/FFAManager.java b/src/main/java/com/solexgames/practice/ffa/FFAManager.java
deleted file mode 100644
index 8a42e3f..0000000
--- a/src/main/java/com/solexgames/practice/ffa/FFAManager.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package com.solexgames.practice.ffa;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.comphenix.EntityHider;
-import com.solexgames.practice.ffa.killstreak.KillStreak;
-import com.solexgames.practice.ffa.killstreak.impl.DebuffKillStreak;
-import com.solexgames.practice.ffa.killstreak.impl.GappleKillStreak;
-import com.solexgames.practice.ffa.killstreak.impl.GodAppleKillStreak;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.PlayerUtil;
-import io.papermc.lib.PaperLib;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Item;
-import org.bukkit.entity.Player;
-import org.bukkit.metadata.FixedMetadataValue;
-
-import java.util.*;
-
-@RequiredArgsConstructor
-public class FFAManager {
-
- @Getter
- private final Map- itemTracker = new HashMap<>();
- @Getter
- private final Map killStreakTracker = new HashMap<>();
-
- @Getter
- private final Set killStreaks = new HashSet<>();
-
- private final Practice plugin = Practice.getInstance();
-
- private final AsyncLocation spawnPoint;
- private final Kit kit;
-
- public void addPlayer(Player player) {
- if (this.spawnPoint == null || this.kit == null) {
- player.sendMessage(CC.RED + "FFA is currently disabled.");
- return;
- }
-
- if (this.killStreaks.isEmpty()) {
- this.killStreaks.add(new GappleKillStreak());
- this.killStreaks.add(new DebuffKillStreak());
- this.killStreaks.add(new GodAppleKillStreak());
- }
-
- PlayerUtil.clearPlayer(player);
-
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
- playerData.setPlayerState(PlayerState.FFA);
-
- PaperLib.teleportAsync(player, this.spawnPoint.toBukkitLocation());
- player.sendMessage(CC.GREEN + "Welcome to the FFA Arena!");
-
- this.kit.applyToPlayer(player);
-
- for (PlayerData data : this.plugin.getPlayerManager().getAllData()) {
- final Player otherPlayer = this.plugin.getServer().getPlayer(data.getUniqueId());
-
- if (data.getPlayerState() == PlayerState.FFA) {
- Practice.getInstance().getEntityHider().showEntity(player, otherPlayer);
- Practice.getInstance().getEntityHider().showEntity(otherPlayer, player);
- } else {
- Practice.getInstance().getEntityHider().hideEntity(player, otherPlayer);
- Practice.getInstance().getEntityHider().hideEntity(otherPlayer, player);
- }
- }
-
- player.sendMessage(Color.SECONDARY_COLOR + "Players will be able to attack you in " + Color.MAIN_COLOR + "5 seconds" + Color.SECONDARY_COLOR + "...");
- player.setMetadata("non-attackable", new FixedMetadataValue(this.plugin, true));
-
- Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
- player.sendMessage(CC.GRAY + "Your invincibility has ran out.");
- player.removeMetadata("non-attackable", this.plugin);
- }, 100L);
- }
-
- public void resetAndAddBack(Player player) {
- if (this.spawnPoint == null || this.kit == null) {
- return;
- }
-
- if (this.killStreaks.isEmpty()) {
- this.killStreaks.add(new GappleKillStreak());
- this.killStreaks.add(new DebuffKillStreak());
- this.killStreaks.add(new GodAppleKillStreak());
- }
-
- PaperLib.teleportAsync(player, this.spawnPoint.toBukkitLocation());
-
- PlayerUtil.clearPlayer(player);
-
- this.kit.applyToPlayer(player);
-
- for (PlayerData data : this.plugin.getPlayerManager().getAllData()) {
- final Player otherPlayer = this.plugin.getServer().getPlayer(data.getUniqueId());
-
- if (data.getPlayerState() == PlayerState.FFA) {
- Practice.getInstance().getEntityHider().showEntity(player, otherPlayer);
- Practice.getInstance().getEntityHider().showEntity(otherPlayer, player);
- } else {
- Practice.getInstance().getEntityHider().hideEntity(player, otherPlayer);
- Practice.getInstance().getEntityHider().hideEntity(otherPlayer, player);
- }
- }
-
- player.sendMessage(Color.SECONDARY_COLOR + "Players will be able to attack you in " + Color.MAIN_COLOR + "5 seconds" + Color.SECONDARY_COLOR + "...");
- player.setMetadata("non-attackable", new FixedMetadataValue(this.plugin, true));
-
- Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
- player.sendMessage(CC.GRAY + "Your non attackable cooldown has expired.");
- player.removeMetadata("non-attackable", this.plugin);
- }, 100L);
- }
-
- public void removePlayer(Player player) {
- for (PlayerData data : this.plugin.getPlayerManager().getAllData()) {
- final Player player1 = this.plugin.getServer().getPlayer(data.getUniqueId());
-
- if (data.getPlayerState() == PlayerState.FFA) {
- Practice.getInstance().getEntityHider().hideEntity(player, player1);
- Practice.getInstance().getEntityHider().hideEntity(player1, player);
- }
- }
-
- player.sendMessage(CC.GREEN + "You've been sent to spawn.");
-
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/ffa/killstreak/KillStreak.java b/src/main/java/com/solexgames/practice/ffa/killstreak/KillStreak.java
deleted file mode 100644
index c7b6588..0000000
--- a/src/main/java/com/solexgames/practice/ffa/killstreak/KillStreak.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.solexgames.practice.ffa.killstreak;
-
-import org.bukkit.entity.Player;
-
-import java.util.List;
-
-public interface KillStreak {
-
- void giveKillStreak(Player player);
-
- List getStreaks();
-
-}
diff --git a/src/main/java/com/solexgames/practice/ffa/killstreak/impl/DebuffKillStreak.java b/src/main/java/com/solexgames/practice/ffa/killstreak/impl/DebuffKillStreak.java
deleted file mode 100644
index 397667d..0000000
--- a/src/main/java/com/solexgames/practice/ffa/killstreak/impl/DebuffKillStreak.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.solexgames.practice.ffa.killstreak.impl;
-
-import com.solexgames.practice.ffa.killstreak.KillStreak;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.PlayerUtil;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class DebuffKillStreak implements KillStreak {
-
- private static final ItemStack SLOWNESS = new ItemStack(Material.POTION, 1, (short) 16394);
- private static final ItemStack POISON = new ItemStack(Material.POTION, 1, (short) 16388);
-
- @Override
- public void giveKillStreak(Player player) {
- PlayerUtil.setFirstSlotOfType(player, Material.POTION, SLOWNESS.clone());
- PlayerUtil.setFirstSlotOfType(player, Material.POTION, POISON.clone());
-
- player.sendMessage(CC.GRAY + "You've received the " + CC.DARK_GREEN + "Debuff" + CC.GRAY + " killstreak!");
- }
-
- @Override
- public List getStreaks() {
- return Arrays.asList(7, 25);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/ffa/killstreak/impl/GappleKillStreak.java b/src/main/java/com/solexgames/practice/ffa/killstreak/impl/GappleKillStreak.java
deleted file mode 100644
index 18790b5..0000000
--- a/src/main/java/com/solexgames/practice/ffa/killstreak/impl/GappleKillStreak.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.solexgames.practice.ffa.killstreak.impl;
-
-import com.solexgames.practice.ffa.killstreak.KillStreak;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.PlayerUtil;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class GappleKillStreak implements KillStreak {
-
- @Override
- public void giveKillStreak(Player player) {
- PlayerUtil.setFirstSlotOfType(player, Material.POTION, new ItemStack(Material.GOLDEN_APPLE, 3));
-
- player.sendMessage(CC.GRAY + "You've received the " + CC.YELLOW + "GApple" + CC.GRAY + " killstreak!");
- }
-
- @Override
- public List getStreaks() {
- return Arrays.asList(3, 15);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/ffa/killstreak/impl/GodAppleKillStreak.java b/src/main/java/com/solexgames/practice/ffa/killstreak/impl/GodAppleKillStreak.java
deleted file mode 100644
index 1aa5619..0000000
--- a/src/main/java/com/solexgames/practice/ffa/killstreak/impl/GodAppleKillStreak.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.solexgames.practice.ffa.killstreak.impl;
-
-import com.solexgames.practice.ffa.killstreak.KillStreak;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.PlayerUtil;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class GodAppleKillStreak implements KillStreak {
-
- @Override
- public void giveKillStreak(Player player) {
- PlayerUtil.setFirstSlotOfType(player, Material.POTION, new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1));
-
- player.sendMessage(CC.GRAY + "You've received the " + CC.AQUA + "GodApple" + CC.GRAY + " killstreak!");
- }
-
- @Override
- public List getStreaks() {
- return Arrays.asList(30, 40, 60, 75, 100);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/flags/Flag.java b/src/main/java/com/solexgames/practice/flags/Flag.java
deleted file mode 100644
index 2e0d5a2..0000000
--- a/src/main/java/com/solexgames/practice/flags/Flag.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.solexgames.practice.flags;
-
-/**
- * @author GrowlyX
- * @since 6/9/2021
- */
-
-public enum Flag {
-
- DEFAULT,
- HCF,
-
- SUMO,
- BUILD,
- SPLEEF,
- PARKOUR,
- BEDWARS,
- BRIDGES,
- STICK_FIGHT,
-
-}
diff --git a/src/main/java/com/solexgames/practice/kit/Kit.java b/src/main/java/com/solexgames/practice/kit/Kit.java
deleted file mode 100644
index 0fed4ad..0000000
--- a/src/main/java/com/solexgames/practice/kit/Kit.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.solexgames.practice.kit;
-
-import com.solexgames.practice.flags.Flag;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.Setter;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-@Getter
-@Setter
-@AllArgsConstructor
-@RequiredArgsConstructor
-public class Kit {
-
- private final String name;
-
- private ItemStack[] contents = new ItemStack[36];
- private ItemStack[] armor = new ItemStack[4];
- private ItemStack[] kitEditContents = new ItemStack[36];
-
- private ItemStack icon;
- private ItemStack leaderboardIcon;
-
- private boolean enabled = true;
- private boolean ranked = false;
- private boolean newKit = false;
-
- private int queueMenu = 0;
-
- private Flag flag = Flag.DEFAULT;
-
- public void applyToPlayer(Player player) {
- player.getInventory().setContents(this.contents);
- player.getInventory().setArmorContents(this.armor);
-
- player.updateInventory();
- }
-}
diff --git a/src/main/java/com/solexgames/practice/kit/PlayerKit.java b/src/main/java/com/solexgames/practice/kit/PlayerKit.java
deleted file mode 100644
index 576f543..0000000
--- a/src/main/java/com/solexgames/practice/kit/PlayerKit.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.solexgames.practice.kit;
-
-import com.solexgames.practice.Practice;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-@Getter
-@Setter
-@AllArgsConstructor
-public class PlayerKit {
-
- private final String name;
- private final int index;
-
- private ItemStack[] contents;
- private String displayName;
-
- public void applyToPlayer(Player player) {
- for (ItemStack itemStack : this.contents) {
- if (itemStack != null) {
- if (itemStack.getAmount() <= 0) {
- itemStack.setAmount(1);
- }
- }
- }
-
- player.getInventory().setContents(this.contents);
- player.getInventory().setArmorContents(Practice.getInstance().getKitManager().getKit(this.name).getArmor());
-
- player.updateInventory();
- }
-}
diff --git a/src/main/java/com/solexgames/practice/listeners/EntityListener.java b/src/main/java/com/solexgames/practice/listeners/EntityListener.java
deleted file mode 100644
index de99c9b..0000000
--- a/src/main/java/com/solexgames/practice/listeners/EntityListener.java
+++ /dev/null
@@ -1,210 +0,0 @@
-package com.solexgames.practice.listeners;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.flags.Flag;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.MatchState;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.runnable.NewRoundRunnable;
-import com.solexgames.practice.tournament.Tournament;
-import com.solexgames.practice.util.CC;
-import io.papermc.lib.PaperLib;
-import org.bukkit.GameMode;
-import org.bukkit.entity.Arrow;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.Projectile;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.PotionSplashEvent;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-import org.bukkit.projectiles.ProjectileSource;
-
-public class EntityListener implements Listener {
-
- private final Practice plugin = Practice.getInstance();
-
- @EventHandler
- public void onEntityDamage(EntityDamageEvent event) {
- final Entity entity = event.getEntity();
-
- if (entity instanceof Player) {
- final Player player = (Player) entity;
- final PlayerData playerData = this.plugin.getPlayerManager()
- .getPlayerData(player.getUniqueId());
-
- if (playerData != null) {
- final Match match = this.plugin.getMatchManager().getMatch(playerData.getUniqueId());
-
- if (match != null) {
- switch (match.getMatchState()) {
- case FIGHTING:
- if (match.getKit().getName().equals("Boxing")) {
- if (event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) {
- event.setCancelled(true);
- return;
- }
-
- if (!event.getCause().equals(EntityDamageEvent.DamageCause.CUSTOM)) {
- event.setDamage(0.0D);
- }
- return;
- }
- break;
- case ENDING:
- case SWITCHING:
- case STARTING:
- event.setCancelled(true);
- break;
- }
- } else {
- if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
- this.plugin.getSpawnManager().fetchSingleLocation("spawn").ifPresent(asyncLocation -> {
- asyncLocation.teleport(player);
- });
- }
-
- event.setCancelled(true);
- }
- }
- }
- }
-
- @EventHandler
- public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
- if (!(event.getEntity() instanceof Player)) {
- event.setCancelled(true);
- return;
- }
-
- Player entity = (Player) event.getEntity();
- Player damager;
-
- if (event.getDamager() instanceof Player) {
- damager = (Player) event.getDamager();
- } else if (event.getDamager() instanceof Projectile) {
- final ProjectileSource projectileSource = ((Projectile) event.getDamager()).getShooter();
-
- if (projectileSource instanceof Player) {
- damager = (Player) ((Projectile) event.getDamager()).getShooter();
- } else {
- return;
- }
- } else {
- return;
- }
-
- PlayerData entityData = this.plugin.getPlayerManager().getPlayerData(entity.getUniqueId());
- PlayerData damagerData = this.plugin.getPlayerManager().getPlayerData(damager.getUniqueId());
-
- if (entityData == null || damagerData == null) {
- event.setDamage(0.0D);
- return;
- }
-
-
- if (damagerData.getPlayerState() == PlayerState.SPECTATING) {
- event.setCancelled(true);
- return;
- }
-
- if ((!entity.canSee(damager) && damager.canSee(entity)) || damager.getGameMode() == GameMode.SPECTATOR) {
- event.setCancelled(true);
- return;
- }
-
- final Match match = this.plugin.getMatchManager().getMatch(entityData);
-
- if (match == null || match.getMatchState().equals(MatchState.STARTING)) {
- event.setCancelled(true);
- return;
- }
-
- if (damagerData.getTeamID() == entityData.getTeamID() && !match.isFFA()) {
- event.setCancelled(true);
- return;
- }
-
- if (match.getKit().getFlag().equals(Flag.PARKOUR)) {
- event.setCancelled(true);
- return;
- }
-
- if (match.getKit().getName().equals("Sumo")) {
- event.setDamage(0.0D);
- return;
- }
-
- if (match.getKit().getFlag().equals(Flag.SPLEEF) || match.getKit().getFlag().equals(Flag.SUMO)) {
- event.setDamage(0.0D);
- }
-
- if (event.getDamager() instanceof Player) {
- if (!match.getMatchState().equals(MatchState.FIGHTING)) {
- return;
- }
-
- damagerData.setCombo(damagerData.getCombo() + 1);
- damagerData.setHits(damagerData.getHits() + 1);
-
- if (damagerData.getCombo() > damagerData.getLongestCombo()) {
- damagerData.setLongestCombo(damagerData.getCombo());
- }
-
- entityData.setCombo(0);
-
- if (match.getKit().getName().contains("Boxing")) {
- if (damagerData.getHits() >= 100) {
- this.plugin.getMatchManager().removeFighter(entity, entityData, false);
- }
-
- event.setDamage(0.0D);
- } else if (match.getKit().getFlag().equals(Flag.STICK_FIGHT)) {
- event.setDamage(0.0D);
- } else if (match.getKit().getFlag().equals(Flag.SPLEEF)) {
- event.setCancelled(true);
- }
- } else if (event.getDamager() instanceof Arrow) {
- Arrow arrow = (Arrow) event.getDamager();
-
- if (arrow.getShooter() instanceof Player) {
- Player shooter = (Player) arrow.getShooter();
-
- if (!entity.getName().equals(shooter.getName())) {
- double health = Math.ceil(entity.getHealth() - event.getFinalDamage()) / 2.0D;
-
- if (health > 0.0D) {
- shooter.sendMessage(entity.getDisplayName() + Color.SECONDARY_COLOR + " is now at " + CC.RED + health + " ❤" + Color.SECONDARY_COLOR + ".");
- }
- }
- }
- }
- }
-
- @EventHandler
- public void onPotionSplash(PotionSplashEvent e) {
- if (!(e.getEntity().getShooter() instanceof Player)) {
- return;
- }
- for (PotionEffect effect : e.getEntity().getEffects()) {
- if (effect.getType().equals(PotionEffectType.HEAL)) {
- Player shooter = (Player) e.getEntity().getShooter();
-
- if (e.getIntensity(shooter) <= 0.5D) {
- PlayerData shooterData = this.plugin.getPlayerManager().getPlayerData(shooter.getUniqueId());
-
- if (shooterData != null) {
- shooterData.setMissedPots(shooterData.getMissedPots() + 1);
- }
- }
- break;
- }
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/listeners/InventoryListener.java b/src/main/java/com/solexgames/practice/listeners/InventoryListener.java
deleted file mode 100644
index b1747eb..0000000
--- a/src/main/java/com/solexgames/practice/listeners/InventoryListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.solexgames.practice.listeners;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import org.bukkit.GameMode;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryClickEvent;
-
-public class InventoryListener implements Listener {
-
- private final Practice plugin = Practice.getInstance();
-
- @EventHandler
- public void onInventoryClick(InventoryClickEvent event) {
- final Player player = (Player) event.getWhoClicked();
-
- if (!player.getGameMode().equals(GameMode.CREATIVE)) {
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData.getPlayerState() == PlayerState.SPAWN || (playerData.getPlayerState() == PlayerState.EVENT && player.getItemInHand() != null && player.getItemInHand().getType() == Material.COMPASS)) {
- event.setCancelled(true);
- }
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/listeners/KillStreakDataTrackerListener.java b/src/main/java/com/solexgames/practice/listeners/KillStreakDataTrackerListener.java
deleted file mode 100644
index 54ac2cd..0000000
--- a/src/main/java/com/solexgames/practice/listeners/KillStreakDataTrackerListener.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.solexgames.practice.listeners;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.event.match.MatchEndEvent;
-import com.solexgames.practice.player.PlayerData;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-
-/**
- * @author GrowlyX
- * @since 7/30/2021
- */
-
-public class KillStreakDataTrackerListener implements Listener {
-
- @EventHandler
- public void onMatchEnd(MatchEndEvent event) {
- if (event.getLosingTeam() != null) {
- event.getLosingTeam().getPlayers().forEach(uuid -> {
- final Player player = Bukkit.getPlayer(uuid);
-
- if (player != null) {
- final PlayerData challengePlayer = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (challengePlayer != null) {
- challengePlayer.setKillstreak(event.getMatch().getKit(), 0);
- Practice.getInstance().getPlayerManager().saveData(challengePlayer);
- }
-
- }
- });
- }
-
- event.getWinningTeam().getPlayers().forEach(uuid -> {
- final Player player = Bukkit.getPlayer(uuid);
-
- if (player != null) {
- final PlayerData challengePlayer = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (challengePlayer != null) {
- final String kitName = event.getMatch().getKit().getName();
- final int current = challengePlayer.getKitKillStreaks().getOrDefault(kitName, -1);
-
- if (current == -1) {
- challengePlayer.getKitKillStreaks().put(kitName, 1);
- } else {
- final PlayerData playerData = Practice.getInstance().getPlayerManager().getPlayerData(uuid);
- final int newKillStreak = current + 1;
-
- challengePlayer.getKitKillStreaks().put(kitName, newKillStreak);
-
- final int highest = playerData.getHighestKillStreak(kitName);
-
- if (highest == 0 || newKillStreak > highest) {
- playerData.setHighestKillStreak(kitName, newKillStreak);
- }
-
- Practice.getInstance().getPlayerManager().saveData(challengePlayer);
- }
-
- }
- }
- });
- }
-}
diff --git a/src/main/java/com/solexgames/practice/listeners/MatchListener.java b/src/main/java/com/solexgames/practice/listeners/MatchListener.java
deleted file mode 100644
index ef36a82..0000000
--- a/src/main/java/com/solexgames/practice/listeners/MatchListener.java
+++ /dev/null
@@ -1,431 +0,0 @@
-package com.solexgames.practice.listeners;
-
-import com.solexgames.core.listener.custom.PlayerFreezeEvent;
-import com.solexgames.core.menu.impl.player.PlayerInfoMenu;
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.clickable.Clickable;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.arena.type.StandaloneArena;
-import com.solexgames.practice.event.match.MatchEndEvent;
-import com.solexgames.practice.event.match.MatchStartEvent;
-import com.solexgames.practice.flags.Flag;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.MatchState;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.queue.QueueType;
-import com.solexgames.practice.runnable.MatchRunnable;
-import com.solexgames.practice.util.*;
-import com.solexgames.practice.util.calc.EloCalculator;
-import net.md_5.bungee.api.chat.BaseComponent;
-import net.md_5.bungee.api.chat.ClickEvent;
-import net.md_5.bungee.api.chat.HoverEvent;
-import org.apache.commons.lang.ArrayUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.ArmorStand;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.entity.CreatureSpawnEvent;
-import org.bukkit.event.entity.EntitySpawnEvent;
-import org.bukkit.event.entity.FoodLevelChangeEvent;
-import org.bukkit.event.player.PlayerInteractAtEntityEvent;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-public class MatchListener implements Listener {
-
- private final Practice plugin = Practice.getInstance();
-
- @EventHandler
- public void onFreeze(PlayerFreezeEvent event) {
- final Player player = event.getPlayer();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData.getCurrentMatchID() == null) {
- return;
- }
-
- final Match match = this.plugin.getMatchManager().getMatch(playerData);
-
- if (match != null) {
- if (match.isParty()) {
- this.plugin.getMatchManager().removeFighter(player, playerData, false);
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
- } else {
- this.plugin.getServer().getPluginManager().callEvent(new MatchEndEvent(match, null, null));
- match.broadcast(CC.RED + "The match has been canceled due to a player being frozen.");
- }
- }
-
- this.plugin.getPartyManager().removePartyInvites(player.getUniqueId());
- this.plugin.getMatchManager().removeMatchRequests(player.getUniqueId());
-
- this.plugin.getPartyManager().leaveParty(player);
- }
-
- @EventHandler
- public void onEntitySpawn(EntitySpawnEvent event) {
- if (event.getEntityType().equals(EntityType.ARMOR_STAND)) {
- event.setCancelled(false);
- return;
- }
-
- event.setCancelled(true);
- }
-
- @EventHandler
- public void onMobSpawn(CreatureSpawnEvent event) {
- if (event.getEntity() instanceof ArmorStand) {
- event.setCancelled(false);
- return;
- }
-
- event.setCancelled(true);
- }
-
- @EventHandler
- public void onHunger(FoodLevelChangeEvent event) {
- final Match match = Practice.getInstance().getMatchManager().getMatch(event.getEntity().getUniqueId());
-
- if (match != null) {
- if (match.getKit().getName().contains("Soup")) {
- event.setCancelled(true);
- }
- }
- }
-
- @EventHandler
- public void onMatchStart(MatchStartEvent event) {
- final Match match = event.getMatch();
- final Kit kit = match.getKit();
-
- match.setMatchState(MatchState.STARTING);
-
- if (!kit.isEnabled()) {
- match.broadcast(CC.RED + "This kit is currently disabled.");
- this.plugin.getMatchManager().removeMatch(match);
- return;
- }
-
- if (match.getKit().getFlag().equals(Flag.BUILD) || match.getKit().getFlag().equals(Flag.SPLEEF)) {
- final StandaloneArena arena = match.getArena().getAvailableArena();
-
- if (arena != null) {
- match.setStandaloneArena(arena);
- this.plugin.getArenaManager().setArenaMatchUUID(arena, match.getMatchId());
- } else {
- match.broadcast(CC.RED + "There are no arenas available at this moment.");
- this.plugin.getMatchManager().removeMatch(match);
- return;
- }
- }
-
- final Set matchPlayers = new HashSet<>();
-
- match.getTeams().forEach(team -> team.streamAlivePlayers().forEach(player -> {
- matchPlayers.add(player);
-
- this.plugin.getMatchManager().removeMatchRequests(player.getUniqueId());
-
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData != null) {
- PlayerUtil.clearPlayer(player);
-
- playerData.setCurrentMatchID(match.getMatchId());
- playerData.setTeamID(team.getTeamID());
-
- playerData.setMissedPots(0);
- playerData.setLongestCombo(0);
- playerData.setCombo(0);
- playerData.setHits(0);
-
- PlayerUtil.updateNametag(player, kit.getFlag().equals(Flag.BUILD));
-
- final AsyncLocation locationA = match.getStandaloneArena() != null ? match.getStandaloneArena().getPositionOne() : match.getArena().getPositionOne();
- final AsyncLocation locationB = match.getStandaloneArena() != null ? match.getStandaloneArena().getPositionTwo() : match.getArena().getPositionTwo();
-
- final CompletableFuture completableFuture = team.getTeamID() == 1 ? locationA.teleport(player) : locationB.teleport(player);
- completableFuture.whenComplete((unused, throwable) -> {
- this.plugin.getMatchManager().giveKits(player, kit);
-
- //BridgePlugin.INSTANCE.applyKnockbackProfile(player, kit.getName().toLowerCase());
-
- if (kit.getName().equals("Combo")) {
- player.setMaximumNoDamageTicks(0);
- }
-
- if (kit.getName().contains("Boxing")) {
- player.getInventory().setContents(this.plugin.getItemManager().getBoxingItems());
- player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 99999, 1));
-
- player.sendMessage(CC.GREEN + "First to 100 hits wins the match!");
- }
-
- if (match.getKit().getFlag().equals(Flag.STICK_FIGHT)) {
- match.getLives().put(player.getUniqueId(), 5);
-
- player.getInventory().setContents(this.plugin.getItemManager().getStickFightItems());
- }
-
- playerData.setPlayerState(PlayerState.FIGHTING);
- });
- }
- }));
-
- for (Player player : matchPlayers) {
- for (Player online : this.plugin.getServer().getOnlinePlayers()) {
- Practice.getInstance().getEntityHider().hideEntity(player, online);
- Practice.getInstance().getEntityHider().hideEntity(online, player);
- }
- }
-
- for (Player player : matchPlayers) {
- for (Player other : matchPlayers) {
- Practice.getInstance().getEntityHider().showEntity(player, other);
- }
- }
-
- new MatchRunnable(match).runTaskTimer(this.plugin, 20L, 20L);
- }
-
-
- @EventHandler
- public void onMatchEnd(MatchEndEvent event) {
- final Match match = event.getMatch();
-
- if (event.getWinningTeam() == null) {
- match.setMatchState(MatchState.ENDING);
- match.setCountdown(1);
- return;
- }
-
- match.broadcast(CC.GRAY + CC.STRIKE_THROUGH + "-----------------------------------------------------");
- match.broadcast(Color.MAIN_COLOR + "Match Results" + CC.GRAY + " (Click names to view inventories)");
-
- final ChatComponentBuilder wInventories = new ChatComponentBuilder("");
- final ChatComponentBuilder lInventories = new ChatComponentBuilder("");
-
- match.setMatchState(MatchState.ENDING);
- match.setWinningTeamId(event.getWinningTeam().getTeamID());
- match.setCountdown(4);
-
- if (match.isFFA()) {
- final Player winner = Bukkit.getPlayer(event.getWinningTeam().getAlivePlayers().get(0));
-
- if (winner == null) {
- return;
- }
-
- lInventories.append(CC.RED + "Participants: " + CC.YELLOW);
-
- event.getWinningTeam().getPlayers().forEach(uuid -> {
- final Player player = Bukkit.getPlayer(uuid);
-
- if (player == null) {
- return;
- }
-
- if (!match.hasSnapshot(player.getUniqueId())) {
- match.addSnapshot(player);
- }
-
- if (!player.getUniqueId().equals(winner.getUniqueId())) {
- final HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new ChatComponentBuilder(CC.GREEN + "Click to view this player's inventory.")).create());
- final ClickEvent click = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/inventory " + match.getSnapshot(player.getUniqueId()).getSnapshotId());
-
- lInventories.append(CC.YELLOW + player.getName());
- lInventories.setCurrentHoverEvent(hover).setCurrentClickEvent(click).append(CC.YELLOW + ", ");
- }
- });
-
- match.getSnapshots().values().forEach(snapshot -> this.plugin.getInventoryManager().addSnapshot(snapshot));
-
- final Clickable winnerClickable = new Clickable(CC.GREEN + "Winner: " + CC.YELLOW);
-
- winnerClickable.add(CC.YELLOW + winner.getName(), CC.GREEN + "Click to view this player's inventory.", "/inventory " + match.getSnapshot(winner.getUniqueId()).getSnapshotId(), ClickEvent.Action.RUN_COMMAND);
-
- match.broadcast(winnerClickable);
- match.broadcast(lInventories.create());
- } else {
- wInventories.append(match.isParty() ? (CC.GREEN + "Winning Team: ") : (CC.GREEN + "Winner: "));
- lInventories.append(match.isParty() ? (CC.RED + "Losing Team: ") : (CC.GRAY + "┃ " + CC.RED + "Loser: "));
-
- match.getTeams().forEach(team -> team.getPlayers().forEach(uuid -> {
- final Player player = Bukkit.getOfflinePlayer(uuid).getPlayer();
-
- if (player == null) {
- return;
- }
-
- if (!match.hasSnapshot(player.getUniqueId())) {
- match.addSnapshot(player);
- }
-
- final boolean onWinningTeam = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId()).getTeamID() == event.getWinningTeam().getTeamID();
-
- final HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new ChatComponentBuilder(CC.GREEN + "Click to view this player's inventory.")).create());
- final ClickEvent click = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/inventory " + match.getSnapshot(player.getUniqueId()).getSnapshotId());
-
- if (onWinningTeam) {
- wInventories.append(CC.YELLOW + player.getName());
- wInventories.setCurrentHoverEvent(hover).setCurrentClickEvent(click).append(CC.WHITE + ", ");
- } else {
- lInventories.append(CC.YELLOW + player.getName());
- lInventories.setCurrentHoverEvent(hover).setCurrentClickEvent(click).append(CC.WHITE + ", ");
- }
- }));
-
- match.getSnapshots().values().forEach(snapshot -> this.plugin.getInventoryManager().addSnapshot(snapshot));
-
- wInventories.getCurrent().setText(wInventories.getCurrent().getText().substring(0, wInventories.getCurrent().getText().length() - 2));
- lInventories.getCurrent().setText(lInventories.getCurrent().getText().substring(0, lInventories.getCurrent().getText().length() - 2));
-
- if (match.isParty()) {
- match.broadcast(wInventories.create());
- match.broadcast(lInventories.create());
- } else {
- final BaseComponent[] winnerComponents = wInventories.create();
- final BaseComponent[] loserComponents = lInventories.create();
- final BaseComponent[] separatorComponents = new ChatComponentBuilder(CC.GRAY + " " + " ").create();
-
- match.broadcast((BaseComponent[]) ArrayUtils.addAll(winnerComponents, ArrayUtils.addAll(separatorComponents, loserComponents)));
- }
-
- if (match.getType().isRanked()) {
- final Player winnerLeader = Bukkit.getPlayer(event.getWinningTeam().getPlayers().get(0));
- final PlayerData winnerLeaderData = plugin.getPlayerManager().getPlayerData(winnerLeader.getUniqueId());
-
- final Player loserLeader = Bukkit.getPlayer(event.getLosingTeam().getPlayers().get(0));
- final PlayerData loserLeaderData = plugin.getPlayerManager().getPlayerData(loserLeader.getUniqueId());
-
- String eloMessage = null;
-
- int winnerElo;
- int loserElo;
-
- final String kitName = match.getKit().getName();
-
- if (event.getWinningTeam().getPlayers().size() == 1) {
- winnerElo = winnerLeaderData.getElo(kitName);
- loserElo = loserLeaderData.getElo(kitName);
-
- final int[] rankings = EloCalculator.getNewRankings(winnerElo, loserElo, true);
-
- eloMessage = Color.SECONDARY_COLOR + "Elo updates: " + CC.GREEN + winnerLeader.getName() + " +" + (rankings[0] - winnerElo) +
- " (" + rankings[0] + ")" + Color.SECONDARY_COLOR + ", " +
- CC.RED + loserLeader.getName() + " -" + (loserElo - rankings[1]) + " (" +
- rankings[1] + ")";
-
- if (match.getType() == QueueType.RANKED) {
- winnerLeaderData.setElo(kitName, rankings[0]);
- loserLeaderData.setElo(kitName, rankings[1]);
-
- winnerLeaderData.setWins(kitName, winnerLeaderData.getWins(kitName) + 1);
- loserLeaderData.setLosses(kitName, loserLeaderData.getLosses(kitName) + 1);
- }
- }
-
- match.broadcast(" ");
-
- if (eloMessage != null) {
- match.broadcast(eloMessage);
- }
- }
-
- this.plugin.getMatchManager().saveRematches(match);
- }
-
- if (match.getSpectators() != null) {
- int spectatorAmount = 0;
- int spectatorOverflow = 0;
-
- final ArrayList specArrayList = new ArrayList<>();
- final Player loserLeader = Bukkit.getPlayer(event.getLosingTeam().getPlayers().get(0));
-
- for (UUID playerUUID : match.getSpectators()) {
- final String playersName = Bukkit.getPlayer(playerUUID).getName();
- final Player player = Bukkit.getPlayer(playersName);
-
- if (player != loserLeader) {
- if (spectatorAmount >= 10) {
- spectatorOverflow++;
- continue;
- }
-
- if (!player.hasPermission("practice.staff")) {
- specArrayList.add(playersName);
- spectatorAmount++;
- }
- }
- }
-
- if (spectatorAmount != 0) {
- final String spectatorList = String.join(", ", specArrayList);
-
- match.broadcast(" ");
- match.broadcast(CC.AQUA + "Spectators (" + spectatorAmount + "): " + CC.YELLOW + spectatorList);
-
- if (spectatorOverflow != 0) {
- match.broadcast(CC.GRAY + "(+" + spectatorOverflow + " more)");
- }
- }
- }
-
- match.broadcast(CC.GRAY + CC.STRIKE_THROUGH + "-----------------------------------------------------");
-
- match.getTeams().forEach(team -> team.getPlayers().forEach(uuid -> {
- final Player player = Bukkit.getPlayer(uuid);
-
- if (player == null) {
- return;
- }
-
- final PlayerData playerData = Practice.getInstance().getPlayerManager().getPlayerData(uuid);
-
- if (match.isShouldGiveXp()) {
- if (team.getTeamID() == match.getWinningTeamId()) {
- if (match.getType().isRanked()) {
- playerData.setRankedWinCount(playerData.getRankedWinCount() + 1);
-
- EXPUtil.addExperienceToPlayer(player, 35, "Ranked match win");
- } else {
- playerData.setUnrankedWinCount(playerData.getUnrankedWinCount() + 1);
-
- EXPUtil.addExperienceToPlayer(player, 10, "Unranked match win");
- }
- PlayerUtil.clearPlayer(player);
- } else if (match.getType().isRanked()) {
- playerData.setRankedLossCount(playerData.getRankedLossCount() + 1);
-
- EXPUtil.addExperienceToPlayer(player, 10, "Competing in ranked");
- } else {
- playerData.setUnrankedLossCount(playerData.getUnrankedLossCount() + 1);
-
- EXPUtil.addExperienceToPlayer(player, 10, "Participating in unranked");
- }
- }
-
- playerData.setLastPlayedArena(match.getArena());
-
- if (!playerData.canPlayRanked() && !player.hasPermission("practice.ranked.bypass")) {
- player.sendMessage(Color.SECONDARY_COLOR + "You need to win " + Color.MAIN_COLOR + playerData.winsUntilRankedUnlocked() + Color.SECONDARY_COLOR + " more matches to play ranked.");
- }
-
- playerData.recalculateGlobalElo();
-
- if (match.getKit().isRanked()) {
- playerData.recalculateDivision();
- }
-
- //BridgePlugin.INSTANCE.applyKnockbackProfile(player, "Default");
- }));
- }
-}
diff --git a/src/main/java/com/solexgames/practice/listeners/MovementListener.java b/src/main/java/com/solexgames/practice/listeners/MovementListener.java
deleted file mode 100644
index c23764e..0000000
--- a/src/main/java/com/solexgames/practice/listeners/MovementListener.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.solexgames.practice.listeners;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.flags.Flag;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.MatchState;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.util.BlockUtil;
-import io.papermc.lib.PaperLib;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerMoveEvent;
-
-/**
- * @author GrowlyX
- * @since 5/20/2021
- */
-
-public class MovementListener implements Listener {
-
- private final Practice plugin = Practice.getInstance();
-
- @EventHandler
- public void onMove(PlayerMoveEvent event) {
- final Player player = event.getPlayer();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData == null) {
- return;
- }
-
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- final Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());
-
- if (player.hasMetadata("frozen")) {
- PaperLib.teleportAsync(player, event.getFrom());
- return;
- }
-
- if (match == null) {
- return;
- }
-
- if (match.getKit().getFlag().equals(Flag.PARKOUR)) {
- if (BlockUtil.isStandingOn(player, Material.GOLD_PLATE)) {
- final Player startingOpponent = match.getTeams().get(0).getPlayers().get(0) == player.getUniqueId()
- ? this.plugin.getServer().getPlayer(match.getTeams().get(1).getPlayers().get(0))
- : this.plugin.getServer().getPlayer(match.getTeams().get(0).getPlayers().get(0));
-
- this.plugin.getMatchManager().removeFighter(startingOpponent, playerData, false);
- }
- }
-
- if (match.getKit().getFlag().equals(Flag.SPLEEF) || match.getKit().getFlag().equals(Flag.SUMO)) {
- final Location location = player.getLocation();
- location.setY(location.getY() - 0.6D);
-
- if (location.getBlock().getType().equals(Material.WATER) || location.getBlock().getType().equals(Material.STATIONARY_WATER) || location.getBlock().getType().equals(Material.LAVA) || location.getBlock().getType().equals(Material.STATIONARY_LAVA)) {
- this.plugin.getMatchManager().removeFighter(player, playerData, true);
- }
-
- if ((event.getTo().getX() != event.getFrom().getX() || event.getTo().getZ() != event.getFrom().getZ()) && match.getMatchState() == MatchState.STARTING) {
- PaperLib.teleportAsync(player, event.getFrom());
- }
- }
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/listeners/PlayerListener.java b/src/main/java/com/solexgames/practice/listeners/PlayerListener.java
deleted file mode 100644
index 67c9877..0000000
--- a/src/main/java/com/solexgames/practice/listeners/PlayerListener.java
+++ /dev/null
@@ -1,672 +0,0 @@
-package com.solexgames.practice.listeners;
-
-import com.solexgames.core.CorePlugin;
-import com.solexgames.core.menu.impl.SettingsMenu;
-import com.solexgames.core.player.PotPlayer;
-import com.solexgames.core.player.prefixes.Prefix;
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.StringUtil;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.PracticeConstants;
-import com.solexgames.practice.PracticeServerType;
-import com.solexgames.practice.ffa.killstreak.KillStreak;
-import com.solexgames.practice.flags.Flag;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.kit.PlayerKit;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.MatchState;
-import com.solexgames.practice.menu.EventHostMenu;
-import com.solexgames.practice.menu.JoinQueueMenu;
-import com.solexgames.practice.menu.SpectateMenu;
-import com.solexgames.practice.menu.editor.KitEditorMainMenu;
-import com.solexgames.practice.menu.editor.KitEditorMenu;
-import com.solexgames.practice.menu.party.PartyEventsMenu;
-import com.solexgames.practice.party.Party;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.queue.QueueType;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.PlayerUtil;
-import com.solexgames.shop.menu.ShopCategoryMenu;
-import io.papermc.lib.PaperLib;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
-import org.bukkit.Material;
-import org.bukkit.block.Sign;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.entity.*;
-import org.bukkit.event.inventory.CraftItemEvent;
-import org.bukkit.event.player.*;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.PlayerInventory;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-
-import java.util.Map;
-import java.util.UUID;
-
-public class PlayerListener implements Listener {
-
- private final Practice plugin = Practice.getInstance();
-
- @EventHandler
- public void onPlayerInteractSoup(final PlayerInteractEvent event) {
- final Player player = event.getPlayer();
-
- if (!player.isDead() && player.getItemInHand().getType() == Material.MUSHROOM_SOUP && player.getHealth() < 19.0) {
- final double newHealth = Math.min(player.getHealth() + 7.0, 20.0);
-
- player.setHealth(newHealth);
- player.getItemInHand().setType(Material.BOWL);
- player.updateInventory();
- }
- }
-
- private final PotionEffect regenerationEffect = new PotionEffect(PotionEffectType.REGENERATION, 200, 1);
- private final PotionEffect absorbtionEffect = new PotionEffect(PotionEffectType.ABSORPTION, 2400, 0);
-
- @EventHandler
- public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
- if (event.getItem().getType() == Material.GOLDEN_APPLE) {
- if (!event.getItem().hasItemMeta() || !event.getItem().getItemMeta().getDisplayName().contains("Golden Head")) {
- return;
- }
-
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(event.getPlayer().getUniqueId());
-
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- final Player player = event.getPlayer();
-
- event.getPlayer().addPotionEffect(this.regenerationEffect);
- event.getPlayer().addPotionEffect(this.absorbtionEffect);
-
- player.setFoodLevel(Math.min(player.getFoodLevel() + 6, 20));
- }
- }
- }
-
- @EventHandler
- public void onRegenerate(EntityRegainHealthEvent event) {
- if (!(event.getEntity() instanceof Player)) {
- return;
- }
- if (event.getRegainReason() != EntityRegainHealthEvent.RegainReason.SATIATED) {
- return;
- }
-
- final Player player = (Player) event.getEntity();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- final Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());
-
- if (match.getKit().getFlag().equals(Flag.BUILD)) {
- event.setCancelled(true);
- }
- }
- }
-
- @EventHandler
- public void onAsyncPreLogin(AsyncPlayerPreLoginEvent event) {
- this.plugin.getPlayerManager().createPlayerData(event);
- }
-
- private final String centeredTitle = StringUtil.getCentered(CC.GOLD + CC.BOLD + "NA Practice");
- private final String centeredSubTitle = StringUtil.getCentered(CC.GRAY + "Click one of the swords to start fighting!");
-
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event) {
- final Player player = event.getPlayer();
- final PracticeServerType serverType = Practice.getInstance().getCurrentType();
-
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
-
- player.sendMessage(new String[]{
- " ",
- this.centeredTitle,
- this.centeredSubTitle,
- " "
- });
-
- switch (serverType) {
- case PROD_WHITELISTED:
- Practice.getInstance().fetchNitroReward(player).whenComplete((aBoolean, throwable) -> {
- if (throwable != null) {
- throwable.printStackTrace();
- }
-
- final PotPlayer potPlayer = CorePlugin.getInstance()
- .getPlayerManager().getPlayer(player);
-
- if (aBoolean && !potPlayer.getAllPrefixes().contains("Booster")) {
- final Prefix prefix = Prefix.getByName("Booster");
-
- if (prefix != null) {
- potPlayer.getAllPrefixes().add(prefix.getName());
- potPlayer.saveWithoutRemove();
-
- player.sendMessage(ChatColor.GREEN + "You've been given access to the " + Color.translate(prefix.getDisplayName()) + ChatColor.GREEN + " prefix.");
- }
-
- CorePlugin.getInstance().getJedisManager().runCommand(jedis -> {
- jedis.hdel(PracticeConstants.JEDIS_DISCORD_REWARD_CATEGORY, player.getUniqueId().toString());
- });
- }
- });
- case PROD_RELEASE_DAY:
- if (!PracticeConstants.CHANGELOG.isEmpty()) {
- player.sendMessage(CC.DARK_AQUA + CC.BOLD + " NEW FEATURES:");
-
- PracticeConstants.CHANGELOG.forEach(s -> {
- player.sendMessage(CC.GRAY + CC.BOLD + " ■ " + s);
- });
-
- player.sendMessage(" ");
- }
- break;
- }
-
- event.setJoinMessage(null);
- }
-
- @EventHandler
- public void onPlayerQuit(PlayerQuitEvent event) {
- final Player player = event.getPlayer();
- final Party party = this.plugin.getPartyManager().getParty(player.getUniqueId());
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- event.setQuitMessage(null);
-
- if (playerData == null) {
- return;
- }
-
- switch (playerData.getPlayerState()) {
- case FIGHTING:
- this.plugin.getMatchManager().removeFighter(player, playerData, false);
- break;
- case SPECTATING:
- this.plugin.getMatchManager().removeSpectator(player, false);
- break;
- case EDITING:
- this.plugin.getEditorManager().removeEditor(player.getUniqueId());
- break;
- case QUEUE:
- if (party == null) {
- this.plugin.getQueueManager().removePlayerFromQueue(player);
- } else if (this.plugin.getPartyManager().isLeader(player.getUniqueId())) {
- this.plugin.getQueueManager().removePartyFromQueue(party);
- }
- break;
- case FFA:
- this.plugin.getFfaManager().removePlayer(player);
- break;
- }
-
- this.plugin.getTournamentManager().leaveTournament(player);
- this.plugin.getPartyManager().leaveParty(player);
-
- this.plugin.getMatchManager().removeMatchRequests(player.getUniqueId());
- this.plugin.getPartyManager().removePartyInvites(player.getUniqueId());
- this.plugin.getPlayerManager().removePlayerData(player.getUniqueId());
- }
-
- @EventHandler
- public void onPlayerKick(PlayerKickEvent event) {
- final Player player = event.getPlayer();
- final Party party = this.plugin.getPartyManager().getParty(player.getUniqueId());
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData == null) {
- return;
- }
-
- switch (playerData.getPlayerState()) {
- case FIGHTING:
- this.plugin.getMatchManager().removeFighter(player, playerData, false);
- break;
- case SPECTATING:
- this.plugin.getMatchManager().removeSpectator(player, false);
- break;
- case EDITING:
- this.plugin.getEditorManager().removeEditor(player.getUniqueId());
- break;
- case QUEUE:
- if (party == null) {
- this.plugin.getQueueManager().removePlayerFromQueue(player);
- } else if (this.plugin.getPartyManager().isLeader(player.getUniqueId())) {
- this.plugin.getQueueManager().removePartyFromQueue(party);
- }
- break;
- case FFA:
- this.plugin.getFfaManager().removePlayer(player);
- break;
- }
-
- this.plugin.getTournamentManager().leaveTournament(player);
- this.plugin.getPartyManager().leaveParty(player);
-
- this.plugin.getMatchManager().removeMatchRequests(player.getUniqueId());
- this.plugin.getPartyManager().removePartyInvites(player.getUniqueId());
- this.plugin.getPlayerManager().removePlayerData(player.getUniqueId());
- }
-
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- final Player player = event.getPlayer();
- final PotPlayer potPlayer = CorePlugin.getInstance().getPlayerManager().getPlayer(player);
-
- if (potPlayer.isStaffMode()) {
- return;
- }
-
- if (player.getGameMode() == GameMode.CREATIVE) {
- return;
- }
-
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (event.getClickedBlock() != null && playerData.getPlayerState() == PlayerState.SPAWN) {
- event.setCancelled(true);
- return;
- }
-
- if (playerData.getPlayerState() == PlayerState.SPECTATING) {
- event.setCancelled(true);
- }
-
- if (event.getAction().name().endsWith("_BLOCK")) {
- if (event.getClickedBlock().getType().name().contains("SIGN") && event.getClickedBlock().getState() instanceof Sign) {
- final Sign sign = (Sign) event.getClickedBlock().getState();
-
- if (ChatColor.stripColor(sign.getLine(1)).equals("[Soup]")) {
- event.setCancelled(true);
-
- final Inventory inventory = this.plugin.getServer().createInventory(null, 54, CC.DARK_GRAY + "Soup Refill");
-
- for (int i = 0; i < 54; i++) {
- inventory.setItem(i, new ItemStack(Material.MUSHROOM_SOUP));
- }
-
- event.getPlayer().openInventory(inventory);
- }
- }
- if (event.getClickedBlock().getType() == Material.CHEST
- || event.getClickedBlock().getType() == Material.ENDER_CHEST) {
- event.setCancelled(true);
- }
- }
-
- if (event.getAction().name().startsWith("RIGHT_")) {
- final ItemStack item = event.getItem();
- final Party party = this.plugin.getPartyManager().getParty(player.getUniqueId());
-
- switch (playerData.getPlayerState()) {
- case LOADING:
- player.sendMessage(CC.RED + "Please wait until your player data is loaded.");
- break;
- case FIGHTING:
- if (item == null) {
- return;
- }
- Match match = this.plugin.getMatchManager().getMatch(playerData);
-
- switch (item.getType()) {
- case ENDER_PEARL:
- if (match.getMatchState() == MatchState.STARTING) {
- event.setCancelled(true);
- player.sendMessage(CC.RED + "You cannot throw enderpearls right now.");
- player.updateInventory();
- }
- break;
- case ENCHANTED_BOOK:
- Kit kit = match.getKit();
- PlayerInventory inventory = player.getInventory();
-
- int kitIndex = inventory.getHeldItemSlot();
-
- if (kitIndex == 8) {
- kit.applyToPlayer(player);
- player.sendMessage(CC.GREEN + "You've equipped the default " + CC.YELLOW + kit.getName() + CC.GREEN + " loadout.");
- } else {
- Map kits = playerData.getPlayerKits(kit.getName());
- PlayerKit playerKit = kits.get(kitIndex + 1);
-
- if (playerKit != null) {
- playerKit.applyToPlayer(player);
- player.sendMessage(CC.GREEN + "You've equipped the default " + CC.YELLOW + playerKit.getDisplayName() + CC.GREEN + " loadout.");
- }
- }
- break;
- }
- break;
- case SPAWN:
- if (item == null) {
- return;
- }
-
- switch (item.getType()) {
- case DIAMOND_SWORD:
- if (!Practice.getInstance().isRankedEnabled()) {
- player.sendMessage(CC.RED + "Ranked queues are currently disabled.");
- return;
- }
-
- if (!playerData.canPlayRanked() && !player.hasPermission("practice.ranked.bypass")) {
- player.sendMessage(ChatColor.RED + "You need " + playerData.winsUntilRankedUnlocked() + " more wins to join ranked queues.");
- return;
- }
-
- new JoinQueueMenu(QueueType.RANKED).openMenu(player);
- break;
- case IRON_SWORD:
- new JoinQueueMenu(QueueType.UNRANKED).openMenu(player);
- break;
- case BLAZE_POWDER:
- final UUID rematching = this.plugin.getMatchManager().getRematcher(player.getUniqueId());
-
- if (rematching == null) {
- player.sendMessage(CC.RED + "The rematch request has expired.");
- break;
- }
-
- final Player toRematch = this.plugin.getServer().getPlayer(rematching);
-
- if (toRematch != null) {
- if (this.plugin.getMatchManager().getMatchRequest(toRematch.getUniqueId(), player.getUniqueId()) != null) {
- this.plugin.getServer().dispatchCommand(player, "accept " + toRematch.getName());
- } else {
- this.plugin.getServer().dispatchCommand(player, "duel " + toRematch.getName());
- }
- } else {
- player.sendMessage(CC.RED + "That player is now offline.");
- }
- break;
- case GOLD_INGOT:
- new ShopCategoryMenu().openMenu(player);
- break;
- case EYE_OF_ENDER:
- player.sendMessage(CC.RED + "This feature is currently unavailable.");
- event.setCancelled(true);
- break;
- case SKULL_ITEM:
- player.performCommand("party info");
- break;
- case BOOK:
- new KitEditorMainMenu().openMenu(player);
- break;
- case EMERALD:
- new SettingsMenu(player).openMenu(player);
- break;
- case GOLD_AXE:
- if (party != null && !this.plugin.getPartyManager().isLeader(player.getUniqueId())) {
- player.sendMessage(CC.RED + "You're not the leader of this party.");
- return;
- }
-
- new PartyEventsMenu().openMenu(player);
- break;
- case NETHER_STAR:
- if (this.plugin.getPartyManager().getParty(player.getUniqueId()) == null) {
- this.plugin.getPartyManager().createParty(player);
- } else {
- this.plugin.getPartyManager().leaveParty(player);
- }
-
- this.plugin.getFollowManager().stopFollowing(player);
- this.plugin.getTournamentManager().leaveTournament(player);
- break;
- }
- break;
- case QUEUE:
- if (item == null) {
- return;
- }
-
- if (item.getType() == Material.INK_SACK) {
- if (party == null) {
- this.plugin.getQueueManager().removePlayerFromQueue(player);
- } else {
- this.plugin.getQueueManager().removePartyFromQueue(party);
- }
- }
- break;
- case SPECTATING:
- if (item == null) {
- return;
- }
-
- if (item.getType() == Material.NETHER_STAR) {
- if (party == null) {
- this.plugin.getMatchManager().removeSpectator(player, false);
- } else {
- this.plugin.getPartyManager().leaveParty(player);
- }
- }
-
- if (item.getType() == Material.COMPASS) {
- new SpectateMenu().openMenu(player);
- }
-
- if (item.getType() == Material.EMERALD) {
- final Match spectating = this.plugin.getMatchManager()
- .getSpectatingMatch(player.getUniqueId());
-
- if (spectating != null) {
- final Player pvp = Bukkit.getPlayer(spectating.getTeams().get(0).getLeader());
-
- if (pvp != null) {
- PaperLib.teleportAsync(player, pvp.getLocation());
- }
- }
- }
- case EDITING:
- if (event.getClickedBlock() == null) {
- return;
- }
-
- switch (event.getClickedBlock().getType()) {
- case WALL_SIGN:
- case SIGN:
- case SIGN_POST:
- this.plugin.getEditorManager().removeEditor(player.getUniqueId());
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
- break;
- case CHEST:
- final Kit kit = this.plugin.getEditorManager().getEditingKit(player.getUniqueId());
-
- if (kit.getKitEditContents()[0] != null) {
- final Inventory editorInventory = this.plugin.getServer().createInventory(null, 36);
-
- editorInventory.setContents(kit.getContents());
- player.openInventory(editorInventory);
-
- event.setCancelled(true);
- }
- break;
- case ANVIL:
- new KitEditorMenu(Practice.getInstance().getEditorManager().getEditingKit(player.getUniqueId())).openMenu(player);
- event.setCancelled(true);
- break;
- }
-
- break;
- }
- }
- }
-
- @EventHandler
- public void onCraft(CraftItemEvent event) {
- event.setCancelled(true);
- }
-
- @EventHandler
- public void onPlayerDropItem(PlayerDropItemEvent event) {
- final Player player = event.getPlayer();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
- final Material drop = event.getItemDrop().getItemStack().getType();
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- switch (drop) {
- case ENCHANTED_BOOK:
- case DIAMOND_SWORD:
- case IRON_AXE:
- case DIAMOND_SPADE:
- case BOW:
- event.setCancelled(true);
- }
-
- if (!event.isCancelled()) {
- final Match match = this.plugin.getMatchManager().getMatch(event.getPlayer().getUniqueId());
-
- this.plugin.getMatchManager().addDroppedItem(match, event.getItemDrop());
- }
- } else {
- event.setCancelled(true);
- }
- }
-
-
- @EventHandler
- public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
- final Player player = event.getPlayer();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
- final Material drop = event.getItem().getType();
-
- switch (playerData.getPlayerState()) {
- case EVENT:
- case FIGHTING:
- if (drop.getId() == 373) {
- this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, () -> {
- player.setItemInHand(new ItemStack(Material.AIR));
- player.updateInventory();
- }, 1L);
- }
- break;
- }
- }
-
- @EventHandler
- public void onPlayerPickupItem(PlayerPickupItemEvent event) {
- final Player player = event.getPlayer();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData.getPlayerState() == PlayerState.SPECTATING) {
- event.setCancelled(true);
- }
- }
-
- @EventHandler
- public void onPlayerDeath(PlayerDeathEvent event) {
- final Player player = event.getEntity();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
- PlayerUtil.animateDeath(player);
- switch (playerData.getPlayerState()) {
- case FIGHTING:
- this.plugin.getMatchManager().removeFighter(player, playerData, true);
- break;
- case FFA:
- for (ItemStack item : player.getInventory().getContents()) {
- if (item != null && item.getType() == Material.MUSHROOM_SOUP) {
- this.plugin.getFfaManager().getItemTracker().put(player.getWorld().dropItemNaturally(player.getLocation(), item), System.currentTimeMillis());
- }
- }
-
- this.plugin.getFfaManager().getKillStreakTracker().put(player.getUniqueId(), 0);
-
- final StringBuilder deathMessage = new StringBuilder(CC.RED + player.getName() + CC.GRAY + " has been killed" + (player.getKiller() == null ? "." : " by " + CC.GREEN + player.getKiller().getName() + CC.GRAY + "."));
-
- if (player.getKiller() != null) {
- final int ks = this.plugin.getFfaManager().getKillStreakTracker().compute(player.getKiller().getUniqueId(), (k, v) -> (v == null ? 0 : v) + 1);
-
- for (final KillStreak killStreak : this.plugin.getFfaManager().getKillStreaks()) {
- if (killStreak.getStreaks().contains(ks)) {
- killStreak.giveKillStreak(player.getKiller());
-
- deathMessage.append("\n")
- .append(CC.AQUA).append(player.getKiller().getName())
- .append(CC.GRAY).append(" is on a ")
- .append(CC.YELLOW).append(ks)
- .append(CC.GRAY).append(" kill streak!");
-
- break;
- }
- }
- }
-
- for (PlayerData data : this.plugin.getPlayerManager().getAllData()) {
- if (data.getPlayerState() == PlayerState.FFA) {
- final Player ffaPlayer = this.plugin.getServer().getPlayer(data.getUniqueId());
-
- ffaPlayer.sendMessage(deathMessage.toString());
- }
- }
-
- player.getInventory().clear();
-
- Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
- Practice.getInstance().getFfaManager().resetAndAddBack(player);
- }, 10L);
- break;
- }
-
- event.getDrops().clear();
- event.setDroppedExp(0);
- event.setDeathMessage(null);
- PlayerUtil.respawnPlayer(player);
- event.getEntity().setHealth(20);
- }
-
- @EventHandler
- public void onFoodLevelChange(FoodLevelChangeEvent event) {
- final Player player = (Player) event.getEntity();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- final Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());
-
- if (match.getKit().getFlag().equals(Flag.PARKOUR) || match.getKit().getFlag().equals(Flag.SUMO) || match.getKit().getName().contains("Boxing")) {
- event.setCancelled(true);
- }
- } else {
- event.setCancelled(true);
- }
- }
-
- @EventHandler
- public void onProjectileLaunch(ProjectileLaunchEvent event) {
- if (event.getEntity().getShooter() instanceof Player) {
- final Player shooter = (Player) event.getEntity().getShooter();
- final PlayerData shooterData = this.plugin.getPlayerManager().getPlayerData(shooter.getUniqueId());
-
- if (shooterData.getPlayerState() == PlayerState.FIGHTING) {
- final Match match = this.plugin.getMatchManager().getMatch(shooter.getUniqueId());
- match.addEntityToRemove(event.getEntity());
- }
- }
- }
-
- @EventHandler
- public void onProjectileHit(ProjectileHitEvent event) {
- if (event.getEntity().getShooter() instanceof Player) {
- final Player shooter = (Player) event.getEntity().getShooter();
- final PlayerData shooterData = this.plugin.getPlayerManager().getPlayerData(shooter.getUniqueId());
-
- if (shooterData != null) {
- if (shooterData.getPlayerState() == PlayerState.FIGHTING) {
- final Match match = this.plugin.getMatchManager().getMatch(shooter.getUniqueId());
-
- match.removeEntityToRemove(event.getEntity());
-
- if (event.getEntityType() == EntityType.ARROW) {
- event.getEntity().remove();
- }
- }
- }
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/listeners/WorldListener.java b/src/main/java/com/solexgames/practice/listeners/WorldListener.java
deleted file mode 100644
index ebffecb..0000000
--- a/src/main/java/com/solexgames/practice/listeners/WorldListener.java
+++ /dev/null
@@ -1,267 +0,0 @@
-package com.solexgames.practice.listeners;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.arena.type.StandaloneArena;
-import com.solexgames.practice.flags.Flag;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.MatchState;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.runnable.BlockRemoveRunnable;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Item;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-import org.bukkit.event.block.*;
-import org.bukkit.event.hanging.HangingBreakEvent;
-import org.bukkit.event.player.PlayerBucketEmptyEvent;
-import org.bukkit.event.weather.WeatherChangeEvent;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.UUID;
-
-public class WorldListener implements Listener {
-
- private final Practice plugin = Practice.getInstance();
-
- @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
- public void onBlockBreak(BlockBreakEvent event) {
- Player player = event.getPlayer();
- PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData == null) {
- this.plugin.getLogger().warning(player.getName() + "'s player data is null");
- event.setCancelled(true);
- return;
- }
-
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());
-
- if (match.getKit().getFlag().equals(Flag.BUILD)) {
- if (!match.getPlacedBlockLocations().contains(event.getBlock().getLocation())) {
- event.setCancelled(true);
- }
- } else if (match.getKit().getFlag().equals(Flag.SPLEEF)) {
- double minX = match.getStandaloneArena().getMin().getX();
- double minZ = match.getStandaloneArena().getMin().getZ();
- double maxX = match.getStandaloneArena().getMax().getX();
- double maxZ = match.getStandaloneArena().getMax().getZ();
- if (minX > maxX) {
- double lastMinX = minX;
- minX = maxX;
- maxX = lastMinX;
- }
-
- if (minZ > maxZ) {
- double lastMinZ = minZ;
- minZ = maxZ;
- maxZ = lastMinZ;
- }
- if (match.getMatchState() == MatchState.STARTING) {
- event.setCancelled(true);
- return;
- }
- if (player.getLocation().getX() >= minX && player.getLocation().getX() <= maxX
- && player.getLocation().getZ() >= minZ && player.getLocation().getZ() <= maxZ) {
- if (event.getBlock().getType() == Material.SNOW_BLOCK && player.getItemInHand().getType() == Material.DIAMOND_SPADE) {
- Location blockLocation = event.getBlock().getLocation();
- event.setCancelled(true);
- match.addOriginalBlockChange(event.getBlock().getState());
- Set
- items = new HashSet<>();
- event.getBlock().getDrops().forEach(itemStack -> items.add(player.getWorld().dropItemNaturally(blockLocation.add(0.0D, 0.25D, 0.0D), itemStack)));
- this.plugin.getMatchManager().addDroppedItems(match, items);
- event.getBlock().setType(Material.AIR);
- } else {
- event.setCancelled(true);
- }
- } else {
- event.setCancelled(true);
- }
- } else {
- event.setCancelled(true);
- }
- } else {
- if (!Practice.getInstance().getBuilderSet().contains(player)) {
- event.setCancelled(true);
- }
- }
- }
-
- @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
- public void onBlockPlace(BlockPlaceEvent event) {
- final Player player = event.getPlayer();
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData == null) {
- event.setCancelled(true);
- return;
- }
-
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- final Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());
-
- if (match == null) {
- event.setCancelled(true);
- return;
- }
-
- if (!match.getKit().getFlag().equals(Flag.BUILD)) {
- if (match.getKit().getFlag().equals(Flag.STICK_FIGHT)) {
- event.setCancelled(false);
-
- new BlockRemoveRunnable(event.getBlock().getLocation());
- return;
- }
-
- event.setCancelled(true);
- } else {
- double minX = match.getStandaloneArena().getMin().getX();
- double minZ = match.getStandaloneArena().getMin().getZ();
- double maxX = match.getStandaloneArena().getMax().getX();
- double maxZ = match.getStandaloneArena().getMax().getZ();
- if (minX > maxX) {
- double lastMinX = minX;
- minX = maxX;
- maxX = lastMinX;
- }
-
- if (minZ > maxZ) {
- double lastMinZ = minZ;
- minZ = maxZ;
- maxZ = lastMinZ;
- }
- if (player.getLocation().getX() >= minX && player.getLocation().getX() <= maxX
- && player.getLocation().getZ() >= minZ && player.getLocation().getZ() <= maxZ) {
- if ((player.getLocation().getY() - match.getStandaloneArena().getPositionOne().getY()) < 5.0D && event.getBlockPlaced() != null) {
- match.addPlacedBlockLocation(event.getBlockPlaced().getLocation());
- } else {
- event.setCancelled(true);
- }
- } else {
- event.setCancelled(true);
- }
- }
- return;
- }
-
- if (!this.plugin.getBuilderSet().contains(player)) {
- event.setCancelled(true);
- }
- }
-
- @EventHandler
- public void onBucketEmpty(PlayerBucketEmptyEvent event) {
- Player player = event.getPlayer();
-
- PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
- if (playerData == null) {
- this.plugin.getLogger().warning(player.getName() + "'s player data is null");
- event.setCancelled(true);
- return;
- }
- if (playerData.getPlayerState() == PlayerState.FIGHTING) {
- Match match = this.plugin.getMatchManager().getMatch(player.getUniqueId());
- if (!match.getKit().getFlag().equals(Flag.BUILD)) {
- event.setCancelled(true);
- } else {
- double minX = match.getStandaloneArena().getMin().getX();
- double minZ = match.getStandaloneArena().getMin().getZ();
- double maxX = match.getStandaloneArena().getMax().getX();
- double maxZ = match.getStandaloneArena().getMax().getZ();
- if (minX > maxX) {
- double lastMinX = minX;
- minX = maxX;
- maxX = lastMinX;
- }
-
- if (minZ > maxZ) {
- double lastMinZ = minZ;
- minZ = maxZ;
- maxZ = lastMinZ;
- }
- if (player.getLocation().getX() >= minX && player.getLocation().getX() <= maxX
- && player.getLocation().getZ() >= minZ && player.getLocation().getZ() <= maxZ) {
- if ((player.getLocation().getY() - match.getStandaloneArena().getPositionOne().getY()) < 5.0D) {
- Block block = event.getBlockClicked().getRelative(event.getBlockFace());
- match.addPlacedBlockLocation(block.getLocation());
- } else {
- event.setCancelled(true);
- }
- } else {
- event.setCancelled(true);
- }
- }
- return;
- }
-
- if (!this.plugin.getBuilderSet().contains(player)) {
- event.setCancelled(true);
- }
- }
-
- @EventHandler
- public void onBlockFromTo(BlockFromToEvent event) {
- if (event.getToBlock() == null) {
- return;
- }
- for (StandaloneArena arena : this.plugin.getArenaManager().getArenaMatchUUIDs().keySet()) {
- double minX = arena.getMin().getX();
- double minZ = arena.getMin().getZ();
- double maxX = arena.getMax().getX();
- double maxZ = arena.getMax().getZ();
- if (minX > maxX) {
- double lastMinX = minX;
- minX = maxX;
- maxX = lastMinX;
- }
-
- if (minZ > maxZ) {
- double lastMinZ = minZ;
- minZ = maxZ;
- maxZ = lastMinZ;
- }
- if (event.getToBlock().getX() >= minX && event.getToBlock().getZ() >= minZ
- && event.getToBlock().getX() <= maxX && event.getToBlock().getZ() <= maxZ) {
- UUID matchUUID = this.plugin.getArenaManager().getArenaMatchUUID(arena);
- Match match = this.plugin.getMatchManager().getMatchFromUUID(matchUUID);
-
- match.addPlacedBlockLocation(event.getToBlock().getLocation());
- break;
- }
- }
- }
-
- @EventHandler
- public void onWeatherChange(WeatherChangeEvent event) {
- if (event.toWeatherState()) {
- event.setCancelled(true);
- }
- }
-
- @EventHandler
- public void onLeavesDecay(LeavesDecayEvent event) {
- event.setCancelled(true);
- }
-
- @EventHandler
- public void onHangingBreak(HangingBreakEvent event) {
- event.setCancelled(true);
- }
-
- @EventHandler
- public void onBlockBurn(BlockBurnEvent event) {
- event.setCancelled(true);
- }
-
- @EventHandler
- public void onBlockSpread(BlockSpreadEvent event) {
- event.setCancelled(true);
- }
-
-}
diff --git a/src/main/java/com/solexgames/practice/location/WrappedLocation.java b/src/main/java/com/solexgames/practice/location/WrappedLocation.java
deleted file mode 100644
index f44cc26..0000000
--- a/src/main/java/com/solexgames/practice/location/WrappedLocation.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.solexgames.practice.location;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-
-import java.util.concurrent.CompletableFuture;
-
-/**
- * @author GrowlyX
- * @since 8/6/2021
- */
-
-public interface WrappedLocation {
-
- double getX();
-
- double getY();
-
- double getZ();
-
- float getYaw();
-
- float getPitch();
-
- String getWorldName();
-
- CompletableFuture teleport(Player player);
-
- default World getWorld() {
- return Bukkit.getWorld(getWorldName());
- }
-
- default Location toBukkitLocation() {
- return new Location(getWorld(), getX(), getY(), getZ(), getYaw(), getPitch());
- }
-
-}
diff --git a/src/main/java/com/solexgames/practice/location/impl/LocationImpl.java b/src/main/java/com/solexgames/practice/location/impl/LocationImpl.java
deleted file mode 100644
index 7bc9a43..0000000
--- a/src/main/java/com/solexgames/practice/location/impl/LocationImpl.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.solexgames.practice.location.impl;
-
-import com.solexgames.practice.location.WrappedLocation;
-import lombok.Data;
-
-/**
- * @author GrowlyX
- * @since 8/6/2021
- */
-
-@Data
-public abstract class LocationImpl implements WrappedLocation {
-
- private final double x, y, z;
- private final float yaw, pitch;
- private final String worldName;
-
-}
diff --git a/src/main/java/com/solexgames/practice/location/impl/impl/AsyncLocation.java b/src/main/java/com/solexgames/practice/location/impl/impl/AsyncLocation.java
deleted file mode 100644
index 2ace8d1..0000000
--- a/src/main/java/com/solexgames/practice/location/impl/impl/AsyncLocation.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.solexgames.practice.location.impl.impl;
-
-import com.solexgames.core.CorePlugin;
-import com.solexgames.practice.location.impl.LocationImpl;
-import com.solexgames.practice.util.old.DeprecatedLocation;
-import io.papermc.lib.PaperLib;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-
-import java.util.concurrent.CompletableFuture;
-
-public class AsyncLocation extends LocationImpl {
-
- public AsyncLocation(double x, double y, double z, float yaw, float pitch, String worldName) {
- super(x, y, z, yaw, pitch, worldName);
- }
-
- @Override
- public CompletableFuture teleport(Player player) {
- final CompletableFuture future = new CompletableFuture<>();
- final Location location = toBukkitLocation();
-
- PaperLib.teleportAsync(player, location).whenComplete((aBoolean, throwable) -> future.complete(null));
-
- return future;
- }
-
- public String toJson() {
- return CorePlugin.GSON.toJson(this);
- }
-
- public static AsyncLocation of(Location location) {
- return new AsyncLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch(), location.getWorld().getName());
- }
-
- public static AsyncLocation of(String string) {
- try {
- final AsyncLocation asyncLocation = CorePlugin.GSON.fromJson(string, AsyncLocation.class);
-
- if (asyncLocation == null) {
- final Location location = DeprecatedLocation.stringToLocation(string).toBukkitLocation();
-
- return AsyncLocation.of(location);
- } else {
- return asyncLocation;
- }
- } catch (Exception ignored) {
- final Location location = DeprecatedLocation.stringToLocation(string).toBukkitLocation();
-
- return AsyncLocation.of(location);
- }
- }
-
-}
diff --git a/src/main/java/com/solexgames/practice/managers/ArenaManager.java b/src/main/java/com/solexgames/practice/managers/ArenaManager.java
deleted file mode 100644
index b5f9151..0000000
--- a/src/main/java/com/solexgames/practice/managers/ArenaManager.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.arena.Arena;
-import com.solexgames.practice.arena.type.StandaloneArena;
-import com.solexgames.practice.flags.Flag;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import com.solexgames.practice.util.FlatFile;
-import lombok.Getter;
-import lombok.Setter;
-import org.bukkit.Material;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
-
-import java.util.*;
-import java.util.concurrent.ThreadLocalRandom;
-
-@Getter
-@Setter
-public class ArenaManager {
-
- private final Practice plugin = Practice.getInstance();
- private final FlatFile config = new FlatFile("arenas", this.plugin);
-
- private final Map arenas = new HashMap<>();
- private final Map arenaMatchUUIDs = new HashMap<>();
-
- private int generatingArenaTask;
-
- public ArenaManager() {
- this.loadArenas();
- }
-
- private void loadArenas() {
- FileConfiguration fileConfig = config.getConfig();
- ConfigurationSection arenaSection = fileConfig.getConfigurationSection("arenas");
-
- if (arenaSection == null) {
- return;
- }
-
- arenaSection.getKeys(false).forEach(name -> {
- String a = arenaSection.getString(name + ".a");
- String b = arenaSection.getString(name + ".b");
- String min = arenaSection.getString(name + ".min");
- String max = arenaSection.getString(name + ".max");
- Material icon = arenaSection.getString(name + ".icon") == null ? Material.PAPER : Material.valueOf(arenaSection.getString(name + ".icon"));
-
- AsyncLocation locA = AsyncLocation.of(a);
- AsyncLocation locB = AsyncLocation.of(b);
- AsyncLocation locMin = AsyncLocation.of(min);
- AsyncLocation locMax = AsyncLocation.of(max);
-
- List standaloneArenas = new ArrayList<>();
-
- ConfigurationSection saSection = arenaSection.getConfigurationSection(name + ".standaloneArenas");
-
- if (saSection != null) {
- saSection.getKeys(false).forEach(id -> {
- String saA = saSection.getString(id + ".a");
- String saB = saSection.getString(id + ".b");
- String saMin = saSection.getString(id + ".min");
- String saMax = saSection.getString(id + ".max");
-
- AsyncLocation locSaA = AsyncLocation.of(saA);
- AsyncLocation locSaB = AsyncLocation.of(saB);
- AsyncLocation locSaMin = AsyncLocation.of(saMin);
- AsyncLocation locSaMax = AsyncLocation.of(saMax);
-
- standaloneArenas.add(new StandaloneArena(locSaA, locSaB, locSaMin, locSaMax));
- });
- }
-
- final boolean enabled = arenaSection.getBoolean(name + ".enabled", false);
- final Flag arenaFlag = Flag.valueOf(arenaSection.getString(name + ".flag", "DEFAULT"));
-
- final Arena arena = new Arena(
- name,
- standaloneArenas,
- new ArrayList<>(standaloneArenas),
- locA, locB,
- locMin, locMax,
- enabled,
- arenaFlag,
- icon
- );
-
- this.arenas.put(name, arena);
- });
- }
-
- public void saveArenas() {
- final FileConfiguration fileConfig = this.config.getConfig();
-
- this.arenas.forEach((arenaName, arena) -> {
- try {
- final String a = arena.getPositionOne().toJson();
- final String b = arena.getPositionTwo().toJson();
- final String min = arena.getMin().toJson();
- final String max = arena.getMax().toJson();
-
- final String arenaRoot = "arenas." + arenaName;
-
- fileConfig.set(arenaRoot + ".a", a);
- fileConfig.set(arenaRoot + ".b", b);
- fileConfig.set(arenaRoot + ".min", min);
- fileConfig.set(arenaRoot + ".max", max);
- fileConfig.set(arenaRoot + ".icon", arena.getIcon() != null ? arena.getIcon().name() : Material.PAPER.name());
- fileConfig.set(arenaRoot + ".enabled", arena.isEnabled());
- fileConfig.set(arenaRoot + ".flag", arena.getFlag().name());
- fileConfig.set(arenaRoot + ".standaloneArenas", null);
-
- int i = 0;
- if (arena.getStandaloneArenas() != null) {
- for (StandaloneArena saArena : arena.getStandaloneArenas()) {
- String saA = saArena.getPositionOne().toJson();
- String saB = saArena.getPositionTwo().toJson();
- String saMin = saArena.getMin().toJson();
- String saMax = saArena.getMax().toJson();
-
- String standAloneRoot = arenaRoot + ".standaloneArenas." + i;
-
- fileConfig.set(standAloneRoot + ".a", saA);
- fileConfig.set(standAloneRoot + ".b", saB);
- fileConfig.set(standAloneRoot + ".min", saMin);
- fileConfig.set(standAloneRoot + ".max", saMax);
-
- i++;
- }
- }
- } catch (Exception ignored) {
- System.out.println("[Practice] [Arena] Failed to save arena: " + arenaName);
- }
- });
-
- this.config.save();
- }
-
- public void reloadArenas() {
- this.saveArenas();
-
- this.arenas.clear();
-
- this.loadArenas();
- }
-
- public void createArena(String name) {
- this.arenas.put(name, new Arena(name));
- }
-
- public void deleteArena(String name) {
- this.arenas.remove(name);
- }
-
- public Arena getArena(String name) {
- return this.arenas.get(name);
- }
-
- public Arena getRandomArena(Kit kit) {
- final List pairedArenas = new ArrayList<>();
-
- for (final Arena arena : this.arenas.values()) {
- if (Practice.getInstance().isKitPairedWithArena(kit, arena)) {
- pairedArenas.add(arena);
- }
- }
-
- if (pairedArenas.size() == 0) {
- return null;
- }
-
- return pairedArenas.get(ThreadLocalRandom.current().nextInt(pairedArenas.size()));
- }
-
- public void removeArenaMatchUUID(StandaloneArena arena) {
- this.arenaMatchUUIDs.remove(arena);
- }
-
- public UUID getArenaMatchUUID(StandaloneArena arena) {
- return this.arenaMatchUUIDs.get(arena);
- }
-
- public void setArenaMatchUUID(StandaloneArena arena, UUID matchUUID) {
- this.arenaMatchUUIDs.put(arena, matchUUID);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/ChunkManager.java b/src/main/java/com/solexgames/practice/managers/ChunkManager.java
deleted file mode 100644
index 5e4c6a9..0000000
--- a/src/main/java/com/solexgames/practice/managers/ChunkManager.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.arena.Arena;
-import com.solexgames.practice.arena.type.StandaloneArena;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import io.papermc.lib.PaperLib;
-import lombok.Getter;
-
-public class ChunkManager {
-
- private final Practice plugin = Practice.getInstance();
-
- @Getter
- private boolean chunksLoaded;
-
- public ChunkManager() {
- this.plugin.getServer().getScheduler().runTaskLater(this.plugin, this::loadChunks, 1L);
- }
-
- private void loadChunks() {
- this.plugin.getLogger().info("Loading chunks for important locations...");
-
- final AsyncLocation spawnMin = this.plugin.getSpawnManager().fetchSingleLocation("spawn-min").orElse(null);
- final AsyncLocation spawnMax = this.plugin.getSpawnManager().fetchSingleLocation("spawn-max").orElse(null);
-
- this.loadChunkFromCoordinates(spawnMin, spawnMax);
-
- final AsyncLocation editorMin = this.plugin.getSpawnManager().fetchSingleLocation("editor-min").orElse(null);
- final AsyncLocation editorMax = this.plugin.getSpawnManager().fetchSingleLocation("editor-max").orElse(null);
-
- this.loadChunkFromCoordinates(editorMin, editorMax);
-
- final AsyncLocation sumoMin = this.plugin.getSpawnManager().fetchSingleLocation("sumo-min").orElse(null);
- final AsyncLocation sumoMax = this.plugin.getSpawnManager().fetchSingleLocation("sumo-max").orElse(null);
-
- this.loadChunkFromCoordinates(sumoMin, sumoMax);
-
- for (final Arena arena : this.plugin.getArenaManager().getArenas().values()) {
- this.loadChunkFromCoordinates(arena.getMin(), arena.getMax());
-
- for (final StandaloneArena saArena : arena.getStandaloneArenas()) {
- this.loadChunkFromCoordinates(saArena.getMin(), saArena.getMax());
- }
- }
-
- this.chunksLoaded = true;
-
- this.plugin.getLogger().info("Finished loading all the chunks!");
- }
-
- private void loadChunkFromCoordinates(AsyncLocation spawnMin, AsyncLocation spawnMax) {
- if (spawnMin != null && spawnMax != null) {
- int spawnMinX = spawnMin.toBukkitLocation().getBlockX() >> 4;
- int spawnMinZ = spawnMin.toBukkitLocation().getBlockZ() >> 4;
- int spawnMaxX = spawnMax.toBukkitLocation().getBlockX() >> 4;
- int spawnMaxZ = spawnMax.toBukkitLocation().getBlockZ() >> 4;
-
- if (spawnMinX > spawnMaxX) {
- int lastSpawnMinX = spawnMinX;
- spawnMinX = spawnMaxX;
- spawnMaxX = lastSpawnMinX;
- }
-
- if (spawnMinZ > spawnMaxZ) {
- int lastSpawnMinZ = spawnMinZ;
- spawnMinZ = spawnMaxZ;
- spawnMaxZ = lastSpawnMinZ;
- }
-
- for (int x = spawnMinX; x <= spawnMaxX; x++) {
- for (int z = spawnMinZ; z <= spawnMaxZ; z++) {
- PaperLib.getChunkAtAsync(spawnMin.getWorld(), x, z);
- }
- }
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/EditorManager.java b/src/main/java/com/solexgames/practice/managers/EditorManager.java
deleted file mode 100644
index 6b5b571..0000000
--- a/src/main/java/com/solexgames/practice/managers/EditorManager.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.PlayerUtil;
-import io.papermc.lib.PaperLib;
-import org.bukkit.entity.Player;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-
-public class EditorManager {
-
- private final Practice plugin = Practice.getInstance();
- private final Map editing = new HashMap<>();
-
- public void addEditor(Player player, Kit kit) {
- final Optional asyncLocationOptional = this.plugin
- .getSpawnManager().fetchSingleLocation("editor");
-
- asyncLocationOptional.ifPresent(asyncLocation -> {
- this.editing.put(player.getUniqueId(), kit);
-
- PlayerUtil.clearPlayer(player);
- asyncLocation.teleport(player);
-
- player.getInventory().setContents(kit.getContents());
-
- player.sendMessage(new String[]{
- Color.SECONDARY_COLOR + "You're currently editing the " + Color.MAIN_COLOR + kit.getName() + Color.SECONDARY_COLOR + " kit!",
- CC.GRAY + CC.ITALIC + "Armor is applied automatically. Abuse of glitches automatically result in a ban."
- });
- });
- }
-
- public void removeEditor(UUID editor) {
- this.editing.remove(editor);
- }
-
- public Kit getEditingKit(UUID editor) {
- return this.editing.get(editor);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/EventManager.java b/src/main/java/com/solexgames/practice/managers/EventManager.java
deleted file mode 100644
index defebd5..0000000
--- a/src/main/java/com/solexgames/practice/managers/EventManager.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.events.Event;
-import com.solexgames.practice.events.EventState;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import lombok.Setter;
-import org.bukkit.Bukkit;
-import org.bukkit.GameMode;
-import org.bukkit.entity.Player;
-
-import java.util.*;
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * @author GrowlyX
- * @since 8/14/2021
- */
-
-@Setter
-public class EventManager {
-
- private final List> events = Arrays.asList(
-// new SumoEvent()
- );
-
- private final HashMap> spectators = new HashMap<>();
-
- private long cooldown;
-
-// public Event> getByName(String name) {
-// return this.events.stream()
-// .filter(event -> event.getName().equalsIgnoreCase(name))
-// .findFirst().orElse(null);
-// }
-//
-// public void hostEvent(Event> event, Player host) {
-// event.setState(EventState.WAITING);
-// event.setHost(host);
-//
-// event.startCountdown();
-// }
-
- public void addSpectatorSumo(Player player, PlayerData playerData/*, SumoEvent event*/) {
-// this.addSpectator(player, playerData, event);
-
-// if (event.getSpawnLocations().size() == 1) {
-// player.teleport(event.getSpawnLocations().get(0).toBukkitLocation());
-// } else {
-// List spawnLocations = new ArrayList<>(event.getSpawnLocations());
-// player.teleport(spawnLocations.remove(ThreadLocalRandom.current().nextInt(spawnLocations.size())).toBukkitLocation());
-// }
-//
-// for (Player eventPlayer : event.getBukkitPlayers()) {
-// player.showPlayer(eventPlayer);
-// }
-
- player.setGameMode(GameMode.ADVENTURE);
-
- player.setAllowFlight(true);
- player.setFlying(true);
- }
-
- private void addSpectator(Player player, PlayerData playerData, Event> event) {
- playerData.setPlayerState(PlayerState.SPECTATING);
- this.spectators.put(player.getUniqueId(), event);
-
- player.getInventory().setContents(Practice.getInstance().getItemManager().getSpecItems());
- player.updateInventory();
-
- Bukkit.getOnlinePlayers().forEach(online -> {
- online.hidePlayer(player);
- player.hidePlayer(online);
- });
- }
-
- public void removeSpectator(Player player) {
- this.spectators.remove(player.getUniqueId());
-
-// if (Practice.getInstance().getEventManager().getEventPlaying(player) != null) {
-// Practice.getInstance().getEventManager().getEventPlaying(player).getPlayers().remove(player.getUniqueId());
-// }
-
- Practice.getInstance().getPlayerManager().sendToSpawnAndReset(player);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/FollowManager.java b/src/main/java/com/solexgames/practice/managers/FollowManager.java
deleted file mode 100644
index 730a623..0000000
--- a/src/main/java/com/solexgames/practice/managers/FollowManager.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.core.CorePlugin;
-import com.solexgames.core.player.PotPlayer;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.util.CC;
-import io.papermc.lib.PaperLib;
-import org.bukkit.entity.Player;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * @author GrowlyX
- * @since 7/10/2021
- */
-
-public class FollowManager {
-
- public List getPlayerWhoIsFollowingPlayer(Player player) {
- return Practice.getInstance().getPlayerManager().getAllData().stream()
- .filter(playerData -> playerData.getFollowing() != null && playerData.getFollowing().equals(player))
- .collect(Collectors.toList());
- }
-
- public void stopFollowing(Player player) {
- final PlayerData playerData = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData.getFollowing() != null) {
- Practice.getInstance().getPlayerManager().sendToSpawnAndReset(player);
- player.sendMessage(CC.YELLOW + "You've stopped following " + playerData.getFollowing().getDisplayName() + CC.YELLOW + ".");
-
- playerData.setFollowing(null);
- }
- }
-
- public void followPlayer(Player player, Player target) {
- final PlayerData playerData = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
- final PlayerData targetData = Practice.getInstance().getPlayerManager().getPlayerData(target.getUniqueId());
-
- if (this.getPlayerWhoIsFollowingPlayer(target).contains(playerData)) {
- player.sendMessage(CC.RED + "Error: You're already following " + CC.YELLOW + target.getName() + CC.RED + ".");
- return;
- }
-
- if (playerData.getFollowing() != null) {
- player.sendMessage(CC.RED + "Error: You're already following " + CC.YELLOW + playerData.getFollowing().getName() + CC.RED + ".");
- return;
- }
-
- player.setAllowFlight(true);
- player.setFlying(true);
-
- switch (targetData.getPlayerState()) {
- case SPAWN:
- final PotPlayer potPlayer = CorePlugin.getInstance().getPlayerManager().getPlayer(player);
-
- if (potPlayer.isStaffMode()) {
- player.getInventory().setItem(4, ItemManager.LEAVE_FOLLOW);
- } else {
- player.getInventory().setContents(Practice.getInstance().getItemManager().getSpecItems());
- }
-
- player.updateInventory();
-
- Practice.getInstance().getEntityHider().showEntity(player, target);
- PaperLib.teleportAsync(player, target.getLocation());
- break;
- case FIGHTING:
- Practice.getInstance().getMatchManager().addSpectator(player, playerData, target, Practice.getInstance().getMatchManager().getMatch(targetData));
- break;
- }
-
- playerData.setFollowing(target);
-
- player.sendMessage(CC.YELLOW + "You're now following " + target.getDisplayName() + CC.YELLOW + ".");
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/FunManager.java b/src/main/java/com/solexgames/practice/managers/FunManager.java
deleted file mode 100644
index 2b5e610..0000000
--- a/src/main/java/com/solexgames/practice/managers/FunManager.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.practice.effects.DeathEffect;
-import com.solexgames.practice.effects.impl.BloodDeathEffect;
-import com.solexgames.practice.effects.impl.ExplosionDeathEffect;
-import com.solexgames.practice.effects.impl.LightningDeathEffect;
-import com.solexgames.practice.message.KillMessage;
-import com.solexgames.practice.message.impl.DefaultDeathMessage;
-import com.solexgames.practice.message.impl.GamerKillMessages;
-import com.solexgames.practice.message.impl.KitchenKillMessages;
-import com.solexgames.practice.message.impl.NerdyKillMessages;
-import lombok.Getter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author GrowlyX
- * @since 5/26/2021
- */
-
-@Getter
-public class FunManager {
-
- private final List effectList = new ArrayList<>();
- private final List messageList = new ArrayList<>();
-
- private final KillMessage defKillMessage = new DefaultDeathMessage();
- private final DeathEffect defDeathEffect = new LightningDeathEffect();
-
- public void setup() {
- this.effectList.add(new LightningDeathEffect());
- this.effectList.add(new ExplosionDeathEffect());
- this.effectList.add(new BloodDeathEffect());
-
- this.messageList.add(new GamerKillMessages());
- this.messageList.add(new NerdyKillMessages());
- this.messageList.add(new KitchenKillMessages());
- this.messageList.add(new DefaultDeathMessage());
- }
-
- public DeathEffect getByName(String name) {
- return this.effectList.stream()
- .filter(deathEffect -> deathEffect.getName().equalsIgnoreCase(name))
- .findFirst().orElse(this.defDeathEffect);
- }
-
- public KillMessage getMessageByName(String name) {
- return this.messageList.stream()
- .filter(deathEffect -> deathEffect.getName().equalsIgnoreCase(name))
- .findFirst().orElse(this.defKillMessage);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/ItemManager.java b/src/main/java/com/solexgames/practice/managers/ItemManager.java
deleted file mode 100644
index 42514ec..0000000
--- a/src/main/java/com/solexgames/practice/managers/ItemManager.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.ItemUtil;
-import lombok.Getter;
-import org.bukkit.Material;
-import org.bukkit.enchantments.Enchantment;
-import org.bukkit.inventory.ItemStack;
-
-@Getter
-public class ItemManager {
-
- public static final ItemStack LEAVE_SPEC = ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Leave Spectator" + CC.GRAY + " (Right Click)");
- public static final ItemStack LEAVE_FOLLOW = ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Stop Following" + CC.GRAY + " (Right Click)");
- public static final ItemStack SHOP_ITEM = ItemUtil.createItem(Material.GOLD_INGOT, CC.GOLD + "Shop" + CC.GRAY + " (Right Click)");
-
- private final ItemStack[] spawnItems;
- private final ItemStack[] queueItems;
- private final ItemStack[] partyItems;
- private final ItemStack[] partyNonLeaderItems;
- private final ItemStack[] tournamentItems;
- private final ItemStack[] eventItems;
- private final ItemStack[] specItems;
- private final ItemStack[] boxingItems;
- private final ItemStack[] stickFightItems;
- private final ItemStack[] partySpecItems;
-
- private final ItemStack defaultBook;
-
- public ItemManager() {
- this.spawnItems = new ItemStack[]{
- ItemUtil.createItem(Material.IRON_SWORD, CC.GOLD + "Join Unranked Matchmaking" + CC.GRAY + " (Right Click)"),
- ItemUtil.createItem(Material.DIAMOND_SWORD, CC.GOLD + "Join Ranked Matchmaking" + CC.GRAY + " (Right Click)"),
- ItemUtil.createItem(Material.NETHER_STAR, CC.GOLD + "Create a Party" + CC.GRAY + " (Right Click)"),
- null,
- ItemUtil.createItem(Material.GOLD_INGOT, CC.GOLD + "Shop" + CC.GRAY + " (Right Click)"),
- null,
- ItemUtil.createItem(Material.EYE_OF_ENDER, CC.GOLD + "Daily Challenges" + CC.GRAY + " (Right Click)"),
- ItemUtil.createItem(Material.BOOK, CC.GOLD + "Kit Editor" + CC.GRAY + " (Right Click)"),
- ItemUtil.createItem(Material.EMERALD, CC.GOLD + "Settings" + CC.GRAY + " (Right Click)")
- };
- this.queueItems = new ItemStack[]{
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- new ItemBuilder(Material.INK_SACK)
- .setDurability(1)
- .setDisplayName(CC.RED + "Leave Queue" + CC.GRAY + " (Right Click)")
- .create(),
- };
- this.specItems = new ItemStack[]{
- ItemUtil.createItem(Material.COMPASS, CC.RED + "Spectate a Match" + CC.GRAY + " (Right Click)"),
- null,
- null,
- null,
- ItemUtil.createItem(Material.EMERALD, CC.RED + "Teleport to last PvP" + CC.GRAY + " (Right Click)"),
- null,
- null,
- null,
- ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Leave Spectator" + CC.GRAY + " (Right Click)"),
- };
- this.partySpecItems = new ItemStack[]{
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Leave Party" + CC.GRAY + " (Right Click)"),
- };
- this.tournamentItems = new ItemStack[]{
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Leave Tournament" + CC.GRAY + " (Right Click)"),
- };
- this.eventItems = new ItemStack[]{
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Leave Event" + CC.GRAY + " (Right Click)"),
- };
- this.partyItems = new ItemStack[]{
- ItemUtil.createItem(Material.GOLD_AXE, CC.GOLD + "Party Events" + CC.GRAY + " (Right Click)"),
- ItemUtil.createItem(Material.SKULL_ITEM, CC.GOLD + "Party Information" + CC.GRAY + " (Right Click)"),
- null,
- null,
- null,
- null,
- null,
- ItemUtil.createItem(Material.BOOK, CC.GOLD + "Edit Kits" + CC.GRAY + " (Right Click)"),
- ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Leave Party" + CC.GRAY + " (Right Click)")
- };
- this.partyNonLeaderItems = new ItemStack[]{
- ItemUtil.createItem(Material.SKULL_ITEM, CC.GOLD + "Party Information" + CC.GRAY + " (Right Click)"),
- ItemUtil.createItem(Material.BOOK, CC.GOLD + "Edit Kits" + CC.GRAY + " (Right Click)"),
- null,
- null,
- null,
- null,
- null,
- null,
- ItemUtil.createItem(Material.NETHER_STAR, CC.RED + "Leave Party" + CC.GRAY + " (Right Click)")
- };
- this.boxingItems = new ItemStack[]{
- new ItemBuilder(Material.DIAMOND_SWORD)
- .setDisplayName(Color.MAIN_COLOR + CC.GOLD + "Boxing Sword")
- .setEnchant(Enchantment.DAMAGE_ALL, 2)
- .setUnbreakable(true)
- .create(),
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- };
- this.stickFightItems = new ItemStack[]{
- new com.solexgames.practice.util.ItemBuilder(Material.STICK)
- .enchantment(Enchantment.KNOCKBACK, 1)
- .unbreakable()
- .build(),
- new ItemBuilder(Material.SHEARS)
- .setUnbreakable(true)
- .create(),
- new ItemBuilder(Material.WOOL)
- .setDurability(1)
- .setAmount(5)
- .create(),
- null,
- null,
- null,
- null,
- null,
- null,
- };
-
- this.defaultBook = ItemUtil.createItem(Material.ENCHANTED_BOOK, CC.GOLD + "Default Kit " + CC.GRAY + "(Click to Equip)");
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/KitManager.java b/src/main/java/com/solexgames/practice/managers/KitManager.java
deleted file mode 100644
index fdded6f..0000000
--- a/src/main/java/com/solexgames/practice/managers/KitManager.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.flags.Flag;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.util.FlatFile;
-import lombok.Getter;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.*;
-
-@Getter
-public class KitManager {
-
- private final Practice plugin = Practice.getInstance();
-
- private final Map kits = new HashMap<>();
- private final List rankedKits = new ArrayList<>();
-
- private final FlatFile config = new FlatFile("kits", this.plugin);
-
- public KitManager() {
- this.loadKits();
-
- this.kits.entrySet().stream()
- .filter(kit -> kit.getValue().isEnabled() && kit.getValue().isRanked())
- .forEach(kit -> this.rankedKits.add(kit.getKey()));
- }
-
- private void loadKits() {
- final ConfigurationSection kitSection = this.config.getConfig().getConfigurationSection("kits");
-
- if (kitSection == null) {
- return;
- }
-
- kitSection.getKeys(false).forEach(name -> {
- final ItemStack[] contents = ((List) kitSection.getList(name + ".contents")).toArray(new ItemStack[0]);
- final ItemStack[] armor = ((List) kitSection.get(name + ".armor")).toArray(new ItemStack[0]);
- final ItemStack[] kitEditContents = ((List) kitSection.get(name + ".kitEditContents")).toArray(new ItemStack[0]);
-
- final ItemStack icon = (ItemStack) kitSection.get(name + ".icon");
-
- final boolean enabled = kitSection.getBoolean(name + ".enabled", false);
- final boolean ranked = kitSection.getBoolean(name + ".ranked", false);
- final int q = kitSection.getInt(name + ".queue", 0);
-
- final Flag kitFlag = Flag.valueOf(kitSection.getString(name + ".flag", "DEFAULT"));
- final Kit kit = new Kit(name, contents, armor, kitEditContents, icon, icon, enabled, ranked, false, q, kitFlag);
-
- this.kits.put(name, kit);
- });
- }
-
- public void saveKits() {
- final FileConfiguration fileConfig = this.config.getConfig();
-
- fileConfig.set("kits", null);
-
- this.kits.forEach((kitName, kit) -> {
- if (kit.getIcon() != null && kit.getContents() != null && kit.getArmor() != null) {
- fileConfig.set("kits." + kitName + ".contents", kit.getContents());
- fileConfig.set("kits." + kitName + ".armor", kit.getArmor());
- fileConfig.set("kits." + kitName + ".kitEditContents", kit.getKitEditContents());
- fileConfig.set("kits." + kitName + ".icon", kit.getIcon());
- fileConfig.set("kits." + kitName + ".enabled", kit.isEnabled());
- fileConfig.set("kits." + kitName + ".ranked", kit.isRanked());
- fileConfig.set("kits." + kitName + ".flag", kit.getFlag().name());
- fileConfig.set("kits." + kitName + ".queue", kit.getQueueMenu());
- }
- });
-
- this.config.save();
- }
-
- public void deleteKit(String name) {
- this.kits.remove(name);
- }
-
- public void createKit(String name) {
- final Kit kit = new Kit(name);
-
- kit.setEnabled(true);
- kit.setRanked(true);
-
- this.kits.put(name, new Kit(name));
- }
-
- public Collection getKits() {
- return this.kits.values();
- }
-
- public Kit getKit(String name) {
- return this.kits.get(name);
- }
-
-}
diff --git a/src/main/java/com/solexgames/practice/managers/MatchManager.java b/src/main/java/com/solexgames/practice/managers/MatchManager.java
deleted file mode 100644
index 14d950b..0000000
--- a/src/main/java/com/solexgames/practice/managers/MatchManager.java
+++ /dev/null
@@ -1,573 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.solexgames.core.CorePlugin;
-import com.solexgames.core.player.PotPlayer;
-import com.solexgames.core.util.Color;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.arena.Arena;
-import com.solexgames.practice.event.match.MatchEndEvent;
-import com.solexgames.practice.event.match.MatchStartEvent;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.kit.PlayerKit;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.MatchRequest;
-import com.solexgames.practice.match.MatchState;
-import com.solexgames.practice.match.snapshot.InventorySnapshot;
-import com.solexgames.practice.match.team.impl.MatchTeam;
-import com.solexgames.practice.message.KillMessage;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.queue.QueueType;
-import com.solexgames.practice.runnable.RematchRunnable;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.ItemUtil;
-import com.solexgames.practice.util.PlayerUtil;
-import com.solexgames.practice.util.TtlHashMap;
-import io.papermc.lib.PaperLib;
-import lombok.Getter;
-import net.minecraft.server.v1_8_R3.EntityPlayer;
-import org.bson.Document;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
-import org.bukkit.entity.Item;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-
-import java.lang.reflect.Constructor;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
-
-public class MatchManager {
-
- private final Map> matchRequests = new TtlHashMap<>(TimeUnit.SECONDS, 30);
- private final Map rematchUUIDs = new TtlHashMap<>(TimeUnit.SECONDS, 30);
- private final Map rematchInventories = new TtlHashMap<>(TimeUnit.SECONDS, 30);
- private final Map spectators = new ConcurrentHashMap<>();
-
- @Getter
- private final Map matches = new ConcurrentHashMap<>();
-
- private final Practice plugin = Practice.getInstance();
-
- public void createMatchRequest(Player requester, Player requested, Arena arena, String kitName, boolean party) {
- final MatchRequest request = new MatchRequest(requester.getUniqueId(), requested.getUniqueId(), arena, kitName, party);
-
- this.matchRequests.computeIfAbsent(requested.getUniqueId(), k -> new HashSet<>()).add(request);
- }
-
- public MatchRequest getMatchRequest(UUID requester, UUID requested) {
- final Set requests = this.matchRequests.get(requested);
-
- if (requests == null) {
- return null;
- }
-
- return requests.stream().filter(req -> req.getRequester().equals(requester)).findAny().orElse(null);
- }
-
- public MatchRequest getMatchRequest(UUID requester, UUID requested, String kitName) {
- final Set requests = this.matchRequests.get(requested);
-
- if (requests == null) {
- return null;
- }
- return requests.stream().filter(req -> req.getRequester().equals(requester) && req.getKitName().equals(kitName))
- .findAny().orElse(null);
- }
-
- public Match getMatch(PlayerData playerData) {
- if (playerData == null || playerData.getCurrentMatchID() == null) {
- return null;
- }
-
- return this.matches.get(playerData.getCurrentMatchID());
- }
-
- public Match getMatch(UUID uuid) {
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(uuid);
-
- return this.getMatch(playerData);
- }
-
- public Match getMatchFromUUID(UUID uuid) {
- return this.matches.get(uuid);
- }
-
- public Match getSpectatingMatch(UUID uuid) {
- return this.matches.get(this.spectators.get(uuid));
- }
-
- public void removeMatchRequests(UUID uuid) {
- this.matchRequests.remove(uuid);
- }
-
- public void createMatch(Match match, boolean noXpMatch) {
- match.setShouldGiveXp(!noXpMatch);
-
- this.matches.put(match.getMatchId(), match);
- this.plugin.getServer().getPluginManager().callEvent(new MatchStartEvent(match));
- }
-
- public void storeMatchInDatabase(Match match, HashMap elo, Consumer idConsumer) {
- CompletableFuture.supplyAsync(() -> {
- final JsonObject matchObject = new JsonObject();
- final JsonArray teamsArray = new JsonArray();
-
- match.getTeams().forEach(team -> {
- final JsonObject teamObject = new JsonObject();
- final JsonArray playersArray = new JsonArray();
-
- team.getPlayers().forEach((uuid) -> {
- final JsonObject playerObject = new JsonObject();
- final PlayerData data = Practice.getInstance().getPlayerManager().getPlayerData(uuid);
- final InventorySnapshot snapshot = Practice.getInstance().getInventoryManager().getByPlayer(uuid);
-
- playerObject.addProperty("uuid", uuid.toString());
- playerObject.addProperty("name", Bukkit.getOfflinePlayer(uuid).getName());
- playerObject.addProperty("changedElo", (match.getType().isRanked() ? (data.getElo(match.getKit().getName()) - elo.get(uuid)) : 0));
-
- playerObject.addProperty("health", snapshot.getHealth());
- playerObject.addProperty("hunger", snapshot.getFood());
- playerObject.addProperty("longestCombo", snapshot.getLongestCombo());
- playerObject.addProperty("potionCount", snapshot.getPotCount());
- playerObject.addProperty("soupCount", snapshot.getSoupCount());
- playerObject.addProperty("totalHits", snapshot.getTotalHits());
-
- playersArray.add(playerObject);
- });
-
- teamObject.addProperty("id", team.getTeamID());
- teamObject.add("players", playersArray);
- teamsArray.add(teamObject);
- });
-
- matchObject.addProperty("_id", UUID.randomUUID().toString());
- matchObject.addProperty("matchId", match.getShortMatchId());
-
- matchObject.addProperty("ladder", match.getKit().getName());
- matchObject.addProperty("queueType", match.getType().name());
- matchObject.addProperty("ladderIcon", match.getKit().getIcon().getType().name().toLowerCase());
-
- matchObject.addProperty("arena", match.getArena().getName());
- matchObject.addProperty("time", System.currentTimeMillis());
- matchObject.addProperty("ffa", match.isFFA());
- matchObject.add("teams", teamsArray);
- matchObject.addProperty("winningTeam", match.getWinningTeamId());
-
- if (match.isFFA()) {
- final JsonObject winnerObject = new JsonObject();
- final Player winner = Bukkit.getPlayer(match.getTeams().get(0).getAlivePlayers().get(0));
-
- winnerObject.addProperty("name", winner.getName());
- winnerObject.addProperty("uuid", winner.getUniqueId().toString());
- matchObject.add("winningPlayer", winnerObject);
- }
-
- MongoManager.getInstance().getMatchOverviews().insertOne(Document.parse(matchObject.toString()));
-
- return match.getShortMatchId();
- }).thenAccept(idConsumer);
- }
-
- public void removeFighter(Player player, PlayerData playerData, boolean spectateDeath) {
- final Match match = this.matches.get(playerData.getCurrentMatchID());
- final Player killer = player.getKiller();
-
- final MatchTeam entityTeam = match.getTeams().get(playerData.getTeamID());
- final MatchTeam winningTeam = match.isFFA() ? entityTeam : match.getTeams().get(entityTeam.getTeamID() == 0 ? 1 : 0);
-
- if (match.getMatchState() == MatchState.ENDING) {
- return;
- }
-
- match.addSnapshot(player);
-
- if (killer != null) {
- final PlayerData data = Practice.getInstance().getPlayerManager()
- .getPlayerData(killer.getUniqueId());
-
- data.getEffect().applyEffect(player, killer);
-
- final KillMessage killMessage = Practice.getInstance().getEffectManager()
- .getMessageByName(data.getDeathMessageType());
-
- match.broadcast(killMessage.getFormatted(player, killer, true));
- } else {
- match.broadcast(CC.RED + player.getName() + CC.GRAY + " has been killed.");
- }
-
- player.setHealth(20);
- player.setFoodLevel(20);
- player.setSaturation(20);
-
- entityTeam.killPlayer(player.getUniqueId());
-
- final int remaining = entityTeam.getAlivePlayers().size();
-
- if (remaining != 0) {
- final Set
- items = new HashSet<>();
-
- for (ItemStack item : player.getInventory().getContents()) {
- if (item != null && item.getType() != Material.AIR) {
- items.add(player.getWorld().dropItemNaturally(player.getLocation(), item));
- }
- }
- for (ItemStack item : player.getInventory().getArmorContents()) {
- if (item != null && item.getType() != Material.AIR) {
- items.add(player.getWorld().dropItemNaturally(player.getLocation(), item));
- }
- }
-
- this.plugin.getMatchManager().addDroppedItems(match, items);
- }
-
- if (spectateDeath) {
- this.addDeathSpectator(player, playerData, match);
- }
-
- if (player.isDead()) {
- Bukkit.getScheduler().runTask(plugin, () -> player.spigot().respawn());
- }
-
- if ((match.isFFA() && remaining == 1) || remaining == 0) {
- this.plugin.getServer().getPluginManager().callEvent(new MatchEndEvent(match, winningTeam, entityTeam));
- }
- }
-
- public void removeMatch(Match match) {
- this.matches.remove(match.getMatchId());
- }
-
- public void giveKits(Player player, Kit kit) {
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
- final Collection playerKits = playerData.getPlayerKits(kit.getName()).values();
-
- if (playerKits.size() == 0) {
- kit.applyToPlayer(player);
- } else {
- player.getInventory().setItem(8, this.plugin.getItemManager().getDefaultBook());
-
- int slot = -1;
- for (PlayerKit playerKit : playerKits) {
- player.getInventory().setItem(++slot, ItemUtil.createItem(Material.ENCHANTED_BOOK, Color.MAIN_COLOR + playerKit.getDisplayName() + CC.GRAY + " (Click to equip)"));
- }
-
- player.updateInventory();
- }
- }
-
- private void addDeathSpectator(Player player, PlayerData playerData, Match match) {
- this.spectators.put(player.getUniqueId(), match.getMatchId());
-
- playerData.setPlayerState(PlayerState.SPECTATING);
-
- PlayerUtil.clearPlayer(player);
-
- final CraftPlayer playerCp = (CraftPlayer) player;
- final EntityPlayer playerEp = playerCp.getHandle();
-
- playerEp.getDataWatcher().watch(6, 0.0F);
-
- match.addRunnable(this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
- match.getTeams().forEach(team -> team.streamAlivePlayers().forEach(member -> Practice.getInstance().getEntityHider().hideEntity(member, player)));
- match.streamSpectators().forEach(member -> Practice.getInstance().getEntityHider().hideEntity(member, player));
-
- player.getActivePotionEffects().stream().map(PotionEffect::getType).forEach(player::removePotionEffect);
- player.setWalkSpeed(0.2F);
- player.setAllowFlight(true);
- }, 20L));
-
- if (match.isRedRover()) {
- for (MatchTeam team : match.getTeams()) {
- for (UUID alivePlayerUUID : team.getAlivePlayers()) {
- final Player alivePlayer = this.plugin.getServer().getPlayer(alivePlayerUUID);
-
- if (alivePlayer != null) {
- Practice.getInstance().getEntityHider().showEntity(player, alivePlayer);
- }
- }
- }
- }
-
- player.setWalkSpeed(0.0F);
- player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10000, -5));
-
- if (match.isParty() || match.isFFA()) {
- this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () ->
- player.getInventory().setContents(this.plugin.getItemManager().getPartySpecItems()), 1L);
- }
-
- player.updateInventory();
- }
-
- public void addSpectator(Player player, PlayerData playerData, Player target, Match targetMatch) {
- this.spectators.put(player.getUniqueId(), targetMatch.getMatchId());
-
- if (targetMatch.getMatchState() != MatchState.ENDING) {
- if (!targetMatch.haveSpectated(player.getUniqueId())) {
- if (!player.hasPermission("practice.staff")) {
- targetMatch.broadcast(player.getDisplayName() + Color.SECONDARY_COLOR + " is now spectating your match.");
- }
- }
- }
-
- targetMatch.addSpectator(player.getUniqueId());
-
- playerData.setPlayerState(PlayerState.SPECTATING);
-
- PaperLib.teleportAsync(player, target.getLocation());
-
- player.setAllowFlight(true);
- player.setFlying(true);
-
- final PotPlayer potPlayer = CorePlugin.getInstance().getPlayerManager().getPlayer(player);
-
- if (potPlayer.isStaffMode()) {
- player.getInventory().setItem(4, ItemManager.LEAVE_SPEC);
- } else {
- player.getInventory().setContents(this.plugin.getItemManager().getSpecItems());
- }
-
- player.updateInventory();
-
- this.plugin.getServer().getOnlinePlayers().forEach(online -> {
- Practice.getInstance().getEntityHider().hideEntity(player, online);
- Practice.getInstance().getEntityHider().hideEntity(online, player);
- });
-
- targetMatch.getTeams().forEach(team -> team.streamAlivePlayers().forEach(player1 -> {
- Practice.getInstance().getEntityHider().showEntity(player, player1);
- }));
- }
-
- public void addDroppedItem(Match match, Item item) {
- match.addEntityToRemove(item);
-
- match.addRunnable(this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> {
- match.removeEntityToRemove(item);
- }, 200L).getTaskId());
- }
-
- public void addDroppedItems(Match match, Set
- items) {
- for (Item item : items) {
- match.addEntityToRemove(item);
- }
-
- match.addRunnable(this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> {
- for (Item item : items) {
- match.removeEntityToRemove(item);
- item.remove();
- }
- }, 100L).getTaskId());
- }
-
- public void removeSpectator(Player player, boolean silent) {
- final Match match = this.matches.get(this.spectators.get(player.getUniqueId()));
-
- match.removeSpectator(player.getUniqueId());
-
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (match.getTeams().size() > playerData.getTeamID() && playerData.getTeamID() >= 0) {
- final MatchTeam entityTeam = match.getTeams().get(playerData.getTeamID());
-
- if (entityTeam != null) {
- entityTeam.killPlayer(player.getUniqueId());
- }
- }
-
- if (match.getMatchState() != MatchState.ENDING) {
- if (!match.haveSpectated(player.getUniqueId())) {
- match.addHaveSpectated(player.getUniqueId());
- }
- }
-
- if (!player.hasPermission("practice.staff") && !silent) {
- match.broadcast(player.getDisplayName() + Color.SECONDARY_COLOR + " is no longer spectating your match.");
- }
-
- this.spectators.remove(player.getUniqueId());
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
- }
-
- public void pickPlayer(Match match) {
- final Player playerA = this.plugin.getServer().getPlayer(match.getTeams().get(0).getAlivePlayers().get(0));
- final PlayerData playerDataA = this.plugin.getPlayerManager().getPlayerData(playerA.getUniqueId());
-
- if (playerDataA.getPlayerState() != PlayerState.FIGHTING) {
- playerA.teleport(match.getArena().getPositionOne().toBukkitLocation());
- PlayerUtil.clearPlayer(playerA);
-
- if (match.getKit().getName().contains("Combo")) {
- playerA.setMaximumNoDamageTicks(3);
- }
-
- this.plugin.getMatchManager().giveKits(playerA, match.getKit());
- playerDataA.setPlayerState(PlayerState.FIGHTING);
- }
-
- final Player playerB = this.plugin.getServer().getPlayer(match.getTeams().get(1).getAlivePlayers().get(0));
- final PlayerData playerDataB = this.plugin.getPlayerManager().getPlayerData(playerB.getUniqueId());
-
- if (playerDataB.getPlayerState() != PlayerState.FIGHTING) {
- playerB.teleport(match.getArena().getPositionTwo().toBukkitLocation());
- PlayerUtil.clearPlayer(playerB);
-
- if (match.getKit().getName().contains("Combo")) {
- playerB.setMaximumNoDamageTicks(3);
- }
-
- this.plugin.getMatchManager().giveKits(playerB, match.getKit());
- playerDataB.setPlayerState(PlayerState.FIGHTING);
- }
-
- for (MatchTeam team : match.getTeams()) {
- for (UUID uuid : team.getAlivePlayers()) {
- final Player player = this.plugin.getServer().getPlayer(uuid);
-
- if (player != null) {
- if (!playerA.equals(player) && !playerB.equals(player)) {
- Practice.getInstance().getEntityHider().hideEntity(playerA, player);
- Practice.getInstance().getEntityHider().hideEntity(playerB, player);
- }
- }
- }
- }
-
- Practice.getInstance().getEntityHider().showEntity(playerA, playerB);
- Practice.getInstance().getEntityHider().showEntity(playerB, playerA);
-
- match.broadcast(Color.SECONDARY_COLOR + "Starting a 1v1 match. " + Color.MAIN_COLOR + playerA.getName() + " vs " + playerB.getName());
- }
-
- public void saveRematches(Match match) {
- if (match.isParty() || match.isFFA()) {
- return;
- }
-
- final UUID playerOne = match.getTeams().get(0).getLeader();
- final UUID playerTwo = match.getTeams().get(1).getLeader();
-
- final PlayerData dataOne = this.plugin.getPlayerManager().getPlayerData(playerOne);
- final PlayerData dataTwo = this.plugin.getPlayerManager().getPlayerData(playerTwo);
-
- this.saveRematchFor(match, playerOne, playerTwo, dataOne);
- this.saveRematchFor(match, playerTwo, playerOne, dataTwo);
- }
-
- private void saveRematchFor(Match match, UUID playerOne, UUID playerTwo, PlayerData dataOne) {
- InventorySnapshot snapshot;
-
- if (dataOne != null) {
- this.rematchUUIDs.put(playerOne, playerTwo);
-
- snapshot = match.getSnapshot(playerTwo);
- if (snapshot != null) {
- this.rematchInventories.put(playerOne, snapshot.getSnapshotId());
- }
- if (dataOne.getRematchID() > -1) {
- this.plugin.getServer().getScheduler().cancelTask(dataOne.getRematchID());
- }
-
- dataOne.setRematchID(this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new RematchRunnable(playerOne), 600L));
- }
- }
-
- public void removeRematch(UUID uuid) {
- this.rematchUUIDs.remove(uuid);
- this.rematchInventories.remove(uuid);
- }
-
- public UUID getRematcher(UUID uuid) {
- return this.rematchUUIDs.get(uuid);
- }
-
- public UUID getRematcherInventory(UUID uuid) {
- return this.rematchInventories.get(uuid);
- }
-
- public boolean isRematching(UUID uuid) {
- return this.rematchUUIDs.containsKey(uuid);
- }
-
- /**
- * Send a title to player
- *
- * @param player Player to send the title to
- * @param text The text displayed in the title
- * @param fadeInTime The time the title takes to fade in
- * @param showTime The time the title is displayed
- * @param fadeOutTime The time the title takes to fade out
- * @param color The color of the title
- */
- public void sendTitle(Player player, String text, int fadeInTime, int showTime, int fadeOutTime, ChatColor color) {
- try {
- Object chatTitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\": \"" + text + "\",color:" + color.name().toLowerCase() + "}");
-
- Constructor> titleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), int.class, int.class, int.class);
- Object packet = titleConstructor.newInstance(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("TITLE").get(null), chatTitle, fadeInTime, showTime, fadeOutTime);
-
- sendPacket(player, packet);
- } catch (Exception ex) {
- //Do something
- }
- }
-
- /**
- * Send a subtitle to player
- *
- * @param player Player to send the title to
- * @param text The text displayed in the title
- * @param fadeInTime The time the title takes to fade in
- * @param showTime The time the title is displayed
- * @param fadeOutTime The time the title takes to fade out
- * @param color The color of the title
- */
- public void sendSubtitle(Player player, String text, int fadeInTime, int showTime, int fadeOutTime, ChatColor color) {
- try {
- Object chatTitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\": \"" + text + "\",color:" + color.name().toLowerCase() + "}");
-
- Constructor> titleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), int.class, int.class, int.class);
- Object packet = titleConstructor.newInstance(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("SUBTITLE").get(null), chatTitle, fadeInTime, showTime, fadeOutTime);
-
- sendPacket(player, packet);
- } catch (Exception ex) {
- //Do something
- }
- }
-
- private void sendPacket(Player player, Object packet) {
- try {
- Object handle = player.getClass().getMethod("getHandle").invoke(player);
- Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
- playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
- } catch (Exception ex) {
- //Do something
- }
- }
-
- /**
- * Get NMS class using reflection
- *
- * @param name Name of the class
- *
- * @return Class
- */
- private Class> getNMSClass(String name) {
- try {
- return Class.forName("net.minecraft.server" + Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3] + "." + name);
- } catch (ClassNotFoundException ex) {
- //Do something
- }
- return null;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/MongoManager.java b/src/main/java/com/solexgames/practice/managers/MongoManager.java
deleted file mode 100644
index 9577a3e..0000000
--- a/src/main/java/com/solexgames/practice/managers/MongoManager.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.mongodb.MongoClient;
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.MongoDatabase;
-import com.solexgames.core.CorePlugin;
-import lombok.Getter;
-import org.bson.Document;
-
-@Getter
-public class MongoManager {
-
- @Getter
- private static MongoManager instance;
-
- private final MongoClient client;
- private final MongoDatabase database;
-
- private final MongoCollection players;
- private final MongoCollection matchOverviews;
- private final MongoCollection arenaRatings;
-
- public MongoManager() {
- if (instance != null) {
- throw new RuntimeException("The mongo database has already been instantiated.");
- }
-
- instance = this;
-
- this.client = CorePlugin.getInstance().getCoreDatabase().getClient();
- this.database = this.client.getDatabase("SGSoftware");
-
- this.players = this.database.getCollection("practice_profiles");
- this.matchOverviews = this.database.getCollection("practice_matches");
- this.arenaRatings = this.database.getCollection("practice_ratings");
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/PartyManager.java b/src/main/java/com/solexgames/practice/managers/PartyManager.java
deleted file mode 100644
index 5c08a5a..0000000
--- a/src/main/java/com/solexgames/practice/managers/PartyManager.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.PracticeConstants;
-import com.solexgames.practice.party.Party;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.TtlHashMap;
-import lombok.Getter;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-@Getter
-public class PartyManager {
-
- private final Practice plugin = Practice.getInstance();
-
- private final Map> partyInvites = new TtlHashMap<>(TimeUnit.SECONDS, 15);
- private final Map parties = new HashMap<>();
- private final Map partyLeaders = new HashMap<>();
-
- public boolean isLeader(UUID uuid) {
- return this.parties.containsKey(uuid);
- }
-
- public void removePartyInvites(UUID uuid) {
- this.partyInvites.remove(uuid);
- }
-
- public boolean hasPartyInvite(UUID player, UUID other) {
- return this.partyInvites.get(player) != null && this.partyInvites.get(player).contains(other);
- }
-
- public void createPartyInvite(UUID requester, UUID requested) {
- this.partyInvites.computeIfAbsent(requested, k -> new ArrayList<>()).add(requester);
- }
-
- public boolean isInParty(UUID player, Party party) {
- final Party targetParty = this.getParty(player);
- return targetParty != null && targetParty.getLeader() == party.getLeader();
- }
-
- public Party getParty(UUID player) {
- if (this.parties.containsKey(player)) {
- return this.parties.get(player);
- }
-
- if (this.partyLeaders.containsKey(player)) {
- final UUID leader = this.partyLeaders.get(player);
- return this.parties.get(leader);
- }
-
- return null;
- }
-
- public void createParty(Player player) {
- final Party party = new Party(player.getUniqueId());
-
- this.parties.put(player.getUniqueId(), party);
- this.plugin.getPlayerManager().reset(Bukkit.getPlayer(player.getUniqueId()));
-
- player.sendMessage(PracticeConstants.PARTY_PREFIX + CC.GREEN + (player.getName().equals("threazy") ? "您創建了一個新派對" : "You've created a new party."));
- }
-
- private void disbandParty(Party party, boolean tournament) {
- this.parties.remove(party.getLeader());
-
- party.broadcast(PracticeConstants.PARTY_PREFIX + CC.RED + "Your party has been disbanded" + (tournament ? " as one of the party members left during the tournament." : "."));
- party.streamPartyMembers().forEach(member -> {
- final PlayerData memberData = this.plugin.getPlayerManager().getPlayerData(member.getUniqueId());
-
- if (this.partyLeaders.get(memberData.getUniqueId()) != null) {
- this.partyLeaders.remove(memberData.getUniqueId());
- }
- if (memberData.getPlayerState() == PlayerState.SPAWN) {
- this.plugin.getPlayerManager().reset(Bukkit.getPlayer(memberData.getUniqueId()));
- }
- });
- }
-
- public void leaveParty(Player player) {
- final Party party = this.getParty(player.getUniqueId());
-
- if (party == null) {
- return;
- }
-
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (this.parties.containsKey(player.getUniqueId())) {
- this.disbandParty(party, false);
- } else if (this.plugin.getTournamentManager().getTournament(player.getUniqueId()) != null) {
- this.disbandParty(party, true);
- } else {
- party.broadcast(PracticeConstants.PARTY_PREFIX + player.getDisplayName() + CC.YELLOW + " has left the party.");
- party.removeMember(player.getUniqueId());
-
- this.partyLeaders.remove(player.getUniqueId());
- }
-
- switch (playerData.getPlayerState()) {
- case FIGHTING:
- this.plugin.getMatchManager().removeFighter(player, playerData, false);
- break;
- case SPECTATING:
- this.plugin.getMatchManager().removeSpectator(player, false);
- break;
- }
-
- party.getMembers().forEach(uuid -> {
- final Player other = Bukkit.getPlayer(uuid);
-
- Practice.getInstance().getEntityHider().hideEntity(player, other);
- Practice.getInstance().getEntityHider().hideEntity(other, player);
- });
-
- this.plugin.getPlayerManager().reset(player);
- }
-
- public void joinParty(UUID leader, Player player) {
- final Party party = this.getParty(leader);
-
- if (this.plugin.getTournamentManager().getTournament(leader) != null) {
- player.sendMessage(PracticeConstants.PARTY_PREFIX + CC.RED + "The leader of the party you tried to join is currently in a party.");
- return;
- }
-
- this.partyLeaders.put(player.getUniqueId(), leader);
- party.addMember(player.getUniqueId());
-
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
-
- party.getMembers().forEach(uuid -> {
- final Player other = Bukkit.getPlayer(uuid);
-
- Practice.getInstance().getEntityHider().showEntity(player, other);
- Practice.getInstance().getEntityHider().showEntity(other, player);
- });
-
- party.broadcast(PracticeConstants.PARTY_PREFIX + player.getDisplayName() + CC.YELLOW + " has joined the party.");
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/PlayerManager.java b/src/main/java/com/solexgames/practice/managers/PlayerManager.java
deleted file mode 100644
index c93b88b..0000000
--- a/src/main/java/com/solexgames/practice/managers/PlayerManager.java
+++ /dev/null
@@ -1,290 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.mongodb.client.model.Filters;
-import com.mongodb.client.model.ReplaceOptions;
-import com.solexgames.core.CorePlugin;
-import com.solexgames.core.player.PotPlayer;
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.PracticeConstants;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.kit.PlayerKit;
-import com.solexgames.practice.party.Party;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.settings.item.ProfileOptionsItemState;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.ItemUtil;
-import com.solexgames.practice.util.PlayerUtil;
-import com.solexgames.practice.util.division.RankedDivision;
-import com.solexgames.practice.util.timer.impl.EnderpearlTimer;
-import lombok.Getter;
-import me.lucko.helper.Schedulers;
-import org.bson.Document;
-import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Getter
-public class PlayerManager {
-
- private static final ItemStack REMATCH_ITEM = new ItemBuilder(Material.BLAZE_POWDER)
- .setDisplayName(CC.AQUA + "Rematch " + CC.GRAY + "(Right Click)")
- .addLore(
- CC.GRAY + "Click to rematch your opponent."
- )
- .create();
-
- private final Practice plugin = Practice.getInstance();
- private final Map playerData = new ConcurrentHashMap<>();
-
- public void createPlayerData(AsyncPlayerPreLoginEvent event) {
- final PlayerData data = new PlayerData(event.getUniqueId(), event.getName());
- this.playerData.put(data.getUniqueId(), data);
-
- this.loadData(data);
- }
-
- private void loadData(PlayerData playerData) {
- playerData.setPlayerState(PlayerState.SPAWN);
-
- CompletableFuture.supplyAsync(() -> MongoManager.getInstance().getPlayers().find(Filters.eq("_id", playerData.getUniqueId())).first())
- .thenAcceptAsync(document -> {
- if (document == null) {
- this.saveData(playerData);
- return;
- }
-
- playerData.getOptions().setSpectators(document.getBoolean("allowingSpectators"));
- playerData.getOptions().setDuelRequests(document.getBoolean("acceptingDuels"));
- playerData.getOptions().setAutoGg(document.getBoolean("autoGg"));
-
- playerData.getOptions().setScoreboardEnabled(document.getBoolean("scoreboardEnabled"));
- playerData.getOptions().setScoreboardState(ProfileOptionsItemState.valueOf(document.getString("scoreboardStyle")));
-
- playerData.setUnrankedWinCount(document.getInteger("unrankedWins"));
- playerData.setRankedWinCount(document.getInteger("rankedWins"));
- playerData.setUnrankedLossCount(document.getInteger("unrankedLosses"));
- playerData.setRankedLossCount(document.getInteger("rankedLosses"));
- playerData.setRankedDivision(RankedDivision.valueOf(document.getString("rankedDivisionCurrent")));
- playerData.setEffect(Practice.getInstance().getEffectManager().getByName(document.getString("effect")));
- playerData.getMatchIds().addAll(document.getList("matches", String.class));
-
- final String deathMessage = document.getString("deathMessage");
- playerData.setDeathMessageType(deathMessage == null ? "Normal" : deathMessage);
-
- final Map eloMap = CorePlugin.GSON.fromJson(document.getString("elo"), PracticeConstants.STRING_INTEGER_MAP_TYPE);
- final Map winMap = CorePlugin.GSON.fromJson(document.getString("wins"), PracticeConstants.STRING_INTEGER_MAP_TYPE);
- final Map lossMap = CorePlugin.GSON.fromJson(document.getString("losses"), PracticeConstants.STRING_INTEGER_MAP_TYPE);
- final Map highestStreakMap = CorePlugin.GSON.fromJson(document.getString("highestKs"), PracticeConstants.STRING_INTEGER_MAP_TYPE);
- final Map killstreakMap = CorePlugin.GSON.fromJson(document.getString("currentKs"), PracticeConstants.STRING_INTEGER_MAP_TYPE);
-
- final Map divisions = CorePlugin.GSON.fromJson(document.getString("divisionClaims"), PracticeConstants.STRING_BOOLEAN_MAP_TYPE);
-
- if (eloMap != null && winMap != null && lossMap != null && divisions != null) {
- eloMap.forEach(playerData::setElo);
- winMap.forEach(playerData::setWins);
- lossMap.forEach(playerData::setLosses);
- highestStreakMap.forEach(playerData::setHighestKillStreak);
- killstreakMap.forEach(playerData::setKillstreak);
- divisions.forEach(playerData.getRankedDivisionBooleanMap()::put);
- }
-
- final List kitList = document.getList("playerKits", Document.class);
-
- if (kitList != null && !kitList.isEmpty()) {
- kitList.forEach(kit -> {
- final List specificKits = kit.getList("kits", Document.class);
-
- specificKits.forEach(specificKit -> {
- final Integer index = specificKit.getInteger("key");
- final PlayerKit playerKit = new PlayerKit(specificKit.getString("name"), specificKit.getInteger("key"), ItemUtil.itemStackArrayFromBase64(specificKit.getString("contents")), specificKit.getString("displayName"));
-
- playerData.addPlayerKit(index, playerKit);
- });
- });
- }
- });
- }
-
- public void removePlayerData(UUID uuid) {
- CompletableFuture.runAsync(() -> {
- PlayerManager.this.saveData(PlayerManager.this.playerData.get(uuid));
- PlayerManager.this.playerData.remove(uuid);
- });
- }
-
- public void saveData(PlayerData playerData) {
- if (playerData == null) {
- return;
- }
-
- final Document document = new Document("_id", playerData.getUniqueId());
-
- document.put("scoreboardEnabled", playerData.getOptions().isScoreboardEnabled());
- document.put("scoreboardStyle", playerData.getOptions().getScoreboardState().name());
- document.put("acceptingDuels", playerData.getOptions().isDuelRequests());
- document.put("allowingSpectators", playerData.getOptions().isSpectators());
- document.put("autoGg", playerData.getOptions().isAutoGg());
-
- document.put("pingRange", playerData.getPingRange());
- document.put("eloRange", playerData.getEloRange());
- document.put("unrankedWins", playerData.getUnrankedWinCount());
- document.put("rankedWins", playerData.getRankedWinCount());
- document.put("unrankedLosses", playerData.getUnrankedLossCount());
- document.put("rankedLosses", playerData.getRankedLossCount());
- document.put("effect", playerData.getEffect().getName());
- document.put("rankedDivisionCurrent", playerData.getRankedDivision().name());
- document.put("deathMessage", playerData.getDeathMessageType() == null ? "Normal" : playerData.getDeathMessageType());
-
- final Map eloMap = new HashMap<>();
- final Map winMap = new HashMap<>();
- final Map lossMap = new HashMap<>();
- final Map highestStreakMap = new HashMap<>();
- final Map killstreakMap = new HashMap<>();
-
- for (Kit kit : this.plugin.getKitManager().getKits()) {
- winMap.put(kit.getName(), playerData.getWins(kit.getName()));
- lossMap.put(kit.getName(), playerData.getLosses(kit.getName()));
-
- if (kit.isRanked()) {
- eloMap.put(kit.getName(), playerData.getElo(kit.getName()));
- }
-
- highestStreakMap.put(kit.getName(), playerData.getHighestKillStreak(kit.getName()));
- killstreakMap.put(kit.getName(), playerData.getKillstreak(kit));
- }
-
- document.put("elo", CorePlugin.GSON.toJson(eloMap));
- document.put("wins", CorePlugin.GSON.toJson(winMap));
- document.put("losses", CorePlugin.GSON.toJson(lossMap));
- document.put("divisionClaims", CorePlugin.GSON.toJson(playerData.getRankedDivisionBooleanMap()));
-
- document.put("highestKs", CorePlugin.GSON.toJson(highestStreakMap));
- document.put("currentKs", CorePlugin.GSON.toJson(killstreakMap));
- document.put("globalElo", playerData.recalculateGlobalElo());
-
- final List playerKitList = new ArrayList<>();
-
- this.plugin.getKitManager().getKits().forEach(kit -> {
- final Map playerKits = playerData.getPlayerKits(kit.getName());
-
- if (playerKits != null) {
- final List documentList = new ArrayList<>();
-
- playerKits.forEach((key, value) -> {
- final Document specificKit = new Document("key", key);
-
- specificKit.put("name", value.getName());
- specificKit.put("displayName", value.getDisplayName());
- specificKit.put("contents", ItemUtil.itemStackArrayToBase64(value.getContents()));
-
- documentList.add(specificKit);
- });
-
- final Document document1 = new Document("kits", documentList);
-
- document1.put("kitName", kit.getName());
-
- playerKitList.add(document1);
- }
- });
-
- document.put("uuid", playerData.getUniqueId().toString());
- document.put("username", playerData.getName());
-
- document.put("matches", playerData.getMatchIds());
- document.put("playerKits", playerKitList);
-
- MongoManager.getInstance().getPlayers().replaceOne(Filters.eq("_id", playerData.getUniqueId()), document, new ReplaceOptions().upsert(true));
- }
-
- public Collection getAllData() {
- return this.playerData.values();
- }
-
- public PlayerData getPlayerData(UUID uuid) {
- return this.playerData.get(uuid);
- }
-
- public void giveLobbyItems(Player player) {
- final Party party = this.plugin.getPartyManager().getParty(player.getUniqueId());
- final boolean inParty = party != null;
- final boolean inTournament = this.plugin.getTournamentManager().getTournament(player.getUniqueId()) != null;
- final boolean isRematching = this.plugin.getMatchManager().isRematching(player.getUniqueId());
-
- final PotPlayer potPlayer = CorePlugin.getInstance().getPlayerManager().getPlayer(player);
- final boolean isModMode = potPlayer != null && potPlayer.isStaffMode();
-
- ItemStack[] items = this.plugin.getItemManager().getSpawnItems();
-
- if (inTournament) {
- items = this.plugin.getItemManager().getTournamentItems();
- } else if (inParty) {
- if (party.getLeader().equals(player.getUniqueId())) {
- items = this.plugin.getItemManager().getPartyItems();
- } else {
- items = this.plugin.getItemManager().getPartyNonLeaderItems();
- }
- }
-
- if (isModMode) {
- CorePlugin.getInstance().getPlayerManager().applyItems(player);
- } else {
- player.getInventory().setContents(items);
- }
-
- if (isRematching && !inParty && !inTournament) {
- player.getInventory().setItem(4, PlayerManager.REMATCH_ITEM);
- }
-
- player.updateInventory();
- }
-
- public void sendToSpawnAndUpdateTag(Player player) {
- this.sendToSpawnAndReset(player);
-
- final PotPlayer potPlayer = CorePlugin.getInstance().getPlayerManager().getPlayer(player);
- potPlayer.setupPlayerTag();
- }
-
- public void reset(Player player) {
- final PlayerData playerData = this.getPlayerData(player.getUniqueId());
- if (player.isDead()) {
- Bukkit.getScheduler().runTask(plugin, () -> player.spigot().respawn());
- }
-
- playerData.setPlayerState(PlayerState.SPAWN);
- PlayerUtil.clearPlayer(player);
-
- this.plugin.getTimerManager().getTimer(EnderpearlTimer.class).clearCooldown(player.getUniqueId());
-
- this.giveLobbyItems(player);
-
- if (player.hasPermission("practice.spawn.fly")) {
- player.setAllowFlight(true);
- player.setFlying(true);
- }
-
- Schedulers.sync().runLater(() -> {
- this.plugin.getServer().getOnlinePlayers().forEach(other -> {
- Practice.getInstance().getEntityHider().hideEntity(player, other);
- Practice.getInstance().getEntityHider().hideEntity(other, player);
- });
- }, 1L);
- }
-
- public void sendToSpawnAndReset(Player player) {
- this.reset(player);
-
- this.plugin.getSpawnManager().fetchSingleLocation("spawn").ifPresent(asyncLocation -> {
- asyncLocation.teleport(player);
- });
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/QueueManager.java b/src/main/java/com/solexgames/practice/managers/QueueManager.java
deleted file mode 100644
index fdd1cae..0000000
--- a/src/main/java/com/solexgames/practice/managers/QueueManager.java
+++ /dev/null
@@ -1,329 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.PlayerUtil;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.arena.Arena;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.team.impl.MatchTeam;
-import com.solexgames.practice.party.Party;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.queue.QueueEntry;
-import com.solexgames.practice.queue.QueueType;
-import com.solexgames.practice.util.CC;
-import lombok.Getter;
-import lombok.Setter;
-import org.bukkit.entity.Player;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Getter
-@Setter
-public class QueueManager {
-
- private final Map queued = new ConcurrentHashMap<>();
- private final Map playerQueueTime = new HashMap<>();
-
- private final Practice plugin = Practice.getInstance();
-
- private boolean rankedEnabled = true;
-
- public QueueManager() {
- this.plugin.getServer().getScheduler().runTaskTimer(this.plugin, () -> this.queued.forEach((key, value) -> {
- if (key == null || value == null) {
- return;
- }
-
- if (value.isParty()) {
- this.findMatch(this.plugin.getPartyManager().getParty(key), value.getKitName(),
- value.getElo(), value.getQueueType());
- } else {
- this.findMatch(this.plugin.getServer().getPlayer(key), value.getKitName(),
- value.getElo(), value.getQueueType());
- }
- }), 20L, 20L);
- }
-
- public void addPlayerToQueue(Player player, PlayerData playerData, String kitName, QueueType type) {
- if (type.isRanked() && !this.rankedEnabled) {
- player.sendMessage(CC.RED + "I'm sorry, but ranked is currently unavailable.");
- player.closeInventory();
- return;
- }
-
- playerData.setPlayerState(PlayerState.QUEUE);
-
- final int elo = type.isRanked() ? playerData.getElo(kitName) : 0;
- final QueueEntry entry = new QueueEntry(type, kitName, elo, PlayerUtil.getPing(player), false);
-
- this.queued.put(playerData.getUniqueId(), entry);
-
- this.giveQueueItems(player);
-
- final String message = CC.YELLOW + "You've been added to the " + CC.AQUA + type.getName() + " " + kitName + CC.YELLOW + " queue." + (type.isRanked() ? CC.GRAY + " (" + elo + " elo)" : "");
- player.sendMessage(message);
-
- this.playerQueueTime.put(player.getUniqueId(), System.currentTimeMillis());
- }
-
- private void giveQueueItems(Player player) {
- player.closeInventory();
- player.getInventory().setContents(this.plugin.getItemManager().getQueueItems());
- player.updateInventory();
- }
-
- public QueueEntry getQueueEntry(UUID uuid) {
- return this.queued.getOrDefault(uuid, null);
- }
-
- public long getPlayerQueueTime(UUID uuid) {
- return this.playerQueueTime.getOrDefault(uuid, null);
- }
-
- public int getQueueSize(String ladder, QueueType type) {
- return (int) this.queued.entrySet().stream()
- .filter(uuidQueueEntryEntry -> uuidQueueEntryEntry != null && uuidQueueEntryEntry.getValue() != null && uuidQueueEntryEntry.getValue().getQueueType() == type && uuidQueueEntryEntry.getValue().getKitName().equals(ladder))
- .count();
- }
-
- private boolean findMatch(Player player, String kitName, int elo, QueueType type) {
- if (this.playerQueueTime.containsKey(player.getUniqueId()) && this.playerQueueTime.get(player.getUniqueId()) == null) {
- return false;
- }
-
- final long queueTime = System.currentTimeMillis() - this.playerQueueTime.get(player.getUniqueId());
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData == null) {
- return false;
- }
-
- if (playerData.getPlayerState() != PlayerState.QUEUE)
- return false;
-
- final QueueEntry queueEntry = this.queued.get(player.getUniqueId());
-
- int eloRange = playerData.getEloRange();
- int pingRange = playerData.getPingRange();
- int seconds = Math.round((float) (queueTime / 1000L));
-
- if (seconds > 5) {
- if (seconds % 15 == 0) {
- pingRange += 20;
-
- if (pingRange > 70) {
- pingRange = 70;
- } else {
- int ping = queueEntry.getPing();
- player.sendMessage(Color.SECONDARY_COLOR + "Expanding your ping range by " + Color.MAIN_COLOR + "20ms" + Color.SECONDARY_COLOR + "..." + CC.GRAY + "[" + Math.max(0, ping - pingRange) + "ms - " + (ping + pingRange) + "ms]");
- }
-
- playerData.setPingRange(pingRange);
- }
- if (type.isRanked() && seconds % 10 == 0) {
- eloRange += 10;
-
- if (eloRange >= 3000)
- eloRange = 3000;
-
- playerData.setEloRange(eloRange);
- }
- }
-
- for (UUID opponent : this.queued.keySet()) {
- String playerFoundMatchMessage, matchedFoundMatchMessage;
- if (opponent.equals(player.getUniqueId()))
- continue;
- QueueEntry opponentQueueEntry = this.queued.get(opponent);
- if (!opponentQueueEntry.getKitName().equals(kitName))
- continue;
- if (opponentQueueEntry.getQueueType() != type)
- continue;
- if (opponentQueueEntry.isParty())
- continue;
- Player opponentPlayer = this.plugin.getServer().getPlayer(opponent);
- PlayerData opponentData = this.plugin.getPlayerManager().getPlayerData(opponent);
- if (opponentData.getPlayerState() != PlayerState.QUEUE)
- continue;
- if (type.isRanked()) {
- int eloDiff = Math.abs(opponentQueueEntry.getElo() - elo);
- if (eloDiff > eloRange)
- continue;
- if (eloDiff > opponentData.getEloRange())
- continue;
- int pingDiff = Math.abs(opponentQueueEntry.getPing() - queueEntry.getPing());
-
- if (playerData.getPingRange() != -1 && pingDiff > playerData.getPingRange())
- continue;
- }
-
- Kit kit = this.plugin.getKitManager().getKit(kitName);
- Arena arena = this.plugin.getArenaManager().getRandomArena(kit);
-
- if (arena == null || kit == null) {
- return false;
- }
-
- if (type.isRanked()) {
- playerFoundMatchMessage = Color.SECONDARY_COLOR + "Found " + type.getName().toLowerCase() + " match: " + CC.GREEN + player.getName() + CC.GRAY + " (" + elo + " elo)" + Color.SECONDARY_COLOR + " vs. " + CC.RED + opponentPlayer.getName() + CC.GRAY + " (" + this.queued.get(opponentPlayer.getUniqueId()).getElo() + " elo)";
- matchedFoundMatchMessage = Color.SECONDARY_COLOR + "Found " + type.getName().toLowerCase() + " match: " + CC.GREEN + opponentPlayer.getName() + CC.GRAY + " (" + this.queued.get(opponentPlayer.getUniqueId()).getElo() + " elo)" + Color.SECONDARY_COLOR + " vs. " + CC.RED + player.getName() + CC.GRAY + " (" + elo + " elo)";
- } else {
- playerFoundMatchMessage = Color.SECONDARY_COLOR + "Found " + type.getName().toLowerCase() + " match: " + CC.GREEN + player.getName() + Color.SECONDARY_COLOR + " vs. " + CC.RED + opponentPlayer.getName();
- matchedFoundMatchMessage = Color.SECONDARY_COLOR + "Found " + type.getName().toLowerCase() + " match: " + CC.GREEN + opponentPlayer.getName() + Color.SECONDARY_COLOR + " vs. " + CC.RED + player.getName();
- }
-
- player.sendMessage(playerFoundMatchMessage);
- opponentPlayer.sendMessage(matchedFoundMatchMessage);
-
- opponentPlayer.sendMessage(Color.SECONDARY_COLOR + "You're playing on the arena " + Color.MAIN_COLOR + arena.getName() + Color.SECONDARY_COLOR + ".");
- player.sendMessage(Color.SECONDARY_COLOR + "You're playing on the arena " + Color.MAIN_COLOR + arena.getName() + Color.SECONDARY_COLOR + ".");
-
- final MatchTeam teamA = new MatchTeam(player.getUniqueId(), Collections.singletonList(player.getUniqueId()), 0);
- final MatchTeam teamB = new MatchTeam(opponentPlayer.getUniqueId(), Collections.singletonList(opponentPlayer.getUniqueId()), 1);
- final Match match = new Match(arena, kit, type, teamA, teamB);
-
- this.plugin.getMatchManager().createMatch(match, false);
-
- this.queued.remove(player.getUniqueId());
- this.queued.remove(opponentPlayer.getUniqueId());
-
- this.playerQueueTime.remove(player.getUniqueId());
-
- return true;
- }
-
- return false;
- }
-
- public void removePlayerFromQueue(Player player) {
- final QueueEntry entry = this.queued.get(player.getUniqueId());
-
- if (entry == null) {
- return;
- }
-
- this.queued.remove(player.getUniqueId());
- this.plugin.getPlayerManager().reset(player);
-
- player.sendMessage(CC.RED + "You've left the " + entry.getQueueType().getName() + " " + entry.getKitName() + " queue.");
- }
-
- public void addPartyToQueue(Player leader, Party party, String kitName, QueueType type) {
- if (type.isRanked() && !this.rankedEnabled) {
- leader.closeInventory();
- } else if (party.getMembers().size() != 2) {
- leader.sendMessage(CC.RED + "There must be at least 2 players in your party to do this.");
- leader.closeInventory();
- } else {
- party.getMembers().stream()
- .map(this.plugin.getPlayerManager()::getPlayerData)
- .forEach(member -> member.setPlayerState(PlayerState.QUEUE));
-
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(leader.getUniqueId());
- final int elo = type.isRanked() ? playerData.getElo(kitName) : -1;
-
- this.queued.put(playerData.getUniqueId(), new QueueEntry(type, kitName, elo, PlayerUtil.getPing(leader), true));
-
- this.giveQueueItems(leader);
-
- final String unrankedMessage = Color.SECONDARY_COLOR + "Your party has been added to the " + Color.MAIN_COLOR + "Unranked 2v2 " + kitName + Color.SECONDARY_COLOR + " queue.";
- final String rankedMessage = Color.SECONDARY_COLOR + "Your party has been added to the " + Color.MAIN_COLOR + "Ranked 2v2 " + kitName + Color.SECONDARY_COLOR + " queue with " + CC.GREEN + elo + " elo" + Color.SECONDARY_COLOR + ".";
-
- party.broadcast(type.isRanked() ? rankedMessage : unrankedMessage);
-
- this.playerQueueTime.put(party.getLeader(), System.currentTimeMillis());
-
- this.findMatch(party, kitName, elo, type);
- }
- }
-
- private void findMatch(Party partyA, String kitName, int elo, QueueType type) {
- if (!this.playerQueueTime.containsKey(partyA.getLeader())) {
- return;
- }
-
- final long queueTime = System.currentTimeMillis() - this.playerQueueTime.get(partyA.getLeader());
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(partyA.getLeader());
-
- if (playerData == null) {
- return;
- }
-
- int eloRange = playerData.getEloRange();
- final int seconds = Math.round(queueTime / 1000L);
-
- if (seconds > 5 && type.isRanked()) {
- eloRange += seconds * 50;
-
- if (eloRange >= 1000) {
- eloRange = 1000;
- }
-
- partyA.broadcast(Color.SECONDARY_COLOR + "Searching in ELO range " + Color.MAIN_COLOR + "[" + (elo - eloRange / 2) + " -> " + (elo + eloRange / 2) + "]");
- }
-
- final int finalEloRange = eloRange;
- final UUID opponent = this.queued.entrySet().stream()
- .filter(entry -> entry.getKey() != partyA.getLeader() && this.plugin.getPlayerManager().getPlayerData(entry.getKey()).getPlayerState() == PlayerState.QUEUE)
- .filter(entry -> entry.getValue().isParty() && entry.getValue().getQueueType() == type)
- .filter(entry -> !type.isRanked() || Math.abs(entry.getValue().getElo() - elo) < finalEloRange && entry.getValue().getKitName().equals(kitName))
- .map(Map.Entry::getKey).findFirst().orElse(null);
-
- if (opponent == null) {
- return;
- }
-
- final PlayerData opponentData = this.plugin.getPlayerManager().getPlayerData(opponent);
-
- if (opponentData.getPlayerState() == PlayerState.FIGHTING || playerData.getPlayerState() == PlayerState.FIGHTING) {
- return;
- }
-
- final Player leaderA = this.plugin.getServer().getPlayer(partyA.getLeader());
- final Player leaderB = this.plugin.getServer().getPlayer(opponent);
-
- final Party partyB = this.plugin.getPartyManager().getParty(opponent);
-
- final Kit kit = this.plugin.getKitManager().getKit(kitName);
- final Arena arena = this.plugin.getArenaManager().getRandomArena(kit);
-
- String partyAFoundMatchMessage;
- String partyBFoundMatchMessage;
-
- if (type.isRanked()) {
- partyAFoundMatchMessage = Color.MAIN_COLOR + leaderB.getName() + Color.SECONDARY_COLOR + "'s Party with " + Color.MAIN_COLOR + this.queued.get(leaderB.getUniqueId()).getElo() + " elo" + Color.SECONDARY_COLOR + ".";
- partyBFoundMatchMessage = Color.MAIN_COLOR + leaderA.getName() + Color.SECONDARY_COLOR + "'s Party with " + Color.MAIN_COLOR + this.queued.get(leaderA.getUniqueId()).getElo() + " elo" + Color.SECONDARY_COLOR + ".";
- } else {
- partyAFoundMatchMessage = Color.MAIN_COLOR + leaderB.getName() + Color.SECONDARY_COLOR + "'s Party.";
- partyBFoundMatchMessage = Color.MAIN_COLOR + leaderA.getName() + Color.SECONDARY_COLOR + "'s Party.";
- }
-
- partyA.broadcast(Color.SECONDARY_COLOR + "Starting a " + partyA.getMembers().size() + "v" + partyB.getMembers().size() + " match against " + partyAFoundMatchMessage);
- partyB.broadcast(Color.SECONDARY_COLOR + "Starting a " + partyB.getMembers().size() + "v" + partyA.getMembers().size() + " match against " + partyBFoundMatchMessage);
-
- final List playersA = new ArrayList<>(partyA.getMembers());
- final List playersB = new ArrayList<>(partyB.getMembers());
-
- final MatchTeam teamA = new MatchTeam(leaderA.getUniqueId(), playersA, 0);
- final MatchTeam teamB = new MatchTeam(leaderB.getUniqueId(), playersB, 1);
-
- final Match match = new Match(arena, kit, type, teamA, teamB);
-
- this.plugin.getMatchManager().createMatch(match, false);
-
- this.queued.remove(partyA.getLeader());
- this.queued.remove(partyB.getLeader());
- }
-
- public void removePartyFromQueue(Party party) {
- final QueueEntry entry = this.queued.get(party.getLeader());
-
- this.queued.remove(party.getLeader());
-
- party.streamPartyMembers().forEach(this.plugin.getPlayerManager()::reset);
- party.broadcast(Color.SECONDARY_COLOR + "Your party has left the " + Color.MAIN_COLOR + entry.getQueueType().getName() + " " + entry.getKitName() + Color.SECONDARY_COLOR + " queue.");
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/SnapshotManager.java b/src/main/java/com/solexgames/practice/managers/SnapshotManager.java
deleted file mode 100644
index 9b2d297..0000000
--- a/src/main/java/com/solexgames/practice/managers/SnapshotManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.practice.match.snapshot.InventorySnapshot;
-import com.solexgames.practice.util.TtlHashMap;
-import lombok.Getter;
-
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-@Getter
-public class SnapshotManager {
-
- private final Map snapshots = new TtlHashMap<>(TimeUnit.SECONDS, 30);
-
- public InventorySnapshot getByPlayer(UUID uuid) {
- return this.snapshots.values().stream()
- .filter(inventorySnapshot -> inventorySnapshot.getBoundPlayer().equals(uuid))
- .findFirst().orElse(null);
- }
-
- public void addSnapshot(InventorySnapshot snapshot) {
- this.snapshots.put(snapshot.getSnapshotId(), snapshot);
- }
-
- public InventorySnapshot getSnapshot(UUID snapshotId) {
- return this.snapshots.get(snapshotId);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/SpawnManager.java b/src/main/java/com/solexgames/practice/managers/SpawnManager.java
deleted file mode 100644
index 0497ac7..0000000
--- a/src/main/java/com/solexgames/practice/managers/SpawnManager.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.location.impl.impl.AsyncLocation;
-import lombok.Getter;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
-
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class SpawnManager {
-
- @Getter
- private final Map> locationMap = new HashMap<>();
-
- public SpawnManager() {
- this.loadAsyncLocationsFromConfig();
- }
-
- public Optional fetchSingleLocation(String id) {
- return Optional.ofNullable(this.locationMap.getOrDefault(id, null) == null || this.locationMap.getOrDefault(id, null).size() == 0 ? null : this.locationMap.getOrDefault(id, null).get(0));
- }
-
- public Optional
> fetchMultipleLocations(String id) {
- return Optional.of(this.locationMap.getOrDefault(id, new ArrayList<>()));
- }
-
- private void loadAsyncLocationsFromConfig() {
- final FileConfiguration config = Practice.getInstance().getConfig();
-
- config.getKeys(false).forEach(sectionId -> {
- final ConfigurationSection section = config.getConfigurationSection(sectionId);
- final List asyncLocations = new ArrayList<>();
-
- final Set keys = section.getKeys(false);
-
- if (keys != null) {
- keys.forEach(number -> {
- final AsyncLocation asyncLocation = AsyncLocation.of(section.getString(number));
- asyncLocations.add(asyncLocation);
- });
- }
-
- this.locationMap.put(sectionId, asyncLocations);
- });
- }
-
- public void saveAsyncLocationsToConfig() {
- final FileConfiguration config = Practice.getInstance().getConfig();
-
- this.locationMap.forEach((id, asyncLocations) -> {
- final AtomicInteger atomicInteger = new AtomicInteger();
-
- asyncLocations.forEach(asyncLocation -> {
- config.set(id + "." + atomicInteger.get(), asyncLocation.toJson());
- });
- });
-
- Practice.getInstance().saveConfig();
- }
-}
diff --git a/src/main/java/com/solexgames/practice/managers/TournamentManager.java b/src/main/java/com/solexgames/practice/managers/TournamentManager.java
deleted file mode 100644
index 3a19409..0000000
--- a/src/main/java/com/solexgames/practice/managers/TournamentManager.java
+++ /dev/null
@@ -1,298 +0,0 @@
-package com.solexgames.practice.managers;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.match.team.impl.MatchTeam;
-import com.solexgames.practice.party.Party;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.runnable.TournamentBroadcastRunnable;
-import com.solexgames.practice.runnable.TournamentRunnable;
-import com.solexgames.practice.tournament.Tournament;
-import com.solexgames.practice.tournament.TournamentState;
-import com.solexgames.practice.tournament.TournamentTeam;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.EXPUtil;
-import com.solexgames.practice.util.TeamUtil;
-import lombok.Getter;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.UUID;
-
-@Getter
-public class TournamentManager {
-
- private final Practice plugin = Practice.getInstance();
-
- private final Map players = new HashMap<>();
- private final Map matches = new HashMap<>();
- private final Map tournaments = new HashMap<>();
- private final Map taskIds = new HashMap<>();
-
- public boolean isInTournament(UUID uuid) {
- return this.players.containsKey(uuid);
- }
-
- public Tournament getTournament(UUID uuid) {
- final Integer id = this.players.get(uuid);
-
- if (id == null) {
- return null;
- }
-
- return this.tournaments.get(id);
- }
-
- public Tournament getTournamentFromMatch(UUID uuid) {
- final Integer id = this.matches.get(uuid);
-
- if (id == null) {
- return null;
- }
-
- return this.tournaments.get(id);
- }
-
- public void createNewTournament(CommandSender sender, int id, int teamSize, int size, String kitName) {
- final Tournament tournament = new Tournament(id, teamSize, size, kitName);
-
- this.tournaments.put(id, tournament);
-
- final BukkitRunnable bukkitRunnable = new TournamentRunnable(tournament);
- bukkitRunnable.runTaskTimerAsynchronously(this.plugin, 0L, 20L);
-
- final BukkitRunnable broadcastRunnable = new TournamentBroadcastRunnable(tournament);
- broadcastRunnable.runTaskTimerAsynchronously(this.plugin, 0L, 200L);
-
- this.taskIds.put(tournament, bukkitRunnable);
-
- sender.sendMessage(new String[]{
- Color.SECONDARY_COLOR + "You've created a new tournament with the id: " + CC.GREEN + id,
- Color.SECONDARY_COLOR + "The team size is currently: " + Color.MAIN_COLOR + teamSize,
- Color.SECONDARY_COLOR + "The maximum capacity is currently: " + Color.MAIN_COLOR + size,
- Color.SECONDARY_COLOR + "The tournament will be running with the kit: " + Color.MAIN_COLOR + kitName,
- "",
- CC.GREEN + "The tournament will start broadcasting in 5 seconds..."
- });
- }
-
- private void removeFromTournament(Tournament tournament, Player player) {
- final TournamentTeam team = tournament.getPlayerTeam(player.getUniqueId());
-
- tournament.removePlayer(player.getUniqueId());
-
- player.sendMessage(CC.GREEN + "You've left the tournament.");
-
- this.players.remove(player.getUniqueId());
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
-
- tournament.broadcast(Color.MAIN_COLOR + player.getName() + Color.SECONDARY_COLOR + " left the tournament." + CC.GREEN + " (" + tournament.getPlayers().size() + "/" + tournament.getSize() + ")");
-
- if (team != null) {
- team.killPlayer(player.getUniqueId());
-
- if (team.getAlivePlayers().size() == 0) {
- tournament.killTeam(team);
-
- if (tournament.getAliveTeams().size() == 1) {
- final TournamentTeam tournamentTeam = tournament.getAliveTeams().get(0);
-
- this.notifyTeamOfRemoval(tournament, tournamentTeam);
- }
- } else {
- if (team.getLeader().equals(player.getUniqueId())) {
- team.setLeader(team.getAlivePlayers().get(0));
- }
- }
- }
- }
-
- private void notifyTeamOfRemoval(Tournament tournament, TournamentTeam tournamentTeam) {
- final String names = TeamUtil.getNames(tournamentTeam);
-
- Bukkit.broadcastMessage(Color.SECONDARY_COLOR + "The tournament has ended and the players " + CC.AQUA + names + Color.SECONDARY_COLOR + " has won.");
-
- for (UUID playerUUID : tournamentTeam.getAlivePlayers()) {
- this.players.remove(playerUUID);
- final Player tournamentPlayer = this.plugin.getServer().getPlayer(playerUUID);
-
- this.plugin.getPlayerManager().sendToSpawnAndReset(tournamentPlayer);
-
- EXPUtil.addExperienceToPlayer(Bukkit.getPlayer(playerUUID), 25, "Playing a Tournament");
- }
-
- this.plugin.getTournamentManager().forceEndTournament(tournament.getId(), false);
- }
-
- private void eliminateTeamFromTournament(Tournament tournament, TournamentTeam winnerTeam, TournamentTeam losingTeam) {
- for (UUID playerUUID : losingTeam.getAlivePlayers()) {
- final Player player = this.plugin.getServer().getPlayer(playerUUID);
-
- tournament.removePlayer(player.getUniqueId());
- this.players.remove(player.getUniqueId());
-
- player.sendMessage(CC.RED + "You've been eliminated from the tournament.");
- }
-
- final String word = losingTeam.getAlivePlayers().size() > 1 ? "have" : "has";
- final boolean isParty = tournament.getTeamSize() > 1;
-
- final String announce = CC.RED + (isParty ? losingTeam.getLeaderName() + "'s Party" : losingTeam.getLeaderName()) + CC.GRAY + " " + word + " been eliminated by " + CC.GREEN + (isParty ? winnerTeam.getLeaderName() + "'s Party" : winnerTeam.getLeaderName()) + CC.GRAY + ".";
- final String alive = CC.YELLOW + "There are now " + CC.AQUA + tournament.getPlayers().size() + "/" + tournament.getSize() + CC.YELLOW + " players remaining in the tournament.";
-
- tournament.broadcast(announce);
- tournament.broadcast(alive);
- }
-
- public void leaveTournament(Player player) {
- final Tournament tournament = this.getTournament(player.getUniqueId());
-
- if (tournament == null) {
- return;
- }
-
- final Party party = this.plugin.getPartyManager().getParty(player.getUniqueId());
-
- if (party != null && tournament.getTournamentState() != TournamentState.FIGHTING) {
- if (this.plugin.getPartyManager().isLeader(player.getUniqueId())) {
- for (UUID memberUUID : party.getMembers()) {
- final Player member = this.plugin.getServer().getPlayer(memberUUID);
-
- this.removeFromTournament(tournament, member);
- }
- } else {
- player.sendMessage(CC.RED + "You're not the leader of the party.");
- }
- } else {
- this.removeFromTournament(tournament, player);
- }
- }
-
- private void addToTournament(Tournament tournament, Player player) {
- tournament.addPlayer(player.getUniqueId());
-
- this.players.put(player.getUniqueId(), tournament.getId());
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
-
- tournament.broadcast(Color.MAIN_COLOR + player.getName() + Color.SECONDARY_COLOR + " joined the tournament." + CC.GREEN + " (" + tournament.getPlayers().size() + "/" + tournament.getSize() + ")");
- }
-
- public void joinTournament(Integer id, Player player) {
- final Tournament tournament = this.tournaments.get(id);
-
- if (tournament == null) {
- return;
- }
-
- final Party party = this.plugin.getPartyManager().getParty(player.getUniqueId());
-
- if (party != null) {
- if (this.plugin.getPartyManager().isLeader(player.getUniqueId())) {
- if ((party.getMembers().size() + tournament.getPlayers().size()) <= tournament.getSize()) {
- if (party.getMembers().size() != tournament.getTeamSize() || party.getMembers().size() == 1) {
- player.sendMessage(CC.RED + "Error: Your party must have " + CC.YELLOW + tournament.getTeamSize() + CC.RED + " players max.");
- } else {
- for (UUID memberUUID : party.getMembers()) {
- final Player member = this.plugin.getServer().getPlayer(memberUUID);
-
- this.addToTournament(tournament, member);
- }
- }
- } else {
- player.sendMessage(CC.RED + "Error: The tournament's currently full.");
- }
- } else {
- player.sendMessage(CC.RED + "Error: You're not the leader of your party.");
- }
- } else {
- this.addToTournament(tournament, player);
- }
-
- if (tournament.getPlayers().size() == tournament.getSize()) {
- tournament.setTournamentState(TournamentState.STARTING);
- }
- }
-
- public Tournament getTournament(Integer id) {
- return this.tournaments.getOrDefault(id, null);
- }
-
- public void forceEndTournament(Integer id, boolean force) {
- final Tournament tournament = this.tournaments.get(id);
-
- if (tournament == null) {
- return;
- }
-
- if (force) {
- final Iterator players = this.players.keySet().iterator();
-
- while (players.hasNext()) {
- final Player player = Bukkit.getPlayer(players.next());
-
- if (player != null) {
- player.sendMessage(CC.RED + "The tournament you were previously in has been ended.");
-
- this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> {
- final PlayerData playerData = this.plugin.getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (playerData != null && tournament.getTournamentState().equals(TournamentState.FIGHTING)) {
- this.plugin.getMatchManager().removeFighter(player, playerData, false);
- }
-
- this.plugin.getPlayerManager().sendToSpawnAndReset(player);
- }, 2L);
- }
-
- players.remove();
- }
- }
-
- if (this.taskIds.containsKey(tournament)) {
- this.taskIds.get(tournament).cancel();
- }
-
- this.tournaments.remove(id);
- }
-
- public void addMatchToTournament(UUID matchId, Integer tournamentId) {
- this.matches.put(matchId, tournamentId);
- }
-
- public void removeMatchFromTournament(Match match) {
- final Tournament tournament = this.getTournamentFromMatch(match.getMatchId());
-
- if (tournament == null) {
- return;
- }
-
- tournament.removeMatch(match.getMatchId());
- this.matches.remove(match.getMatchId());
-
- final MatchTeam losingTeam = match.getWinningTeamId() == 0 ? match.getTeams().get(1) : match.getTeams().get(0);
- final TournamentTeam losingTournamentTeam = tournament.getPlayerTeam(losingTeam.getPlayers().get(0));
-
- tournament.killTeam(losingTournamentTeam);
-
- final MatchTeam winningTeam = match.getTeams().get(match.getWinningTeamId());
- final TournamentTeam winningTournamentTeam = tournament.getPlayerTeam(winningTeam.getAlivePlayers().get(0));
-
- this.eliminateTeamFromTournament(tournament, winningTournamentTeam, losingTournamentTeam);
-
- if (tournament.getMatches().size() == 0) {
- if (tournament.getAliveTeams().size() > 1) {
- tournament.setTournamentState(TournamentState.STARTING);
- tournament.setCurrentRound(tournament.getCurrentRound() + 1);
- tournament.setCountdown(16);
- } else {
- this.notifyTeamOfRemoval(tournament, winningTournamentTeam);
- }
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/match/Match.java b/src/main/java/com/solexgames/practice/match/Match.java
deleted file mode 100644
index 981b2d9..0000000
--- a/src/main/java/com/solexgames/practice/match/Match.java
+++ /dev/null
@@ -1,228 +0,0 @@
-package com.solexgames.practice.match;
-
-import com.google.common.collect.Sets;
-import com.solexgames.core.util.SaltUtil;
-import com.solexgames.core.util.clickable.Clickable;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.arena.Arena;
-import com.solexgames.practice.arena.type.StandaloneArena;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.match.snapshot.InventorySnapshot;
-import com.solexgames.practice.match.team.impl.MatchTeam;
-import com.solexgames.practice.queue.QueueType;
-import io.netty.util.internal.ConcurrentSet;
-import lombok.Getter;
-import lombok.Setter;
-import net.md_5.bungee.api.chat.BaseComponent;
-import org.apache.commons.lang.time.DurationFormatUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.Sound;
-import org.bukkit.block.BlockState;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Stream;
-
-@Getter
-@Setter
-public class Match {
-
- private final Practice plugin = Practice.getInstance();
-
- private final Map snapshots = new HashMap<>();
- private final Map lives = new HashMap<>();
-
- private final UUID matchId = UUID.randomUUID();
- private final String shortMatchId = SaltUtil.getRandomSaltedString(7);
-
- private final Set entitiesToRemove = new HashSet<>();
-
- private final Set originalBlockChanges = Sets.newConcurrentHashSet();
- private final Set placedBlockLocations = Sets.newConcurrentHashSet();
-
- private final Set spectators = new ConcurrentSet<>();
- private final Set haveSpectated = new HashSet<>();
-
- private final Set taskIds = new HashSet<>();
-
- private final List teams;
-
- private final QueueType type;
- private final Arena arena;
- private final Kit kit;
-
- private final boolean redRover;
- private final long start;
- private final int rounds;
-
- private boolean shouldGiveXp = true;
-
- @Getter
- private StandaloneArena standaloneArena;
-
- private MatchState matchState = MatchState.STARTING;
-
- private int winningTeamId;
- private int countdown = 6;
-
- private Map betPool = new HashMap<>();
-
- public Match(Arena arena, Kit kit, QueueType type, MatchTeam... teams) {
- this(arena, kit, type, false, 1, teams);
- }
-
- public Match(Arena arena, Kit kit, QueueType type, int rounds, MatchTeam... teams) {
- this(arena, kit, type, false, rounds, teams);
- }
-
- public Match(Arena arena, Kit kit, QueueType type, boolean redRover, int rounds, MatchTeam... teams) {
- this.arena = arena;
- this.kit = kit;
- this.type = type;
- this.redRover = redRover;
- this.rounds = rounds;
- this.start = System.currentTimeMillis();
- this.teams = Arrays.asList(teams);
- }
-
- public void addSpectator(UUID uuid) {
- this.spectators.add(uuid);
- }
-
- public void removeSpectator(UUID uuid) {
- this.spectators.remove(uuid);
- }
-
- public void addHaveSpectated(UUID uuid) {
- this.haveSpectated.add(uuid);
- }
-
- public boolean haveSpectated(UUID uuid) {
- return this.haveSpectated.contains(uuid);
- }
-
- public void addSnapshot(Player player) {
- this.snapshots.put(player.getUniqueId(), new InventorySnapshot(player, this));
- }
-
- public boolean hasSnapshot(UUID uuid) {
- return this.snapshots.containsKey(uuid);
- }
-
- public InventorySnapshot getSnapshot(UUID uuid) {
- return this.snapshots.get(uuid);
- }
-
- public void addEntityToRemove(Entity entity) {
- this.entitiesToRemove.add(entity);
- }
-
- public void removeEntityToRemove(Entity entity) {
- this.entitiesToRemove.remove(entity);
- }
-
- public void clearEntitiesToRemove() {
- this.entitiesToRemove.clear();
- }
-
- public void addRunnable(int id) {
- this.taskIds.add(id);
- }
-
- public void addOriginalBlockChange(BlockState blockState) {
- this.originalBlockChanges.add(blockState);
- }
-
- public void addPlacedBlockLocation(Location location) {
- this.placedBlockLocations.add(location);
- }
-
- public void broadcast(String message) {
- this.teams.forEach(team -> team.streamAlivePlayers().forEach(player -> player.sendMessage(message)));
- this.streamSpectators().forEach(spectator -> spectator.sendMessage(message));
- }
-
- public void broadcast(String... message) {
- this.teams.forEach(team -> team.streamAlivePlayers().forEach(player -> player.sendMessage(message)));
- this.streamSpectators().forEach(spectator -> spectator.sendMessage(message));
- }
-
- public void broadcast(Clickable message) {
- this.teams.forEach(team -> team.streamAlivePlayers().forEach(player -> player.spigot().sendMessage(message.asComponents())));
- this.streamSpectators().forEach(player -> player.spigot().sendMessage(message.asComponents()));
- }
-
- public void broadcast(BaseComponent[] message) {
- this.teams.forEach(team -> team.streamAlivePlayers().forEach(player -> player.spigot().sendMessage(message)));
- this.streamSpectators().forEach(player -> player.spigot().sendMessage(message));
- }
-
- public void broadcast(String message, Sound sound) {
- this.teams.forEach(team -> team.getPlayers().forEach(uuid -> {
- final Player player = Bukkit.getPlayer(uuid);
-
- player.sendMessage(message);
- player.playSound(player.getLocation(), sound, 10.0F, 1.0F);
- }));
- this.spectators.forEach(spectator -> {
- final Player player = Bukkit.getPlayer(spectator);
-
- player.sendMessage(message);
- player.playSound(player.getLocation(), sound, 10.0F, 1.0F);
- });
- }
-
- public MatchTeam getTeamById(int id) {
- return this.teams.stream().filter(team -> team.getTeamID() == id).findFirst().orElse(null);
- }
-
- public MatchTeam getTeamByPlayer(UUID uuid) {
- return this.teams.stream().filter(team -> team.getPlayers().contains(uuid)).findFirst().orElse(null);
- }
-
- public Stream streamSpectators() {
- return this.spectators.stream()
- .map(this.plugin.getServer()::getPlayer)
- .filter(Objects::nonNull);
- }
-
- public int decrementCountdown() {
- return --this.countdown;
- }
-
- public boolean isParty() {
- return this.isFFA() || this.teams.get(0).getPlayers().size() != 1 && this.teams.get(1).getPlayers().size() != 1;
- }
-
- public boolean isPartyMatch() {
- return this.isFFA() || (this.teams.get(0).getPlayers().size() >= 2 || this.teams.get(1).getPlayers().size() >= 2);
- }
-
- public boolean isFFA() {
- return this.teams.size() == 1;
- }
-
- public String getDuration() {
- final long duration = System.currentTimeMillis() - this.start;
- return DurationFormatUtils.formatDuration(duration, "mm:ss");
- }
-
- // Surely there is a better way to do this???
- public int getTotalBets() {
- return this.betPool.values()
- .stream()
- .mapToInt(value -> value)
- .sum();
- }
-
- public void addBet(UUID uuid, int amount) {
-
- }
-
- public void removeBet(UUID uuid) {
-
- }
-}
diff --git a/src/main/java/com/solexgames/practice/match/MatchRequest.java b/src/main/java/com/solexgames/practice/match/MatchRequest.java
deleted file mode 100644
index 08884a4..0000000
--- a/src/main/java/com/solexgames/practice/match/MatchRequest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.solexgames.practice.match;
-
-import com.solexgames.practice.arena.Arena;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.UUID;
-
-@Getter
-@RequiredArgsConstructor
-public class MatchRequest {
-
- private final UUID requester;
- private final UUID requested;
-
- private final Arena arena;
- private final String kitName;
-
- private final boolean party;
-
-}
diff --git a/src/main/java/com/solexgames/practice/match/MatchState.java b/src/main/java/com/solexgames/practice/match/MatchState.java
deleted file mode 100644
index d0c43d5..0000000
--- a/src/main/java/com/solexgames/practice/match/MatchState.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.solexgames.practice.match;
-
-public enum MatchState {
-
- STARTING,
- FIGHTING,
- SWITCHING,
- ENDING
-
-}
diff --git a/src/main/java/com/solexgames/practice/match/snapshot/InventorySnapshot.java b/src/main/java/com/solexgames/practice/match/snapshot/InventorySnapshot.java
deleted file mode 100644
index 5c80dbb..0000000
--- a/src/main/java/com/solexgames/practice/match/snapshot/InventorySnapshot.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.solexgames.practice.match.snapshot;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.PlayerUtil;
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.Menu;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.match.Match;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.MathUtil;
-import com.solexgames.practice.util.StringUtil;
-import lombok.Getter;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.potion.PotionEffect;
-
-import java.util.*;
-
-@Getter
-public class InventorySnapshot extends Menu {
-
- private static final List NO_EFFECT_LIST = Collections.singletonList(
- CC.RED + "No potion effects found!"
- );
-
- private static final ItemStack AIR = new ItemStack(Material.AIR);
-
- private final UUID boundPlayer;
-
- private final ItemStack[] originalInventory;
- private final ItemStack[] originalArmor;
-
- private final UUID snapshotId = UUID.randomUUID();
-
- private final double health;
- private final double food;
-
- private final int longestCombo;
- private final int totalHits;
-
- private final Player target;
- private final Map buttonMap = new HashMap<>();
-
- private int potCount = 0;
- private int soupCount = 0;
-
- private boolean potionMatch;
- private boolean soupMatch;
-
- public InventorySnapshot(Player player, Match match) {
- final ItemStack[] contents = player.getInventory().getContents();
- final ItemStack[] armor = player.getInventory().getArmorContents();
-
- this.boundPlayer = player.getUniqueId();
-
- this.originalInventory = contents;
- this.originalArmor = armor;
-
- this.target = player;
-
- final PlayerData playerData = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- this.health = player.getHealth();
- this.food = player.getFoodLevel();
-
- final List potionEffectStrings = new ArrayList<>();
-
- for (PotionEffect potionEffect : player.getActivePotionEffects()) {
- final String romanNumeral = MathUtil.convertToRomanNumeral(potionEffect.getAmplifier() + 1);
- final String effectName = StringUtil.toNiceString(potionEffect.getType().getName().toLowerCase());
- final String duration = MathUtil.convertTicksToMinutes(potionEffect.getDuration());
-
- potionEffectStrings.add(CC.GRAY + " - " + CC.WHITE + effectName + " " + romanNumeral + CC.GRAY + " (" + duration + ")");
- }
-
- for (int i = 0; i < 9; i++) {
- this.buttonMap.put(i + 27, new ItemBuilder(contents[i] == null ? InventorySnapshot.AIR : contents[i]).toButton());
- this.buttonMap.put(i + 18, new ItemBuilder(contents[i + 27] == null ? InventorySnapshot.AIR : contents[i + 27]).toButton());
- this.buttonMap.put(i + 9, new ItemBuilder(contents[i + 18] == null ? InventorySnapshot.AIR : contents[i + 18]).toButton());
- this.buttonMap.put(i, new ItemBuilder(contents[i + 9] == null ? InventorySnapshot.AIR : contents[i + 9]).toButton());
- }
-
- potionMatch = false;
- soupMatch = false;
-
- for (final ItemStack item : match.getKit().getContents()) {
- if (item == null) {
- continue;
- }
-
- if (item.getType() == Material.MUSHROOM_SOUP) {
- soupMatch = true;
- break;
- } else if (item.getType() == Material.POTION && item.getDurability() == (short) 16421) {
- potionMatch = true;
- break;
- }
- }
-
- if (potionMatch) {
- this.potCount = (int) Arrays.stream(contents).filter(Objects::nonNull).map(ItemStack::getDurability).filter(d -> d == 16421).count();
-
- this.buttonMap.put(48, new ItemBuilder(Material.POTION)
- .setDisplayName(CC.AQUA + "Potion Statistics")
- .setDurability(16421)
- .setAmount(this.potCount)
- .addLore(
- CC.GRAY + "Health Pots: " + CC.WHITE + this.potCount + " potion" + (this.potCount > 1 ? "s" : ""),
- CC.GRAY + "Missed Pots: " + CC.WHITE + playerData.getMissedPots() + " potion" + (playerData.getMissedPots() > 1 ? "s" : "")
- )
- .toButton()
- );
- } else if (soupMatch) {
- this.soupCount = (int) Arrays.stream(contents).filter(Objects::nonNull).map(ItemStack::getType).filter(d -> d == Material.MUSHROOM_SOUP).count();
-
- this.buttonMap.put(48, new ItemBuilder(Material.MUSHROOM_SOUP)
- .setDisplayName(CC.GRAY + "Soups Left: " + CC.WHITE + this.soupCount)
- .setAmount(this.soupCount)
- .toButton()
- );
- }
-
- final double roundedHealth = Math.round(health / 2.0 * 2.0) / 2.0;
-
- this.buttonMap.put(45, new ItemBuilder(Material.SPECKLED_MELON)
- .setDisplayName(CC.GRAY + "Health: " + CC.AQUA + roundedHealth)
- .setAmount((int) roundedHealth)
- .toButton()
- );
-
- final double roundedFood = Math.round(health / 2.0 * 2.0) / 2.0;
-
- this.buttonMap.put(46, new ItemBuilder(Material.COOKED_BEEF)
- .setDisplayName(CC.GRAY + "Hunger: " + CC.AQUA + roundedFood)
- .setAmount((int) roundedFood)
- .toButton()
- );
-
- this.buttonMap.put(47, new ItemBuilder(Material.POTION)
- .setDisplayName(CC.AQUA + "Potion Effects")
- .setAmount(potionEffectStrings.size())
- .addLore(
- potionEffectStrings.isEmpty() ? InventorySnapshot.NO_EFFECT_LIST : potionEffectStrings
- )
- .toButton()
- );
-
- this.longestCombo = playerData.getLongestCombo();
- this.totalHits = playerData.getHits();
-
- final int ping = PlayerUtil.getPing(player);
-
- this.buttonMap.put(49, new ItemBuilder(Material.PAPER)
- .setDisplayName(CC.AQUA + "Match Statistics")
- .addLore(
- CC.GRAY + "Longest Combo: " + CC.WHITE + playerData.getLongestCombo() + " hit" + (playerData.getLongestCombo() > 1 ? "s" : ""),
- CC.GRAY + "Total Hits: " + CC.WHITE + playerData.getHits() + " hit" + (playerData.getHits() > 1 ? "s" : ""),
- CC.GRAY + "Average Ping: " + CC.WHITE + (ping == 1 ? "Unknown" : ping + " ms")
- )
- .toButton()
- );
-
- if (!match.isParty()) {
- this.buttonMap.put(53, new ItemBuilder(Material.LEVER)
- .setDisplayName(Color.MAIN_COLOR + "Opponent's Inventory")
- .addLore(
- CC.GRAY + "See your opponent's inventory",
- CC.GRAY + "and combat details."
- )
- .toButton((player1, clickType) -> {
- final UUID uuid = Practice.getInstance().getMatchManager().getRematcherInventory(player.getUniqueId());
-
- if (uuid == null) {
- player1.sendMessage(CC.RED + "The inventory you're currently viewing has expired.");
- player1.closeInventory();
- return;
- }
-
- player1.performCommand("inventory " + uuid);
- })
- );
- }
-
- for (int i = 36; i < 40; i++) {
- this.buttonMap.put(i, new ItemBuilder(armor[39 - i] == null ? InventorySnapshot.AIR : armor[39 - i])
- .toButton()
- );
- }
- }
-
- @Override
- public String getTitle(Player player) {
- return "Inventory » " + this.target.getDisplayName();
- }
-
- @Override
- public Map getButtons(Player player) {
- return this.buttonMap;
- }
-
- @Override
- public int getSize() {
- return 54;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/match/team/KillableTeam.java b/src/main/java/com/solexgames/practice/match/team/KillableTeam.java
deleted file mode 100644
index 830a980..0000000
--- a/src/main/java/com/solexgames/practice/match/team/KillableTeam.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.solexgames.practice.match.team;
-
-import com.solexgames.practice.Practice;
-import lombok.Getter;
-import lombok.Setter;
-import org.bukkit.entity.Player;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.UUID;
-import java.util.stream.Stream;
-
-@Getter
-@Setter
-public class KillableTeam {
-
- protected final Practice plugin = Practice.getInstance();
-
- private final List players;
- private final List alivePlayers = new ArrayList<>();
- private final String leaderName;
-
- private UUID leader;
-
- public KillableTeam(UUID leader, List players) {
- this.leader = leader;
- this.leaderName = this.plugin.getServer().getPlayer(leader).getName();
- this.players = players;
- this.alivePlayers.addAll(players);
- }
-
- public void killPlayer(UUID playerUUID) {
- this.alivePlayers.remove(playerUUID);
- }
-
- public Stream streamAlivePlayers() {
- return this.players.stream()
- .map(this.plugin.getServer()::getPlayer)
- .filter(Objects::nonNull);
- }
-}
diff --git a/src/main/java/com/solexgames/practice/match/team/impl/MatchTeam.java b/src/main/java/com/solexgames/practice/match/team/impl/MatchTeam.java
deleted file mode 100644
index b352d50..0000000
--- a/src/main/java/com/solexgames/practice/match/team/impl/MatchTeam.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.solexgames.practice.match.team.impl;
-
-import com.solexgames.practice.match.team.KillableTeam;
-import lombok.Getter;
-
-import java.util.List;
-import java.util.UUID;
-
-@Getter
-public class MatchTeam extends KillableTeam {
-
- private final int teamID;
-
- public MatchTeam(UUID leader, List players, int teamID) {
- super(leader, players);
- this.teamID = teamID;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/menu/DeathEffectMenu.java b/src/main/java/com/solexgames/practice/menu/DeathEffectMenu.java
deleted file mode 100644
index 3727a32..0000000
--- a/src/main/java/com/solexgames/practice/menu/DeathEffectMenu.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.solexgames.practice.menu;
-
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.Menu;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.util.CC;
-import org.bukkit.entity.Player;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author GrowlyX
- * @since 7/7/2021
- */
-
-public class DeathEffectMenu extends Menu {
-
- @Override
- public String getTitle(Player player) {
- return "Death Effects";
- }
-
- @Override
- public Map getButtons(Player player) {
- final Map buttonMap = new HashMap<>();
- final AtomicInteger atomicInteger = new AtomicInteger();
- final PlayerData data = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- Practice.getInstance().getEffectManager().getEffectList().forEach(effect -> {
- final boolean equipped = data.getEffect().getName().equals(effect.getName());
-
- buttonMap.put(atomicInteger.getAndIncrement(), new ItemBuilder(effect.getIcon())
- .setDisplayName(equipped ? CC.GREEN + effect.getName() : CC.RED + effect.getName())
- .addLore(
- equipped ? CC.GRAY + "You have this equipped." : CC.GRAY + "You don't have this equipped.",
- "",
- equipped ? CC.RED + "[Already have equipped]" : CC.YELLOW + "[Click to equip]"
- )
- .toUpdatingButton((player1, clickType) -> {
- if (equipped) {
- player.sendMessage(CC.RED + "You already have this effect equipped.");
- return;
- }
-
- if (effect.getPermission() != null && !player.hasPermission(effect.getPermission())) {
- player.sendMessage(CC.RED + "You don't have permission to apply this cosmetic.");
- return;
- }
-
- data.setEffect(effect);
- player.sendMessage(CC.YELLOW + "You've equipped the " + CC.AQUA + effect.getName() + CC.YELLOW + " effect.");
- })
- );
- });
-
- return buttonMap;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/menu/DivisionViewMenu.java b/src/main/java/com/solexgames/practice/menu/DivisionViewMenu.java
deleted file mode 100644
index f0b1d5e..0000000
--- a/src/main/java/com/solexgames/practice/menu/DivisionViewMenu.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.solexgames.practice.menu;
-
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.pagination.PaginatedMenu;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.division.RankedDivision;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author GrowlyX
- * @since 8/12/2021
- */
-
-public class DivisionViewMenu extends PaginatedMenu {
-
- private final Player target;
-
- public DivisionViewMenu(Player target) {
- super(9);
-
- this.target = target;
- }
-
- @Override
- public Map getGlobalButtons(Player player) {
- final Map buttonMap = new HashMap<>();
-
- buttonMap.put(4, new ItemBuilder(Material.BED)
- .setDisplayName(CC.RED + "Click to return")
- .addLore(
- CC.GRAY + "Return to the main",
- CC.GRAY + "statistics menu."
- )
- .toButton((player1, clickType) -> {
- new StatisticsMenu(this.target).openMenu(player1);
- })
- );
-
- return buttonMap;
- }
-
- @Override
- public String getPrePaginatedTitle(Player player) {
- return "Divisions";
- }
-
- @Override
- public Map getAllPagesButtons(Player player) {
- final Map buttonMap = new HashMap<>();
- final AtomicInteger atomicInteger = new AtomicInteger();
-
- RankedDivision.DIVISIONS.forEach(division -> {
- buttonMap.put(atomicInteger.getAndIncrement(), new ItemBuilder(Material.GLOWSTONE_DUST)
- .setDisplayName(division.getFancyName())
- .addLore(
- CC.GRAY + "Minimum ELO: " + CC.WHITE + division.getMinimum(),
- CC.GRAY + "Maximum ELO: " + CC.WHITE + division.getMaximum()
- )
- .toButton()
- );
- });
-
- return buttonMap;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/menu/EventHostMenu.java b/src/main/java/com/solexgames/practice/menu/EventHostMenu.java
deleted file mode 100644
index 24d9d53..0000000
--- a/src/main/java/com/solexgames/practice/menu/EventHostMenu.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package com.solexgames.practice.menu;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.Menu;
-import com.solexgames.practice.util.CC;
-import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author GrowlyX
- * @since 5/15/2021
- */
-
-public class EventHostMenu extends Menu {
-
- @Override
- public String getTitle(Player player) {
- return "Host an Event";
- }
-
- @Override
- public Map getButtons(Player player) {
- final Map buttonMap = new HashMap<>();
-
- buttonMap.put(1, new ItemBuilder(Material.GOLD_BOOTS)
- .setDisplayName(Color.MAIN_COLOR + "TNT Run")
- .addLore(
- "&7Run around the arena",
- "&7while tnt disappears",
- "&7behind you. Try not to",
- "&7fall to your death!",
- "",
- "&7You need the &6Gold&7",
- "&7rank to host this event.",
- "",
- "&e[Click to host TNT Run]"
- )
- .toButton((player1, clickType) -> {
- Bukkit.dispatchCommand(player1, "host TNTRun");
- player.closeInventory();
- })
- );
-
- buttonMap.put(2, new ItemBuilder(Material.WOOL)
- .setDurability(3)
- .setDisplayName(Color.MAIN_COLOR + "4Corners")
- .addLore(
- "&7Players choose a platform",
- "&7out of four and hope their ",
- "&7choice lets them live.",
- "",
- "&7You need the &aBasic&7",
- "&7rank to host this event.",
- "",
- "&e[Click to host 4Corners]"
- )
- .toButton((player1, clickType) -> {
- Bukkit.dispatchCommand(player1, "host 4Corners");
- player.closeInventory();
- })
- );
- buttonMap.put(3, new ItemBuilder(Material.BOW)
- .setDisplayName(Color.MAIN_COLOR + "One in the Chamber")
- .addLore(
- "&7Players kill each other to",
- "&7become the first to " + Color.SECONDARY_COLOR + CC.BOLD + "20 kills&7.",
- "",
- "&7You need the &aBasic&7",
- "&7rank to host this event.",
- "",
- "&e[Click to host OITC]"
- )
- .toButton((player1, clickType) -> {
- Bukkit.dispatchCommand(player1, "host OITC");
- player.closeInventory();
- })
- );
- buttonMap.put(5, new ItemBuilder(Material.STICK)
- .setDisplayName(Color.MAIN_COLOR + "Sumo")
- .addLore(
- "&7Players attempt to hit their",
- "&7opponent of the round platform.",
- "",
- "&7You need the &7Silver&7",
- "&7rank to host this event.",
- "",
- "&e[Click to host Sumo]"
- )
- .toButton((player1, clickType) -> {
- Bukkit.dispatchCommand(player1, "host Sumo");
- player.closeInventory();
- })
- );
- buttonMap.put(6, new ItemBuilder(Material.GOLD_PLATE)
- .setDisplayName(Color.MAIN_COLOR + "Parkour")
- .addLore(
- "&7Jump across the map and try",
- "&7to beat your opponent to the",
- "&7end of the arena.",
- "",
- "&7You need the &7Silver&7",
- "&7rank to host this event.",
- "",
- "&e[Click to host Parkour]"
- )
- .toButton((player1, clickType) -> {
- Bukkit.dispatchCommand(player1, "host Parkour");
- player.closeInventory();
- })
- );
- buttonMap.put(7, new ItemBuilder(Material.DIAMOND_AXE)
- .setDisplayName(Color.MAIN_COLOR + "Last Man Standing")
- .addLore(
- "&7Play with 75 other players in",
- "&7a large arena and try to stay",
- "&7alive until the end.",
- "",
- "&7You need the &bPlatinum&7",
- "&7rank to host this event.",
- "",
- "&c[This event is coming soon]"
- )
- .toButton((player1, clickType) -> {
- Bukkit.dispatchCommand(player1, "host LMS");
- player.closeInventory();
- })
- );
-
- return buttonMap;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/menu/JoinQueueMenu.java b/src/main/java/com/solexgames/practice/menu/JoinQueueMenu.java
deleted file mode 100644
index 72a7526..0000000
--- a/src/main/java/com/solexgames/practice/menu/JoinQueueMenu.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.solexgames.practice.menu;
-
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.Menu;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.party.Party;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.queue.QueueType;
-import com.solexgames.practice.runnable.LeaderboardUpdateRunnable;
-import com.solexgames.practice.runnable.cache.StatusCache;
-import com.solexgames.practice.util.CC;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.inventory.ClickType;
-import org.bukkit.inventory.ItemFlag;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.*;
-
-/**
- * @author GrowlyX
- * @since 5/15/2021
- */
-
-@Getter
-@RequiredArgsConstructor
-public class JoinQueueMenu extends Menu {
-
- private final QueueType queueType;
-
- @Override
- public String getTitle(Player player) {
- return "Join an " + this.queueType.getName() + " queue";
- }
-
- @Override
- public Map getButtons(Player player) {
- final Map buttonMap = new HashMap<>();
- final PlayerData data = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (this.queueType.isRanked()) {
- Practice.getInstance().getKitManager().getKits().stream()
- .filter(Objects::nonNull)
- .filter(Kit::isRanked)
- .filter(Kit::isEnabled)
- .forEachOrdered(kit -> buttonMap.put(kit.getQueueMenu() + 10, new KitButton(kit, data)));
- } else {
- Practice.getInstance().getKitManager().getKits().stream()
- .filter(Objects::nonNull)
- .filter(Kit::isEnabled)
- .forEachOrdered(kit -> buttonMap.put(kit.getQueueMenu() + 10, new KitButton(kit, data)));
- }
-
- return buttonMap;
- }
-
- @RequiredArgsConstructor
- private class KitButton extends Button {
-
- private final Kit queue;
- private final PlayerData data;
-
- @Override
- public ItemStack getButtonItem(final Player player) {
- final List lore = new ArrayList<>();
- final int playing = StatusCache.getInstance().getFightingKits().get(this.queue);
-
- lore.add("&7In Queue: &f" + Practice.getInstance().getQueueManager().getQueueSize(this.queue.getName(), JoinQueueMenu.this.queueType));
- lore.add("&7In Fights: &f" + playing);
- lore.add(" ");
- lore.add("&6&lDaily Winstreaks:");
- lore.addAll(LeaderboardUpdateRunnable.KIT_SPECIFIC_WIN_STREAK_LORE_SHORT.getOrDefault(this.queue, Collections.emptyList()));
- lore.add(" ");
- lore.add(CC.YELLOW + "[Click to join queue]");
-
- return new ItemBuilder(this.queue.getIcon().clone())
- .setDisplayName(Color.MAIN_COLOR + CC.BOLD + this.queue.getName())
- .addLore(lore)
- .setAmount(playing > 64 ? 64 : playing == 0 ? 1 : playing)
- .addItemFlags(ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ENCHANTS)
- .create();
- }
-
- @Override
- public void clicked(Player player, ClickType clickType) {
- final Party party = Practice.getInstance().getPartyManager().getParty(player.getUniqueId());
-
- if (this.data.getPlayerState() != PlayerState.SPAWN) {
- player.sendMessage(CC.RED + "You must be at spawn to queue for a ladder.");
- return;
- }
-
- player.closeInventory();
-
- if (this.queue != null) {
- if (party == null) {
- Practice.getInstance().getQueueManager().addPlayerToQueue(player, this.data, this.queue.getName(), JoinQueueMenu.this.queueType);
- } else if (Practice.getInstance().getPartyManager().isLeader(player.getUniqueId())) {
- Practice.getInstance().getQueueManager().addPartyToQueue(player, party, this.queue.getName(), JoinQueueMenu.this.queueType);
- }
- }
- }
- }
-
- @Override
- public int getSize() {
- return 36;
- }
-
- @Override
- public boolean isFillBorders() {
- return true;
- }
-
- @Override
- public boolean isAutoUpdate() {
- return true;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/menu/KillMessageMenu.java b/src/main/java/com/solexgames/practice/menu/KillMessageMenu.java
deleted file mode 100644
index 8a6dd09..0000000
--- a/src/main/java/com/solexgames/practice/menu/KillMessageMenu.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.solexgames.practice.menu;
-
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.Menu;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.util.CC;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author GrowlyX
- * @since 7/7/2021
- */
-
-public class KillMessageMenu extends Menu {
-
- @Override
- public String getTitle(Player player) {
- return "Kill Messages";
- }
-
- @Override
- public Map getButtons(Player player) {
- final Map buttonMap = new HashMap<>();
- final AtomicInteger atomicInteger = new AtomicInteger();
- final PlayerData data = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- Practice.getInstance().getEffectManager().getMessageList().forEach(message -> {
- final boolean equipped = data.getDeathMessageType().equals(message.getName());
-
- buttonMap.put(atomicInteger.getAndIncrement(), new ItemBuilder(Material.BOOK_AND_QUILL)
- .setDisplayName(equipped ? CC.GREEN + message.getName() : CC.RED + message.getName())
- .addLore(
- equipped ? CC.GRAY + "You have this equipped." : CC.GRAY + "You don't have this equipped.",
- "",
- equipped ? CC.RED + "[Already have equipped]" : CC.YELLOW + "[Click to equip]"
- )
- .toUpdatingButton((player1, clickType) -> {
- if (equipped) {
- player.sendMessage(CC.RED + "You already have this effect equipped.");
- return;
- }
-
- if (!message.getName().equals("Normal") && !player.hasPermission("practice.killmessages." + message.getName().toLowerCase())) {
- player.sendMessage(CC.RED + "You don't have permission to apply this cosmetic.");
- return;
- }
-
- data.setDeathMessageType(message.getName());
-
- player.sendMessage(CC.YELLOW + "You've equipped the " + CC.AQUA + message.getName() + CC.YELLOW + " kill message bundle.");
- })
- );
- });
-
- return buttonMap;
- }
-}
diff --git a/src/main/java/com/solexgames/practice/menu/KyroJoinQueueMenu.java b/src/main/java/com/solexgames/practice/menu/KyroJoinQueueMenu.java
deleted file mode 100644
index 7d4aac9..0000000
--- a/src/main/java/com/solexgames/practice/menu/KyroJoinQueueMenu.java
+++ /dev/null
@@ -1,228 +0,0 @@
-package com.solexgames.practice.menu;
-
-import com.cryptomorin.xseries.XMaterial;
-import com.solexgames.core.menu.impl.SettingsMenu;
-import com.solexgames.core.util.Color;
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.Menu;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.party.Party;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.player.PlayerState;
-import com.solexgames.practice.queue.QueueType;
-import com.solexgames.practice.util.CC;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.commons.lang3.StringUtils;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.inventory.ClickType;
-import org.bukkit.inventory.ItemFlag;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author GrowlyX
- * @since 5/15/2021
- */
-
-@Getter
-@RequiredArgsConstructor
-public class KyroJoinQueueMenu extends Menu {
-
- private final QueueType queueType;
-
- @Override
- public String getTitle(Player player) {
- return this.queueType.getName() + " Queue";
- }
-
- @Override
- public Map getButtons(Player player) {
- final Map buttonMap = new HashMap<>();
- final AtomicInteger atomicInteger = new AtomicInteger(10);
- final PlayerData data = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
- if (this.queueType.isRanked()) {
- for (int i = 0; i <= 53; ++i) {
- buttonMap.put(i, (new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE).setDurability(7).setDisplayName(" ").toButton()));
- }
- buttonMap.put(4, new ItemBuilder(Material.WATCH)
- .setDisplayName(CC.GREEN + "Queuing")
- .addLore(
- ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 38),
- CC.GRAY + "Select a kit below to join a " + CC.AQUA + this.queueType.getName() + CC.GRAY + " queue",
- ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 38)
- )
- .toButton());
-
- buttonMap.put(45, new ItemBuilder(Material.STONE_BUTTON)
- .setDisplayName(ChatColor.YELLOW + "Open Unranked Queues Menu " + CC.GRAY + "(" + CC.WHITE + "Right Click" + CC.GRAY + ")")
- .addLore("&7Right Click to open the next queue menu.")
- .toButton((player1, clickType) -> new JoinQueueMenu(QueueType.UNRANKED).openMenu(player)));
-
- buttonMap.put(53, new ItemBuilder(Material.REDSTONE)
- .setDisplayName(ChatColor.RED + "Close Ranked Queues Menu")
- .addLore("&7Right Click to close this menu.")
- .toButton((player1, clickType) -> player.closeInventory()));
-
- Practice.getInstance().getKitManager().getKits().stream()
- .filter(Objects::nonNull)
- .filter(Kit::isRanked)
- .filter(Kit::isEnabled)
- .forEachOrdered(kit -> {
- buttonMap.put(atomicInteger.get(), new KitButton(kit, data));
-
- if (atomicInteger.get() == 16) {
- atomicInteger.set(19);
- } else if (atomicInteger.get() == 25) {
- atomicInteger.set(28);
- } else if (atomicInteger.get() == 34) {
- atomicInteger.set(37);
- } else {
- atomicInteger.getAndIncrement();
- }
- });
- } else {
- for (int i = 0; i <= 53; ++i) {
- buttonMap.put(i, (new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE).setDurability(7).setDisplayName(" ").toButton()));
- }
- buttonMap.put(4, new ItemBuilder(Material.WATCH)
- .setDisplayName(CC.GREEN + "Queuing")
- .addLore(
- ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 38),
- CC.GRAY + "Select a kit below to join a " + CC.AQUA + this.queueType.getName() + CC.GRAY + " queue",
- ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 38)
- )
- .toButton());
-
- buttonMap.put(53, new ItemBuilder(Material.STONE_BUTTON)
- .setDisplayName(ChatColor.AQUA + "Open Ranked Queues menu " + CC.GRAY + "(" + CC.WHITE + "Right Click" + CC.GRAY + ")")
- .addLore("&7Right Click to open the next queue menu.")
- .toButton((player1, clickType) -> new JoinQueueMenu(QueueType.RANKED).openMenu(player)));
-
- buttonMap.put(45, new ItemBuilder(Material.REDSTONE)
- .setDisplayName(ChatColor.RED + "Close Unranked Queues Menu")
- .addLore("&7Right Click to close this menu.")
- .toButton((player1, clickType) -> player.closeInventory()));
-
- Practice.getInstance().getKitManager().getKits().stream()
- .filter(Objects::nonNull)
- .filter(Kit::isEnabled)
- .forEachOrdered(kit -> {
- buttonMap.put(atomicInteger.get(), new KitButton(kit, data));
-
- if (atomicInteger.get() == 16) {
- atomicInteger.set(19);
- } else if (atomicInteger.get() == 25) {
- atomicInteger.set(28);
- } else if (atomicInteger.get() == 34) {
- atomicInteger.set(37);
- } else {
- atomicInteger.getAndIncrement();
- }
- });
- }
-
- buttonMap.put(0, new ItemBuilder(Material.REDSTONE)
- .setDisplayName(ChatColor.RED + "Close " + this.getQueueType().getName() + " Queue Menu")
- .addLore("&7Right Click to close this menu.")
- .toButton((player1, clickType) -> player.closeInventory()));
-
- buttonMap.put(1, new ItemBuilder(Material.ANVIL)
- .setDisplayName(ChatColor.LIGHT_PURPLE + "Open Settings " + CC.GRAY + "(" + CC.WHITE + "Right Click" + CC.GRAY + ")")
- .addLore("&7Right Click to open the Settings menu.")
- .toButton((player1, clickType) -> new SettingsMenu(player).openMenu(player)));
-
- buttonMap.put(7, new ItemBuilder(Material.ITEM_FRAME)
- .setDisplayName(ChatColor.AQUA + "Open Leaderboards " + CC.GRAY + "(" + CC.WHITE + "Right Click" + CC.GRAY + ")")
- .addLore("&7Right Click to open the Leaderboards menu.")
- .toButton((player1, clickType) -> player.sendMessage(CC.RED + "This feature is currently unavailable.")));
-
- buttonMap.put(8, new ItemBuilder(Material.REDSTONE)
- .setDisplayName(ChatColor.RED + "Close " + this.getQueueType().getName() + " Queue Menu")
- .addLore("&7Right Click to close this menu.")
- .toButton((player1, clickType) -> player.closeInventory()));
-
- buttonMap.put(47, new ItemBuilder(Material.CARPET)
- .setDurability(5)
- .setDisplayName(ChatColor.GREEN + "1v1")
- .addLore("&7You're currently viewing 1v1.")
- .toButton((player1, clickType) -> player.sendMessage(CC.RED + "This mode is currently unavailable.")));
-
- buttonMap.put(49, new ItemBuilder(Material.CARPET)
- .setDurability(7)
- .setDisplayName(ChatColor.RED + "2v2")
- .addLore("&7Click to switch to 2v2.")
- .toButton((player1, clickType) -> player.sendMessage(CC.RED + "This mode is currently unavailable.")));
-
- buttonMap.put(51, new ItemBuilder(Material.CARPET)
- .setDurability(7)
- .setDisplayName(ChatColor.RED + "3v3")
- .addLore("&7Click to switch to 3v3.")
- .toButton((player1, clickType) -> player.sendMessage(CC.RED + "This mode is currently unavailable.")));
-
- return buttonMap;
- }
-
- @RequiredArgsConstructor
- private class KitButton extends Button {
-
- private final Kit queue;
- private final PlayerData data;
-
- @Override
- public ItemStack getButtonItem(final Player player) {
- final List lore = new ArrayList<>();
- final PlayerData data = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
- final int playing = (int) Practice.getInstance().getPlayerManager().getAllData().stream()
- .filter(Objects::nonNull)
- .filter(playerData -> playerData.getPlayerState().equals(PlayerState.FIGHTING) && Practice.getInstance().getMatchManager().getMatch(playerData.getCurrentMatchID()) != null && Practice.getInstance().getMatchManager().getMatch(playerData.getCurrentMatchID()).getKit().getName().equals((this.queue != null ? this.queue.getName() : "")))
- .count();
-
- lore.add("&7In Queue: " + Color.MAIN_COLOR + Practice.getInstance().getQueueManager().getQueueSize(this.queue.getName(), KyroJoinQueueMenu.this.queueType));
- lore.add("&7In Fights: " + Color.MAIN_COLOR + playing);
- lore.add(" ");
- lore.add("&7Wins: " + Color.MAIN_COLOR + data.getWins(this.queue.getName()));
- lore.add("&7Losses: " + Color.MAIN_COLOR + data.getLosses(this.queue.getName()));
-
- if (this.queue.isRanked() && KyroJoinQueueMenu.this.queueType.isRanked()) {
- lore.add(" ");
- lore.add("&7Elo: &f" + this.data.getElo(this.queue.getName()));
- }
-
- lore.add(" ");
- lore.add(CC.YELLOW + "[Click to join the queue]");
-
- return new ItemBuilder(this.queue.getIcon().clone())
- .setDisplayName(Color.MAIN_COLOR + CC.BOLD + this.queue.getName())
- .addLore(lore)
- .addItemFlags(ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ENCHANTS)
- .create();
- }
-
- @Override
- public void clicked(Player player, ClickType clickType) {
- final Party party = Practice.getInstance().getPartyManager().getParty(player.getUniqueId());
-
- if (this.data.getPlayerState() != PlayerState.SPAWN) {
- player.sendMessage(CC.RED + "You must be at spawn to queue for a ladder.");
- return;
- }
-
- player.closeInventory();
-
- if (this.queue != null) {
- if (party == null) {
- Practice.getInstance().getQueueManager().addPlayerToQueue(player, this.data, this.queue.getName(), KyroJoinQueueMenu.this.queueType);
- } else if (Practice.getInstance().getPartyManager().isLeader(player.getUniqueId())) {
- Practice.getInstance().getQueueManager().addPartyToQueue(player, party, this.queue.getName(), KyroJoinQueueMenu.this.queueType);
- }
- }
- }
- }
-}
diff --git a/src/main/java/com/solexgames/practice/menu/LeaderboardsMenu.java b/src/main/java/com/solexgames/practice/menu/LeaderboardsMenu.java
deleted file mode 100644
index 9175b5c..0000000
--- a/src/main/java/com/solexgames/practice/menu/LeaderboardsMenu.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.solexgames.practice.menu;
-
-import com.solexgames.core.player.ranks.Rank;
-import com.solexgames.core.util.builder.ItemBuilder;
-import com.solexgames.core.util.external.Button;
-import com.solexgames.core.util.external.Menu;
-import com.solexgames.practice.Practice;
-import com.solexgames.practice.kit.Kit;
-import com.solexgames.practice.player.PlayerData;
-import com.solexgames.practice.runnable.LeaderboardUpdateRunnable;
-import com.solexgames.practice.util.CC;
-import com.solexgames.practice.util.division.RankedDivision;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemFlag;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.*;
-
-/**
- * @author GrowlyX
- * @since 5/15/2021
- */
-
-@Getter
-public class LeaderboardsMenu extends Menu {
-
- private boolean winStreakLb = false;
-
- @Override
- public String getTitle(Player player) {
- return "Leaderboards";
- }
-
- @Override
- public Map getButtons(Player player) {
- final Map buttonMap = new HashMap<>();
- final PlayerData playerData = Practice.getInstance().getPlayerManager().getPlayerData(player.getUniqueId());
-
- if (!this.winStreakLb) {
- final List