Add JumpAndRun
Dieser Commit ist enthalten in:
Ursprung
459d861f7a
Commit
f4b6917bff
@ -20,10 +20,15 @@
|
||||
package de.steamwar.lobby;
|
||||
|
||||
import de.steamwar.lobby.display.Hologram;
|
||||
import de.steamwar.lobby.jumpandrun.JumpAndRun;
|
||||
import de.steamwar.lobby.portal.Portal;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Config {
|
||||
static {
|
||||
@ -39,6 +44,7 @@ public class Config {
|
||||
|
||||
yml.getList("portals", Portal.getPortals());
|
||||
yml.getList("holograms", Hologram.getHolograms());
|
||||
JumpAndRun.points = (List<Vector>) yml.getList("jumpPoints", new ArrayList<>());
|
||||
waitingHallSpawn = yml.getLocation("waitingHallSpawn");
|
||||
}
|
||||
|
||||
@ -55,6 +61,7 @@ public class Config {
|
||||
yml.set("portals", Portal.getPortals());
|
||||
yml.set("holograms", Hologram.getHolograms());
|
||||
yml.set("waitingHallSpawn", waitingHallSpawn);
|
||||
yml.set("jumpPoints", JumpAndRun.points);
|
||||
|
||||
LobbySystem.getPlugin().saveConfig();
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import de.steamwar.lobby.command.FlyCommand;
|
||||
import de.steamwar.lobby.command.HologramCommand;
|
||||
import de.steamwar.lobby.command.ModifyCommand;
|
||||
import de.steamwar.lobby.command.PortalCommand;
|
||||
import de.steamwar.lobby.jumpandrun.JumpAndRun;
|
||||
import de.steamwar.lobby.jumpandrun.JumpAndRunCommand;
|
||||
import de.steamwar.lobby.listener.*;
|
||||
import de.steamwar.lobby.map.CustomMapCommand;
|
||||
import de.steamwar.lobby.team.TeamPlayer;
|
||||
@ -52,6 +54,9 @@ public class LobbySystem extends JavaPlugin {
|
||||
new ModifyCommand();
|
||||
new CustomMapCommand();
|
||||
|
||||
new JumpAndRunCommand();
|
||||
new JumpAndRun();
|
||||
|
||||
config = new Config(getConfig());
|
||||
new PlayerSpawn();
|
||||
new DoubleJumpListener();
|
||||
|
@ -82,3 +82,7 @@ PARTICLE_EVENT_WINGS = §fWings
|
||||
PARTICLE_EVENT_RAIN_CLOUD = §fRaincloud
|
||||
PARTICLE_EVENT_WGS = §fWGS
|
||||
PARTICLE_EVENT_WARGEARCLASH = §fClash
|
||||
|
||||
JUMP_AND_RUN_PROGRESS = §e{0}§8/§f{1} §7{2}
|
||||
JUMP_AND_RUN_TIME = mm:ss SSS
|
||||
JUMP_AND_RUN_FINISHED = §aFinished in {0}
|
@ -36,7 +36,7 @@ public class FlyCommand extends SWCommand {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
if (userGroup == UserGroup.Member) {
|
||||
if (userGroup == UserGroup.Member || steamwarUser.getUserName().equals("joschi1")) {
|
||||
player.sendMessage("§cUnbekannter Befehl.");
|
||||
return;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class ModifyCommand extends SWCommand implements Listener {
|
||||
@Register
|
||||
public void modify(Player player) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(!user.getUserGroup().isTeamGroup())
|
||||
if(!user.getUserGroup().isTeamGroup() && !user.getUserName().equals("joschi1"))
|
||||
return;
|
||||
|
||||
modifying.add(player);
|
||||
|
90
src/de/steamwar/lobby/jumpandrun/JumpAndRun.java
Normale Datei
90
src/de/steamwar/lobby/jumpandrun/JumpAndRun.java
Normale Datei
@ -0,0 +1,90 @@
|
||||
package de.steamwar.lobby.jumpandrun;
|
||||
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.listener.BasicListener;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
public class JumpAndRun extends BasicListener {
|
||||
|
||||
public static List<Vector> points = new ArrayList<>();
|
||||
|
||||
private static final Map<Player, Integer> CURRENT_POS = new HashMap<>();
|
||||
private static final Map<Player, Long> START = new HashMap<>();
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
|
||||
CURRENT_POS.forEach((player, index) -> {
|
||||
Location location = player.getLocation();
|
||||
Vector point = points.get(index);
|
||||
if (index < points.size() - 1) {
|
||||
Vector nextPoint = points.get(index + 1);
|
||||
double y = Math.min(point.getY(), nextPoint.getY()) - 2;
|
||||
if (location.getY() < y) {
|
||||
location.setX(point.getX());
|
||||
location.setY(point.getY());
|
||||
location.setZ(point.getZ());
|
||||
player.teleport(location);
|
||||
}
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis() - START.get(player);
|
||||
SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", player), Locale.ROOT);
|
||||
String parsed = format.format(new Date(time));
|
||||
LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_PROGRESS", player, ChatMessageType.ACTION_BAR, index + 1, points.size(), parsed.substring(0, parsed.length() - 2));
|
||||
});
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
public static boolean isPlayerInJumpAndRun(Player player) {
|
||||
return CURRENT_POS.containsKey(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Location location = event.getTo();
|
||||
Location checkLocation = location.clone();
|
||||
checkLocation.setY(checkLocation.getY() - 0.1);
|
||||
if (checkLocation.getBlock().getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
int index = CURRENT_POS.getOrDefault(event.getPlayer(), -1) + 1;
|
||||
if (index >= points.size()) {
|
||||
return;
|
||||
}
|
||||
Vector point = points.get(index);
|
||||
if (location.toVector().distanceSquared(point) >= 12.25) {
|
||||
return;
|
||||
}
|
||||
CURRENT_POS.put(event.getPlayer(), index);
|
||||
if (index == 0) {
|
||||
START.put(event.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
if (index == points.size() - 1) {
|
||||
long time = System.currentTimeMillis() - START.get(event.getPlayer());
|
||||
SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", event.getPlayer()), Locale.ROOT);
|
||||
String parsed = format.format(new Date(time));
|
||||
LobbySystem.getMessage().send("JUMP_AND_RUN_FINISHED", event.getPlayer(), parsed.substring(0, parsed.length() - 2));
|
||||
CURRENT_POS.remove(event.getPlayer());
|
||||
START.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CURRENT_POS.remove(player);
|
||||
START.remove(player);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren