13
0
Dieser Commit ist enthalten in:
yoyosource 2022-11-13 16:24:04 +01:00
Ursprung f4b6917bff
Commit d0f3ace73f
5 geänderte Dateien mit 31 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -83,6 +83,6 @@ PARTICLE_EVENT_RAIN_CLOUD = §fRaincloud
PARTICLE_EVENT_WGS = §fWGS PARTICLE_EVENT_WGS = §fWGS
PARTICLE_EVENT_WARGEARCLASH = §fClash PARTICLE_EVENT_WARGEARCLASH = §fClash
JUMP_AND_RUN_PROGRESS = §e{0}§8/§f{1} §7{2} JUMP_AND_RUN_PROGRESS = §e{0}§8/§f{1} §c{2} §7{3}
JUMP_AND_RUN_TIME = mm:ss SSS JUMP_AND_RUN_TIME = mm:ss SSS
JUMP_AND_RUN_FINISHED = §aFinished in {0} JUMP_AND_RUN_FINISHED = §aFinished in {0} with {1} fails

Datei anzeigen

@ -2,18 +2,20 @@ package de.steamwar.lobby.jumpandrun;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.listener.PlayerSpawn;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
public class JumpAndRun extends BasicListener { public class JumpAndRun extends BasicListener {
@ -21,6 +23,7 @@ public class JumpAndRun extends BasicListener {
public static List<Vector> points = new ArrayList<>(); public static List<Vector> points = new ArrayList<>();
private static final Map<Player, Integer> CURRENT_POS = new HashMap<>(); private static final Map<Player, Integer> CURRENT_POS = new HashMap<>();
private static final Map<Player, Integer> FAILS = new HashMap<>();
private static final Map<Player, Long> START = new HashMap<>(); private static final Map<Player, Long> START = new HashMap<>();
static { static {
@ -36,13 +39,15 @@ public class JumpAndRun extends BasicListener {
location.setY(point.getY()); location.setY(point.getY());
location.setZ(point.getZ()); location.setZ(point.getZ());
player.teleport(location); player.teleport(location);
player.playSound(location, Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
FAILS.put(player, FAILS.getOrDefault(player, 0) + 1);
} }
} }
long time = System.currentTimeMillis() - START.get(player); long time = System.currentTimeMillis() - START.get(player);
SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", player), Locale.ROOT); SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", player), Locale.ROOT);
String parsed = format.format(new Date(time)); 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)); LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_PROGRESS", player, ChatMessageType.ACTION_BAR, index + 1, points.size(), FAILS.get(player), parsed.substring(0, parsed.length() - 2));
}); });
}, 1, 1); }, 1, 1);
} }
@ -68,16 +73,28 @@ public class JumpAndRun extends BasicListener {
return; return;
} }
CURRENT_POS.put(event.getPlayer(), index); CURRENT_POS.put(event.getPlayer(), index);
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.4F, 1);
if (index < points.size() - 1) {
event.getPlayer().setCompassTarget(points.get(index + 1).toLocation(location.getWorld()));
}
if (index == 0) { if (index == 0) {
event.getPlayer().setAllowFlight(false);
event.getPlayer().getInventory().clear();
event.getPlayer().updateInventory();
event.getPlayer().getInventory().setItem(4, new ItemStack(Material.COMPASS, 1));
FAILS.put(event.getPlayer(), 0);
START.put(event.getPlayer(), System.currentTimeMillis()); START.put(event.getPlayer(), System.currentTimeMillis());
} }
if (index == points.size() - 1) { if (index == points.size() - 1) {
long time = System.currentTimeMillis() - START.get(event.getPlayer()); long time = System.currentTimeMillis() - START.get(event.getPlayer());
SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", event.getPlayer()), Locale.ROOT); SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", event.getPlayer()), Locale.ROOT);
String parsed = format.format(new Date(time)); String parsed = format.format(new Date(time));
LobbySystem.getMessage().send("JUMP_AND_RUN_FINISHED", event.getPlayer(), parsed.substring(0, parsed.length() - 2)); LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_FINISHED", event.getPlayer(), parsed.substring(0, parsed.length() - 2), FAILS.get(event.getPlayer()));
PlayerSpawn.giveItems(event.getPlayer());
event.getPlayer().setAllowFlight(true);
CURRENT_POS.remove(event.getPlayer()); CURRENT_POS.remove(event.getPlayer());
START.remove(event.getPlayer()); START.remove(event.getPlayer());
FAILS.remove(event.getPlayer());
} }
} }
@ -86,5 +103,6 @@ public class JumpAndRun extends BasicListener {
Player player = event.getPlayer(); Player player = event.getPlayer();
CURRENT_POS.remove(player); CURRENT_POS.remove(player);
START.remove(player); START.remove(player);
FAILS.remove(player);
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.lobby.listener; package de.steamwar.lobby.listener;
import de.steamwar.lobby.jumpandrun.JumpAndRun;
import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
@ -44,6 +45,7 @@ public class DoubleJumpListener extends BasicListener {
@EventHandler @EventHandler
public void handlePlayerToggleFlight(PlayerToggleFlightEvent event) { public void handlePlayerToggleFlight(PlayerToggleFlightEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (JumpAndRun.isPlayerInJumpAndRun(player)) return;
if (player.getGameMode() != GameMode.ADVENTURE && player.getGameMode() != GameMode.SURVIVAL) { if (player.getGameMode() != GameMode.ADVENTURE && player.getGameMode() != GameMode.SURVIVAL) {
return; return;
} }
@ -67,6 +69,7 @@ public class DoubleJumpListener extends BasicListener {
@EventHandler @EventHandler
public void handlePlayerMove(PlayerMoveEvent event) { public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (JumpAndRun.isPlayerInJumpAndRun(player)) return;
if(player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR) return; if(player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR) return;
if (LobbyPlayer.getLobbyPlayer(player).isFlying()) return; if (LobbyPlayer.getLobbyPlayer(player).isFlying()) return;

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.lobby.listener; package de.steamwar.lobby.listener;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.jumpandrun.JumpAndRun;
import de.steamwar.lobby.particle.BaseParticle; import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleData;
import de.steamwar.lobby.particle.ParticleInventory; import de.steamwar.lobby.particle.ParticleInventory;
@ -45,6 +46,7 @@ public class ParticleListener extends BasicListener {
deg += 0.1; deg += 0.1;
if (deg > 360) deg = 0; if (deg > 360) deg = 0;
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
if (JumpAndRun.isPlayerInJumpAndRun(player)) return;
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
ParticleEnum particle = lobbyPlayer.getParticle(); ParticleEnum particle = lobbyPlayer.getParticle();
if (particle == null) return; if (particle == null) return;
@ -60,6 +62,7 @@ public class ParticleListener extends BasicListener {
public void handlePlayerInteract(PlayerInteractEvent event) { public void handlePlayerInteract(PlayerInteractEvent event) {
if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return; if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (JumpAndRun.isPlayerInJumpAndRun(player)) return;
if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return; if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return;
event.setCancelled(true); event.setCancelled(true);
@ -70,6 +73,7 @@ public class ParticleListener extends BasicListener {
public void handlePlayerMove(PlayerMoveEvent event) { public void handlePlayerMove(PlayerMoveEvent event) {
if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return; if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (JumpAndRun.isPlayerInJumpAndRun(player)) return;
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
ParticleEnum particle = lobbyPlayer.getParticle(); ParticleEnum particle = lobbyPlayer.getParticle();
if (particle == null) return; if (particle == null) return;

Datei anzeigen

@ -61,7 +61,7 @@ public class PlayerSpawn extends BasicListener {
Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> NetworkSender.send(new ImALobbyPacket(), player), 20); Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> NetworkSender.send(new ImALobbyPacket(), player), 20);
} }
private void giveItems(Player player) { public static void giveItems(Player player) {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
inventory.setItem(EquipmentSlot.CHEST, ELYTRA); inventory.setItem(EquipmentSlot.CHEST, ELYTRA);