Skip to content

Commit 799ba2b

Browse files
v1.3
1 parent 622ff94 commit 799ba2b

9 files changed

Lines changed: 486 additions & 139 deletions

File tree

README.md

Lines changed: 61 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,90 @@
11
# Resourceloader
22

3-
**Resourceloader** is a simple, flexible plugin for Minecraft servers that allows for seamless management of resource packs without requiring players to endure the default server resource pack loading process. The plugin supports multiple resource packs, enabling players to load specific packs on demand via commands.
3+
A simple and flexible resource pack loader and merger plugin for Minecraft servers. Load different resource packs and merge multiple packs into one with ResourceLoader!
44

5-
## Key Features
5+
## Features
66

7-
- **Simplified Resource Pack Loading:** Avoid the default server-side resource pack loading experience, which can be confusing or annoying for new players.
8-
- **Dynamic Resource Pack Selection:** Load specific resource packs as needed using commands.
9-
- **Customizable Configurations:** Define and manage multiple resource packs via the `config.yml` file.
7+
- Load the server's default resource pack with a simple command
8+
- Configure and load multiple additional resource packs
9+
- Merge multiple resource packs in the plugin itself
10+
- Support for both URL and file-based resource packs
11+
- Easy-to-use commands
12+
- Permission-based access control
13+
- Simple configuration
1014

1115
## Commands
1216

13-
### `/load [packname]`
14-
- **Description:** Loads a resource pack for the player.
15-
- **Usage:**
16-
- `/load` - Loads the default server pack.
17-
- `/load <packname>` - Loads a specific resource pack by name.
18-
- **Permission:** `resourceloader.load`
19-
20-
### `/listpacks`
21-
- **Description:** Lists all available resource packs.
22-
- **Usage:** `/listpacks`
23-
- **Permission:** `resourceloader.list`
24-
25-
### `/resourcereload`
26-
- **Description:** Reloads the plugin configuration.
27-
- **Usage:** `/resourcereload`
28-
- **Permission:** `resourceloader.reload`
17+
- `/load` - Load the default server resource pack
18+
- `/load <packname>` - Load a specific resource pack
19+
- `/mergepack <output-file>.zip <pack1> <pack2> [pack3...]` - Merge existing resource packs in the plugin itself
20+
- `/listpacks` - List all available resource packs
21+
- `/resourcereload` - Reload the plugin configuration
22+
- `/resourceversion` - Check the version of ResourceLoader you're running
2923

3024
## Permissions
3125

32-
- **`resourceloader.load`**
33-
- Allows players to load resource packs.
34-
- Default: `true`
35-
- **`resourceloader.list`**
36-
- Allows players to list available resource packs.
37-
- Default: `true`
38-
- **`resourceloader.reload`**
39-
- Allows operators to reload the plugin configuration.
40-
- Default: `op`
41-
42-
## Configuration (`config.yml`)
26+
- `resourceloader.load` - Allows using the /load command (default: true)
27+
- `resourceloader.list` - Allows using the /listpacks command (default: true)
28+
- `resourceloader.reload` - Allows reloading the plugin configuration (default: op)
29+
- `resourceloader.admin` - Allows access to all the admin commands of ResourceLoader (default: op)
30+
-
31+
## Configuration
4332

