Skip to content

Commit

Permalink
Merge pull request #1 from Catalyst105/disable-open-message
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinkazo authored Nov 30, 2024
2 parents 2340986 + 17bcaeb commit 3cd7204
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 147 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Eclipse IDE
.classpath
.settings/
.project

# User-specific stuff
.idea/

Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
For more information visit: https://www.spigotmc.org/resources/1-20-1-21-customenderchest-inventory-enderchest-system.120973/
# CustomEnderChest

CustomEnderChest is a powerful plugin that revolutionizes the vanilla enderchest system by adding permissions-based size control, MySQL/SQLite support, and advanced viewing capabilities. Perfect for servers looking to add an extra layer of progression and staff management tools!


For more informations on the [Spigot Page](https://www.spigotmc.org/resources/1-20-1-21-customenderchest-inventory-enderchest-system.120973/)

## How to build .jar

1. Clone this repository
2. Install depedencies with `mvn install`
3. *(Import in you favorite IDE and make changes)*
4. Compile .jar with `mvn package`
5. Copy the file in `target/CustomEnderChest-x.x.x.jar` in your `plugin` folder.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.dark</groupId>
<artifactId>CustomEnderChest</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<packaging>jar</packaging>

<name>CustomEnderChest</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ private String getMessage(String path, String... replacements) {

return message;
}

private void sendMessageExceptIfBlank(CommandSender sender, String message) {
if (!message.equals("")) {
sender.sendMessage(getMessage(message));
}
}

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length < 1) {
sender.sendMessage(getMessage("achest-usage"));
sendMessageExceptIfBlank(sender, getMessage("achest-usage"));
return true;
}

Expand All @@ -64,28 +70,28 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
break;
case "view":
if (args.length < 2) {
sender.sendMessage(getMessage("view-usage"));
sendMessageExceptIfBlank(sender, getMessage("view-usage"));
return true;
}
handleViewCommand(sender, args[1]);
break;
case "delete":
if (args.length < 2) {
sender.sendMessage(getMessage("achest-usage"));
sendMessageExceptIfBlank(sender, getMessage("achest-usage"));
return true;
}
handleDeleteCommand(sender, args[1]);
break;
default:
sender.sendMessage(getMessage("achest-usage"));
sendMessageExceptIfBlank(sender, getMessage("achest-usage"));
}

return true;
}

private void handleReloadCommand(CommandSender sender) {
if (!sender.hasPermission("enderchest.admin.reload")) {
sender.sendMessage(getMessage("no-permission-reload"));
sendMessageExceptIfBlank(sender, getMessage("no-permission-reload"));
return;
}

Expand All @@ -103,29 +109,29 @@ private void handleReloadCommand(CommandSender sender) {
openEnderChests.clear();


sender.sendMessage(getMessage("config-reloaded"));
sendMessageExceptIfBlank(sender, getMessage("config-reloaded"));
} catch (Exception e) {
plugin.getLogger().severe("Error during plugin reload: " + e.getMessage());
sender.sendMessage(getMessage("no-permission-reload"));
sendMessageExceptIfBlank(sender, getMessage("no-permission-reload"));
}
}

private void handleViewCommand(CommandSender sender, String targetName) {
if (!(sender instanceof Player)) {
sender.sendMessage(getMessage("only-players"));
sendMessageExceptIfBlank(sender, getMessage("only-players"));
return;
}

if (!sender.hasPermission("enderchest.admin.view")) {
sender.sendMessage(getMessage("no-permission-view"));
sendMessageExceptIfBlank(sender, getMessage("no-permission-view"));
return;
}

Player viewer = (Player) sender;
UUID targetUUID = getPlayerUUID(targetName);

if (targetUUID == null) {
sender.sendMessage(getMessage("no-enderchest-found"));
sendMessageExceptIfBlank(sender, getMessage("no-enderchest-found"));
return;
}

Expand All @@ -134,18 +140,18 @@ private void handleViewCommand(CommandSender sender, String targetName) {

private void handleDeleteCommand(CommandSender sender, String targetName) {
if (!sender.hasPermission("enderchest.admin.delete")) {
sender.sendMessage(getMessage("no-permission-view"));
sendMessageExceptIfBlank(sender, getMessage("no-permission-view"));
return;
}

UUID targetUUID = getPlayerUUID(targetName);
if (targetUUID == null) {
sender.sendMessage(getMessage("no-enderchest-found"));
sendMessageExceptIfBlank(sender, getMessage("no-enderchest-found"));
return;
}

if (deletePlayerData(targetUUID)) {
sender.sendMessage(ChatColor.GREEN + "Successfully deleted EnderChest data for " + targetName);
sendMessageExceptIfBlank(sender, ChatColor.GREEN + "Successfully deleted EnderChest data for " + targetName);

// Close the inventory if any player is viewing it
for (Map.Entry<UUID, UUID> entry : openEnderChests.entrySet()) {
Expand All @@ -157,7 +163,7 @@ private void handleDeleteCommand(CommandSender sender, String targetName) {
}
}
} else {
sender.sendMessage(ChatColor.RED + "Failed to delete EnderChest data for " + targetName);
sendMessageExceptIfBlank(sender, ChatColor.RED + "Failed to delete EnderChest data for " + targetName);
}
}

Expand Down
Loading

0 comments on commit 3cd7204

Please sign in to comment.