Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public V get(K key, Loader<V> loader) {
}


/**
* Clears all entries from the cache.
*/
public void clear() {
this.cache.clear();
}

/**
* Functional interface for loading values into the cache. Implementations of this interface
* provide a method to load a value, typically involving an operation such as fetching data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ public enum Permission {
ESSENTIALS_STEP_START,
ESSENTIALS_STEP_FINISH,
ESSENTIALS_ITEMFRAME,
ESSENTIALS_SILENT_DEATH("Allows you to die silently without a death message");
ESSENTIALS_SILENT_DEATH("Allows you to die silently without a death message"),
ESSENTIALS_DEATH_MESSAGE_TELEPORT("Allows clicking death messages to teleport to death location"),
ESSENTIALS_DEATH_MESSAGE_TOGGLE("Allows toggling death messages visibility"),
ESSENTIALS_DEATH_MESSAGE_TOGGLE_OTHER("Allows toggling death messages for other players");

private final String description;
private final String[] args;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ public enum Message {

TELEPORT_DAMAGE("<error>You must not take damage during teleportation."),
TELEPORT_ERROR_LOCATION("<error>Unable to teleport you safely."),
TELEPORT_CROSS_SERVER_NOT_SUPPORTED("<error>Cross-server teleportation is not supported on this server."),
TELEPORT_CROSS_SERVER_CONNECTING("<success>Connecting to server &f%server%<success>..."),
TELEPORT_CROSS_SERVER_PLAYER_NOT_FOUND("<error>Player &f%player% <error>was not found on any server."),

// RTP Queue System Messages
TELEPORT_ALREADY_IN_QUEUE("<error>You are already in the teleportation queue!"),
Expand Down Expand Up @@ -970,12 +973,41 @@ public enum Message {
COMMAND_ITEMFRAME_VISIBLE("<success>Item frame is now <white>visible<success>."),
COMMAND_ITEMFRAME_NOT_FOUND("<error>No item frame found. Look at an item frame and try again."),

// Death Messages
DEATH_MESSAGE_GENERIC("#99E0FF%player% &7died."),
DEATH_MESSAGE_PLAYER("#99E0FF%player% &7was slain by #34cfe0%killer% &7using %weapon%&7."),
DEATH_MESSAGE_FISTS("&7fists"),
DEATH_MESSAGE_MOB("#99E0FF%player% &7was killed by &c%mob%&7."),
DEATH_MESSAGE_MYTHIC_MOB("#99E0FF%player% &7was slain by <gradient:#ff6600:#ff0000>%mob%</gradient>&7!"),
// Death Message Module
DESCRIPTION_DEATH_MESSAGE("Custom death messages"),

DEATH_GENERIC("#C084FC☠ #E9D5FF%player% #B794F4died."),
DEATH_BY_PLAYER("#C084FC⚔ #E9D5FF%player% #B794F4was slain by #E9D5FF%killer%#B794F4."),
DEATH_BY_MOB("#C084FC☠ #E9D5FF%player% #B794F4was killed by #E9D5FF%killer%#B794F4."),
DEATH_BY_PROJECTILE("#C084FC🏹 #E9D5FF%player% #B794F4was shot by #E9D5FF%killer%#B794F4."),
DEATH_BY_MOB_EXPLOSION("#C084FC💥 #E9D5FF%player% #B794F4was blown up by #E9D5FF%killer%#B794F4."),
DEATH_BY_FALL("#C084FC⬇ #E9D5FF%player% #B794F4fell from a high place."),
DEATH_BY_FIRE("#C084FC🔥 #E9D5FF%player% #B794F4burned to death."),
DEATH_BY_LAVA("#C084FC🌋 #E9D5FF%player% #B794F4tried to swim in lava."),
DEATH_BY_DROWNING("#C084FC💧 #E9D5FF%player% #B794F4drowned."),
DEATH_BY_EXPLOSION("#C084FC💥 #E9D5FF%player% #B794F4was blown up."),
DEATH_BY_LIGHTNING("#C084FC⚡ #E9D5FF%player% #B794F4was struck by lightning."),
DEATH_BY_SUFFOCATION("#C084FC▓ #E9D5FF%player% #B794F4suffocated in a wall."),
DEATH_BY_STARVATION("#C084FC🍖 #E9D5FF%player% #B794F4starved to death."),
DEATH_BY_POISON("#C084FC☣ #E9D5FF%player% #B794F4was poisoned."),
DEATH_BY_MAGIC("#C084FC✦ #E9D5FF%player% #B794F4was killed by magic."),
DEATH_BY_WITHER("#C084FC💀 #E9D5FF%player% #B794F4withered away."),
DEATH_BY_FALLING_BLOCK("#C084FC▼ #E9D5FF%player% #B794F4was squashed by a falling block."),
DEATH_BY_FLY_INTO_WALL("#C084FC💨 #E9D5FF%player% #B794F4experienced kinetic energy."),
DEATH_BY_VOID("#C084FC✧ #E9D5FF%player% #B794F4fell out of the world."),
DEATH_BY_CACTUS("#C084FC🌵 #E9D5FF%player% #B794F4was pricked to death."),
DEATH_BY_CRAMMING("#C084FC⊞ #E9D5FF%player% #B794F4was squished too much."),
DEATH_BY_FREEZE("#C084FC❄ #E9D5FF%player% #B794F4froze to death."),
DEATH_BY_SONIC_BOOM("#C084FC◈ #E9D5FF%player% #B794F4was obliterated by a sonic boom."),
DEATH_BY_MAGMA("#C084FC♨ #E9D5FF%player% #B794F4discovered that the floor was lava."),
DEATH_BY_THORNS("#C084FC✵ #E9D5FF%player% #B794F4was killed trying to hurt someone."),
DEATH_BY_CAMPFIRE("#C084FC🔥 #E9D5FF%player% #B794F4walked into a campfire."),

DEATH_HOVER_DETAILS("#D8B4FE☠ Death Location#B794F4:\n#E9D5FF▸ World: #D8B4FE%world%\n#E9D5FF▸ Position: #D8B4FE%x%#E9D5FF, #D8B4FE%y%#E9D5FF, #D8B4FE%z%\n\n#9F7AEA&oClick to teleport"),

COMMAND_DEATH_MESSAGE_TOGGLE_DISABLE("#C084FC☠ #B794F4Death messages are now #E9D5FFhidden #B794F4for %player%#B794F4."),
COMMAND_DEATH_MESSAGE_TOGGLE_ENABLE("#C084FC☠ #B794F4Death messages are now #E9D5FFvisible #B794F4for %player%#B794F4."),
DESCRIPTION_DEATH_MESSAGE_TOGGLE("Toggle death messages visibility"),
;

private EssentialsPlugin plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@ public interface Module extends Listener {
*/
boolean isRegisterEvent();

