mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2025-07-01 05:34:43 +02:00
Fixes various smaller issues
Fixes players immediately being thrown out because the spawn teleportation triggered the PlayerLeaveListener Reduces default velocity from the insane terminal velocity to just 1 Uses UUID instead of player object when storing dropper arena sessions Prevents players from joining an arena if in creative, spectator mode, or is flying Implements the leave command to allow leaving the arena Only counts fall damage as a loss, but still prevents all damage in the arena Prevents players from dying of fall damage when exiting the dropper arena Prevents loadArenas from returning null
This commit is contained in:
@ -7,6 +7,7 @@ import net.knarcraft.dropper.arena.DropperArenaSession;
|
||||
import net.knarcraft.dropper.property.ArenaGameMode;
|
||||
import net.knarcraft.dropper.util.ArenaStorageHelper;
|
||||
import net.knarcraft.dropper.util.PlayerTeleporter;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -30,8 +31,14 @@ public class JoinArenaCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isFlying() || player.getGameMode() == GameMode.CREATIVE ||
|
||||
player.getGameMode() == GameMode.SPECTATOR) {
|
||||
commandSender.sendMessage("You cannot join a dropper arena while able to fly!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disallow joining if the player is already in a dropper arena
|
||||
DropperArenaSession existingSession = Dropper.getInstance().getPlayerRegistry().getArenaSession(player);
|
||||
DropperArenaSession existingSession = Dropper.getInstance().getPlayerRegistry().getArenaSession(player.getUniqueId());
|
||||
if (existingSession != null) {
|
||||
commandSender.sendMessage("You are already in a dropper arena!");
|
||||
return false;
|
||||
@ -64,7 +71,7 @@ public class JoinArenaCommand implements CommandExecutor {
|
||||
// Register the player's session
|
||||
DropperArenaSession newSession = new DropperArenaSession(specifiedArena, player, gameMode);
|
||||
DropperArenaPlayerRegistry playerRegistry = Dropper.getInstance().getPlayerRegistry();
|
||||
playerRegistry.registerPlayer(player, newSession);
|
||||
playerRegistry.registerPlayer(player.getUniqueId(), newSession);
|
||||
|
||||
// Try to teleport the player to the arena
|
||||
boolean teleported = PlayerTeleporter.teleportPlayer(player, specifiedArena.getSpawnLocation(), false);
|
||||
|
@ -1,8 +1,11 @@
|
||||
package net.knarcraft.dropper.command;
|
||||
|
||||
import net.knarcraft.dropper.Dropper;
|
||||
import net.knarcraft.dropper.arena.DropperArenaSession;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -13,10 +16,19 @@ public class LeaveArenaCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
||||
@NotNull String[] strings) {
|
||||
//TODO: Make sure the console cannot run this
|
||||
//TODO: If the player isn't currently in an arena, just display an error message
|
||||
//TODO: Trigger the player's session's triggerQuit() method
|
||||
return false;
|
||||
if (!(commandSender instanceof Player player)) {
|
||||
commandSender.sendMessage("This command must be used by a player");
|
||||
return false;
|
||||
}
|
||||
|
||||
DropperArenaSession existingSession = Dropper.getInstance().getPlayerRegistry().getArenaSession(player.getUniqueId());
|
||||
if (existingSession == null) {
|
||||
commandSender.sendMessage("You are not in a dropper arena!");
|
||||
return false;
|
||||
}
|
||||
|
||||
existingSession.triggerQuit();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user