Hub progress
This commit is contained in:
parent
153d5bdc63
commit
623cd77031
@ -8,69 +8,62 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
|
||||
/**
|
||||
* A simple 3D vector stored shape
|
||||
* A simple 3D vector stored shape
|
||||
*/
|
||||
|
||||
public class Shape
|
||||
{
|
||||
|
||||
|
||||
protected final static double DEFAULT_DENSITY = 1;
|
||||
|
||||
|
||||
protected HashSet<Vector> _points = new HashSet<>();
|
||||
|
||||
public Shape(){}
|
||||
|
||||
|
||||
public Shape(Collection<Vector> points){
|
||||
this._points.addAll(points);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate this shape along the X-axis
|
||||
* @param radians Radians to rotate the shape
|
||||
*/
|
||||
public void rotateOnXAxis(double radians)
|
||||
{
|
||||
for(Vector v : _points)
|
||||
for(Vector v : _points)
|
||||
{
|
||||
double y = v.getY();
|
||||
double z = v.getZ();
|
||||
v.setY(y * Math.cos(radians) - z * Math.sin(radians));
|
||||
v.setZ(y * Math.sin(radians) + z * Math.cos(radians));
|
||||
UtilAlg.rotateAroundXAxis(v, radians);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate this shape along the Y-axis
|
||||
* @param radians Radians to rotate the shape
|
||||
*/
|
||||
public void rotateOnYAxis(double radians)
|
||||
{
|
||||
for(Vector v : _points)
|
||||
for(Vector v : _points)
|
||||
{
|
||||
double x = v.getX();
|
||||
double z = v.getZ();
|
||||
v.setX(x * Math.cos(radians) - z * Math.sin(radians));
|
||||
v.setZ(x * Math.sin(radians) + z * Math.cos(radians));
|
||||
UtilAlg.rotateAroundYAxis(v, radians);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate this shape along the Z-axis
|
||||
* @param radians Radians to rotate the shape
|
||||
*/
|
||||
public void rotateOnZAxis(double radians)
|
||||
{
|
||||
for(Vector v : _points)
|
||||
for(Vector v : _points)
|
||||
{
|
||||
double x = v.getX();
|
||||
double y = v.getY();
|
||||
v.setX(x * Math.cos(radians) - y * Math.sin(radians));
|
||||
v.setY(x * Math.sin(radians) + y * Math.cos(radians));
|
||||
}
|
||||
|
||||
UtilAlg.rotateAroundZAxis(v, radians);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Offsets all the points based on the given vector
|
||||
* @param v
|
||||
@ -79,26 +72,26 @@ public class Shape
|
||||
{
|
||||
for(Vector p : _points) p.add(v);
|
||||
}
|
||||
|
||||
|
||||
public void addPoint(Vector v)
|
||||
{
|
||||
_points.add(v);
|
||||
}
|
||||
|
||||
|
||||
public boolean removePoint(Vector v)
|
||||
{
|
||||
return _points.remove(v);
|
||||
}
|
||||
|
||||
|
||||
public Set<Vector> getPoints()
|
||||
{
|
||||
return new HashSet<>(_points);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Multiply all the points by m.
|
||||
* If m > 1 then the shape will become larger.
|
||||
* If m < 1 then the shape will become smaller.
|
||||
* Multiply all the points by m.
|
||||
* If m > 1 then the shape will become larger.
|
||||
* If m < 1 then the shape will become smaller.
|
||||
* If m = 1 then the shape will stay the same.
|
||||
* If m < 0 then the shape will become inverted.
|
||||
* @param m
|
||||
@ -107,7 +100,7 @@ public class Shape
|
||||
{
|
||||
for(Vector v : _points) v.multiply(m);
|
||||
}
|
||||
|
||||
|
||||
public Shape clone() {
|
||||
List<Vector> list = new ArrayList<>();
|
||||
for(Vector p : _points)
|
||||
@ -116,12 +109,12 @@ public class Shape
|
||||
}
|
||||
return new Shape(list);
|
||||
}
|
||||
|
||||
|
||||
public Vector getMidPoint()
|
||||
{
|
||||
return getMaxAABBCorner().subtract(getMinAABBCorner()).multiply(0.5);
|
||||
}
|
||||
|
||||
|
||||
public Vector getMaxAABBCorner()
|
||||
{
|
||||
Vector max = null;
|
||||
@ -138,7 +131,7 @@ public class Shape
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
public Vector getMinAABBCorner()
|
||||
{
|
||||
Vector min = null;
|
||||
@ -155,7 +148,7 @@ public class Shape
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the closest length which will be a factor of the provided length, but not longer then max
|
||||
* E.g. You want to split a length of 9 into even peaces, but the peaces should not be longer than the max 5, then this will
|
||||
@ -164,12 +157,12 @@ public class Shape
|
||||
* @param max The max distance of the returned length
|
||||
* @return The closest to length to be a factor of the provided length which is <= max
|
||||
*/
|
||||
|
||||
|
||||
public static double getRoundFactor(double length, double max)
|
||||
{
|
||||
return length/Math.ceil(length/max);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the closest RoundFactor length applied to a vector, using the vector as the max length. The returned vector is a cloned
|
||||
* parallel vector to the provided length
|
||||
@ -177,13 +170,13 @@ public class Shape
|
||||
* @param maxLength The max length of the new returned vector
|
||||
* @return Returns a parallel vector to the given length vector which is also a factor of the provided vector, but not longer
|
||||
* then maxLength
|
||||
*
|
||||
*
|
||||
* @see #getRoundFactor(double, double)
|
||||
*/
|
||||
public static Vector getVectorFactor(Vector length, double maxLength)
|
||||
{
|
||||
return length.clone().multiply(getRoundFactor(length.length(), maxLength));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -699,4 +699,15 @@ public class UtilAlg
|
||||
double x = vec.getX(), y = vec.getY(), sin = Math.sin(angle), cos = Math.cos(angle);
|
||||
return vec.setX(x * cos - y * sin).setZ(x * sin + y * cos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the yaw of a location to face the nearest location in the lookAt collection.
|
||||
*
|
||||
* @param location The location to adjust the yaw of
|
||||
* @param lookAt The list of locations to look at
|
||||
*/
|
||||
public static void lookAtNearest(Location location, List<Location> lookAt)
|
||||
{
|
||||
location.setYaw(GetYaw(getTrajectory(location, findClosest(location, lookAt))));
|
||||
}
|
||||
}
|
||||
|
@ -981,11 +981,6 @@ public class UtilEnt
|
||||
return .51 * ((double) size);
|
||||
}
|
||||
|
||||
public static boolean inWater(LivingEntity ent)
|
||||
{
|
||||
return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9;
|
||||
}
|
||||
|
||||
public static void setBoundingBox(Entity ent, double width, double height)
|
||||
{
|
||||
((CraftEntity)ent).getHandle().setSize((float) width, (float)height);
|
||||
|
@ -4,6 +4,7 @@ import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.PlayerList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
@ -14,6 +15,7 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
@ -70,6 +72,11 @@ public class ServerConfiguration extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
if (UtilServer.isTestServer() && !Bukkit.hasWhitelist())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getUniqueId()).hasPermission(Perm.JOIN_STAFF_SERVER))
|
||||
{
|
||||
event.disallow(Result.KICK_OTHER, "This is a staff only server.");
|
||||
|
@ -43,7 +43,7 @@ public class LegendaryRewardAnimation extends TreasureRewardAnimation
|
||||
@Override
|
||||
public void onTick()
|
||||
{
|
||||
if (getTicks() % 6 == 0)
|
||||
if (getTicks() % 8 == 0)
|
||||
{
|
||||
UtilFirework.playFirework(getLocation(), FIREWORK_EFFECT);
|
||||
|
||||
|
@ -43,7 +43,9 @@ public class PurchaseTreasurePage extends ShopPageBase<TreasureManager, Treasure
|
||||
|
||||
_treasure = treasure;
|
||||
_previous = previous;
|
||||
_available = plugin.getRewardManager().getTotalItems(treasure) - plugin.getRewardManager().getOwnedItems(player, treasure) - plugin.getChestsToOpen(player, treasure);
|
||||
_available = treasure.isDuplicates()
|
||||
? Integer.MAX_VALUE
|
||||
: plugin.getRewardManager().getTotalItems(treasure) - plugin.getRewardManager().getOwnedItems(player, treasure) - plugin.getChestsToOpen(player, treasure);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
@ -90,8 +90,9 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.youtube.YoutubeManager;
|
||||
import mineplex.hub.commands.GadgetToggle;
|
||||
import mineplex.hub.doublejump.JumpManager;
|
||||
import mineplex.hub.gamemode.GameModeManager;
|
||||
import mineplex.hub.player.CreativeManager;
|
||||
import mineplex.hub.gimmicks.AdminPunch;
|
||||
import mineplex.hub.gimmicks.StaffBuild;
|
||||
import mineplex.hub.hubgame.HubGameManager;
|
||||
import mineplex.hub.modules.ForcefieldManager;
|
||||
import mineplex.hub.modules.HubVisibilityManager;
|
||||
@ -164,7 +165,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
_jumpManager = new JumpManager(this);
|
||||
|
||||
require(NewsManager.class);
|
||||
require(GameModeManager.class);
|
||||
require(CreativeManager.class);
|
||||
require(HubWorldManager.class);
|
||||
|
||||
new BenefitManager(_plugin, clientManager, inventoryManager);
|
||||
@ -230,6 +231,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
require(ProfileManager.class);
|
||||
require(HubPlayerManager.class);
|
||||
require(AdminPunch.class);
|
||||
require(StaffBuild.class);
|
||||
require(HubPortalManager.class);
|
||||
|
||||
//_hubPlugin = new HalloweenHubPlugin();
|
||||
|
@ -92,7 +92,9 @@ public class JumpManager extends MiniPlugin
|
||||
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))
|
||||
@ -111,7 +113,8 @@ public class JumpManager extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
||||
//if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
||||
if (UtilEnt.onBlock(player))
|
||||
{
|
||||
if(!player.getAllowFlight() && Recharge.Instance.usable(player, "Double Jump"))
|
||||
{
|
||||
|
@ -1,51 +0,0 @@
|
||||
package mineplex.hub.gamemode;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.gamemode.GameModeManager;
|
||||
|
||||
public class GameModeCommand extends CommandBase<GameModeManager>
|
||||
{
|
||||
public GameModeCommand(GameModeManager plugin)
|
||||
{
|
||||
super(plugin, HubManager.Perm.GAMEMODE_COMMAND, "gm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Player target = caller;
|
||||
|
||||
if (args != null && args.length >= 1)
|
||||
{
|
||||
target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (target.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
target.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
|
||||
if (!target.equals(caller))
|
||||
{
|
||||
Plugin.addGameMode(caller, target);
|
||||
UtilPlayer.message(target, F.main("Game Mode", caller.getName() + " toggled your Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Game Mode", target.getName() + " Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
|
||||
}
|
||||
}
|
@ -3,12 +3,9 @@ package mineplex.hub.gimmicks;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
128
Plugins/Mineplex.Hub/src/mineplex/hub/gimmicks/StaffBuild.java
Normal file
128
Plugins/Mineplex.Hub/src/mineplex/hub/gimmicks/StaffBuild.java
Normal file
@ -0,0 +1,128 @@
|
||||
package mineplex.hub.gimmicks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.player.CreativeManager;
|
||||
import mineplex.hub.player.HubPlayerManager;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class StaffBuild extends MiniPlugin
|
||||
{
|
||||
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
BUILD
|
||||
}
|
||||
|
||||
private static final int MAX_Y_DIFFERENCE = 50;
|
||||
|
||||
private final CoreClientManager _clientManager;
|
||||
private final CreativeManager _creativeManager;
|
||||
private final HubPlayerManager _playerManager;
|
||||
private final List<Location> _buildLocations;
|
||||
|
||||
private StaffBuild()
|
||||
{
|
||||
super("Staff Build");
|
||||
|
||||
_clientManager = require(CoreClientManager.class);
|
||||
_creativeManager = require(CreativeManager.class);
|
||||
_playerManager = require(HubPlayerManager.class);
|
||||
_buildLocations = require(WorldDataModule.class).getCustomLocation(String.valueOf(Material.RED_SANDSTONE.getId()));
|
||||
_buildLocations.forEach(location -> location.getBlock().setType(Material.AIR));
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionGroup.BUILDER.setPermission(Perm.BUILD, true, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCreative(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
{
|
||||
boolean allowed = isAllowed(player, player.getLocation());
|
||||
boolean creative = player.getGameMode() == GameMode.CREATIVE;
|
||||
|
||||
if (allowed && !creative)
|
||||
{
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
sendMessage(player, true);
|
||||
player.getInventory().clear();
|
||||
}
|
||||
else if (!allowed && creative)
|
||||
{
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
sendMessage(player, false);
|
||||
_playerManager.giveHotbar(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessage(Player player, boolean enabled)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "Build mode " + F.ed(enabled) + "."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockBreak(BlockBreakEvent event)
|
||||
{
|
||||
event.setCancelled(!isAllowed(event.getPlayer(), event.getBlock().getLocation()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
event.setCancelled(!isAllowed(event.getPlayer(), event.getBlock().getLocation()));
|
||||
}
|
||||
|
||||
private boolean isAllowed(Player player, Location location)
|
||||
{
|
||||
if (_creativeManager.isInCreative(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!_clientManager.Get(player).hasPermission(Perm.BUILD))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Location buildLocation : _buildLocations)
|
||||
{
|
||||
int delta = location.getBlockY() - buildLocation.getBlockY();
|
||||
|
||||
if (location.getBlockX() == buildLocation.getBlockX() && location.getBlockZ() == buildLocation.getBlockZ() && delta >= 0 && delta < MAX_Y_DIFFERENCE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.hub.hubgame.CycledGame;
|
||||
@ -82,13 +83,6 @@ public class BlockRecorderComponent extends HubGameComponent<CycledGame>
|
||||
return;
|
||||
}
|
||||
|
||||
_game.getManager().runSyncLater(() ->
|
||||
{
|
||||
UtilBlock.startQuickRecording();
|
||||
|
||||
_blocks.forEach((location, pair) -> UtilBlock.setQuick(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), pair.getLeft().getId(), pair.getRight()));
|
||||
|
||||
UtilBlock.stopQuickRecording();
|
||||
}, 1);
|
||||
_game.getManager().runSyncLater(() -> _blocks.forEach((location, pair) -> MapUtil.QuickChangeBlockAt(location, pair.getLeft(), pair.getRight())), 1);
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,85 @@
|
||||
package mineplex.hub.parkour;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
public class ParkourData
|
||||
public class ParkourData implements Listener
|
||||
{
|
||||
|
||||
protected final ParkourManager _manager;
|
||||
private final String _name;
|
||||
private final List<Location> _checkpoints;
|
||||
private final Location _reset;
|
||||
private final Location _cornerA;
|
||||
private final Location _cornerB;
|
||||
|
||||
public ParkourData(WorldDataModule worldData, String name)
|
||||
public ParkourData(ParkourManager manager, String name)
|
||||
{
|
||||
_manager = manager;
|
||||
_name = name;
|
||||
|
||||
name = name.toUpperCase();
|
||||
|
||||
WorldDataModule worldData = manager.getWorldData();
|
||||
List<Location> corners = worldData.getCustomLocation(name + " BORDER");
|
||||
List<Location> lookAt = worldData.getCustomLocation("LOOK AT");
|
||||
_checkpoints = worldData.getCustomLocation(name + " CHECK");
|
||||
_reset = worldData.getCustomLocation(name + " RESET").get(0);
|
||||
UtilAlg.lookAtNearest(_reset, lookAt);
|
||||
_cornerA = corners.get(0);
|
||||
_cornerB = corners.get(1);
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public void onStart(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
public void onEnd(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateFail(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entry<Player, ParkourAttempt> entry : _manager.getActivePlayers(this))
|
||||
{
|
||||
Player player = entry.getKey();
|
||||
|
||||
if (hasFailed(player))
|
||||
{
|
||||
reset(player);
|
||||
_manager.startParkour(player, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void reset(Player player)
|
||||
{
|
||||
player.teleport(_reset);
|
||||
}
|
||||
|
||||
protected boolean hasFailed(Player player)
|
||||
{
|
||||
return UtilEnt.isInWater(player);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@ -33,7 +94,12 @@ public class ParkourData
|
||||
|
||||
public boolean cheatCheck(ParkourAttempt attempt)
|
||||
{
|
||||
return attempt.getCheckpoints().size() > (_checkpoints.size() * 0.75D);
|
||||
return attempt.getCheckpoints().size() > (_checkpoints.size() * 0.8D);
|
||||
}
|
||||
|
||||
public boolean isInArea(Location location)
|
||||
{
|
||||
return UtilAlg.inBoundingBox(location, _cornerA, _cornerB);
|
||||
}
|
||||
|
||||
public List<Location> getCheckpoints()
|
||||
|
@ -5,15 +5,17 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -26,17 +28,21 @@ 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.teleport.event.MineplexTeleportEvent;
|
||||
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.parkour.data.WaterParkourData;
|
||||
import mineplex.hub.world.WorldDataModule;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class ParkourManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private final WorldDataModule _worldData;
|
||||
|
||||
private final Map<Player, ParkourAttempt> _attempts;
|
||||
private final Set<ParkourData> _parkours;
|
||||
|
||||
@ -44,20 +50,23 @@ public class ParkourManager extends MiniPlugin
|
||||
{
|
||||
super("Parkour");
|
||||
|
||||
_worldData = require(WorldDataModule.class);
|
||||
|
||||
_attempts = new HashMap<>();
|
||||
_parkours = new HashSet<>();
|
||||
|
||||
WorldDataModule worldData = require(WorldDataModule.class);
|
||||
_parkours.add(new ParkourData(worldData, "Test"));
|
||||
_parkours.add(new ParkourData(this, "House"));
|
||||
_parkours.add(new WaterParkourData(this));
|
||||
|
||||
List<Snake> snakes = new ArrayList<>();
|
||||
List<Location> path = _worldData.getCustomLocation(String.valueOf(Material.QUARTZ_ORE.getId()));
|
||||
|
||||
for (Location head : worldData.getDataLocation("LIGHT_BLUE"))
|
||||
for (Location head : _worldData.getDataLocation("LIGHT_BLUE"))
|
||||
{
|
||||
snakes.add(new Snake(head, worldData.getCustomLocation("153")));
|
||||
snakes.add(new Snake(head, path));
|
||||
}
|
||||
|
||||
_parkours.add(new SnakeParkourData(this, worldData, snakes));
|
||||
_parkours.add(new SnakeParkourData(this, snakes));
|
||||
|
||||
NewNPCManager npcManager = require(NewNPCManager.class);
|
||||
|
||||
@ -73,24 +82,6 @@ public class ParkourManager extends MiniPlugin
|
||||
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)
|
||||
{
|
||||
@ -99,16 +90,29 @@ public class ParkourManager extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
_attempts.forEach((player, attempt) ->
|
||||
_attempts.entrySet().removeIf(entry ->
|
||||
{
|
||||
Player player = entry.getKey();
|
||||
ParkourAttempt attempt = entry.getValue();
|
||||
Location playerLocation = player.getLocation();
|
||||
|
||||
for (Location location : attempt.getData().getCheckpoints())
|
||||
{
|
||||
if (UtilMath.offset2dSquared(player.getLocation(), location) < 9)
|
||||
if (UtilMath.offset2dSquared(playerLocation, location) < 9)
|
||||
{
|
||||
attempt.getCheckpoints().add(location);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!attempt.getData().isInArea(playerLocation))
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You left the Parkour area."));
|
||||
attempt.getData().onEnd(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@ -142,14 +146,7 @@ public class ParkourManager extends MiniPlugin
|
||||
{
|
||||
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;
|
||||
startParkour(player, data);
|
||||
}
|
||||
else if (metadata.equals(data.getKey() + " END"))
|
||||
{
|
||||
@ -175,24 +172,46 @@ public class ParkourManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void startParkour(Player player, ParkourData data)
|
||||
{
|
||||
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));
|
||||
data.onStart(player);
|
||||
}
|
||||
|
||||
private void rewardPlayer(Player player, ParkourData data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int getActivePlayers(ParkourData data)
|
||||
public List<Entry<Player, ParkourAttempt>> getActivePlayers(ParkourData data)
|
||||
{
|
||||
int active = 0;
|
||||
return _attempts.entrySet().stream()
|
||||
.filter(entry -> entry.getValue().getData().equals(data))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
for (ParkourAttempt attempt : _attempts.values())
|
||||
@EventHandler
|
||||
public void playerVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
if (attempt.getData().equals(data))
|
||||
{
|
||||
active++;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
@EventHandler
|
||||
public void disableGadgets(GadgetEnableEvent event)
|
||||
{
|
||||
if (isParkourMode(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -207,21 +226,25 @@ public class ParkourManager extends MiniPlugin
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerTeleport(PlayerTeleportEvent event)
|
||||
public void playerTeleport(MineplexTeleportEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (isParkourMode(player))
|
||||
if (_attempts.remove(player) != null)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You can't teleport during parkour."));
|
||||
_attempts.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_attempts.remove(event.getPlayer());
|
||||
ParkourAttempt attempt = _attempts.remove(event.getPlayer());
|
||||
|
||||
if (attempt != null)
|
||||
{
|
||||
attempt.getData().onEnd(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -233,4 +256,9 @@ public class ParkourManager extends MiniPlugin
|
||||
event.getPlayer().sendMessage(F.main("Team", "You cannot join a team while in parkour mode!"));
|
||||
}
|
||||
}
|
||||
|
||||
public WorldDataModule getWorldData()
|
||||
{
|
||||
return _worldData;
|
||||
}
|
||||
}
|
||||
|
@ -2,38 +2,35 @@ package mineplex.hub.parkour.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
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 static final int MAX_FALL_DISTANCE = 5;
|
||||
|
||||
private final ParkourManager _manager;
|
||||
private final List<Snake> _snakes;
|
||||
|
||||
public SnakeParkourData(ParkourManager manager, WorldDataModule worldData, List<Snake> snakes)
|
||||
public SnakeParkourData(ParkourManager manager, List<Snake> snakes)
|
||||
{
|
||||
super(worldData, "Snake");
|
||||
super(manager, "Snake");
|
||||
|
||||
_manager = manager;
|
||||
_snakes = snakes;
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER || _manager.getActivePlayers(this) == 0)
|
||||
if (event.getType() != UpdateType.FASTER || _manager.getActivePlayers(this).isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -41,12 +38,9 @@ public class SnakeParkourData extends ParkourData implements Listener
|
||||
_snakes.forEach(Snake::update);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockPhysics(BlockPhysicsEvent event)
|
||||
@Override
|
||||
protected boolean hasFailed(Player player)
|
||||
{
|
||||
if (event.getBlock().getType() == Material.BROWN_MUSHROOM)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return super.hasFailed(player) || player.getFallDistance() > MAX_FALL_DISTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package mineplex.hub.parkour.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.hub.parkour.ParkourData;
|
||||
import mineplex.hub.parkour.ParkourManager;
|
||||
|
||||
public class WaterParkourData extends ParkourData implements Listener
|
||||
{
|
||||
|
||||
private static final int MIN_MOVE_DISTANCE_SQUARED = 3;
|
||||
private static final int MIN_Y = 57;
|
||||
|
||||
private final ParkourManager _manager;
|
||||
private final Map<Player, Location> _lastLocation;
|
||||
|
||||
public WaterParkourData(ParkourManager manager)
|
||||
{
|
||||
super(manager, "Water");
|
||||
|
||||
_manager = manager;
|
||||
_lastLocation = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Player player)
|
||||
{
|
||||
_lastLocation.put(player, player.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd(Player player)
|
||||
{
|
||||
_lastLocation.remove(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasFailed(Player player)
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
|
||||
if (location.getY() > MIN_Y && UtilMath.offsetSquared(location, _lastLocation.get(player)) < MIN_MOVE_DISTANCE_SQUARED)
|
||||
{
|
||||
player.sendMessage(F.main(_manager.getName(), "You cannot stop running on the " + F.name(getName()) + " Parkour."));
|
||||
return true;
|
||||
}
|
||||
|
||||
_lastLocation.put(player, location);
|
||||
return super.hasFailed(player);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.hub.gamemode;
|
||||
package mineplex.hub.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -14,16 +14,17 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.player.command.CreativeCommand;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class GameModeManager extends MiniPlugin
|
||||
public class CreativeManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private final Map<Player, List<String>> _creativeAdmin;
|
||||
|
||||
private GameModeManager()
|
||||
private CreativeManager()
|
||||
{
|
||||
super("Gamemode");
|
||||
super("Creative");
|
||||
|
||||
_creativeAdmin = new HashMap<>();
|
||||
}
|
||||
@ -31,15 +32,12 @@ public class GameModeManager extends MiniPlugin
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new GameModeCommand(this));
|
||||
addCommand(new CreativeCommand(this));
|
||||
}
|
||||
|
||||
public void addGameMode(Player caller, Player target)
|
||||
{
|
||||
if (!_creativeAdmin.containsKey(caller))
|
||||
{
|
||||
_creativeAdmin.put(caller, new ArrayList<>());
|
||||
}
|
||||
_creativeAdmin.putIfAbsent(caller, new ArrayList<>());
|
||||
|
||||
List<String> creative = _creativeAdmin.get(caller);
|
||||
|
||||
@ -53,6 +51,21 @@ public class GameModeManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInCreative(Player player)
|
||||
{
|
||||
String name = player.getName();
|
||||
|
||||
for (List<String> players : _creativeAdmin.values())
|
||||
{
|
||||
if (players.contains(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void clearGameMode(PlayerQuitEvent event)
|
||||
{
|
@ -0,0 +1,47 @@
|
||||
package mineplex.hub.player.command;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.player.CreativeManager;
|
||||
|
||||
public class CreativeCommand extends CommandBase<CreativeManager>
|
||||
{
|
||||
|
||||
public CreativeCommand(CreativeManager plugin)
|
||||
{
|
||||
super(plugin, HubManager.Perm.GAMEMODE_COMMAND, "gm", "gamemode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Player target = caller;
|
||||
|
||||
if (args != null && args.length >= 1)
|
||||
{
|
||||
target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean enabled = target.getGameMode() == GameMode.CREATIVE;
|
||||
|
||||
target.setGameMode(enabled ? GameMode.ADVENTURE : GameMode.CREATIVE);
|
||||
Plugin.addGameMode(caller, target);
|
||||
|
||||
if (!target.equals(caller))
|
||||
{
|
||||
UtilPlayer.message(target, F.main(Plugin.getName(), F.name(caller.getName()) + " toggled your Creative Mode: " + F.tf(!enabled)));
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.name(target.getName()) + " Creative Mode: " + F.tf(!enabled)));
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ public class HubPortalManager extends MiniPlugin
|
||||
{
|
||||
Location portal = locations.get(0);
|
||||
Location destination = _worldData.getCustomLocation(key + " DESTINATION").get(0);
|
||||
destination.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(destination, UtilAlg.findClosest(destination, lookAt))));
|
||||
UtilAlg.lookAtNearest(destination, lookAt);
|
||||
|
||||
_portals.put(portal, destination);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
@ -133,6 +134,15 @@ public class HubWorldManager extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents liquid flow
|
||||
*/
|
||||
@EventHandler
|
||||
public void blockPhysics(BlockPhysicsEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent entities catching fire
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ public class DefensiveStance extends SkillActive
|
||||
if (event.GetCause() != DamageCause.ENTITY_ATTACK && event.GetCause() != DamageCause.PROJECTILE)
|
||||
return;
|
||||
|
||||
if (UtilEnt.inWater(event.GetDamageeEntity()))
|
||||
if (UtilEnt.isInWater(event.GetDamageeEntity()))
|
||||
return;
|
||||
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
|
@ -54,7 +54,7 @@ public class HiltSmash extends SkillActive
|
||||
@Override
|
||||
public boolean CustomCheck(Player player, int level)
|
||||
{
|
||||
if (UtilEnt.inWater(player))
|
||||
if (UtilEnt.isInWater(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water."));
|
||||
return false;
|
||||
@ -119,7 +119,7 @@ public class HiltSmash extends SkillActive
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (UtilEnt.inWater(event.getPlayer()))
|
||||
if (UtilEnt.isInWater(event.getPlayer()))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
@ -40,7 +40,7 @@ public class PerkWaterDamage extends Perk
|
||||
if (!Recharge.Instance.use(player, "Not Water Bender Damage", _time, false, false))
|
||||
continue;
|
||||
|
||||
if (UtilEnt.inWater(player))
|
||||
if (UtilEnt.isInWater(player))
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.DROWNING, _damage, false, false, true, "Water", "Water Hating Kit");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user