Compare commits

...

8 Commits

Author SHA1 Message Date
Sebastian Beckmann
6d076d760b temporary hack 2025-11-26 00:41:00 +01:00
Sebastian Beckmann
c7e2244e15 utils: Send message with player inventory if hs couldn't be created 2025-11-25 17:38:46 +01:00
Sebastian Beckmann
7c4198bfff Build headstone further up if radius of 5 is blocked 2025-11-13 15:32:45 +01:00
Sebastian Beckmann
83983d6dd7 commands: Print custom message if there are no headstones 2025-11-12 18:14:23 +01:00
Sebastian Beckmann
4f28d526c6 tmp: Disable check for incompatible mod
With this check we get a runtime crash because it can't find the class.
We don't have this mod anyways so the check isn't needed.
(TODO: Find out why this error occurs!)
2025-11-12 12:33:29 +01:00
Sebastian Beckmann
b8275d81c5 Send message if plugin failed to find a headstone location 2025-11-12 12:28:42 +01:00
Sebastian Beckmann
f092dd61b6 commands: Add headstone list subcommand 2025-11-12 12:22:06 +01:00
Sebastian Beckmann
7057b03c68 maven: Fix papermc maven repository 2025-11-12 12:18:22 +01:00
6 changed files with 73 additions and 5 deletions

View File

@@ -55,8 +55,8 @@
<repositories> <repositories>
<repository> <repository>
<id>papermc-repo</id> <id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url> <url>https://repo.papermc.io/repository/maven-public/</url>
</repository> </repository>
<repository> <repository>

View File

