Border
Dieser Commit ist enthalten in:
Ursprung
7bd7bd52c2
Commit
f5150aa27c
@ -60,10 +60,12 @@ public class LobbySystem extends JavaPlugin {
|
||||
new ParticleListener();
|
||||
new PlayerInventoryListener();
|
||||
new PlayerWorldInteractionListener();
|
||||
new PlayerMoveListener();
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
world.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
|
||||
Bukkit.getOfflinePlayer("zOnlyKroks").setWhitelisted(true);
|
||||
Bukkit.getOfflinePlayer("LordMainex").setWhitelisted(true);
|
||||
}
|
||||
|
||||
public static LobbySystem getPlugin() {
|
||||
|
@ -24,10 +24,13 @@ public class ElytraListener extends BasicListener {
|
||||
Player player = event.getPlayer();
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
|
||||
|
||||
if (event.getMaterial() != LobbyInventory.ELYTRA_READY) return;
|
||||
|
||||
if(!lobbyPlayer.isFlyingElytra()) {
|
||||
player.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
|
||||
player.setGliding(true);
|
||||
player.teleport(new Location(Bukkit.getWorlds().get(0),player.getLocation().getX(),player.getLocation().getY() + 4, player.getLocation().getZ(), player.getLocation().getYaw(), player.getLocation().getPitch()));
|
||||
player.setGliding(true);
|
||||
lobbyPlayer.setFlyingElytra(true);
|
||||
LobbyInventory.givePlayerLobbyItems(player);
|
||||
}
|
||||
|
52
src/de/steamwar/lobby/listener/features/PlayerMoveListener.java
Normale Datei
52
src/de/steamwar/lobby/listener/features/PlayerMoveListener.java
Normale Datei
@ -0,0 +1,52 @@
|
||||
package de.steamwar.lobby.listener.features;
|
||||
|
||||
import de.steamwar.lobby.Config;
|
||||
import de.steamwar.lobby.listener.BasicListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class PlayerMoveListener extends BasicListener {
|
||||
|
||||
final BorderData data = new BorderData();
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location playerLoc = player.getLocation();
|
||||
|
||||
if(!data.locationIsInRegion(playerLoc)) {
|
||||
player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch));
|
||||
}
|
||||
}
|
||||
|
||||
public static final class BorderData {
|
||||
|
||||
final World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
final Location loc1 = new Location(world,1337,0,1803);
|
||||
final Location loc2 = new Location(world,2610,0,1800);
|
||||
|
||||
private double maxX;
|
||||
private double maxZ;
|
||||
|
||||
private double minX;
|
||||
private double minZ;
|
||||
|
||||
public BorderData() {
|
||||
maxX = Math.max(loc1.getX(), loc2.getX());
|
||||
maxZ = Math.max(loc1.getZ(), loc2.getZ());
|
||||
|
||||
minX = Math.min(loc1.getX(), loc2.getX());
|
||||
minZ = Math.min(loc1.getZ(), loc2.getZ());
|
||||
}
|
||||
|
||||
public boolean locationIsInRegion(Location loc) {
|
||||
return loc.getX() > minX && loc.getX() < maxX
|
||||
&& loc.getZ() > minZ && loc.getZ() < maxZ;
|
||||
}
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren