Fix Old Parkours not working and Player Profile

This commit is contained in:
Sam 2017-10-30 11:28:07 +00:00 committed by Alexander Meech
parent 093e4404e4
commit cd4d638963
6 changed files with 968 additions and 8 deletions

View File

@ -2,6 +2,13 @@ package mineplex.hub;
import java.util.UUID; import java.util.UUID;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -68,6 +75,7 @@ import mineplex.core.quests.QuestManager;
import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.TabListSorter; import mineplex.core.scoreboard.TabListSorter;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
import mineplex.core.thank.ThankManager; import mineplex.core.thank.ThankManager;
import mineplex.core.treasure.TreasureManager; import mineplex.core.treasure.TreasureManager;
import mineplex.core.twofactor.TwoFactorAuth; import mineplex.core.twofactor.TwoFactorAuth;
@ -80,11 +88,11 @@ import mineplex.hub.gimmicks.AdminPunch;
import mineplex.hub.hubgame.HubGameManager; import mineplex.hub.hubgame.HubGameManager;
import mineplex.hub.modules.ForcefieldManager; import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.HubVisibilityManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.SoccerManager; import mineplex.hub.modules.SoccerManager;
import mineplex.hub.modules.TemporaryGemHuntersServerSender; import mineplex.hub.modules.TemporaryGemHuntersServerSender;
import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager; import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager;
import mineplex.hub.news.NewsManager; import mineplex.hub.news.NewsManager;
import mineplex.hub.parkour.ParkourManager;
import mineplex.hub.player.CreativeManager; import mineplex.hub.player.CreativeManager;
import mineplex.hub.player.HubPlayerManager; import mineplex.hub.player.HubPlayerManager;
import mineplex.hub.plugin.HalloweenHubPlugin; import mineplex.hub.plugin.HalloweenHubPlugin;
@ -94,12 +102,6 @@ import mineplex.hub.world.HubWorldManager;
import mineplex.hub.world.WorldDataModule; import mineplex.hub.world.WorldDataModule;
import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
{ {
@ -150,7 +152,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
// Disable item merging // Disable item merging
((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0;
require(ParkourManager.class); new ParkourManager(this, donationManager, new TaskManager(_plugin, clientManager));
_jumpManager = new JumpManager(this); _jumpManager = new JumpManager(this);
require(NewsManager.class); require(NewsManager.class);

View File

@ -0,0 +1,554 @@
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.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 musicDisable(GadgetEnableEvent event)
{
if (event.getGadget() instanceof MusicGadget)
{
if (InsideParkour(event.getPlayer().getLocation()))
{
event.setCancelled(true);
}
}
}
}

View File

@ -0,0 +1,64 @@
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();
}
}

View File

@ -0,0 +1,214 @@
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();
}
}

View File

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

View File

@ -6,19 +6,23 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.customdata.CustomDataManager; import mineplex.core.customdata.CustomDataManager;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.PartyManager; import mineplex.core.party.PartyManager;
import mineplex.core.personalServer.PersonalServerManager;
import mineplex.core.titles.Titles; import mineplex.core.titles.Titles;
import mineplex.hub.HubManager; import mineplex.hub.HubManager;
import mineplex.hub.profile.gui.GUIProfile;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class HubPlayerManager extends MiniPlugin public class HubPlayerManager extends MiniPlugin
@ -34,18 +38,22 @@ public class HubPlayerManager extends MiniPlugin
.build(); .build();
private static final String HUB_KEY = "spawn-location"; private static final String HUB_KEY = "spawn-location";
private final AchievementManager _achievementManager;
private final CustomDataManager _customDataManager; private final CustomDataManager _customDataManager;
private final CosmeticManager _cosmeticManager; private final CosmeticManager _cosmeticManager;
private final HubManager _hubManager; private final HubManager _hubManager;
private final PersonalServerManager _personalServerManager;
private final Titles _titles; private final Titles _titles;
private HubPlayerManager() private HubPlayerManager()
{ {
super("Hub Player"); super("Hub Player");
_achievementManager = require(AchievementManager.class);
_customDataManager = require(CustomDataManager.class); _customDataManager = require(CustomDataManager.class);
_cosmeticManager = require(CosmeticManager.class); _cosmeticManager = require(CosmeticManager.class);
_hubManager = require(HubManager.class); _hubManager = require(HubManager.class);
_personalServerManager = require(PersonalServerManager.class);
_titles = require(Titles.class); _titles = require(Titles.class);
} }
@ -76,6 +84,21 @@ public class HubPlayerManager extends MiniPlugin
giveHotbar(player); giveHotbar(player);
} }
@EventHandler
public void profileInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (itemStack == null || itemStack.getType() != Material.SKULL_ITEM)
{
return;
}
new GUIProfile(_plugin, player, _hubManager.getPreferences(), _achievementManager, _personalServerManager)
.openInventory();
}
public void giveHotbar(Player player) public void giveHotbar(Player player)
{ {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
@ -89,5 +112,9 @@ public class HubPlayerManager extends MiniPlugin
inventory.setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM); inventory.setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM);
_titles.giveBook(player, false); _titles.giveBook(player, false);
inventory.setItem(8, new ItemBuilder(Material.SKULL_ITEM, (byte) 3)
.setTitle("My Profile")
.setPlayerHead(player.getName())
.build());
} }
} }