/**
* Called when the module is being disabled.
*/
default void onDisable() {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ public enum Option {
WORLDEDIT_INVENTORY,
WORLDEDIT_BOSSBAR_DISABLE,
TELEPORT_REQUEST_DISABLE,
DEATH_MESSAGE_DISABLE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public void setPitch(float pitch) {

public Location getLocation() {
if (this.location == null) {
this.location = new Location(Bukkit.getWorld(this.world), this.x, this.y, this.z, this.yaw, this.pitch);
var bukkitWorld = Bukkit.getWorld(this.world);
if (bukkitWorld == null) return null;
this.location = new Location(bukkitWorld, this.x, this.y, this.z, this.yaw, this.pitch);
}
return location;
}
Expand Down
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ allprojects {
maven(url = "https://repo.tcoded.com/releases")
}

configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "net.kyori" && requested.name == "adventure-text-serializer-ansi" && (requested.version.isNullOrBlank() || requested.version == ".")) {
useVersion("4.20.0")
}
}
}

java {
withSourcesJar()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ private void displaySanction(int slot, Sanction sanction, Player player, User ta
placeholders.register("reason", sanction.getReason());
placeholders.register("duration", TimerBuilder.getStringTime(sanction.getDuration()));
placeholders.register("remaining", sanction.isActive() ? TimerBuilder.getStringTime(sanction.getDurationRemaining().toMillis()) : Message.EXPIRED.getMessageAsString());
placeholders.register("created_at", simpleDateFormat.format(sanction.getCreatedAt()));
placeholders.register("expired_at", simpleDateFormat.format(sanction.getExpiredAt()));
placeholders.register("created_at", sanction.getCreatedAt() != null ? simpleDateFormat.format(sanction.getCreatedAt()) : "N/A");
placeholders.register("expired_at", sanction.getExpiredAt() != null ? simpleDateFormat.format(sanction.getExpiredAt()) : "N/A");
placeholders.register("sender", sanctionModule.getSanctionBy(sanction.getSenderUniqueId()));

inventory.addItem(slot, menuItemStack.build(player, false, placeholders));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import fr.maxlego08.essentials.commands.commands.chat.CommandShowItem;
import fr.maxlego08.essentials.commands.commands.clearinventory.ClearInventoryCommand;
import fr.maxlego08.essentials.commands.commands.cooldown.CommandCooldown;
import fr.maxlego08.essentials.commands.commands.deathmessage.CommandDeathMessageToggle;
import fr.maxlego08.essentials.commands.commands.discord.CommandLink;
import fr.maxlego08.essentials.commands.commands.discord.CommandUnLink;
import fr.maxlego08.essentials.commands.commands.economy.CommandBalanceTop;
Expand Down Expand Up @@ -285,6 +286,7 @@ public void loadCommands(CommandManager commandManager) {
register("pub", CommandPub.class);
register("step", CommandStep.class);
register("itemframe", CommandItemFrame.class, "iframe");
register("deathmessage", CommandDeathMessageToggle.class, "dm", "deathmsg");

for (RegisterCommand registerCommand : this.commands) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public class ZCommandManager extends ZUtils implements CommandManager {
commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
constructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
constructor.setAccessible(true);
} catch (Exception ignored) {
} catch (Exception exception) {
Bukkit.getLogger().severe("[zEssentials] Failed to initialize command map or PluginCommand constructor: " + exception.getMessage());
exception.printStackTrace();
}
}

Expand Down Expand Up @@ -283,6 +285,11 @@ public void registerCommand(Plugin plugin, String mainCommand, EssentialsCommand
}

try {
if (constructor == null || commandMap == null) {
this.plugin.getLogger().severe("Cannot register command '" + mainCommand + "': CommandMap or PluginCommand constructor is not initialized!");
return;
}

PluginCommand command = constructor.newInstance(mainCommand, plugin);
command.setExecutor(this);
command.setTabCompleter(this);
Expand All @@ -296,7 +303,7 @@ public void registerCommand(Plugin plugin, String mainCommand, EssentialsCommand
commands.add(essentialsCommand);

if (!commandMap.register(command.getName(), plugin.getDescription().getName(), command)) {
plugin.getLogger().info("Unable to add the command " + essentialsCommand.getSyntax());
plugin.getLogger().warning("Unable to add the command /" + mainCommand + " (already registered by another plugin). Use /zessentials:" + mainCommand + " instead.");
}

if (essentialsCommand.getPermission() != null) {
Expand All @@ -307,6 +314,7 @@ public void registerCommand(Plugin plugin, String mainCommand, EssentialsCommand
Bukkit.getPluginManager().addPermission(new Permission(essentialsCommand.getPermission(), essentialsCommand.getDescription() == null ? "No description" : essentialsCommand.getDescription()));
}
} catch (Exception exception) {
this.plugin.getLogger().severe("Failed to register command '" + mainCommand + "': " + exception.getMessage());
exception.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public CommandCooldownDelete(EssentialsPlugin plugin) {
if (offlinePlayer == null) return new ArrayList<>();

User user = plugin.getUser(offlinePlayer.getUniqueId());
if (user == null) return new ArrayList<>();
return new ArrayList<>(user.getCooldowns().keySet());

} catch (Exception ignored) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ protected CommandResultType perform(EssentialsPlugin plugin) {
boolean silent = this.argAsBoolean(4, false);
String reason = this.getArgs(6, getMessage(plugin.getEconomyManager().getCommandGiveRandomReason(), "%sender%", sender.getName()));

minAmount = Math.min(minAmount, maxAmount);
maxAmount = Math.max(minAmount, maxAmount);
double correctedMin = Math.min(minAmount, maxAmount);
double correctedMax = Math.max(minAmount, maxAmount);
minAmount = correctedMin;
maxAmount = correctedMax;

return give(this.sender, userName, economyName, minAmount + Math.random() * (maxAmount - minAmount), silent, reason);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected CommandResultType perform(EssentialsPlugin plugin) {
String userName = this.argAsString(1);
double amount = this.argAsDouble(2);
boolean silent = this.argAsBoolean(3, false);
String reason = this.getArgs(5, getMessage(plugin.getEconomyManager().getCommandResetReason(), "%sender%", sender.getName()));
String reason = this.getArgs(5, getMessage(plugin.getEconomyManager().getCommandSetReason(), "%sender%", sender.getName()));

EconomyManager economyManager = plugin.getEconomyManager();
Optional<Economy> optional = economyManager.getEconomy(economyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected CommandResultType perform(EssentialsPlugin plugin) {

EconomyManager economyManager = plugin.getEconomyManager();
String userName = this.argAsString(0, null);
if (userName == null || userName.equalsIgnoreCase(user.getName()) && hasPermission(sender, Permission.ESSENTIALS_MONEY_OTHER)) {
if (userName == null || (userName.equalsIgnoreCase(user.getName()) && !hasPermission(sender, Permission.ESSENTIALS_MONEY_OTHER))) {

List<String> arguments = new ArrayList<>();
economyManager.getEconomies().forEach(economy -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ protected CommandResultType perform(EssentialsPlugin plugin) {
EconomyManager economyManager = plugin.getEconomyManager();
String userName = this.argAsString(0);
String amountAsString = this.argAsString(1);
String economyName = this.argAsString(2, economyManager.getDefaultEconomy().getName());
Economy defaultEconomy = economyManager.getDefaultEconomy();
if (defaultEconomy == null) return CommandResultType.DEFAULT;
String economyName = this.argAsString(2, defaultEconomy.getName());

if (amountAsString.contains("-")) {
message(sender, Message.COMMAND_PAY_NEGATIVE);
Expand All @@ -46,7 +48,7 @@ protected CommandResultType perform(EssentialsPlugin plugin) {
final String sanitizedString = amountAsString.replaceAll("[^0-9.]", "");
if (sanitizedString.isEmpty()) return CommandResultType.SYNTAX_ERROR;

BigDecimal amount = new BigDecimal(amountAsString.replaceAll("[^0-9.]", ""));
BigDecimal amount = new BigDecimal(sanitizedString);
String format = amountAsString.replace(sanitizedString, "");
Optional<NumberMultiplicationFormat> optional = economyManager.getMultiplication(format);
if (optional.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public CommandPayToggle(EssentialsPlugin plugin) {
this.setModule(MessageModule.class);
this.setPermission(Permission.ESSENTIALS_PAY_TOGGLE);
this.setDescription(Message.DESCRIPTION_PAY_TOGGLE);
this.onlyPlayers();
this.addOptionalArg("player");
}

Expand All @@ -29,10 +30,11 @@ protected CommandResultType perform(EssentialsPlugin plugin) {
return CommandResultType.SYNTAX_ERROR;
}

if (player == this.player || !hasPermission(sender, Permission.ESSENTIALS_PAY_TOGGLE_OTHER)) {
if (player.equals(this.player) || !hasPermission(sender, Permission.ESSENTIALS_PAY_TOGGLE_OTHER)) {
togglePay(player, this.user, sender);
} else {
User otherUser = getUser(player);
if (otherUser == null) return CommandResultType.SYNTAX_ERROR;
togglePay(player, otherUser, sender);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CommandEnderChest extends VCommand {
public CommandEnderChest(EssentialsPlugin plugin) {
super(plugin);
this.setPermission(Permission.ESSENTIALS_ENDERCHEST);
this.setDescription(Message.DESCRIPTION_DAY);
this.setDescription(Message.DESCRIPTION_ENDERCHEST);
this.onlyPlayers();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public CommandEssentialsClearRandomWord(EssentialsPlugin plugin) {
super(plugin);
this.addSubCommand("clear-random-word");
this.setPermission(Permission.ESSENTIALS_CLEAR_RANDOM_WORD);
this.setDescription(Message.DESCRIPTION_RELOAD);
this.setDescription(Message.DESCRIPTION_CLEAR_RANDOM_WORD);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ protected CommandResultType perform(EssentialsPlugin plugin) {
var user = plugin.getUser(uniqueId);
long flySeconds = user == null ? storage.getFlySeconds(uniqueId) : user.getFlySeconds();
if (user == null) {
flySeconds *= seconds;
flySeconds -= seconds;
if (flySeconds < 0) flySeconds = 0;
storage.upsertFlySeconds(uniqueId, flySeconds);
} else user.removeFlySeconds(seconds);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public CommandDelHome(EssentialsPlugin plugin) {
this.addRequireArg("name", (sender, args) -> {
if (sender instanceof Player player) {
User user = plugin.getUser(player.getUniqueId());
return user.getHomes().stream().map(Home::getName).toList();
if (user != null) return user.getHomes().stream().map(Home::getName).toList();
}
return new ArrayList<>();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public CommandDelHomeConfirm(EssentialsPlugin plugin) {
this.addRequireArg("name", (sender, args) -> {
if (sender instanceof Player player) {
User user = plugin.getUser(player.getUniqueId());
if (user == null) return new ArrayList<>();
return user.getHomes().stream().map(Home::getName).toList();
}
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public CommandHome(EssentialsPlugin plugin) {
this.addOptionalArg("name", (sender, args) -> {
if (sender instanceof Player player) {
User user = plugin.getUser(player.getUniqueId());
if (user == null) return new ArrayList<>();
return user.getHomes().stream().map(Home::getName).toList();
}
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public CommandGive(EssentialsPlugin plugin) {
this.addRequirePlayerNameArg();
this.addRequireArg("item", (sender, args) -> {
List<String> materials = new ArrayList<>(plugin.getMaterials().stream().map(Material::name).map(String::toLowerCase).toList());
materials.addAll(plugin.getModuleManager().getModule(ItemModule.class).getItemsName());
var itemModule = plugin.getModuleManager().getModule(ItemModule.class);
if (itemModule != null) materials.addAll(itemModule.getItemsName());
return materials;
});
this.addOptionalArg("amount", (sender, args) -> Arrays.asList("1", "64", "full"));
Expand All @@ -32,10 +33,12 @@ public CommandGive(EssentialsPlugin plugin) {
protected CommandResultType perform(EssentialsPlugin plugin) {

Player player = this.argAsPlayer(0);
if (player == null) return CommandResultType.SYNTAX_ERROR;
String itemName = this.argAsString(1);
String amount = this.argAsString(2, "1");

var module = plugin.getModuleManager().getModule(ItemModule.class);
if (module == null) return CommandResultType.DEFAULT;
if (amount.equalsIgnoreCase("full")) {

module.giveFullInventory(sender, player, itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ protected CommandResultType perform(EssentialsPlugin plugin) {
List<Component> components = itemMeta.hasLore() ? itemMeta.lore() : new ArrayList<>();
if (components == null) components = new ArrayList<>();

if (components.size() < index) {
message(sender, Message.COMMAND_ITEM_LORE_SET_ERROR, "%line%", index);
return CommandResultType.DEFAULT;
}

PaperComponent paperComponent = (PaperComponent) this.componentMessage;
if (components.size() < index) {
for (int i = components.size(); i < index; i++) {
Expand Down
Loading
Loading