@@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import tk.alex3025.headstones.commands.HeadstonesCommand; import tk.alex3025.headstones.commands.HeadstonesCommand;
import tk.alex3025.headstones.commands.subcommands.ClearDatabaseCommand; import tk.alex3025.headstones.commands.subcommands.ClearDatabaseCommand;
import tk.alex3025.headstones.commands.subcommands.ListHeadstonesCommand;
import tk.alex3025.headstones.commands.subcommands.ReloadConfigCommand; import tk.alex3025.headstones.commands.subcommands.ReloadConfigCommand;
import tk.alex3025.headstones.listeners.BlockBreakListener; import tk.alex3025.headstones.listeners.BlockBreakListener;
import tk.alex3025.headstones.listeners.PlayerDeathListener; import tk.alex3025.headstones.listeners.PlayerDeathListener;
@@ -50,6 +51,7 @@ public final class Headstones extends JavaPlugin {
// Subcommands // Subcommands
new ClearDatabaseCommand(); new ClearDatabaseCommand();
new ReloadConfigCommand(); new ReloadConfigCommand();
new ListHeadstonesCommand();
} }
public static Headstones getInstance() { public static Headstones getInstance() {

View File

@@ -0,0 +1,37 @@
package tk.alex3025.headstones.commands.subcommands;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import tk.alex3025.headstones.Headstones;
import tk.alex3025.headstones.utils.ConfigFile;
import tk.alex3025.headstones.utils.Message;
import java.util.Set;
import java.util.UUID;
public class ListHeadstonesCommand extends SubcommandBase {
public ListHeadstonesCommand() {
super("list", "headstones.list", false);
}
@Override
public boolean onCommand(CommandSender sender, String[] args) {
ConfigFile config = Headstones.getInstance().getDatabase();
ConfigurationSection headstones = config.getConfigurationSection("headstones");
Set<String> keys = headstones.getKeys(false);
if (keys.isEmpty()) {
Message.sendPrefixedMessage(sender, "&a There are no headstones.");
} else {
Message.sendPrefixedMessage(sender, "&a All headstones:");
headstones.getKeys(false).forEach(headstoneUUID -> {
ConfigurationSection headstone = headstones.getConfigurationSection(headstoneUUID);
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(headstone.getString("owner")));
Message.sendMessage(sender, "&a " + player.getName() + ": " + headstone.getInt("x") + " " + headstone.getInt("y") + " " + headstone.getInt("z") + " (in world \"" + headstone.getString("world") + "\")");
});
}
return true;
}
}

View File

@@ -1,6 +1,6 @@
package tk.alex3025.headstones.listeners; package tk.alex3025.headstones.listeners;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC; //import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@@ -16,7 +16,7 @@ public class PlayerDeathListener extends ListenerBase {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Check if the player is a chunk loader from the WildLoaders plugin // Check if the player is a chunk loader from the WildLoaders plugin
if (player instanceof ChunkLoaderNPC) return; //if (player instanceof ChunkLoaderNPC) return;
boolean keepExperience = !event.getKeepLevel() && player.hasPermission("headstones.keep-experience"); boolean keepExperience = !event.getKeepLevel() && player.hasPermission("headstones.keep-experience");
boolean keepInventory = !event.getKeepInventory() && player.hasPermission("headstones.keep-inventory"); boolean keepInventory = !event.getKeepInventory() && player.hasPermission("headstones.keep-inventory");

View File

@@ -99,6 +99,8 @@ public class Headstone {
event.setShouldDropExperience(false); event.setShouldDropExperience(false);
this.savePlayerData(skullLocation, keepExperience, keepInventory); this.savePlayerData(skullLocation, keepExperience, keepInventory);
} else {
Message.sendBroadcast("&4 Inventory of " + owner.getName() + ": " + InventorySerializer.serialize(this.inventory));
} }
} }
@@ -165,6 +167,18 @@ public class Headstone {
} }
} }
private static boolean blockIsAllowed(Block block) {
Material material = block.getType();
if (material != Material.AIR && material != Material.CAVE_AIR)
return false;
if (block.getWorld().getName().equals("world_the_end") && block.getY() < 60)
return false;
return true;
}
private @Nullable Block checkForSafeBlock() { private @Nullable Block checkForSafeBlock() {
int playerX = this.location.getBlockX(); int playerX = this.location.getBlockX();
int playerY = this.location.getBlockY(); int playerY = this.location.getBlockY();
@@ -176,7 +190,7 @@ public class Headstone {
for (int y = playerY - radius; y <= playerY + radius; y++) for (int y = playerY - radius; y <= playerY + radius; y++)
for (int z = playerZ - radius; z <= playerZ + radius; z++) { for (int z = playerZ - radius; z <= playerZ + radius; z++) {
Block block = this.location.getWorld().getBlockAt(x,y,z); Block block = this.location.getWorld().getBlockAt(x,y,z);
if (block.getType().isEmpty()) if (blockIsAllowed(block))
return block; return block;
} }
@@ -184,6 +198,12 @@ public class Headstone {
radius++; radius++;
} }
for (int y = playerY; y < 320; y++) {
Block block = this.location.getWorld().getBlockAt(playerX, y, playerZ);
if (blockIsAllowed(block))
return block;
}
return null; return null;
} }
@@ -212,6 +232,7 @@ public class Headstone {
return block.getLocation(); return block.getLocation();
} }
} }
Message.sendBroadcast("&4 Could not create headstone for the most recent death of " + owner.getName() + "!");
return null; return null;
} }

View File

@@ -1,5 +1,8 @@
package tk.alex3025.headstones.utils; package tk.alex3025.headstones.utils;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -61,6 +64,11 @@ public class Message {
Message.sendMessage(sender, prefix + " " + message); Message.sendMessage(sender, prefix + " " + message);
} }
public static void sendBroadcast(String message) {
TextComponent component = LegacyComponentSerializer.legacyAmpersand().deserialize(message);
Bukkit.broadcast(component);
}
public static String getTranslation(String key) { public static String getTranslation(String key) {
return Headstones.getInstance().getMessages().getString(key); return Headstones.getInstance().getMessages().getString(key);
} }