Skip to content

Commit

Permalink
Update 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
CptGummiball committed Sep 12, 2024
1 parent 488a148 commit 44818ba
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 43 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

## 1.1.2 [11.09.2024]
## 1.1.3 [12.09.2024]
### Changed:
- rules ar now set in ``config.yml``

## 1.1.2 [12.09.2024]
### Fixed:
- Lang Error
- removes messages files and placed the translation into ``config.yml``
Expand Down
37 changes: 14 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,21 @@ notifications:
use_api: false

# Optional URL for server rules
# If set, the URL will be displayed as a hyperlink instead of showing the rules from rules.yml
# If set, the URL will be displayed as a hyperlink instead of showing the rules from rules section.
rules_url: ""
# Rules configuration
# Define your server rules here. Each rule should be a list item (-).
# These rules will be displayed on the web interface if rules_url was not set.
rules:
- "No griefing."
- "Be respectful to other players."
- "No hacking or cheating."
- "Follow the instructions of the server admins."

# Example:
# rules:
# - "Your first rule."
# - "Your second rule."

# Translation
messages:
Expand All @@ -57,28 +70,6 @@ messages:
server_rules_link_text: "Click here to read the server rules."
````

**rules.yml:**

````yaml
# Rules configuration
# Define your server rules here. Each rule should be a list item (-).
# These rules will be displayed on the web interface.
rules:
- "No griefing."
- "Be respectful to other players."
- "No hacking or cheating."
- "Follow the instructions of the server admins."

# Example:
# rules:
# - "Your first rule."
# - "Your second rule."
````

**messages.yml:**

This file stores all language-specific messages. You can customize texts like the server rules title, application success message, etc.

### Starting the Web Server:

The plugin automatically starts a Jetty web server on the configured port (default: 8013). You can access the application form at http://<your-server-ip>:<port>/.
Expand Down
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.cptgummiball</groupId>
<artifactId>Whitelister</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<packaging>jar</packaging>

<name>Whitelister</name>
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/cptgummiball/whitelister/WebHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ private void handleWebRequests(String target, Request baseRequest, HttpServletRe
// If a URL is set, display the hyperlink
response.getWriter().println("<p><a href='" + rulesUrl + "' target='_blank'>" + linkText + "</a></p>");
} else {
// Otherwise, load and display rules from rules.yml
FileConfiguration rulesConfig = plugin.getConfig("rules.yml");
for (String rule : rulesConfig.getStringList("rules")) {
response.getWriter().println("<p>" + rule + "</p>");
}
// Otherwise, load and display rules from config.yml
String rule = String.valueOf(plugin.getConfig().getStringList("rules"));
response.getWriter().println("<p>" + rule + "</p>");
}

// Add the form for the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;

import java.util.ArrayList;
Expand All @@ -18,20 +17,17 @@ public class WhitelistCommand implements CommandExecutor, TabCompleter {

public WhitelistCommand(Whitelister plugin) {
this.plugin = plugin;
FileConfiguration config = plugin.getConfig();
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (args.length == 0 || args[0].equalsIgnoreCase("list")) {

listPendingApplications(player);
} else if (args[0].equalsIgnoreCase("accept") && args.length == 2) {
acceptApplication(player, args[1]);
}
return true;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class WhitelistManager {

public WhitelistManager(Whitelister plugin) {
this.plugin = plugin;
FileConfiguration config = plugin.getConfig();
this.applicationsFile = new File(plugin.getDataFolder(), "pending_applications.json");
loadPendingApplications();
}
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/cptgummiball/whitelister/Whitelister.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ public void onEnable() {
saveDefaultConfig();
whitelistManager = new WhitelistManager(this);

// Deploy Files
saveResource("rules.yml", false);

// Start Jetty server on configured port
startWebServer();

// Register commands and tab completer
WhitelisterCommand whitelisterCommand = new WhitelisterCommand(this);
this.getCommand("whitelister").setExecutor(whitelisterCommand);
this.getCommand("whitelister").setTabCompleter(whitelisterCommand); // Register tab completer
WhitelistCommand whitelistCommand = new WhitelistCommand(this);
this.getCommand("whitelister").setExecutor(whitelistCommand);
this.getCommand("whitelister").setTabCompleter(whitelistCommand); // Register tab completer

// Register event listener for player join notifications
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Expand Down
15 changes: 14 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ notifications:
use_api: false

# Optional URL for server rules
# If set, the URL will be displayed as a hyperlink instead of showing the rules from rules.yml
# If set, the URL will be displayed as a hyperlink instead of showing the rules from rules section.
rules_url: ""
# Rules configuration
# Define your server rules here. Each rule should be a list item (-).
# These rules will be displayed on the web interface if rules_url was not set.
rules:
- "No griefing."
- "Be respectful to other players."
- "No hacking or cheating."
- "Follow the instructions of the server admins."

# Example:
# rules:
# - "Your first rule."
# - "Your second rule."

# Translation
messages:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Whitelister
version: '1.1.2'
version: '1.1.3'
main: org.cptgummiball.whitelister.Whitelister
api-version: '1.20'
authors: [cptgummiball]
Expand Down

0 comments on commit 44818ba

Please sign in to comment.