4433
```yaml
45-
# Main server resource pack URL
46-
# This pack is loaded when using /load without arguments
47-
server-pack: "https://example.com/server-pack.zip"
34+
# Main server resource pack
35+
# Can be either a URL or a file name in the packs folder
36+
# For URLs: "https://example.com/server-pack.zip"
37+
# For files: "server-pack.zip"
38+
server-pack: "server-pack.zip"
39+
40+
# Web server settings
41+
server-port: 40021 # Default port, can be changed to any open port on your host
42+
localhost: false # Set to false for production servers, true only for local testing
43+
server-address: "" # Will try to auto-detect if empty
44+
fallback-address: "localhost" # Used if auto-detection fails
4845

4946
# Additional resource packs
50-
# These packs can be loaded using /load <packname>
51-
# To add a new pack, use a key:"value" format
47+
# Can use either URLs or files from the packs folder
48+
# For URLs: "https://example.com/examplepack.zip"
49+
# For files: "example-pack.zip"
5250
resource-packs:
53-
example: "https://example.com/dungeons-pack.zip"
54-
example0: "https://example.com/example0.zip"
55-
example1: "https://example.com/example1.zip"
51+
exampleurlpack: "https://example.com/examplepack.zip"
52+
examplefilepack: "example-pack.zip"
5653
```
5754
58-
### Adding New Resource Packs
59-
1. Open `config.yml`.
60-
2. Add a new entry under `resource-packs` in the format `key: "URL"`.
61-
3. Save the file and run `/resourcereload` to apply the changes.
62-
63-
## How It Works
64-
65-
1. Players can use `/load` to load the default resource pack or a specific pack by name.
66-
2. Use `/listpacks` to see all available resource packs.
67-
3. Administrators can reload the plugin configuration using `/resourcereload`.
68-
69-
## Example
70-
71-
- **Loading Default Pack:**
72-
```
73-
/load
74-
```
55+
## Installation
7556
76-
- **Loading a Specific Pack:**
77-
```
78-
/load example
79-
```
57+
1. Download the latest release
58+
2. Place the JAR file in your server's `plugins` folder
59+
3. Start/restart your server
60+
4. A `packs` folder will be created in `plugins/Resourceloader/`
61+
5. Place your resource pack files in the `packs` folder
62+
6. Configure the packs in `config.yml`
63+
7. Use `/resourcereload` to apply changes
8064

81-
- **Listing Available Packs:**
82-
```
83-
/listpacks
84-
```
65+
## File-based Resource Packs
8566

86-
- **Reloading Configuration:**
87-
```
88-
/resourcereload
89-
```
67+
To use file-based resource packs:
68+
1. Place your .zip resource pack files in the `plugins/Resourceloader/packs/` folder
69+
2. In config.yml, use just the filename (e.g., "my-pack.zip") instead of a full URL
70+
3. The plugin will automatically look for the file in the packs folder
9071

91-
## Installation
72+
## URL-based Resource Packs
9273

93-
1. Download the plugin JAR file.
94-
2. Place it in the `plugins` folder of your Minecraft server.
95-
3. Start the server to generate the default configuration file.
96-
4. Customize `config.yml` as needed.
97-
5. Use `/resourcereload` to apply your changes.
74+
For URL-based packs:
75+
1. Use the complete URL in config.yml (e.g., "https://example.com/pack.zip")
76+
2. Ensure the URL is directly downloadable
77+
3. The URL must point to a valid Minecraft resource pack .zip file
9878

9979
## Requirements
10080

101-
- Minecraft Server Version: `1.13` or higher
102-
- Java Version: `17` or higher
81+
- Minecraft 1.13 or newer
82+
- Spigot/Paper server
10383

104-
## Credits
84+
## Support
10585

