Skip to content

Commit

Permalink
use new java features more
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Dec 11, 2024
1 parent f3433f3 commit d82b168
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ public class GrimStopSpectating extends BaseCommand {
@CommandPermission("grim.spectate")
@CommandCompletion("@stopspectating")
public void onStopSpectate(CommandSender sender, String[] args) {
if (!(sender instanceof Player player)) return;
String string = args.length > 0 ? args[0] : null;
if (!(sender instanceof Player)) return;
Player player = (Player) sender;
if (GrimAPI.INSTANCE.getSpectateManager().isSpectating(player.getUniqueId())) {
boolean teleportBack = string == null || !string.equalsIgnoreCase("here") || !sender.hasPermission("grim.spectate.stophere");
GrimAPI.INSTANCE.getSpectateManager().disable(player, teleportBack);
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,17 +592,14 @@ public double[] getPossibleEyeHeights() { // We don't return sleeping eye height
return this.isSneaking ? this.possibleEyeHeights[1] : this.possibleEyeHeights[0];
} else {
// 1.8 players just have their pose set to standing all the time
switch (pose) {
case FALL_FLYING: // Elytra gliding
case SPIN_ATTACK: // Riptide trident
case SWIMMING: // Swimming (includes crawling in 1.14+)
return this.possibleEyeHeights[2]; // [swimming/gliding/riptide height, standing height, sneaking height]
case NINE_CROUCHING:
case CROUCHING:
return this.possibleEyeHeights[1]; // [sneaking height, standing height, swimming/gliding/riptide height]
default:
return this.possibleEyeHeights[0]; // [standing height, sneaking height, swimming/gliding/riptide height]
}
return switch (pose) {
case FALL_FLYING, // Elytra gliding
SPIN_ATTACK, // Riptide trident
SWIMMING -> // Swimming (includes crawling in 1.14+)
this.possibleEyeHeights[2]; // [swimming/gliding/riptide height, standing height, sneaking height]
case NINE_CROUCHING, CROUCHING -> this.possibleEyeHeights[1]; // [sneaking height, standing height, swimming/gliding/riptide height]
default -> this.possibleEyeHeights[0]; // [standing height, sneaking height, swimming/gliding/riptide height]
};
}
}

Expand Down

0 comments on commit d82b168

Please sign in to comment.