generated from AitorAstorga/Best-README-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new commands and improve codebase
- Loading branch information
1 parent
72ef2a3
commit 25f24d2
Showing
7 changed files
with
244 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
# Changelog | ||
|
||
## v1.0.0 | ||
## 1.3.0 | ||
|
||
### Added or Changed | ||
- Added this changelog :) | ||
- Fixed typos in both templates | ||
- Back to top links | ||
- Added more "Built With" frameworks/libraries | ||
- Changed table of contents to start collapsed | ||
- Added checkboxes for major features on roadmap | ||
- Added `ban-message` to the `config.yml` | ||
- Lowered time limit to 5 seconds | ||
- Added the following commands: | ||
* `/BotBlocker status` - Show wether BotBlocker is enabled or disabled. | ||
* `/BotBlocker getTimeLimit` - Display the configured time limit for detecting bots. | ||
* `/BotBlocker setBanMessage [message]` - Set the ban message. | ||
* `/BotBlocker getBanMessage` - Display the configured ban message. | ||
- Added brief instructions for compiling this Bukkit/Spigot plugin using Maven (so I won't forget next time). | ||
- Fixed package names to be compliant with naming conventions. | ||
- Added usage hint to the setTimeLimit command. | ||
- Created `CommandHandler` class to improve readability. | ||
- Updated `README.md` and this `CHANGELOG.md` :) | ||
|
||
### Removed | ||
|
||
- Some packages/libraries from acknowledgements I no longer use | ||
- Maven target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/main/java/ovh/aichan/botblockerminecraft/CommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package ovh.aichan.botblockerminecraft; | ||
|
||
import org.bukkit.command.CommandSender; | ||
|
||
public class CommandHandler { | ||
|
||
private final BotBlocker plugin; | ||
|
||
/** | ||
* Constructor for CommandHandler. | ||
* @param plugin BotBlocker plugin | ||
*/ | ||
public CommandHandler(BotBlocker plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
/** | ||
* Enable the BotBlocker plugin. | ||
* @param sender Command sender | ||
*/ | ||
public void enable(CommandSender sender) { | ||
plugin.setPluginEnabled(true); | ||
sender.sendMessage("BotBlocker enabled."); | ||
plugin.saveConfig(); | ||
} | ||
|
||
/** | ||
* Disable the BotBlocker plugin. | ||
* @param sender Command sender | ||
*/ | ||
public void disable(CommandSender sender) { | ||
plugin.setPluginEnabled(false); | ||
sender.sendMessage("BotBlocker disabled."); | ||
plugin.saveConfig(); | ||
} | ||
|
||
/** | ||
* Show wether BotBlocker is enabled or disabled. | ||
* @param sender Command sender | ||
*/ | ||
public void status(CommandSender sender) { | ||
sender.sendMessage("BotBlocker status: " + (plugin.isEnabled() ? "§a§lENABLED" : "§c§lDISABLED")); | ||
} | ||
|
||
/** | ||
* Set the time limit for detecting bots. Default is 5 seconds. | ||
* @param sender Command sender | ||
* @param args Command arguments | ||
*/ | ||
public void setTimeLimit(CommandSender sender, String[] args) { | ||
if(args.length > 1) { | ||
try { | ||
int timeLimit = Integer.parseInt(args[1]); | ||
plugin.setTimeLimit(timeLimit); | ||
sender.sendMessage("Time limit set to " + timeLimit + " seconds."); | ||
} catch (NumberFormatException e) { | ||
sender.sendMessage("Invalid number format. Please enter a valid integer."); | ||
} | ||
} else { | ||
sender.sendMessage("Usage: /botblocker setTimeLimit <timeLimit>"); | ||
} | ||
} | ||
|
||
/** | ||
* Display the configured time limit for detecting bots. | ||
* @param sender Command sender | ||
*/ | ||
public void getTimeLimit(CommandSender sender) { | ||
sender.sendMessage("Time limit set to " + plugin.getTimeLimit() + " seconds."); | ||
} | ||
|
||
/** | ||
* Set the ban message. | ||
* @param sender Command sender | ||
* @param args Command arguments | ||
*/ | ||
public void setBanMessage(CommandSender sender, String[] args) { | ||
if(args.length > 1) { | ||
StringBuilder message = new StringBuilder(); | ||
for(int i = 1; i < args.length; i++) { | ||
message.append(args[i]).append(" "); | ||
} | ||
plugin.getConfig().set("ban-message", message.toString()); | ||
plugin.saveConfig(); | ||
sender.sendMessage("Ban message set to: " + message.toString()); | ||
} else { | ||
sender.sendMessage("Usage: /botblocker setBanMessage <message>"); | ||
} | ||
} | ||
|
||
/** | ||
* Display the configured ban message. | ||
* @param sender Command sender | ||
*/ | ||
public void getBanMessage(CommandSender sender) { | ||
sender.sendMessage("Ban message: " + plugin.getConfig().getString("ban-message")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Time limit in seconds | ||
time-limit: 60 | ||
enabled: true | ||
time-limit: 5 | ||
ban-message: "Bot detected. If you are a legitimate user, please contact the admin." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
name: BotBlocker | ||
main: eus.aichan.Blocker.BotBlocker | ||
version: 1.2 | ||
main: ovh.aichan.botblockerminecraft.BotBlocker | ||
version: 1.3.0 | ||
api-version: '1.20' | ||
author: aichan | ||
description: A plugin to ban users who connect for the first time and disconnect within a certain time limit. | ||
commands: | ||
botblocker: | ||
description: Manages the BotBlocker plugin | ||
usage: | | ||
/<command> enable - Enables the BotBlocker plugin | ||
/<command> disable - Disables the BotBlocker plugin | ||
/<command> setTimeLimit [seconds] - Sets the time limit | ||
/<command> enable - Enable the BotBlocker plugin. | ||
/<command> disable - Disable the BotBlocker plugin. | ||
/<command> status - Show wether BotBlocker is enabled or disabled. | ||
/<command> setTimeLimit [seconds] - Set the time limit for detecting bots. Default is 5 seconds. | ||
/<command> getTimeLimit - Display the configured time limit for detecting bots. | ||
/<command> setBanMessage [message] - Set the ban message. | ||
/<command> getBanMessage - Display the configured ban message. |