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