More hub stuff
This commit is contained in:
parent
8532f6eca1
commit
0458f18843
@ -751,10 +751,7 @@ public class UtilPlayer
|
||||
public static void clearInventory(Player player)
|
||||
{
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setHelmet(null);
|
||||
player.getInventory().setChestplate(null);
|
||||
player.getInventory().setLeggings(null);
|
||||
player.getInventory().setBoots(null);
|
||||
player.getInventory().setArmorContents(null);
|
||||
}
|
||||
|
||||
public static void clearPotionEffects(Player player)
|
||||
|
@ -5,8 +5,10 @@ import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -51,10 +53,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.book.BookBuilder;
|
||||
import mineplex.core.common.DummyEntity;
|
||||
import mineplex.core.common.MinecraftVersion;
|
||||
@ -72,7 +72,6 @@ import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.titles.commands.GiveTrackCommand;
|
||||
import mineplex.core.titles.commands.TrackCommand;
|
||||
import mineplex.core.titles.tracks.Track;
|
||||
import mineplex.core.titles.tracks.TrackFormat;
|
||||
@ -118,11 +117,14 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
.color(ChatColor.YELLOW)
|
||||
.create();
|
||||
|
||||
private final Set<Player> _disabledPlayers;
|
||||
private boolean _disabled;
|
||||
|
||||
private Titles()
|
||||
{
|
||||
super("Titles", UtilServer.getPlugin(), Managers.require(CoreClientManager.class));
|
||||
super("Titles");
|
||||
|
||||
_disabledPlayers = new HashSet<>();
|
||||
|
||||
require(PacketHandler.class).addPacketHandler(this, PacketHandler.ListenerPriority.LOW, PacketPlayOutNamedEntitySpawn.class, PacketPlayOutEntityDestroy.class);
|
||||
}
|
||||
@ -178,6 +180,7 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
{
|
||||
task.cancel();
|
||||
}
|
||||
_disabledPlayers.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -222,7 +225,7 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
|
||||
public void setOrToggleTrackForPlayer(Player player, Track track, boolean clickedBook)
|
||||
{
|
||||
if (_disabled)
|
||||
if (_disabled || _disabledPlayers.contains(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Track", "Tracks are disabled right now!"));
|
||||
return;
|
||||
@ -705,7 +708,7 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
|
||||
private void updateTitle(Player player, Track track)
|
||||
{
|
||||
if (_disabled)
|
||||
if (_disabled || _disabledPlayers.contains(player))
|
||||
return;
|
||||
|
||||
if (track != null && track.getRequirements().getTier(player) != null)
|
||||
@ -722,7 +725,7 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
|
||||
private void updateTitle(Player player, String str)
|
||||
{
|
||||
if (_disabled)
|
||||
if (_disabled || _disabledPlayers.contains(player))
|
||||
return;
|
||||
|
||||
Map<UUID, Integer> map = _armorStandIds.get(player.getEntityId());
|
||||
@ -753,12 +756,12 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket();
|
||||
Entity entity = UtilEnt.getEntityById(packet.a);
|
||||
|
||||
if (!(entity instanceof Player))
|
||||
if (!(entity instanceof Player) || _disabledPlayers.contains(entity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player owner = (Player) UtilEnt.getEntityById(packet.a);
|
||||
Player owner = (Player) entity;
|
||||
if (_gadgetManager.getActive(owner, GadgetType.MORPH) == null)
|
||||
{
|
||||
summonForEntity(packetInfo.getPlayer(), owner);
|
||||
@ -962,7 +965,7 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
|
||||
private void updateArmorStand(Player owner, Player receiver, String newName, int entityId)
|
||||
{
|
||||
if (_disabled)
|
||||
if (_disabled || _disabledPlayers.contains(owner))
|
||||
return;
|
||||
|
||||
switch (UtilPlayer.getVersion(receiver))
|
||||
@ -1063,15 +1066,9 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
{
|
||||
_disabled = false;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
{
|
||||
for (Player player1 : UtilServer.getPlayers())
|
||||
{
|
||||
if (player != player1)
|
||||
{
|
||||
summonForEntity(player, player1);
|
||||
}
|
||||
}
|
||||
forceEnable(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1084,13 +1081,39 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
for (Player player1 : UtilServer.getPlayers())
|
||||
forceDisable(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forceEnable(Player player)
|
||||
{
|
||||
if (_disabledPlayers.remove(player))
|
||||
{
|
||||
for (Player other : UtilServer.getPlayersCollection())
|
||||
{
|
||||
if (player.equals(other))
|
||||
{
|
||||
if (player != player1)
|
||||
{
|
||||
destroyForEntity(player, player1.getEntityId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
summonForEntity(player, other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forceDisable(Player player)
|
||||
{
|
||||
if (_disabledPlayers.add(player))
|
||||
{
|
||||
for (Player other : UtilServer.getPlayersCollection())
|
||||
{
|
||||
if (player.equals(other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
destroyForEntity(player, other.getEntityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.Constants;
|
||||
import mineplex.core.common.events.ServerShutdownEvent;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
@ -54,7 +53,6 @@ import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teamspeak.TeamspeakManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
@ -143,13 +141,11 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
SkillConditionManager conditionManager = new SkillConditionManager(this);
|
||||
|
||||
new CustomDataManager(this, clientManager);
|
||||
|
||||
new PersonalServerManager(this, clientManager);
|
||||
String boosterGroup = serverConfiguration.getServerGroup().getBoosterGroup();
|
||||
ThankManager thankManager = new ThankManager(this, clientManager, donationManager);
|
||||
BoosterManager boosterManager = new BoosterManager(this, boosterGroup, clientManager, donationManager, inventoryManager, thankManager);
|
||||
HubManager hubManager = new HubManager( blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager,packetHandler, punish, serverStatusManager, thankManager, boosterManager, castleManager);
|
||||
HubManager hubManager = new HubManager( blockRestore, clientManager, incognito, donationManager, inventoryManager, disguiseManager, portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager,packetHandler, punish, serverStatusManager, thankManager, boosterManager, castleManager);
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, eloManager, partyManager);
|
||||
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, queueManager, boosterManager);
|
||||
@ -182,7 +178,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
new Updater(this);
|
||||
|
||||
require(TrackManager.class);
|
||||
require(Titles.class).forceDisable();
|
||||
require(Titles.class);
|
||||
require(TwoFactorAuth.class);
|
||||
require(TeamspeakManager.class);
|
||||
new WebsiteLinkManager(this, clientManager);
|
||||
|
@ -14,14 +14,11 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@ -29,7 +26,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
@ -55,8 +51,8 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseSlime;
|
||||
import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.facebook.FacebookManager;
|
||||
@ -90,7 +86,6 @@ import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.scoreboard.TabListSorter;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
@ -103,7 +98,6 @@ import mineplex.hub.doublejump.JumpManager;
|
||||
import mineplex.hub.events.HubType;
|
||||
import mineplex.hub.gamemode.GameModeManager;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.modules.EasterEggHunt;
|
||||
import mineplex.hub.modules.ForcefieldManager;
|
||||
import mineplex.hub.modules.HubVisibilityManager;
|
||||
import mineplex.hub.modules.KothManager;
|
||||
@ -113,9 +107,13 @@ import mineplex.hub.modules.TemporaryGemHuntersServerSender;
|
||||
import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager;
|
||||
import mineplex.hub.news.NewsManager;
|
||||
import mineplex.hub.parkour.ParkourManager;
|
||||
import mineplex.hub.player.HotbarManager;
|
||||
import mineplex.hub.player.HubPlayer;
|
||||
import mineplex.hub.scoreboard.HubScoreboard;
|
||||
import mineplex.hub.world.HubWorldManager;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
|
||||
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
|
||||
@ -127,13 +125,13 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
AUTO_OP,
|
||||
VANISH,
|
||||
SPAWN_PM,
|
||||
NEWS_COMMAND,
|
||||
JOIN_FULL,
|
||||
}
|
||||
|
||||
// ☃❅ Snowman!
|
||||
|
||||
private final CoreClientManager _clientManager;
|
||||
private final CustomDataManager _customDataManager;
|
||||
private final DonationManager _donationManager;
|
||||
private final DisguiseManager _disguiseManager;
|
||||
private final PartyManager _partyManager;
|
||||
@ -150,14 +148,14 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
private final WorldDataModule _worldData;
|
||||
private final Location _spawn;
|
||||
|
||||
|
||||
private boolean _shuttingDown;
|
||||
|
||||
public HubManager(BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager)
|
||||
public HubManager(BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, DisguiseManager disguiseManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager)
|
||||
{
|
||||
super("Hub Manager");
|
||||
|
||||
_clientManager = clientManager;
|
||||
_customDataManager = new CustomDataManager(_plugin, clientManager);
|
||||
_donationManager = donationManager;
|
||||
_disguiseManager = disguiseManager;
|
||||
|
||||
@ -220,12 +218,13 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
|
||||
_hologramManager = hologramManager;
|
||||
|
||||
new EasterEggHunt(_plugin, _clientManager);
|
||||
//new EasterEggHunt(_plugin, _clientManager);
|
||||
|
||||
new QuestManager(hologramManager, null, inventoryManager, _donationManager);
|
||||
|
||||
new TemporaryGemHuntersServerSender(_portal);
|
||||
|
||||
|
||||
require(TabListSorter.class);
|
||||
|
||||
Managers.put(new HubScoreboard(_plugin, this), ScoreboardManager.class);
|
||||
@ -233,6 +232,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
require(TwoFactorAuth.class);
|
||||
require(HubGameManager.class);
|
||||
require(ProfileManager.class);
|
||||
require(HotbarManager.class);
|
||||
|
||||
new HubType();
|
||||
|
||||
@ -243,7 +243,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
{
|
||||
PermissionGroup.ADMIN.setPermission(Perm.GADGET_TOGGLE_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.GAMEMODE_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.NEWS_COMMAND, true, true);
|
||||
if (UtilServer.isDevServer() || UtilServer.isTestServer())
|
||||
{
|
||||
PermissionGroup.ADMIN.setPermission(Perm.AUTO_OP, true, true);
|
||||
@ -295,37 +294,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventEggSpawn(ItemSpawnEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Egg)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void OnChunkLoad(ChunkLoadEvent event)
|
||||
{
|
||||
for (Entity entity : event.getChunk().getEntities())
|
||||
{
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
if (((LivingEntity) entity).isCustomNameVisible() && ((LivingEntity) entity).getCustomName() != null)
|
||||
{
|
||||
if (ChatColor.stripColor(((LivingEntity) entity).getCustomName()).equalsIgnoreCase("Block Hunt"))
|
||||
{
|
||||
DisguiseSlime disguise = new DisguiseSlime(entity);
|
||||
disguise.setCustomNameVisible(true);
|
||||
disguise.setName(((LivingEntity) entity).getCustomName(), null);
|
||||
disguise.SetSize(2);
|
||||
_disguiseManager.disguise(disguise);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void login(final PlayerLoginEvent event)
|
||||
{
|
||||
@ -363,11 +331,8 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
event.setJoinMessage(null);
|
||||
|
||||
player.teleport(GetSpawn());
|
||||
player.setHealth(player.getMaxHealth());
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
UtilInv.Clear(player);
|
||||
|
||||
player.getInventory().setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM);
|
||||
require(Titles.class).giveBook(player, false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -376,6 +341,12 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
event.setQuitMessage(null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void combatDeath(CombatDeathEvent event)
|
||||
{
|
||||
event.SetBroadcastType(DeathMessageType.None);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerPrivateMessage(PrivateMessageEvent event)
|
||||
{
|
||||
@ -508,6 +479,11 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
return new HubClient(Bukkit.getPlayer(uuid).getName());
|
||||
}
|
||||
|
||||
public HubPlayer getHubPlayer(Player player)
|
||||
{
|
||||
return new HubPlayer(player, _customDataManager);
|
||||
}
|
||||
|
||||
public CoreClientManager GetClients()
|
||||
{
|
||||
return _clientManager;
|
||||
@ -606,4 +582,4 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,14 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class DoubleJumpEvent extends PlayerEvent implements Cancellable
|
||||
public class DoubleJumpPrepareEvent extends PlayerEvent implements Cancellable
|
||||
{
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public DoubleJumpEvent(Player who)
|
||||
public DoubleJumpPrepareEvent(Player who)
|
||||
{
|
||||
super(who);
|
||||
}
|
@ -42,7 +42,7 @@ public class JumpManager extends MiniPlugin
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void FlightHop(PlayerToggleFlightEvent event)
|
||||
public void toggleFlight(PlayerToggleFlightEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@ -62,16 +62,6 @@ public class JumpManager extends MiniPlugin
|
||||
((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman || disguise instanceof DisguiseWither))
|
||||
return;
|
||||
|
||||
DoubleJumpEvent jumpEvent = new DoubleJumpEvent(player);
|
||||
UtilServer.CallEvent(jumpEvent);
|
||||
|
||||
if (jumpEvent.isCancelled())
|
||||
{
|
||||
player.setFlying(false);
|
||||
player.setAllowFlight(false);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
player.setFlying(false);
|
||||
|
||||
@ -87,32 +77,38 @@ public class JumpManager extends MiniPlugin
|
||||
|
||||
//Sound
|
||||
player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
|
||||
|
||||
|
||||
Recharge.Instance.useForce(player, "Double Jump", 250);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void FlightUpdate(UpdateEvent event)
|
||||
public void updateFlight(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
{
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
continue;
|
||||
|
||||
// TODO put this somewhere better
|
||||
if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().Get(player).hasPermission(Preference.INVISIBILITY))
|
||||
{
|
||||
player.setAllowFlight(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Manager.GetParkour().isParkourMode(player))
|
||||
|
||||
DoubleJumpPrepareEvent jumpEvent = new DoubleJumpPrepareEvent(player);
|
||||
UtilServer.CallEvent(jumpEvent);
|
||||
|
||||
if (jumpEvent.isCancelled())
|
||||
{
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
continue;
|
||||
player.setAllowFlight(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
||||
|
@ -1,7 +1,9 @@
|
||||
package mineplex.hub.hubgame;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -9,12 +11,12 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.lifetimes.PhasedLifetime;
|
||||
import mineplex.core.newnpc.NPC;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
import mineplex.hub.hubgame.event.HubGamePlayerDeathEvent;
|
||||
import mineplex.hub.hubgame.event.HubGameStateChangeEvent;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
@ -22,6 +24,7 @@ public abstract class CycledGame extends PhasedLifetime<GameState> implements Hu
|
||||
{
|
||||
|
||||
private final HubGameManager _manager;
|
||||
private final Map<Class<? extends HubGameComponent<?>>, HubGameComponent<?>> _components;
|
||||
|
||||
// Game Properties
|
||||
private final HubGameType _type;
|
||||
@ -49,6 +52,7 @@ public abstract class CycledGame extends PhasedLifetime<GameState> implements Hu
|
||||
public CycledGame(HubGameManager manager, HubGameType type)
|
||||
{
|
||||
_manager = manager;
|
||||
_components = new HashMap<>();
|
||||
_type = type;
|
||||
_state = GameState.Waiting;
|
||||
|
||||
@ -107,12 +111,24 @@ public abstract class CycledGame extends PhasedLifetime<GameState> implements Hu
|
||||
return _allPlayers;
|
||||
}
|
||||
|
||||
protected <T extends HubGameComponent<?>> T registerComponent(T instance)
|
||||
@Override
|
||||
public Location getSpawn()
|
||||
{
|
||||
return _spawn;
|
||||
}
|
||||
|
||||
protected <T extends HubGameComponent<?>> T registerComponent(T instance)
|
||||
{
|
||||
register(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends HubGameComponent<?>> T getComponent(Class<T> clazz)
|
||||
{
|
||||
return (T) _components.get(clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
Game Events
|
||||
*/
|
||||
@ -158,18 +174,8 @@ public abstract class CycledGame extends PhasedLifetime<GameState> implements Hu
|
||||
|
||||
public void onPlayerDeath(Player player, boolean end)
|
||||
{
|
||||
if (!end)
|
||||
{
|
||||
_alivePlayers.remove(player);
|
||||
}
|
||||
|
||||
_places.add(player);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
player.setFireTicks(0);
|
||||
_manager.runSyncLater(() -> player.teleport(_spawn), 1);
|
||||
HubGamePlayerDeathEvent event = new HubGamePlayerDeathEvent(player, this, end);
|
||||
UtilServer.CallEvent(event);
|
||||
}
|
||||
|
||||
public void onCleanupPlayer(Player player)
|
||||
|
@ -2,6 +2,7 @@ package mineplex.hub.hubgame;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
@ -21,6 +22,8 @@ public interface HubGame
|
||||
|
||||
WorldDataModule getWorldData();
|
||||
|
||||
Location getSpawn();
|
||||
|
||||
void onPlayerDeath(Player player);
|
||||
|
||||
List<Player> getAlivePlayers();
|
||||
|
@ -14,12 +14,21 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.newnpc.NPC;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.event.NPCInteractEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
import mineplex.hub.hubgame.event.HubGamePlayerDeathEvent;
|
||||
import mineplex.hub.player.HotbarManager;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class HubGameManager extends MiniPlugin
|
||||
@ -29,12 +38,17 @@ public class HubGameManager extends MiniPlugin
|
||||
private static final int MAX_PLAYERS_COUNTDOWN = 5;
|
||||
private static final int PREPARE_COUNTDOWN = 5;
|
||||
private static final String HEADER_FOOTER = C.cDGreen + C.Strike + "================================================";
|
||||
|
||||
public static String getHeaderFooter()
|
||||
{
|
||||
return HEADER_FOOTER;
|
||||
}
|
||||
|
||||
private final GadgetManager _gadgetManager;
|
||||
private final HologramManager _hologramManager;
|
||||
private final HotbarManager _hotbarManager;
|
||||
private final NewNPCManager _npcManager;
|
||||
private final WorldDataModule _worldData;
|
||||
|
||||
private final List<HubGame> _games;
|
||||
|
||||
@ -42,11 +56,15 @@ public class HubGameManager extends MiniPlugin
|
||||
{
|
||||
super("Hub Games");
|
||||
|
||||
_gadgetManager = require(GadgetManager.class);
|
||||
_hologramManager = require(HologramManager.class);
|
||||
_hotbarManager = require(HotbarManager.class);
|
||||
_npcManager = require(NewNPCManager.class);
|
||||
_worldData = require(WorldDataModule.class);
|
||||
|
||||
_games = new ArrayList<>();
|
||||
|
||||
runSyncLater(this::spawnNPCs, 50);
|
||||
spawnNPCs();
|
||||
}
|
||||
|
||||
public void addGame(HubGame game)
|
||||
@ -56,7 +74,13 @@ public class HubGameManager extends MiniPlugin
|
||||
|
||||
private void spawnNPCs()
|
||||
{
|
||||
_games.forEach(game -> _npcManager.spawnNPCs(game.getGameType().name(), game::setNpc));
|
||||
_games.forEach(game ->
|
||||
{
|
||||
_npcManager.spawnNPCs(game.getGameType().name(), game::setNpc);
|
||||
|
||||
new Hologram(_hologramManager, _worldData.getCustomLocation(game.getGameType().name() + " INFO").get(0), true, game.getGameType().getDescription())
|
||||
.start();
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -79,9 +103,11 @@ public class HubGameManager extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
NPC npc = event.getNpc();
|
||||
|
||||
for (HubGame game : _games)
|
||||
{
|
||||
if (!(game instanceof CycledGame) || !event.getNpc().getMetadata().equals(game.getGameType().name()))
|
||||
if (!(game instanceof CycledGame) || !npc.getMetadata().equals(game.getGameType().name()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -90,47 +116,64 @@ public class HubGameManager extends MiniPlugin
|
||||
Player player = event.getPlayer();
|
||||
List<Player> queuedPlayers = cycledGame.getQueuedPlayers();
|
||||
|
||||
if (queuedPlayers.contains(player))
|
||||
if (event.isLeftClick())
|
||||
{
|
||||
if (event.isLeftClick())
|
||||
if (queuedPlayers.contains(player))
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You are already in the queue for " + F.name(getGameName(cycledGame)) + "."));
|
||||
informQueuePosition(cycledGame, player);
|
||||
leaveQueue(cycledGame, player, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
leaveQueue(cycledGame, player);
|
||||
joinQueue(cycledGame, player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (event.isRightClick())
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You are not in the queue for " + F.name(getGameName(cycledGame)) + ". " + F.elem("Left-Click") + " to join the queue."));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (HubGame other : _games)
|
||||
{
|
||||
if (other instanceof CycledGame && ((CycledGame) other).getQueuedPlayers().remove(player))
|
||||
{
|
||||
leaveQueue((CycledGame) other, player);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "You have joined the queue for " + F.name(getGameName(cycledGame)) + "."));
|
||||
queuedPlayers.add(player);
|
||||
cycledGame.onPlayerQueue(player);
|
||||
informQueuePosition(cycledGame, player);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void leaveQueue(CycledGame game, Player player)
|
||||
private void disableGadgets(Player player, GadgetType type)
|
||||
{
|
||||
_gadgetManager.getGadgets(type).forEach(gadget -> gadget.disable(player));
|
||||
}
|
||||
|
||||
public void joinQueue(CycledGame game, Player player)
|
||||
{
|
||||
for (HubGame other : _games)
|
||||
{
|
||||
if (other instanceof CycledGame && ((CycledGame) other).getQueuedPlayers().remove(player))
|
||||
{
|
||||
leaveQueue((CycledGame) other, player, true);
|
||||
}
|
||||
}
|
||||
|
||||
clearPlayer(player);
|
||||
|
||||
disableGadgets(player, GadgetType.MORPH);
|
||||
disableGadgets(player, GadgetType.MOUNT);
|
||||
disableGadgets(player, GadgetType.COSTUME);
|
||||
disableGadgets(player, GadgetType.ITEM);
|
||||
disableGadgets(player, GadgetType.BALLOON);
|
||||
disableGadgets(player, GadgetType.FLAG);
|
||||
disableGadgets(player, GadgetType.HAT);
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "You have joined the queue for " + F.name(getGameName(game)) + "."));
|
||||
game.getQueuedPlayers().add(player);
|
||||
game.onPlayerQueue(player);
|
||||
informQueuePosition(game, player);
|
||||
}
|
||||
|
||||
public void leaveQueue(CycledGame game, Player player, boolean forAnother)
|
||||
{
|
||||
if (!forAnother)
|
||||
{
|
||||
_hotbarManager.giveHotbar(player);
|
||||
}
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "You have left the queue for " + F.name(getGameName(game)) + "."));
|
||||
game.getQueuedPlayers().remove(player);
|
||||
game.onPlayerLeaveQueue(player);
|
||||
@ -250,7 +293,6 @@ public class HubGameManager extends MiniPlugin
|
||||
}
|
||||
|
||||
CycledGame cycledGame = (CycledGame) game;
|
||||
HubGameType gameType = game.getGameType();
|
||||
|
||||
if (cycledGame.getGameState() != GameState.Prepare)
|
||||
{
|
||||
@ -259,28 +301,7 @@ public class HubGameManager extends MiniPlugin
|
||||
|
||||
int countdown = cycledGame.getCountdown();
|
||||
|
||||
if (countdown == PREPARE_COUNTDOWN)
|
||||
{
|
||||
String gameString = getGameHeader(cycledGame);
|
||||
|
||||
for (Player player : cycledGame.getAllPlayers())
|
||||
{
|
||||
player.sendMessage(HEADER_FOOTER);
|
||||
player.sendMessage(gameString);
|
||||
player.sendMessage("");
|
||||
|
||||
for (String description : gameType.getDescription())
|
||||
{
|
||||
player.sendMessage(" " + description);
|
||||
}
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(HEADER_FOOTER);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1.2F);
|
||||
}
|
||||
}
|
||||
else if (countdown == 0)
|
||||
if (countdown == 0)
|
||||
{
|
||||
for (Player player : cycledGame.getAllPlayers())
|
||||
{
|
||||
@ -289,7 +310,7 @@ public class HubGameManager extends MiniPlugin
|
||||
|
||||
cycledGame.setState(GameState.Live);
|
||||
}
|
||||
else
|
||||
else if (countdown <= 3)
|
||||
{
|
||||
for (Player player : cycledGame.getAllPlayers())
|
||||
{
|
||||
@ -321,43 +342,15 @@ public class HubGameManager extends MiniPlugin
|
||||
|
||||
if (cycledGame.isLive() && cycledGame.endCheck())
|
||||
{
|
||||
cycledGame.onEnd();
|
||||
cycledGame.setState(GameState.End);
|
||||
|
||||
for (Player player : cycledGame.getAlivePlayers())
|
||||
{
|
||||
cycledGame.onPlayerDeath(player, true);
|
||||
}
|
||||
|
||||
List<Player> places = cycledGame.getPlaces();
|
||||
Collections.reverse(places);
|
||||
String gameString = getGameHeader(cycledGame);
|
||||
Collections.reverse(cycledGame.getPlaces());
|
||||
|
||||
for (Player player : places)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.sendMessage(HEADER_FOOTER);
|
||||
player.sendMessage(gameString);
|
||||
player.sendMessage("");
|
||||
if (!places.isEmpty())
|
||||
{
|
||||
player.sendMessage(C.cRedB + "1st Place " + C.cWhite + places.get(0).getName());
|
||||
}
|
||||
if (places.size() > 1)
|
||||
{
|
||||
player.sendMessage(C.cGoldB + "2nd Place " + C.cWhite + places.get(1).getName());
|
||||
}
|
||||
if (places.size() > 2)
|
||||
{
|
||||
player.sendMessage(C.cYellowB + "3rd Place " + C.cWhite + places.get(2).getName());
|
||||
}
|
||||
player.sendMessage("");
|
||||
player.sendMessage(HEADER_FOOTER);
|
||||
}
|
||||
cycledGame.onEnd();
|
||||
cycledGame.setState(GameState.End);
|
||||
|
||||
cycledGame.onCleanup();
|
||||
cycledGame.setState(GameState.Waiting);
|
||||
@ -383,7 +376,33 @@ public class HubGameManager extends MiniPlugin
|
||||
return enough;
|
||||
}
|
||||
|
||||
private String getGameHeader(CycledGame game)
|
||||
@EventHandler
|
||||
public void playerDeath(HubGamePlayerDeathEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
CycledGame game = event.getGame();
|
||||
|
||||
if (!event.isEnding())
|
||||
{
|
||||
game.getAlivePlayers().remove(player);
|
||||
}
|
||||
|
||||
game.getPlaces().add(player);
|
||||
clearPlayer(player);
|
||||
player.teleport(game.getSpawn());
|
||||
_hotbarManager.giveHotbar(player);
|
||||
}
|
||||
|
||||
private void clearPlayer(Player player)
|
||||
{
|
||||
UtilPlayer.clearPotionEffects(player);
|
||||
UtilPlayer.clearInventory(player);
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
|
||||
public String getGameHeader(CycledGame game)
|
||||
{
|
||||
return C.cWhiteB + "Game" + C.cYellow + " - " + C.cWhiteB + getGameName(game);
|
||||
}
|
||||
|
@ -1,29 +1,41 @@
|
||||
package mineplex.hub.hubgame;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
|
||||
public enum HubGameType
|
||||
{
|
||||
|
||||
TRON("Tron", new String[]
|
||||
{
|
||||
"Testing 1",
|
||||
"Testing 2"
|
||||
}, 2, 4),
|
||||
"Control your Slime by looking in the direction",
|
||||
"you want to go!",
|
||||
"Avoid other trails and walls.",
|
||||
"Last player standing wins!",
|
||||
}, new ItemStack(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SLIME)), 2, 4),
|
||||
DUELS("Duels", new String[]
|
||||
{
|
||||
"Testing 1",
|
||||
"Testing 2"
|
||||
}, 2, 2),
|
||||
"A 1v1 duel against another player.",
|
||||
"You do not regenerate health.",
|
||||
"You can place blocks!",
|
||||
"Kill your opponent to win!"
|
||||
}, new ItemStack(Material.DIAMOND_SWORD), 2, 2),
|
||||
;
|
||||
|
||||
private final String _name;
|
||||
private final String[] _description;
|
||||
private final ItemStack _itemStack;
|
||||
private final int _minPlayers;
|
||||
private final int _maxPlayers;
|
||||
|
||||
HubGameType(String name, String[] description, int minPlayers, int maxPlayers)
|
||||
HubGameType(String name, String[] description, ItemStack itemStack, int minPlayers, int maxPlayers)
|
||||
{
|
||||
_name = name;
|
||||
_description = description;
|
||||
_itemStack = itemStack;
|
||||
_minPlayers = minPlayers;
|
||||
_maxPlayers = maxPlayers;
|
||||
}
|
||||
@ -38,6 +50,11 @@ public enum HubGameType
|
||||
return _description;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return _itemStack;
|
||||
}
|
||||
|
||||
public int getMinPlayers()
|
||||
{
|
||||
return _minPlayers;
|
||||
|
@ -5,19 +5,46 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
import mineplex.hub.hubgame.HubGame;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
import mineplex.hub.hubgame.event.HubGameStateChangeEvent;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
|
||||
public class DamageComponent extends HubGameComponent<HubGame>
|
||||
{
|
||||
|
||||
private static final Titles TITLES = Managers.get(Titles.class);
|
||||
|
||||
public DamageComponent(HubGame game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableTitles(HubGameStateChangeEvent event)
|
||||
{
|
||||
if (event.getState() != GameState.Prepare && event.getState() != GameState.End)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : _game.getAlivePlayers())
|
||||
{
|
||||
if (event.getState() == GameState.Prepare)
|
||||
{
|
||||
TITLES.forceDisable(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
TITLES.forceEnable(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void entityDamage(EntityDamageEvent event)
|
||||
{
|
||||
|
@ -42,20 +42,20 @@ public class PVPTrackerComponent extends HubGameComponent<HubGame>
|
||||
private static final String HEART = C.cRed + "❤" + C.Reset;
|
||||
private static final DecimalFormat FORMAT = new DecimalFormat("0.#");
|
||||
|
||||
private final LinkedList<Match> _stats;
|
||||
private final LinkedList<Match> _matches;
|
||||
|
||||
public PVPTrackerComponent(HubGame game)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_stats = new LinkedList<>();
|
||||
_matches = new LinkedList<>();
|
||||
}
|
||||
|
||||
private Match getLatestMatch(Player player)
|
||||
{
|
||||
Match latest = null;
|
||||
|
||||
for (Match match : _stats)
|
||||
for (Match match : _matches)
|
||||
{
|
||||
if (match.PlayerA.Player.equals(player) || match.PlayerB.Player.equals(player))
|
||||
{
|
||||
@ -71,7 +71,7 @@ public class PVPTrackerComponent extends HubGameComponent<HubGame>
|
||||
{
|
||||
PVPStats latest = null;
|
||||
|
||||
for (Match match : _stats)
|
||||
for (Match match : _matches)
|
||||
{
|
||||
if (match.PlayerA.Player.equals(player))
|
||||
{
|
||||
@ -101,7 +101,7 @@ public class PVPTrackerComponent extends HubGameComponent<HubGame>
|
||||
PVPStats killerStats = getLatestStats(killer);
|
||||
|
||||
playerStats.EndHealth = 0;
|
||||
killerStats.EndHealth = killer.getHealth();
|
||||
killerStats.EndHealth = killer.getHealth() / 2D;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -233,16 +233,16 @@ public class PVPTrackerComponent extends HubGameComponent<HubGame>
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stats.size() >= MATCH_HISTORY_SIZE)
|
||||
if (_matches.size() >= MATCH_HISTORY_SIZE)
|
||||
{
|
||||
_stats.removeFirst();
|
||||
_matches.removeFirst();
|
||||
}
|
||||
|
||||
List<Player> alive = _game.getAlivePlayers();
|
||||
Player a = alive.get(0);
|
||||
Player b = alive.get(1);
|
||||
|
||||
_stats.add(new Match(new PVPStats(a, b), new PVPStats(b, a)));
|
||||
_matches.add(new Match(new PVPStats(a, b), new PVPStats(b, a)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -255,7 +255,7 @@ public class PVPTrackerComponent extends HubGameComponent<HubGame>
|
||||
|
||||
UtilServer.runSyncLater(() ->
|
||||
{
|
||||
Match match = _stats.getLast();
|
||||
Match match = _matches.getLast();
|
||||
match.Complete = true;
|
||||
|
||||
for (Player player : match.getPlayers())
|
||||
@ -297,8 +297,14 @@ public class PVPTrackerComponent extends HubGameComponent<HubGame>
|
||||
return;
|
||||
}
|
||||
|
||||
sendMatch(player, match);
|
||||
}
|
||||
|
||||
public void sendMatch(Player player, Match match)
|
||||
{
|
||||
boolean playerA = match.PlayerA.Player.equals(player);
|
||||
PVPStats stats = playerA ? match.PlayerA : match.PlayerB;
|
||||
boolean none = !playerA && !match.PlayerB.equals(player);
|
||||
PVPStats stats = playerA || none ? match.PlayerA : match.PlayerB;
|
||||
PVPStats other = playerA ? match.PlayerB : match.PlayerA;
|
||||
|
||||
player.sendMessage(HubGameManager.getHeaderFooter());
|
||||
@ -354,7 +360,12 @@ public class PVPTrackerComponent extends HubGameComponent<HubGame>
|
||||
return hoverText ? output : UtilText.centerChat(output, LineFormat.CHAT);
|
||||
}
|
||||
|
||||
private class Match
|
||||
public LinkedList<Match> getMatches()
|
||||
{
|
||||
return _matches;
|
||||
}
|
||||
|
||||
public class Match
|
||||
{
|
||||
|
||||
PVPStats PlayerA;
|
||||
|
@ -2,7 +2,7 @@ package mineplex.hub.hubgame.common.general;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.hub.doublejump.DoubleJumpEvent;
|
||||
import mineplex.hub.doublejump.DoubleJumpPrepareEvent;
|
||||
import mineplex.hub.hubgame.HubGame;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
|
||||
@ -15,7 +15,7 @@ public class DoubleJumpComponent extends HubGameComponent<HubGame>
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void doubleJump(DoubleJumpEvent event)
|
||||
public void doubleJump(DoubleJumpPrepareEvent event)
|
||||
{
|
||||
if (!_game.isAlive(event.getPlayer()))
|
||||
{
|
||||
|
@ -0,0 +1,73 @@
|
||||
package mineplex.hub.hubgame.common.general;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
import mineplex.hub.hubgame.event.HubGameStateChangeEvent;
|
||||
|
||||
public class GameDescriptionComponent extends HubGameComponent<CycledGame>
|
||||
{
|
||||
|
||||
private final Function<Player, String> _customLines;
|
||||
|
||||
public GameDescriptionComponent(CycledGame game)
|
||||
{
|
||||
this(game, null);
|
||||
}
|
||||
|
||||
public GameDescriptionComponent(CycledGame game, Function<Player, String> customLine)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_customLines = customLine;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void displayDescription(HubGameStateChangeEvent event)
|
||||
{
|
||||
if (event.getState() != GameState.Prepare || !event.getGame().equals(_game))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CycledGame game = event.getGame();
|
||||
|
||||
String gameString = _game.getManager().getGameHeader(game);
|
||||
|
||||
for (Player player : game.getAllPlayers())
|
||||
{
|
||||
player.sendMessage(HubGameManager.getHeaderFooter());
|
||||
player.sendMessage(gameString);
|
||||
player.sendMessage("");
|
||||
|
||||
for (String description : game.getGameType().getDescription())
|
||||
{
|
||||
player.sendMessage(" " + description);
|
||||
}
|
||||
|
||||
if (_customLines != null)
|
||||
{
|
||||
String line = _customLines.apply(player);
|
||||
|
||||
if (line != null)
|
||||
{
|
||||
player.sendMessage("");
|
||||
player.sendMessage(" " + line);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(HubGameManager.getHeaderFooter());
|
||||
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1.2F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package mineplex.hub.hubgame.common.general;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -12,7 +15,10 @@ import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
public class GameTimeoutComponent extends HubGameComponent<CycledGame>
|
||||
{
|
||||
|
||||
private static final long SECONDS_30 = TimeUnit.SECONDS.toMillis(30);
|
||||
|
||||
private final long _timeout;
|
||||
private boolean _announced30Seconds;
|
||||
|
||||
public GameTimeoutComponent(CycledGame game, long timeout)
|
||||
{
|
||||
@ -24,18 +30,27 @@ public class GameTimeoutComponent extends HubGameComponent<CycledGame>
|
||||
@EventHandler
|
||||
public void updateTimeout(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || !_game.isLive() || !UtilTime.elapsed(_game.getLastStart(), _timeout))
|
||||
if (event.getType() != UpdateType.SEC || !_game.isLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_game.announce("The game took too long and has timed out.");
|
||||
|
||||
for (Player player : _game.getAlivePlayers())
|
||||
if (!_announced30Seconds && UtilTime.elapsed(_game.getLastStart(), _timeout - SECONDS_30))
|
||||
{
|
||||
_game.onPlayerDeath(player, true);
|
||||
_game.announce("The game will end in " + F.time("30 Seconds") + ".");
|
||||
_announced30Seconds = true;
|
||||
}
|
||||
else if (UtilTime.elapsed(_game.getLastStart(), _timeout))
|
||||
{
|
||||
_game.announce("The game took too long and has ended");
|
||||
|
||||
_game.getAlivePlayers().clear();
|
||||
for (Player player : _game.getAlivePlayers())
|
||||
{
|
||||
_game.onPlayerDeath(player, true);
|
||||
}
|
||||
|
||||
_game.getAlivePlayers().clear();
|
||||
_announced30Seconds = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
package mineplex.hub.hubgame.common.general;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
import mineplex.hub.hubgame.event.HubGameStateChangeEvent;
|
||||
|
||||
public class PlacesComponent extends HubGameComponent<CycledGame>
|
||||
{
|
||||
|
||||
public PlacesComponent(CycledGame game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void displayPlaces(HubGameStateChangeEvent event)
|
||||
{
|
||||
if (event.getState() != GameState.End || !event.getGame().equals(_game))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CycledGame game = event.getGame();
|
||||
List<Player> places = game.getPlaces();
|
||||
String gameString = _game.getManager().getGameHeader(game);
|
||||
|
||||
for (Player player : places)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.sendMessage(HubGameManager.getHeaderFooter());
|
||||
player.sendMessage(gameString);
|
||||
player.sendMessage("");
|
||||
if (!places.isEmpty())
|
||||
{
|
||||
player.sendMessage(C.cRedB + "1st Place " + C.cWhite + places.get(0).getName());
|
||||
}
|
||||
if (places.size() > 1)
|
||||
{
|
||||
player.sendMessage(C.cGoldB + "2nd Place " + C.cWhite + places.get(1).getName());
|
||||
}
|
||||
if (places.size() > 2)
|
||||
{
|
||||
player.sendMessage(C.cYellowB + "3rd Place " + C.cWhite + places.get(2).getName());
|
||||
}
|
||||
player.sendMessage("");
|
||||
player.sendMessage(HubGameManager.getHeaderFooter());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package mineplex.hub.hubgame.common.general;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
import mineplex.hub.hubgame.event.HubGamePlayerDeathEvent;
|
||||
import mineplex.hub.hubgame.event.HubGameStateChangeEvent;
|
||||
|
||||
public class PlayerGameModeComponent extends HubGameComponent<CycledGame>
|
||||
{
|
||||
|
||||
private final GameMode _gameMode;
|
||||
|
||||
public PlayerGameModeComponent(CycledGame game, GameMode gameMode)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_gameMode = gameMode;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void prepare(HubGameStateChangeEvent event)
|
||||
{
|
||||
if (event.getState() != GameState.Prepare)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_game.getAlivePlayers().forEach(player -> player.setGameMode(_gameMode));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerDeath(HubGamePlayerDeathEvent event)
|
||||
{
|
||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package mineplex.hub.hubgame.common.general;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
import mineplex.hub.hubgame.event.HubGameStateChangeEvent;
|
||||
|
||||
public class SingleWinnerComponent extends HubGameComponent<CycledGame>
|
||||
{
|
||||
|
||||
public SingleWinnerComponent(CycledGame game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void displayWinner(HubGameStateChangeEvent event)
|
||||
{
|
||||
if (event.getState() != GameState.End || !event.getGame().equals(_game))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CycledGame game = event.getGame();
|
||||
List<Player> places = game.getPlaces();
|
||||
|
||||
if (places.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player winner = places.get(0);
|
||||
String gameString = _game.getManager().getGameHeader(game);
|
||||
|
||||
for (Player player : places)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.sendMessage(HubGameManager.getHeaderFooter());
|
||||
player.sendMessage(gameString);
|
||||
player.sendMessage("");
|
||||
|
||||
player.sendMessage(UtilText.centerChat(C.cWhiteB + "Winner " + (winner.equals(player) ? C.cGreen : C.cRed) + winner.getName(), LineFormat.CHAT));
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(HubGameManager.getHeaderFooter());
|
||||
}
|
||||
}
|
||||
}
|
@ -82,10 +82,13 @@ public class BlockRecorderComponent extends HubGameComponent<CycledGame>
|
||||
return;
|
||||
}
|
||||
|
||||
UtilBlock.startQuickRecording();
|
||||
_game.getManager().runSyncLater(() ->
|
||||
{
|
||||
UtilBlock.startQuickRecording();
|
||||
|
||||
_blocks.forEach((location, pair) -> UtilBlock.setQuick(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), pair.getLeft().getId(), pair.getRight()));
|
||||
_blocks.forEach((location, pair) -> UtilBlock.setQuick(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), pair.getLeft().getId(), pair.getRight()));
|
||||
|
||||
UtilBlock.stopQuickRecording();
|
||||
UtilBlock.stopQuickRecording();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
package mineplex.hub.hubgame.common.map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.hubgame.HubGame;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
|
||||
public class PreventNonAlivePlayersComponent extends HubGameComponent<HubGame>
|
||||
{
|
||||
|
||||
private final Location _cornerA;
|
||||
private final Location _cornerB;
|
||||
|
||||
public PreventNonAlivePlayersComponent(HubGame game, Location cornerA, Location cornerB)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_cornerA = cornerA;
|
||||
_cornerB = cornerB;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
{
|
||||
if (!_game.isAlive(player) && UtilAlg.inBoundingBox(player.getLocation(), _cornerA, _cornerB))
|
||||
{
|
||||
player.sendMessage(F.main(_game.getManager().getName(), "You are not allowed to enter the game area."));
|
||||
player.teleport(_game.getSpawn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void gadgetSelectBlock(GadgetSelectLocationEvent event)
|
||||
{
|
||||
if (UtilAlg.inBoundingBox(event.getLocation(), _cornerA, _cornerB))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package mineplex.hub.hubgame.common.powerup;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
public abstract class ItemPowerup implements Powerup, Listener
|
||||
{
|
||||
|
||||
private final String _name;
|
||||
private final ItemStack _itemStack;
|
||||
|
||||
public ItemPowerup(String name, ItemStack itemStack)
|
||||
{
|
||||
_name = name;
|
||||
_itemStack = new ItemBuilder(itemStack)
|
||||
.setTitle(name + C.cWhite + " - " + C.cYellowB + "Click")
|
||||
.build();
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCollect(Player player)
|
||||
{
|
||||
player.getInventory().addItem(_itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return _itemStack;
|
||||
}
|
||||
|
||||
public abstract void onInteractItem(Player player);
|
||||
|
||||
@EventHandler
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
|
||||
if (itemStack == null || !itemStack.isSimilar(_itemStack))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (itemStack.getAmount() == 1)
|
||||
{
|
||||
player.setItemInHand(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
|
||||
onInteractItem(player);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package mineplex.hub.hubgame.duel;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -12,6 +13,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
@ -19,10 +21,14 @@ import mineplex.hub.hubgame.HubGameType;
|
||||
import mineplex.hub.hubgame.common.damage.DamageComponent;
|
||||
import mineplex.hub.hubgame.common.damage.PVPTrackerComponent;
|
||||
import mineplex.hub.hubgame.common.general.DoubleJumpComponent;
|
||||
import mineplex.hub.hubgame.common.general.GameDescriptionComponent;
|
||||
import mineplex.hub.hubgame.common.general.GameTimeoutComponent;
|
||||
import mineplex.hub.hubgame.common.general.InventoryEditComponent;
|
||||
import mineplex.hub.hubgame.common.general.PlayerGameModeComponent;
|
||||
import mineplex.hub.hubgame.common.general.PrepareFreezeComponent;
|
||||
import mineplex.hub.hubgame.common.general.SingleWinnerComponent;
|
||||
import mineplex.hub.hubgame.common.map.BlockRecorderComponent;
|
||||
import mineplex.hub.hubgame.common.map.PreventNonAlivePlayersComponent;
|
||||
import mineplex.hub.hubgame.common.map.TeleportIntoMapComponent;
|
||||
|
||||
public class Duels extends CycledGame
|
||||
@ -74,15 +80,32 @@ public class Duels extends CycledGame
|
||||
|
||||
registerComponent(new DamageComponent(this));
|
||||
registerComponent(new PVPTrackerComponent(this));
|
||||
registerComponent(new GameDescriptionComponent(this, player ->
|
||||
{
|
||||
for (Player other : getAlivePlayers())
|
||||
{
|
||||
if (!player.equals(other))
|
||||
{
|
||||
return C.cWhiteB + "Opponent " + C.cRedB + other.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}));
|
||||
registerComponent(new TeleportIntoMapComponent(this, _worldData.getDataLocation("YELLOW")));
|
||||
registerComponent(new PrepareFreezeComponent(this));
|
||||
registerComponent(new InventoryEditComponent(this));
|
||||
registerComponent(new DoubleJumpComponent(this));
|
||||
registerComponent(new GameTimeoutComponent(this, TimeUnit.MINUTES.toMillis(2)));
|
||||
registerComponent(new SingleWinnerComponent(this));
|
||||
registerComponent(new PlayerGameModeComponent(this, GameMode.SURVIVAL));
|
||||
|
||||
List<Location> corners = _worldData.getDataLocation("LIME");
|
||||
Location a = corners.get(0);
|
||||
Location b = corners.get(1);
|
||||
|
||||
registerComponent(new BlockRecorderComponent(this, corners.get(0), corners.get(1)));
|
||||
registerComponent(new BlockRecorderComponent(this, a, b));
|
||||
registerComponent(new PreventNonAlivePlayersComponent(this, a, b));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,8 +113,6 @@ public class Duels extends CycledGame
|
||||
{
|
||||
for (Player player : getAlivePlayers())
|
||||
{
|
||||
//TODO remove clear when proper inventory handling is added
|
||||
player.getInventory().clear();
|
||||
player.getInventory().addItem(ITEMS);
|
||||
player.getInventory().setArmorContents(ARMOUR);
|
||||
}
|
||||
@ -118,4 +139,6 @@ public class Duels extends CycledGame
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package mineplex.hub.hubgame.duel;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.hubgame.common.damage.PVPTrackerComponent;
|
||||
import mineplex.hub.hubgame.common.damage.PVPTrackerComponent.Match;
|
||||
import mineplex.hub.hubgame.ui.HubGamePage;
|
||||
import mineplex.hub.hubgame.ui.HubGameShop;
|
||||
|
||||
public class DuelsUI extends HubGamePage
|
||||
{
|
||||
|
||||
private final Duels _game;
|
||||
|
||||
public DuelsUI(HubGameManager plugin, HubGameShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Duels game)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, player, game, 45);
|
||||
|
||||
_game = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
super.buildPage();
|
||||
|
||||
PVPTrackerComponent tracker = _game.getComponent(PVPTrackerComponent.class);
|
||||
int slot = 20;
|
||||
|
||||
for (int i = 4; i >= 0; i--)
|
||||
{
|
||||
Match match = tracker.getMatches().get(i);
|
||||
|
||||
addButton(slot++, getMatchItem(match), (player, clickType) -> tracker.sendMatch(player, match));
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getMatchItem(Match match)
|
||||
{
|
||||
Player[] players = match.getPlayers();
|
||||
|
||||
return new ItemBuilder(Material.DIAMOND)
|
||||
.setTitle(C.cGreen + players[0].getName() + C.cWhiteB + " v " + C.cGreen + players[1].getName())
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package mineplex.hub.hubgame.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.CycledGame.GameState;
|
||||
|
||||
public class HubGamePlayerDeathEvent extends PlayerEvent
|
||||
{
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
private final CycledGame _game;
|
||||
private final boolean _end;
|
||||
|
||||
public HubGamePlayerDeathEvent(Player player, CycledGame game, boolean end)
|
||||
{
|
||||
super(player);
|
||||
|
||||
_game = game;
|
||||
_end = end;
|
||||
}
|
||||
|
||||
public CycledGame getGame()
|
||||
{
|
||||
return _game;
|
||||
}
|
||||
|
||||
public boolean isEnding()
|
||||
{
|
||||
return _end;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package mineplex.hub.hubgame.tron;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -14,15 +15,18 @@ import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.hubgame.HubGameType;
|
||||
import mineplex.hub.hubgame.common.general.GameDescriptionComponent;
|
||||
import mineplex.hub.hubgame.common.general.GameTimeoutComponent;
|
||||
import mineplex.hub.hubgame.common.general.PlacesComponent;
|
||||
import mineplex.hub.hubgame.common.map.PreventNonAlivePlayersComponent;
|
||||
import mineplex.hub.hubgame.common.map.TeleportIntoMapComponent;
|
||||
import mineplex.hub.hubgame.common.powerup.PowerupComponent;
|
||||
import mineplex.hub.hubgame.tron.powerup.JumpPowerup;
|
||||
import mineplex.hub.hubgame.tron.powerup.SpeedPowerup;
|
||||
|
||||
public class Tron extends CycledGame
|
||||
@ -47,9 +51,18 @@ public class Tron extends CycledGame
|
||||
PowerupComponent powerupComponent = registerComponent(new PowerupComponent(this, _worldData.getDataLocation("ORANGE")));
|
||||
_speedPowerup = new SpeedPowerup();
|
||||
powerupComponent.addPowerup(_speedPowerup);
|
||||
powerupComponent.addPowerup(new JumpPowerup());
|
||||
|
||||
registerComponent(new TeleportIntoMapComponent(this, _worldData.getDataLocation("RED")));
|
||||
registerComponent(new GameDescriptionComponent(this));
|
||||
registerComponent(new GameTimeoutComponent(this, TimeUnit.MINUTES.toMillis(3)));
|
||||
registerComponent(new PlacesComponent(this));
|
||||
|
||||
List<Location> corners = _worldData.getDataLocation("WHITE");
|
||||
Location a = corners.get(0);
|
||||
Location b = corners.get(1);
|
||||
|
||||
registerComponent(new PreventNonAlivePlayersComponent(this, a, b));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,7 +100,7 @@ public class Tron extends CycledGame
|
||||
|
||||
bike.updateDirection();
|
||||
|
||||
if (isLive() && bike.updateLocation(_speedPowerup.isActive(player)) && UtilTime.elapsed(getLastStart(), 1000))
|
||||
if (isLive() && bike.updateLocation(_speedPowerup.isActive(player)))
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
package mineplex.hub.hubgame.tron.powerup;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.hub.hubgame.common.powerup.ItemPowerup;
|
||||
|
||||
public class JumpPowerup extends ItemPowerup
|
||||
{
|
||||
|
||||
private static final ItemStack ITEM_STACK = new ItemStack(Material.FEATHER);
|
||||
private static final Vector DIRECTION = new Vector(0, 1.5, 0);
|
||||
|
||||
public JumpPowerup()
|
||||
{
|
||||
super(C.cGoldB + "Jump", ITEM_STACK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInteractItem(Player player)
|
||||
{
|
||||
Entity entity = player.getPassenger();
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
entity.setVelocity(DIRECTION);
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import mineplex.hub.hubgame.common.powerup.TimedPowerup;
|
||||
public class SpeedPowerup extends TimedPowerup
|
||||
{
|
||||
|
||||
private static final ItemStack ITEM_STACK = new ItemStack(Material.FEATHER);
|
||||
private static final ItemStack ITEM_STACK = new ItemStack(Material.DIAMOND_BOOTS);
|
||||
private static final long LENGTH = TimeUnit.SECONDS.toMillis(3);
|
||||
|
||||
public SpeedPowerup()
|
||||
|
@ -0,0 +1,75 @@
|
||||
package mineplex.hub.hubgame.ui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
import mineplex.hub.hubgame.HubGame;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.hubgame.HubGameType;
|
||||
|
||||
public class HubGamePage extends ShopPageBase<HubGameManager, HubGameShop>
|
||||
{
|
||||
|
||||
private final HubGame _game;
|
||||
|
||||
public HubGamePage(HubGameManager plugin, HubGameShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, HubGame game)
|
||||
{
|
||||
this(plugin, shop, clientManager, donationManager, player, game, 27);
|
||||
}
|
||||
|
||||
public HubGamePage(HubGameManager plugin, HubGameShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, HubGame game, int slots)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, game.getGameType().getName(), player, slots);
|
||||
|
||||
_game = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
HubGameType gameType = _game.getGameType();
|
||||
ItemBuilder builder = new ItemBuilder(gameType.getItemStack());
|
||||
|
||||
builder.setTitle(C.cYellow + gameType.getName());
|
||||
builder.addLore("");
|
||||
builder.addLore(gameType.getDescription());
|
||||
builder.addLore("", C.cWhite + "Alive Players: " + C.cYellow + _game.getAlivePlayers().size());
|
||||
|
||||
if (_game instanceof CycledGame)
|
||||
{
|
||||
List<Player> queue = ((CycledGame) _game).getQueuedPlayers();
|
||||
int index = queue.indexOf(getPlayer());
|
||||
|
||||
builder.addLore("", "Queue Position: " + C.cYellow + (index == -1 ? "Not in queue" : (index + 1) + C.cGray + "/" + C.cYellow + queue.size()));
|
||||
builder.addLore("", C.cGreen + (index == -1 ? "Click to join the queue." : "Click to leave the queue."));
|
||||
}
|
||||
|
||||
addButton(14, builder.build(), (player, clickType) ->
|
||||
{
|
||||
if (_game instanceof CycledGame)
|
||||
{
|
||||
CycledGame game = (CycledGame) _game;
|
||||
List<Player> queue = game.getQueuedPlayers();
|
||||
int index = queue.indexOf(getPlayer());
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
_game.getManager().joinQueue(game, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_game.getManager().leaveQueue(game, player, false);
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package mineplex.hub.hubgame.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
|
||||
public class HubGameShop extends ShopBase<HubGameManager>
|
||||
{
|
||||
|
||||
public HubGameShop(HubGameManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<HubGameManager, ? extends ShopBase<HubGameManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -27,6 +28,7 @@ import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.event.NPCInteractEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.doublejump.DoubleJumpPrepareEvent;
|
||||
import mineplex.hub.parkour.data.Snake;
|
||||
import mineplex.hub.parkour.data.SnakeParkourData;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
@ -193,6 +195,29 @@ public class ParkourManager extends MiniPlugin
|
||||
return active;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void doubleJump(DoubleJumpPrepareEvent event)
|
||||
{
|
||||
if (!isParkourMode(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (isParkourMode(player))
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You can't teleport during parkour."));
|
||||
_attempts.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
|
@ -0,0 +1,61 @@
|
||||
package mineplex.hub.player;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.titles.Titles;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class HotbarManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private static final ItemStack GAME_MENU = new ItemBuilder(Material.COMPASS)
|
||||
.setTitle(C.cGreen + "Game Menu")
|
||||
.addLore("Click to open the Game Menu.")
|
||||
.build();
|
||||
private static final ItemStack LOBBY_MENU = new ItemBuilder(Material.WATCH)
|
||||
.setTitle(C.cGreen + "Lobby Menu")
|
||||
.addLore("Click to open the Game Menu.")
|
||||
.build();
|
||||
|
||||
private final CosmeticManager _cosmeticManager;
|
||||
private final Titles _titles;
|
||||
|
||||
private HotbarManager()
|
||||
{
|
||||
super("Hotbar");
|
||||
|
||||
_cosmeticManager = require(CosmeticManager.class);
|
||||
_titles = require(Titles.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
giveHotbar(event.getPlayer());
|
||||
}
|
||||
|
||||
public void giveHotbar(Player player)
|
||||
{
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
inventory.clear();
|
||||
|
||||
inventory.setItem(0, GAME_MENU);
|
||||
inventory.setItem(1, LOBBY_MENU);
|
||||
|
||||
_cosmeticManager.giveInterfaceItem(player);
|
||||
|
||||
//inventory.setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM);
|
||||
_titles.giveBook(player, false);
|
||||
}
|
||||
}
|
21
Plugins/Mineplex.Hub/src/mineplex/hub/player/HubPlayer.java
Normal file
21
Plugins/Mineplex.Hub/src/mineplex/hub/player/HubPlayer.java
Normal file
@ -0,0 +1,21 @@
|
||||
package mineplex.hub.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.customdata.MineplexPlayer;
|
||||
|
||||
public class HubPlayer extends MineplexPlayer
|
||||
{
|
||||
|
||||
public HubPlayer(Player player, CustomDataManager customDataManager)
|
||||
{
|
||||
super(player, customDataManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyPrefix()
|
||||
{
|
||||
return "hub.";
|
||||
}
|
||||
}
|
@ -134,13 +134,6 @@ public class ServerManager extends MiniPlugin
|
||||
PermissionGroup.BUILDER.setPermission(Perm.FEATURE_SERVER, true, true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.COMPASS.getId(), (byte)0, 1, ChatColor.GREEN + "Game Menu"));
|
||||
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WATCH.getId(), (byte)0, 1, ChatColor.GREEN + "Lobby Menu"));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void playerPortalEvent(PlayerPortalEvent event)
|
||||
{
|
||||
|
@ -27,7 +27,9 @@ import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
@ -285,6 +287,15 @@ public class HubWorldManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent the crafting of items
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void itemCraft(CraftItemEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This event only works for {@link PlayerEvent} and {@link EntityEvent} events.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user