Skip to content

Commit

Permalink
1.14.3
Browse files Browse the repository at this point in the history
  • Loading branch information
BenceX100 committed Oct 8, 2024
1 parent 572045c commit c8e582e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.artillexstudios</groupId>
<artifactId>AxGraves</artifactId>
<version>1.14.2</version>
<version>1.14.3</version>
<packaging>jar</packaging>

<name>AxGraves</name>
Expand Down Expand Up @@ -106,7 +106,7 @@
<dependency>
<groupId>com.artillexstudios.axapi</groupId>
<artifactId>axapi</artifactId>
<version>1.4.332</version>
<version>1.4.380</version>
<scope>compile</scope>
<classifier>all</classifier>
</dependency>
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/com/artillexstudios/axgraves/commands/Commands.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.artillexstudios.axgraves.commands;

import com.artillexstudios.axapi.utils.PaperUtils;
import com.artillexstudios.axapi.utils.StringUtils;
import com.artillexstudios.axgraves.commands.subcommands.SubCommandList;
import com.artillexstudios.axgraves.commands.subcommands.SubCommandReload;
import com.artillexstudios.axgraves.grave.SpawnedGraves;
import org.bukkit.Location;
import com.artillexstudios.axgraves.commands.subcommands.SubCommandTeleport;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand All @@ -31,22 +29,18 @@ public void help(@NotNull CommandSender sender) {
@Subcommand("reload")
@CommandPermission("axgraves.reload")
public void reload(@NotNull CommandSender sender) {
new SubCommandReload().subCommand(sender);
SubCommandReload.INSTANCE.subCommand(sender);
}

@Subcommand("list")
@CommandPermission("axgraves.list")
public void list(@NotNull CommandSender sender) {
new SubCommandList().subCommand(sender);
SubCommandList.INSTANCE.subCommand(sender);
}

@Subcommand("tp")
@CommandPermission("axgraves.tp")
public void tp(@NotNull Player sender, World world, double x, double y, double z) {
final Location location = new Location(world, x, y, z);
if (!sender.hasPermission("axgraves.tp.bypass") && SpawnedGraves.getGraves().stream().filter(grave -> grave.getPlayer().getUniqueId().equals(sender.getUniqueId())).filter(grave -> grave.getLocation().equals(location)).findAny().isEmpty()) {
return;
}
PaperUtils.teleportAsync(sender, location);
SubCommandTeleport.INSTANCE.subCommand(sender, world, x, y, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import static com.artillexstudios.axgraves.AxGraves.MESSAGES;
import static com.artillexstudios.axgraves.AxGraves.MESSAGEUTILS;

public class SubCommandList {
public enum SubCommandList {
INSTANCE;

public void subCommand(@NotNull CommandSender sender) {
if (SpawnedGraves.getGraves().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import static com.artillexstudios.axgraves.AxGraves.MESSAGES;
import static com.artillexstudios.axgraves.AxGraves.MESSAGEUTILS;

public class SubCommandReload {
public enum SubCommandReload {
INSTANCE;

public void subCommand(@NotNull CommandSender sender) {

final String errorMsg = CONFIG.getString("prefix") + MESSAGES.getString("reload.failed");

if (!CONFIG.reload()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.artillexstudios.axgraves.commands.subcommands;

import com.artillexstudios.axapi.utils.PaperUtils;
import com.artillexstudios.axgraves.grave.Grave;
import com.artillexstudios.axgraves.grave.SpawnedGraves;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;

public enum SubCommandTeleport {
INSTANCE;

public void subCommand(@NotNull Player sender, World world, double x, double y, double z) {
final Location location = new Location(world, x, y, z);

Optional<Grave> foundGrave = SpawnedGraves.getGraves().stream()
.filter(grave -> grave.getPlayer().getUniqueId().equals(sender.getUniqueId()))
.filter(grave -> grave.getLocation().distanceSquared(location) < 1)
.findAny();

if (!sender.hasPermission("axgraves.tp.bypass") && foundGrave.isEmpty()) return;
PaperUtils.teleportAsync(sender, foundGrave.isEmpty() ? location : foundGrave.get().getLocation());
}
}
7 changes: 4 additions & 3 deletions src/main/java/com/artillexstudios/axgraves/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public class Utils {
@NotNull
public static ItemStack getPlayerHead(@NotNull OfflinePlayer player) {
final ItemStack it = new ItemStack(Material.PLAYER_HEAD);
final SkullMeta skullMeta = (SkullMeta) it.getItemMeta();
skullMeta.setOwningPlayer(player);
it.setItemMeta(skullMeta);
if (it.getItemMeta() instanceof SkullMeta skullMeta) {
skullMeta.setOwningPlayer(player);
it.setItemMeta(skullMeta);
}

return it;
}
Expand Down

0 comments on commit c8e582e

Please sign in to comment.