New Parkour System
This commit is contained in:
parent
bf82b7c0f4
commit
8532f6eca1
@ -64,14 +64,14 @@ public class LevelingManager extends MiniDbClientPlugin<List<Integer>>
|
||||
populateRewards();
|
||||
generatePermissions();
|
||||
|
||||
new CommandBase<LevelingManager>(this, Perm.VIEW_LEVEL_MENU,"level")
|
||||
addCommand(new CommandBase<LevelingManager>(this, Perm.VIEW_LEVEL_MENU,"level")
|
||||
{
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
_shop.attemptShopOpen(caller);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
|
@ -35,8 +35,6 @@ import mineplex.core.newnpc.command.NPCCommand;
|
||||
import mineplex.core.newnpc.command.NPCDeleteCommand;
|
||||
import mineplex.core.newnpc.event.NPCInteractEvent;
|
||||
import mineplex.core.newnpc.event.NPCRefreshEvent;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.npc.NpcManager.Perm;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
|
@ -99,20 +99,20 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.youtube.YoutubeManager;
|
||||
import mineplex.hub.commands.GadgetToggle;
|
||||
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.JumpManager;
|
||||
import mineplex.hub.modules.KothManager;
|
||||
import mineplex.hub.modules.MavericksManager;
|
||||
import mineplex.hub.modules.ParkourManager;
|
||||
import mineplex.hub.modules.SoccerManager;
|
||||
import mineplex.hub.modules.TemporaryGemHuntersServerSender;
|
||||
import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager;
|
||||
import mineplex.hub.news.NewsManager;
|
||||
import mineplex.hub.parkour.ParkourManager;
|
||||
import mineplex.hub.scoreboard.HubScoreboard;
|
||||
import mineplex.hub.world.HubWorldManager;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
@ -168,8 +168,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
// Disable item merging
|
||||
((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0;
|
||||
|
||||
_parkour = new ParkourManager(this, donationManager, taskManager);
|
||||
|
||||
_parkour = require(ParkourManager.class);
|
||||
_jumpManager = new JumpManager(this);
|
||||
|
||||
require(NewsManager.class);
|
||||
@ -229,7 +228,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
|
||||
require(TabListSorter.class);
|
||||
|
||||
Managers.put(require(HubScoreboard.class), ScoreboardManager.class);
|
||||
Managers.put(new HubScoreboard(_plugin, this), ScoreboardManager.class);
|
||||
|
||||
require(TwoFactorAuth.class);
|
||||
require(HubGameManager.class);
|
||||
|
@ -0,0 +1,43 @@
|
||||
package mineplex.hub.doublejump;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class DoubleJumpEvent extends PlayerEvent implements Cancellable
|
||||
{
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public DoubleJumpEvent(Player who)
|
||||
{
|
||||
super(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.modules;
|
||||
package mineplex.hub.doublejump;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -61,7 +61,17 @@ public class JumpManager extends MiniPlugin
|
||||
if (disguise != null &&
|
||||
((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);
|
||||
|
@ -0,0 +1,27 @@
|
||||
package mineplex.hub.hubgame.common.general;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.hub.doublejump.DoubleJumpEvent;
|
||||
import mineplex.hub.hubgame.HubGame;
|
||||
import mineplex.hub.hubgame.common.HubGameComponent;
|
||||
|
||||
public class DoubleJumpComponent extends HubGameComponent<HubGame>
|
||||
{
|
||||
|
||||
public DoubleJumpComponent(HubGame game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void doubleJump(DoubleJumpEvent event)
|
||||
{
|
||||
if (!_game.isAlive(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import mineplex.hub.hubgame.HubGameManager;
|
||||
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.GameTimeoutComponent;
|
||||
import mineplex.hub.hubgame.common.general.InventoryEditComponent;
|
||||
import mineplex.hub.hubgame.common.general.PrepareFreezeComponent;
|
||||
@ -76,6 +77,7 @@ public class Duels extends CycledGame
|
||||
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)));
|
||||
|
||||
List<Location> corners = _worldData.getDataLocation("LIME");
|
||||
|
@ -1,565 +0,0 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||
import mineplex.core.gadget.types.MusicGadget;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.treasure.event.TreasurePreStartEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.parkour.ParkourData;
|
||||
|
||||
public class ParkourManager extends MiniPlugin
|
||||
{
|
||||
private final String[] RUINS_DESCRIPTION = {
|
||||
"This is an extremely difficult parkour.",
|
||||
"You will need to find the correct way through",
|
||||
"the ruins, overcoming many challenging jumps.",
|
||||
};
|
||||
|
||||
private final String[] GWEN_DESCRIPTION = {
|
||||
"Can you escape from our Guardians?",
|
||||
"I hear they have infested the water",
|
||||
"sending anyone who falls in back to the start!",
|
||||
};
|
||||
|
||||
private final String[] LAVA_DESCRIPTION = {
|
||||
"This parkour is HOT! It's so hot that you",
|
||||
"must keep sprinting for the entire course,",
|
||||
"or you will die in flames!"
|
||||
};
|
||||
|
||||
private final String[] DESERT_DESCRIPTION = {
|
||||
"Ever heard of Prince of Persia",
|
||||
"well, this isn't as exciting.",
|
||||
"yet...."
|
||||
};
|
||||
|
||||
private final int RUINS_GEMS = 10000;
|
||||
private final int GWEN_GEMS = 4000;
|
||||
private final int LAVA_GEMS = 5000;
|
||||
private final int DESERT_GEMS = 3000;
|
||||
|
||||
public HubManager Manager;
|
||||
|
||||
private Map<UUID, ParkourData> _active = Maps.newHashMap();
|
||||
|
||||
private HashSet<ParkourData> _parkour = new HashSet<ParkourData>();
|
||||
|
||||
//private Location _snakeParkourReturn;
|
||||
private Location _lavaParkourReturn;
|
||||
private Location _waterReturn;
|
||||
private WeakHashMap<Player, Location> _lavaLocation = new WeakHashMap<Player, Location>();
|
||||
private WeakHashMap<Player, Long> _lavaTimer = new WeakHashMap<Player, Long>();
|
||||
|
||||
//Modules
|
||||
protected DonationManager _donationManager;
|
||||
protected TaskManager _taskManager;
|
||||
|
||||
public ParkourManager(HubManager manager, DonationManager donation, TaskManager task)
|
||||
{
|
||||
super("Parkour", manager.getPlugin());
|
||||
|
||||
Manager = manager;
|
||||
|
||||
_taskManager = task;
|
||||
_donationManager = donation;
|
||||
|
||||
_parkour.add(new ParkourData("Ruins Parkour", RUINS_DESCRIPTION, RUINS_GEMS,
|
||||
new Location(Manager.GetSpawn().getWorld(), 113.5, 66, -46.5),
|
||||
new Location(Manager.GetSpawn().getWorld(), 124, 86, 18),
|
||||
new Location(Manager.GetSpawn().getWorld(), 105, 57, -53)));
|
||||
|
||||
_parkour.add(new ParkourData("G.W.E.N Parkour", GWEN_DESCRIPTION, GWEN_GEMS,
|
||||
new Location(Manager.GetSpawn().getWorld(), 55.5, 68, -94.5),
|
||||
new Location(Manager.GetSpawn().getWorld(), 106, 96, -142),
|
||||
new Location(Manager.GetSpawn().getWorld(), 52, 61, -81)));
|
||||
|
||||
_parkour.add(new ParkourData("Lava Parkour", LAVA_DESCRIPTION, LAVA_GEMS,
|
||||
new Location(Manager.GetSpawn().getWorld(), -93.5, 67, 37.5),
|
||||
new Location(Manager.GetSpawn().getWorld(), -144, 97, -21),
|
||||
new Location(Manager.GetSpawn().getWorld(), -88, 62, 41)));
|
||||
|
||||
_parkour.add(new ParkourData("Desert Village Parkour", DESERT_DESCRIPTION, DESERT_GEMS,
|
||||
new Location(Manager.GetSpawn().getWorld(), -63.5, 69, -32.5),
|
||||
new Location(Manager.GetSpawn().getWorld(), -57, 82, -35),
|
||||
new Location(Manager.GetSpawn().getWorld(), -122, 45, 57)));
|
||||
|
||||
_lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5, 68, 36.5);
|
||||
_lavaParkourReturn.setYaw(90);
|
||||
_waterReturn = new Location(Manager.GetSpawn().getWorld(), 56.5, 68, -88.5);
|
||||
_waterReturn.setYaw(-141);
|
||||
}
|
||||
|
||||
public boolean isParkourMode(Player player)
|
||||
{
|
||||
return _active.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void setParkourMode(Player player, boolean enabled, ParkourData data)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
_active.put(player.getUniqueId(), data);
|
||||
UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Parkour Mode") + "."));
|
||||
|
||||
Manager.GetGadget().disableAll(player);
|
||||
|
||||
player.setVelocity(new Vector(0, -1, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAllowFlight(true);
|
||||
_active.remove(player.getUniqueId());
|
||||
UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Parkour Mode") + "."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableGadgets(GadgetEnableEvent event)
|
||||
{
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerEnterParkour(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (isParkourMode(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
_parkour.stream()
|
||||
.filter(data -> UtilMath.offset(player.getLocation(), data.NPC) < 6)
|
||||
.filter(data -> Recharge.Instance.use(player, data.Name + " Info", 300000, false, false))
|
||||
.forEach(data -> data.Inform(player));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void parkourUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> players = Lists.newArrayList(_active.keySet().stream().map(Bukkit::getPlayer).collect(Collectors.toList()));
|
||||
for (Player player : players)
|
||||
{
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
if (!InsideParkour(player.getLocation()))
|
||||
{
|
||||
setParkourMode(player, false, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects())
|
||||
{
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
players.clear();
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_active.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disallowBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.getPlayer().teleport(Manager.GetSpawn());
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You cannot break blocks in Parkour Mode!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void disallowBlockPlace(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getPlayer().getItemInHand() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.getPlayer().getItemInHand().getType().isBlock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.getPlayer().teleport(Manager.GetSpawn());
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You cannot place blocks in Parkour Mode!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void lavaReturn(EntityDamageEvent event)
|
||||
{
|
||||
if (event.getCause() != DamageCause.LAVA)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
{
|
||||
if (event.getEntity().hasMetadata("balloon"))
|
||||
return;
|
||||
event.getEntity().remove();
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!isParkourMode(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.getEntity().eject();
|
||||
event.getEntity().leaveVehicle();
|
||||
event.getEntity().teleport(_lavaParkourReturn);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void waterReturn(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!isParkourMode(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Arrays.equals(_active.get(player.getUniqueId()).Desc, GWEN_DESCRIPTION))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getTo().getBlock().getType() == Material.WATER || event.getTo().getBlock().getType() == Material.STATIONARY_WATER)
|
||||
{
|
||||
player.eject();
|
||||
player.leaveVehicle();
|
||||
player.teleport(_waterReturn);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onTeam(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().startsWith("/team ") && isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(F.main("Team", "You cannot join a team while in parkour mode!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void lavaBlockReturn(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (!UtilEnt.isGrounded(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isParkourMode(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getTypeId();
|
||||
int data = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getData();
|
||||
if (id != 0 && id != 112 && id != 114 && !(id == 43 && data == 6) && !(id == 44 && data == 6))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_lavaLocation.containsKey(player) || UtilMath.offset(player.getLocation(), _lavaLocation.get(player)) > 1.5)
|
||||
{
|
||||
_lavaLocation.put(player, player.getLocation());
|
||||
_lavaTimer.put(player, System.currentTimeMillis());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UtilTime.elapsed(_lavaTimer.get(player), 500))
|
||||
{
|
||||
boolean inCourse = false;
|
||||
for (Block block : UtilBlock.getInRadius(player.getLocation(), 1.5).keySet())
|
||||
{
|
||||
if (block.getType() == Material.NETHER_BRICK || block.getType() == Material.NETHER_BRICK_STAIRS)
|
||||
{
|
||||
inCourse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inCourse)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_lavaLocation.remove(player);
|
||||
_lavaTimer.remove(player);
|
||||
|
||||
player.eject();
|
||||
player.leaveVehicle();
|
||||
player.teleport(_lavaParkourReturn);
|
||||
player.setFireTicks(0);
|
||||
|
||||
UtilPlayer.message(player, F.main("Parkour", "You cannot stop running during Lava Parkour!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void finishParkour(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (event.getRightClicked() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getRightClicked() instanceof LivingEntity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity ent = (LivingEntity) event.getRightClicked();
|
||||
|
||||
if (ent.getCustomName() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Start Message
|
||||
if (ent.getCustomName().contains("Start"))
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (ParkourData data : _parkour)
|
||||
{
|
||||
if (!ent.getCustomName().contains(data.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isParkourMode(player))
|
||||
{
|
||||
setParkourMode(player, false, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
setParkourMode(player, true, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Finish Message
|
||||
if (ent.getCustomName().contains("Finish"))
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (!isParkourMode(player))
|
||||
{
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Parkour", "You must be in " + F.elem("Parkour Mode") + " to cleanup."));
|
||||
UtilPlayer.message(player, F.main("Parkour", "Talk to the " + F.elem("Start NPC") + " to enter Parkour Mode."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.use(player, "Finish Parkour", 30000, false, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ParkourData data = _active.get(player.getUniqueId());
|
||||
|
||||
if (!ent.getCustomName().contains(data.Name))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Parkour", "This is not the entity you are looking for..."));
|
||||
player.teleport(data.NPC);
|
||||
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0f, 1.0F);
|
||||
return;
|
||||
}
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Parkour", "You completed " + F.elem(data.Name) + "."));
|
||||
|
||||
setParkourMode(player, false, null);
|
||||
|
||||
//Gems
|
||||
if (!_taskManager.hasCompletedTask(player, data.Name))
|
||||
{
|
||||
final ParkourData fData = data;
|
||||
|
||||
_taskManager.completedTask(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.GEM, player, "Parkour " + fData.Name, fData.Gems, success ->
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Parkour", "You received " + F.elem(C.cGreen + fData.Gems + " Gems") + "."));
|
||||
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskManager.Get(player).TasksCompleted.remove(_taskManager.getTaskId(fData.Name));
|
||||
UtilPlayer.message(player, F.main("Parkour", "There was an error giving " + F.elem(C.cGreen + fData.Gems + " Gems to you. Please click the NPC again.") + "."));
|
||||
}
|
||||
});
|
||||
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
}
|
||||
}, player, fData.Name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void gadgetBlockChange(GadgetBlockEvent event)
|
||||
{
|
||||
for (Iterator<Block> iterator = event.getBlocks().iterator(); iterator.hasNext(); )
|
||||
{
|
||||
Block block = iterator.next();
|
||||
|
||||
for (ParkourData data : _parkour)
|
||||
{
|
||||
if (data.InBoundary(block.getLocation()))
|
||||
{
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean InsideParkour(Location loc)
|
||||
{
|
||||
for (ParkourData data : _parkour)
|
||||
if (data.InBoundary(loc))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventTreasureNearParkour(TreasurePreStartEvent event)
|
||||
{
|
||||
if (InsideParkour(event.getPlayer().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You can't open chests near Parkour."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void musicDisable(GadgetEnableEvent event)
|
||||
{
|
||||
if (event.getGadget() instanceof MusicGadget)
|
||||
{
|
||||
if (InsideParkour(event.getPlayer().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package mineplex.hub.modules.parkour;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ParkourData
|
||||
{
|
||||
public String Name;
|
||||
public String[] Desc;
|
||||
public int Gems;
|
||||
public Location NPC;
|
||||
public Location CornerA;
|
||||
public Location CornerB;
|
||||
public double Distance;
|
||||
|
||||
public ParkourData(String name, String[] desc, int gems, Location npc, Location cornerA, Location cornerB)
|
||||
{
|
||||
Name = name;
|
||||
Desc = desc;
|
||||
Gems = gems;
|
||||
NPC = npc;
|
||||
CornerA = cornerA;
|
||||
CornerB = cornerB;
|
||||
}
|
||||
|
||||
public void Inform(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, "");
|
||||
UtilPlayer.message(player, C.cDGreen + C.Strike + "=============================================");
|
||||
|
||||
UtilPlayer.message(player, "§f§l" + Name + " Course");
|
||||
UtilPlayer.message(player, "");
|
||||
|
||||
for (String cur : Desc)
|
||||
{
|
||||
UtilPlayer.message(player, " " + cur);
|
||||
}
|
||||
|
||||
UtilPlayer.message(player, "");
|
||||
UtilPlayer.message(player, C.cWhite + C.Bold + "You must " + C.cGreen + C.Bold + "Right-Click" + C.cWhite + C.Bold + " the NPC to begin!");
|
||||
|
||||
UtilPlayer.message(player, "");
|
||||
UtilPlayer.message(player, C.cDGreen + C.Strike + "=============================================");
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||
}
|
||||
|
||||
public boolean InBoundary(Location loc)
|
||||
{
|
||||
return (UtilAlg.inBoundingBox(loc, CornerA, CornerB));
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return CornerA.getWorld();
|
||||
}
|
||||
}
|
@ -1,214 +0,0 @@
|
||||
package mineplex.hub.modules.parkour;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
|
||||
public class ParkourSnake extends ParkourData
|
||||
{
|
||||
private ArrayList<SnakePart> _snakes;
|
||||
|
||||
public ParkourSnake(String name, String[] desc, int gems, Location npc, Location cornerA, Location cornerB)
|
||||
{
|
||||
super(name, desc, gems, npc, cornerA, cornerB);
|
||||
|
||||
//THIS SHOULD BE COMMENTED OUT
|
||||
//parseSnakes();
|
||||
|
||||
loadSnakes();
|
||||
}
|
||||
|
||||
public void loadSnakes()
|
||||
{
|
||||
_snakes = new ArrayList<SnakePart>();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedReader br = new BufferedReader(new FileReader("SnakeRoutes.dat"));
|
||||
try
|
||||
{
|
||||
String line = br.readLine();
|
||||
|
||||
while (line != null)
|
||||
{
|
||||
if (line.length() > 6)
|
||||
_snakes.add(loadSnake(line));
|
||||
|
||||
line = br.readLine();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public SnakePart loadSnake(String locString)
|
||||
{
|
||||
ArrayList<Location> locs = new ArrayList<Location>();
|
||||
|
||||
for (String cur : locString.split(":"))
|
||||
{
|
||||
String[] tokens = cur.split(",");
|
||||
|
||||
try
|
||||
{
|
||||
Location loc = new Location(getWorld(), Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]));
|
||||
|
||||
if (InBoundary(loc))
|
||||
locs.add(loc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Invalid Hub Snake Location: " + cur);
|
||||
}
|
||||
}
|
||||
|
||||
return new SnakePart(locs);
|
||||
}
|
||||
|
||||
public void parseSnakes()
|
||||
{
|
||||
String locString = "-22,78,-72:-22,79,-72:-22,80,-72:-22,80,-71:-22,80,-70:-22,80,-69:-22,78,-68:-22,79,-68:-22,80,-68:-22,79,-57:-22,79,-56:-22,79,-55:-22,79,-54:-22,79,-53:-21,75,-78:-21,76,-78:-21,77,-78:-21,75,-77:-21,75,-76:-21,75,-75:-21,75,-74:-21,76,-74:-21,77,-74:-21,78,-74:-21,78,-73:-21,78,-72:-21,76,-68:-21,77,-68:-21,78,-68:-21,76,-67:-21,76,-66:-21,76,-65:-21,76,-64:-21,77,-64:-21,78,-64:-21,79,-64:-21,79,-63:-21,77,-62:-21,78,-62:-21,79,-62:-21,79,-57:-21,79,-56:-21,79,-55:-21,79,-54:-21,79,-53:-20,77,-78:-20,77,-62:-20,79,-57:-20,79,-56:-20,79,-55:-20,79,-54:-20,79,-53:-19,75,-78:-19,76,-78:-19,77,-78:-19,75,-77:-19,75,-76:-19,75,-75:-19,75,-74:-19,77,-74:-19,78,-74:-19,79,-74:-19,75,-73:-19,76,-73:-19,77,-73:-19,77,-62:-18,79,-74:-18,77,-62:-17,79,-74:-17,77,-62:-16,79,-74:-16,77,-62:-15,77,-74:-15,78,-74:-15,79,-74:-15,75,-73:-15,76,-73:-15,77,-73:-15,75,-72:-15,75,-71:-15,75,-70:-15,75,-69:-15,76,-69:-15,77,-69:-15,77,-68:-15,77,-67:-15,77,-66:-15,77,-65:-15,77,-64:-15,77,-63:-15,77,-62:-11,77,-68:-11,78,-68:-11,79,-68:-11,77,-67:-11,77,-66:-11,77,-65:-11,78,-65:-11,79,-65:-10,79,-68:-10,79,-65:-9,79,-68:-9,79,-65:-8,77,-68:-8,78,-68:-8,79,-68:-8,77,-67:-8,77,-66:-8,77,-65:-8,78,-65:-8,79,-65:-7,75,-75:-7,75,-74:-7,75,-73:-7,76,-73:-7,77,-73:-7,73,-71:-7,74,-71:-7,75,-71:-7,73,-70:-7,73,-69:-7,72,-66:-7,73,-66:-7,74,-66:-7,72,-65:-7,72,-64:-7,72,-63:-7,73,-63:-7,74,-63:-7,75,-63:-6,71,-79:-6,72,-79:-6,73,-79:-6,74,-79:-6,75,-79:-6,75,-78:-6,76,-78:-6,77,-78:-6,75,-75:-6,77,-73:-6,75,-71:-6,73,-69:-6,74,-66:-6,75,-63:-5,71,-79:-5,77,-78:-5,75,-75:-5,75,-74:-5,75,-73:-5,76,-73:-5,77,-73:-5,73,-71:-5,74,-71:-5,75,-71:-5,73,-70:-5,73,-69:-5,77,-69:-5,77,-68:-5,77,-67:-5,74,-66:-5,75,-66:-5,76,-66:-5,77,-66:-5,72,-63:-5,73,-63:-5,74,-63:-5,75,-63:-4,71,-79:-4,77,-78:-4,77,-69:-4,72,-63:-3,71,-79:-3,77,-78:-3,77,-69:-3,72,-63:-2,71,-79:-2,73,-79:-2,74,-79:-2,75,-79:-2,75,-78:-2,76,-78:-2,77,-78:-2,74,-69:-2,75,-69:-2,76,-69:-2,77,-69:-2,74,-68:-2,74,-67:-2,74,-66:-2,74,-65:-2,75,-65:-2,76,-65:-2,76,-64:-2,72,-63:-2,73,-63:-2,74,-63:-2,75,-63:-2,76,-63:-1,71,-79:-1,73,-79:0,71,-79:0,73,-79:1,71,-79:1,73,-79:1,74,-79:1,75,-79:1,75,-78:1,76,-78:1,77,-78:2,71,-79:2,77,-78:3,71,-79:3,77,-78:4,71,-79:4,73,-79:4,74,-79:4,75,-79:4,75,-78:4,76,-78:4,77,-78:5,71,-79:5,73,-79:6,71,-79:6,73,-79:7,71,-79:7,73,-79:7,74,-79:7,75,-79:7,75,-78:7,76,-78:7,77,-78:7,69,-67:7,70,-67:7,71,-67:7,71,-66:7,71,-65:7,69,-64:7,70,-64:7,71,-64:8,71,-79:8,77,-78:8,66,-74:8,67,-74:8,68,-74:8,68,-73:8,68,-72:8,68,-71:8,68,-70:8,68,-69:8,69,-69:8,70,-69:8,71,-69:8,69,-67:8,69,-64:9,71,-79:9,77,-78:9,66,-74:9,71,-69:9,69,-67:9,69,-64:10,71,-79:10,72,-79:10,73,-79:10,74,-79:10,75,-79:10,75,-78:10,76,-78:10,77,-78:10,66,-74:10,68,-74:10,69,-74:10,70,-74:10,71,-74:10,71,-73:10,69,-72:10,70,-72:10,71,-72:10,69,-71:10,69,-70:10,69,-69:10,70,-69:10,71,-69:10,69,-67:10,70,-67:10,71,-67:10,71,-66:10,71,-65:10,69,-64:10,70,-64:10,71,-64:11,66,-74:11,68,-74:12,66,-74:12,68,-74:13,75,-80:13,76,-80:13,77,-80:13,75,-79:13,75,-78:13,75,-77:13,76,-77:13,77,-77:13,66,-74:13,68,-74:13,69,-74:13,70,-74:13,71,-74:13,72,-74:13,71,-67:13,71,-66:13,71,-65:13,69,-64:13,70,-64:13,71,-64:13,69,-63:13,69,-62:13,69,-61:13,69,-60:13,69,-59:13,69,-58:14,77,-80:14,77,-77:14,66,-74:14,72,-74:14,71,-67:14,69,-58:15,77,-80:15,77,-77:15,66,-74:15,71,-74:15,72,-74:15,69,-67:15,70,-67:15,71,-67:15,69,-58:16,75,-80:16,76,-80:16,77,-80:16,75,-79:16,75,-78:16,75,-77:16,76,-77:16,77,-77:16,66,-74:16,71,-74:16,69,-67:16,69,-58:17,66,-74:17,71,-74:17,69,-67:17,69,-58:18,66,-74:18,71,-74:18,72,-74:18,73,-74:18,69,-67:18,70,-67:18,69,-58:19,74,-79:19,74,-78:19,74,-77:19,66,-74:19,73,-74:19,70,-67:19,67,-62:19,68,-62:19,69,-62:19,69,-61:19,69,-60:19,69,-59:19,69,-58:20,74,-79:20,74,-77:20,66,-74:20,67,-74:20,68,-74:20,69,-74:20,70,-74:20,71,-74:20,72,-74:20,73,-74:20,68,-67:20,69,-67:20,70,-67:20,67,-62:21,72,-79:21,73,-79:21,74,-79:21,72,-78:21,72,-77:21,73,-77:21,74,-77:21,68,-67:21,67,-62:22,68,-67:22,69,-67:22,70,-67:22,70,-66:22,69,-65:22,70,-65:22,69,-64:22,69,-63:22,67,-62:22,68,-62:22,69,-62:";
|
||||
|
||||
ArrayList<Location> locs = new ArrayList<Location>();
|
||||
|
||||
for (String cur : locString.split(":"))
|
||||
{
|
||||
String[] tokens = cur.split(",");
|
||||
|
||||
try
|
||||
{
|
||||
Location loc = new Location(getWorld(), Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]));
|
||||
|
||||
if (InBoundary(loc))
|
||||
locs.add(loc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Invalid Hub Snake Location: " + cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ArrayList<ArrayList<Location>> snakes = new ArrayList<ArrayList<Location>>();
|
||||
|
||||
//Get Blacks
|
||||
Iterator<Location> locIterator = locs.iterator();
|
||||
while (locIterator.hasNext())
|
||||
{
|
||||
Location loc = locIterator.next();
|
||||
|
||||
if (loc.getBlock().getData() != 0)
|
||||
continue;
|
||||
|
||||
ArrayList<Location> newSnake = new ArrayList<Location>();
|
||||
newSnake.add(loc);
|
||||
snakes.add(newSnake);
|
||||
locIterator.remove();
|
||||
}
|
||||
|
||||
//Get Body
|
||||
int partsAdded = 1;
|
||||
while (partsAdded > 0)
|
||||
{
|
||||
partsAdded = 0;
|
||||
|
||||
locIterator = locs.iterator();
|
||||
while (locIterator.hasNext())
|
||||
{
|
||||
Location loc = locIterator.next();
|
||||
|
||||
if (loc.getBlock().getData() == 15)
|
||||
continue;
|
||||
|
||||
for (ArrayList<Location> snake : snakes)
|
||||
{
|
||||
if (UtilMath.offset(loc, snake.get(snake.size() - 1)) != 1)
|
||||
continue;
|
||||
|
||||
snake.add(loc);
|
||||
locIterator.remove();
|
||||
|
||||
partsAdded++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Get Tail
|
||||
try
|
||||
{
|
||||
locIterator = locs.iterator();
|
||||
while (locIterator.hasNext())
|
||||
{
|
||||
Location loc = locIterator.next();
|
||||
|
||||
for (ArrayList<Location> snake : snakes)
|
||||
{
|
||||
if (UtilMath.offset(loc, snake.get(snake.size() - 1)) != 1)
|
||||
continue;
|
||||
|
||||
snake.add(loc);
|
||||
locIterator.remove();
|
||||
|
||||
partsAdded++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Write
|
||||
try
|
||||
{
|
||||
File file = new File("SnakeRoutes.dat");
|
||||
if (!file.exists())
|
||||
file.createNewFile();
|
||||
|
||||
FileWriter fw = new FileWriter(file.getAbsoluteFile());
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
|
||||
for (ArrayList<Location> snake : snakes)
|
||||
{
|
||||
String out = "";
|
||||
|
||||
for (Location loc : snake)
|
||||
out += loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + ":";
|
||||
|
||||
bw.write(out + "\n\n\n");
|
||||
}
|
||||
|
||||
bw.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_snakes == null)
|
||||
return;
|
||||
|
||||
for (SnakePart snake : _snakes)
|
||||
snake.Update();
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package mineplex.hub.modules.parkour;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SnakePart
|
||||
{
|
||||
private ArrayList<Location> _path = new ArrayList<Location>();
|
||||
private byte _color = 0;
|
||||
|
||||
private int _index = 0;
|
||||
private boolean _colorTick = false;
|
||||
|
||||
private int _pathId = 39;
|
||||
|
||||
public SnakePart(ArrayList<Location> path)
|
||||
{
|
||||
_path = path;
|
||||
|
||||
_color = path.get(1).getBlock().getData();
|
||||
|
||||
for (Location loc : path)
|
||||
MapUtil.QuickChangeBlockAt(loc, 35, _color);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_path.isEmpty())
|
||||
return;
|
||||
|
||||
//Set Block
|
||||
sendBlock(_path.get(_index), 35, GetColor());
|
||||
|
||||
int back = _index - 10;
|
||||
while (back < 0)
|
||||
back += _path.size();
|
||||
|
||||
//Unset Tail
|
||||
sendBlock(_path.get(back), _pathId, (byte) 0);
|
||||
|
||||
//ALT
|
||||
if (_path.size() > 50)
|
||||
{
|
||||
int newIndex = (_index + (_path.size()/2))%_path.size();
|
||||
|
||||
//Set Block
|
||||
sendBlock(_path.get(newIndex), 35, GetColor());
|
||||
|
||||
back = newIndex - 10;
|
||||
if (back < 0)
|
||||
back += _path.size();
|
||||
|
||||
//Unset Tail
|
||||
sendBlock(_path.get(back), _pathId, (byte) 0);
|
||||
}
|
||||
|
||||
_index = (_index+1)%_path.size();
|
||||
_colorTick = !_colorTick;
|
||||
|
||||
/*
|
||||
for (Location loc : _path)
|
||||
if (loc.getBlock().getType() == Material.AIR)
|
||||
UtilParticle.PlayParticle(ParticleType.CRIT, loc, 0, 0, 0, 0, 1);
|
||||
*/
|
||||
}
|
||||
|
||||
public void sendBlock(Location loc, int id, byte data)
|
||||
{
|
||||
MapUtil.ChunkBlockChange(loc, id, data, false);
|
||||
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (UtilMath.offset(player.getLocation(), loc) < 64)
|
||||
{
|
||||
player.sendBlockChange(loc, Material.getMaterial(id), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte GetColor()
|
||||
{
|
||||
if (_colorTick)
|
||||
return _color;
|
||||
return _color;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package mineplex.hub.parkour;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class ParkourAttempt
|
||||
{
|
||||
|
||||
private final ParkourData _data;
|
||||
private final long _start;
|
||||
private long _end;
|
||||
private final Set<Location> _checkpoints;
|
||||
|
||||
public ParkourAttempt(ParkourData data)
|
||||
{
|
||||
_data = data;
|
||||
_start = System.currentTimeMillis();
|
||||
_checkpoints = new HashSet<>();
|
||||
}
|
||||
|
||||
public ParkourData getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public long getStart()
|
||||
{
|
||||
return _start;
|
||||
}
|
||||
|
||||
public void setEnd()
|
||||
{
|
||||
_end = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long getDuration()
|
||||
{
|
||||
return _end - _start;
|
||||
}
|
||||
|
||||
public Set<Location> getCheckpoints()
|
||||
{
|
||||
return _checkpoints;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package mineplex.hub.parkour;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
public class ParkourData
|
||||
{
|
||||
|
||||
private final String _name;
|
||||
private final List<Location> _checkpoints;
|
||||
|
||||
public ParkourData(WorldDataModule worldData, String name)
|
||||
{
|
||||
_name = name;
|
||||
|
||||
name = name.toUpperCase();
|
||||
|
||||
_checkpoints = worldData.getCustomLocation(name + " CHECK");
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return _name.toUpperCase();
|
||||
}
|
||||
|
||||
public boolean cheatCheck(ParkourAttempt attempt)
|
||||
{
|
||||
return attempt.getCheckpoints().size() > (_checkpoints.size() * 0.75D);
|
||||
}
|
||||
|
||||
public List<Location> getCheckpoints()
|
||||
{
|
||||
return _checkpoints;
|
||||
}
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
package mineplex.hub.parkour;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
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.PlayerVelocityEvent;
|
||||
|
||||
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.UtilMath;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||
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.parkour.data.Snake;
|
||||
import mineplex.hub.parkour.data.SnakeParkourData;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class ParkourManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private final Map<Player, ParkourAttempt> _attempts;
|
||||
private final Set<ParkourData> _parkours;
|
||||
|
||||
private ParkourManager()
|
||||
{
|
||||
super("Parkour");
|
||||
|
||||
_attempts = new HashMap<>();
|
||||
_parkours = new HashSet<>();
|
||||
|
||||
WorldDataModule worldData = require(WorldDataModule.class);
|
||||
_parkours.add(new ParkourData(worldData, "Test"));
|
||||
|
||||
List<Snake> snakes = new ArrayList<>();
|
||||
|
||||
for (Location head : worldData.getDataLocation("LIGHT_BLUE"))
|
||||
{
|
||||
snakes.add(new Snake(head, worldData.getCustomLocation("153")));
|
||||
}
|
||||
|
||||
_parkours.add(new SnakeParkourData(this, worldData, snakes));
|
||||
|
||||
NewNPCManager npcManager = require(NewNPCManager.class);
|
||||
|
||||
for (ParkourData data : _parkours)
|
||||
{
|
||||
npcManager.spawnNPCs(data.getKey() + " START", null);
|
||||
npcManager.spawnNPCs(data.getKey() + " END", null);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isParkourMode(Player player)
|
||||
{
|
||||
return _attempts.containsKey(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableGadgets(GadgetEnableEvent event)
|
||||
{
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void checkpointUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_attempts.forEach((player, attempt) ->
|
||||
{
|
||||
for (Location location : attempt.getData().getCheckpoints())
|
||||
{
|
||||
if (UtilMath.offset2dSquared(player.getLocation(), location) < 9)
|
||||
{
|
||||
attempt.getCheckpoints().add(location);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void timeUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_attempts.forEach((player, attempt) ->
|
||||
{
|
||||
UtilTextBottom.display(C.cGreenB + "Time: " + C.cPurple + ((System.currentTimeMillis() - attempt.getStart()) / 1000D) + " seconds", player);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void npcInteract(NPCInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
NPC npc = event.getNpc();
|
||||
String metadata = npc.getMetadata();
|
||||
|
||||
for (ParkourData data : _parkours)
|
||||
{
|
||||
if (metadata.equals(data.getKey() + " START"))
|
||||
{
|
||||
if (isParkourMode(player))
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "Reset your time for " + F.name(data.getName()) + "."));
|
||||
}
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "Started " + F.name(data.getName()) + "."));
|
||||
_attempts.put(player, new ParkourAttempt(data));
|
||||
return;
|
||||
}
|
||||
else if (metadata.equals(data.getKey() + " END"))
|
||||
{
|
||||
if (!isParkourMode(player))
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You must be in parkour mode in order to complete parkour."));
|
||||
return;
|
||||
}
|
||||
|
||||
ParkourAttempt attempt = _attempts.remove(player);
|
||||
|
||||
if (!data.cheatCheck(attempt))
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You seem to have cheated. No reward for you."));
|
||||
return;
|
||||
}
|
||||
|
||||
attempt.setEnd();
|
||||
double duration = (attempt.getDuration() / 1000D);
|
||||
player.sendMessage(F.main(_moduleName, "You completed " + F.name(data.getName()) + " in " + F.elem(duration) + " seconds."));
|
||||
rewardPlayer(player, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardPlayer(Player player, ParkourData data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int getActivePlayers(ParkourData data)
|
||||
{
|
||||
int active = 0;
|
||||
|
||||
for (ParkourAttempt attempt : _attempts.values())
|
||||
{
|
||||
if (attempt.getData().equals(data))
|
||||
{
|
||||
active++;
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_attempts.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onTeam(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().startsWith("/team ") && isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(F.main("Team", "You cannot join a team while in parkour mode!"));
|
||||
}
|
||||
}
|
||||
}
|
118
Plugins/Mineplex.Hub/src/mineplex/hub/parkour/data/Snake.java
Normal file
118
Plugins/Mineplex.Hub/src/mineplex/hub/parkour/data/Snake.java
Normal file
@ -0,0 +1,118 @@
|
||||
package mineplex.hub.parkour.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
public class Snake
|
||||
{
|
||||
|
||||
private static final int TAIL_LENGTH = 10;
|
||||
|
||||
private final List<Location> _path;
|
||||
private byte _color;
|
||||
|
||||
private int _index = 0;
|
||||
private boolean _colorTick;
|
||||
|
||||
public Snake(Location loc, List<Location> path)
|
||||
{
|
||||
_path = new ArrayList<>(path.size());
|
||||
|
||||
//First
|
||||
_path.add(loc);
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.BROWN_MUSHROOM);
|
||||
|
||||
//Direction
|
||||
for (Block block : UtilBlock.getSurrounding(loc.getBlock(), false))
|
||||
{
|
||||
if (block.getType() == Material.WOOL)
|
||||
{
|
||||
_path.add(block.getLocation().add(0.5, 0.5, 0.5));
|
||||
_color = block.getData();
|
||||
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.BROWN_MUSHROOM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Path
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
Iterator<Location> pathIterator = path.iterator();
|
||||
|
||||
while (pathIterator.hasNext())
|
||||
{
|
||||
Location pathLoc = pathIterator.next();
|
||||
|
||||
if (UtilMath.offset(_path.get(_path.size() - 1).getBlock().getLocation(), pathLoc.getBlock().getLocation()) <= 1)
|
||||
{
|
||||
_path.add(pathLoc);
|
||||
MapUtil.QuickChangeBlockAt(pathLoc, Material.BROWN_MUSHROOM);
|
||||
pathIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (_path.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Set Block
|
||||
MapUtil.QuickChangeBlockAt(_path.get(_index), Material.WOOL, getColor());
|
||||
|
||||
int back = _index - TAIL_LENGTH;
|
||||
if (back < 0)
|
||||
{
|
||||
back += _path.size();
|
||||
}
|
||||
|
||||
//Unset Tail
|
||||
MapUtil.QuickChangeBlockAt(_path.get(back), Material.BROWN_MUSHROOM);
|
||||
|
||||
//ALT
|
||||
if (_path.size() > 50)
|
||||
{
|
||||
int newIndex = (_index + (_path.size() / 2)) % _path.size();
|
||||
|
||||
//Set Block
|
||||
MapUtil.QuickChangeBlockAt(_path.get(newIndex), Material.WOOL, getColor());
|
||||
|
||||
back = newIndex - TAIL_LENGTH;
|
||||
if (back < 0)
|
||||
{
|
||||
back += _path.size();
|
||||
}
|
||||
|
||||
//Unset Tail
|
||||
MapUtil.QuickChangeBlockAt(_path.get(back), Material.BROWN_MUSHROOM);
|
||||
}
|
||||
|
||||
_index = (_index + 1) % _path.size();
|
||||
_colorTick = !_colorTick;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
for (Location location : _path)
|
||||
{
|
||||
MapUtil.QuickChangeBlockAt(location, Material.BROWN_MUSHROOM);
|
||||
}
|
||||
}
|
||||
|
||||
private byte getColor()
|
||||
{
|
||||
return _colorTick ? _color : 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package mineplex.hub.parkour.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.parkour.ParkourData;
|
||||
import mineplex.hub.parkour.ParkourManager;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
public class SnakeParkourData extends ParkourData implements Listener
|
||||
{
|
||||
|
||||
private final ParkourManager _manager;
|
||||
private final List<Snake> _snakes;
|
||||
|
||||
public SnakeParkourData(ParkourManager manager, WorldDataModule worldData, List<Snake> snakes)
|
||||
{
|
||||
super(worldData, "Snake");
|
||||
|
||||
_manager = manager;
|
||||
_snakes = snakes;
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER || _manager.getActivePlayers(this) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_snakes.forEach(Snake::update);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockPhysics(BlockPhysicsEvent event)
|
||||
{
|
||||
if (event.getBlock().getType() == Material.BROWN_MUSHROOM)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
@ -141,15 +142,15 @@ public class HubWorldManager extends MiniPlugin
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void entityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
if (event.getCause() == DamageCause.VOID)
|
||||
{
|
||||
event.getEntity().eject();
|
||||
event.getEntity().leaveVehicle();
|
||||
event.getEntity().teleport(_manager.GetSpawn());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!UtilEnt.hasFlag(event.getEntity(), UtilEnt.FLAG_NO_REMOVE))
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
event.getEntity().eject();
|
||||
event.getEntity().leaveVehicle();
|
||||
event.getEntity().teleport(_manager.GetSpawn());
|
||||
}
|
||||
else if (!UtilEnt.hasFlag(event.getEntity(), UtilEnt.FLAG_NO_REMOVE))
|
||||
{
|
||||
event.getEntity().remove();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user