106-
**Author:** DefectiveVortex
107-
**Website:** [GitHub Repository](https://github.com/DefectiveVortex/Resourceloader)
86+
If you encounter any issues or have suggestions, please create an issue on the GitHub repository.
10887

109-
---
88+
## License
11089

111-
Feel free to contribute or suggest improvements via the [GitHub repository](https://github.com/DefectiveVortex/Resourceloader).
90+
This project is licensed under the MIT License - see the LICENSE file for details.

license.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 DefectiveVortex
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.vortex</groupId>
88
<artifactId>Resourceloader</artifactId>
9-
<version>1.1</version>
9+
<version>1.3</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Resourceloader</name>
@@ -78,5 +78,20 @@
7878
<artifactId>json-simple</artifactId>
7979
<version>1.1.1</version>
8080
</dependency>
81+
<dependency>
82+
<groupId>com.google.code.gson</groupId>
83+
<artifactId>gson</artifactId>
84+
<version>2.10.1</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>com.fasterxml.jackson.core</groupId>
88+
<artifactId>jackson-databind</artifactId>
89+
<version>2.15.2</version>
90+
</dependency>
91+
<dependency>
92+
<groupId>commons-io</groupId>
93+
<artifactId>commons-io</artifactId>
94+
<version>2.11.0</version>
95+
</dependency>
8196
</dependencies>
8297
</project>
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package org.vortex.resourceloader;
2+
3+
import org.bukkit.ChatColor;
4+
import org.bukkit.command.Command;
5+
import org.bukkit.command.CommandExecutor;
6+
import org.bukkit.command.CommandSender;
7+
import org.bukkit.command.TabCompleter;
8+
import org.bukkit.util.StringUtil;
9+
import org.bukkit.scheduler.BukkitRunnable;
10+
11+
import java.io.File;
12+
import java.io.IOException;
13+
import java.util.ArrayList;
14+
import java.util.Collections;
15+
import java.util.List;
16+
17+
public class MergeCommand implements CommandExecutor, TabCompleter {
18+
private final Resourceloader plugin;
19+
private final ResourcePackMerger merger;
20+
private boolean isCurrentlyMerging = false;
21+
22+
public MergeCommand(Resourceloader plugin) {
23+
this.plugin = plugin;
24+
this.merger = new ResourcePackMerger(plugin);
25+
}
26+
27+
@Override
28+
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
29+
if (!sender.hasPermission("resourceloader.admin")) {
30+
sender.sendMessage(ChatColor.RED + "You don't have permission to merge resource packs.");
31+
return true;
32+
}
33+
34+
if (isCurrentlyMerging) {
35+
sender.sendMessage(ChatColor.RED + "A merge operation is already in progress. Please wait.");
36+
return true;
37+
}
38+
39+
if (args.length < 3) {
40+
sender.sendMessage(ChatColor.RED + "Usage: /mergepack <output_name> <pack1> <pack2> [pack3...]");
41+
return true;
42+
}
43+
44+
String outputName = args[0];
45+
if (!outputName.toLowerCase().endsWith(".zip")) {
46+
outputName += ".zip";
47+
}
48+
49+
// Validate all packs exist before starting the merge
50+
List<File> inputPacks = new ArrayList<>();
51+
for (int i = 1; i < args.length; i++) {
52+
String packName = args[i];
53+
File packFile = plugin.getResourcePacks().get(packName);
54+
if (packFile == null) {
55+
sender.sendMessage(ChatColor.RED + "Resource pack '" + packName + "' not found!");
56+
return true;
57+
}
58+
inputPacks.add(packFile);
59+
}
60+
61+
// Mark as merging
62+
isCurrentlyMerging = true;
63+
sender.sendMessage(ChatColor.YELLOW + "Starting resource pack merge process...");
64+
65+
// Use final variables for the inner class
66+
final String finalOutputName = outputName;
67+
final List<File> finalInputPacks = inputPacks;
68+
69+
new BukkitRunnable() {
70+
@Override
71+
public void run() {
72+
try {
73+
// Perform merge operation async
74+
File outputFile = merger.mergeResourcePacks(finalInputPacks, finalOutputName);
75+
76+
// Switch back to main thread to update plugin state
77+
new BukkitRunnable() {
78+
@Override
79+
public void run() {
80+
try {
81+
plugin.loadResourcePacks();
82+
sender.sendMessage(ChatColor.GREEN + "Successfully merged resource packs into: " + finalOutputName);
83+
} catch (Exception e) {
84+
sender.sendMessage(ChatColor.RED + "Error loading merged pack: " + e.getMessage());
85+
plugin.getLogger().warning("Error loading merged pack: " + e.getMessage());
86+
e.printStackTrace();
87+
} finally {
88+
isCurrentlyMerging = false;
89+
}
90+
}
91+
}.runTask(plugin);
92+
93+
} catch (IOException e) {
94+
// Switch back to main thread to send error message
95+
new BukkitRunnable() {
96+
@Override
97+
public void run() {
98+
sender.sendMessage(ChatColor.RED + "Failed to merge resource packs: " + e.getMessage());
99+
plugin.getLogger().warning("Failed to merge resource packs: " + e.getMessage());
100+
e.printStackTrace();
101+
isCurrentlyMerging = false;
102+
}
103+
}.runTask(plugin);
104+
}
105+
}
106+
}.runTaskAsynchronously(plugin);
107+
108+
return true;
109+
}
110+
111+
@Override
112+
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
113+
List<String> completions = new ArrayList<>();
114+
115+
if (args.length >= 2) {
116+
if (sender.hasPermission("resourceloader.admin")) {
117+
List<String> packs = new ArrayList<>(plugin.getResourcePacks().keySet());
118+
StringUtil.copyPartialMatches(args[args.length - 1], packs, completions);
119+
}
120+
}
121+
122+
Collections.sort(completions);
123+
return completions;
124+
}
125+
}

0 commit comments

Comments
 (0)