Compare commits

...

7 Commits

Author SHA1 Message Date
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 60 additions and 4 deletions

View File

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

View File

@@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import tk.alex3025.headstones.commands.HeadstonesCommand;
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.listeners.BlockBreakListener;
import tk.alex3025.headstones.listeners.PlayerDeathListener;
@@ -50,6 +51,7 @@ public final class Headstones extends JavaPlugin {
// Subcommands
new ClearDatabaseCommand();
new ReloadConfigCommand();
new ListHeadstonesCommand();
}
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;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
//import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -16,7 +16,7 @@ public class PlayerDeathListener extends ListenerBase {
Player player = event.getPlayer();
// 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 keepInventory = !event.getKeepInventory() && player.hasPermission("headstones.keep-inventory");

View File

@@ -99,6 +99,8 @@ public class Headstone {
event.setShouldDropExperience(false);
this.savePlayerData(skullLocation, keepExperience, keepInventory);
} else {
Message.sendBroadcast("&4 Inventory of " + owner.getName() + ": " + InventorySerializer.serialize(this.inventory));
}
}
@@ -184,6 +186,12 @@ public class Headstone {
radius++;
}
for (int y = playerY; y < 320; y++) {
Block block = this.location.getWorld().getBlockAt(playerX, y, playerZ);
if (block.getType().isEmpty())
return block;
}
return null;
}
@@ -212,6 +220,7 @@ public class Headstone {
return block.getLocation();
}
}
Message.sendBroadcast("&4 Could not create headstone for the most recent death of " + owner.getName() + "!");
return null;
}

View File

@@ -1,5 +1,8 @@
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.command.CommandSender;
import org.jetbrains.annotations.NotNull;
@@ -61,6 +64,11 @@ public class 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) {
return Headstones.getInstance().getMessages().getString(key);
}