Compare commits
7 Commits
4fa9f55761
...
c7e2244e15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7e2244e15 | ||
|
|
7c4198bfff | ||
|
|
83983d6dd7 | ||
|
|
4f28d526c6 | ||
|
|
b8275d81c5 | ||
|
|
f092dd61b6 | ||
|
|
7057b03c68 |
4
pom.xml
4
pom.xml
@@ -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>
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user