Skip to content

Commit

Permalink
Merge pull request #6 from BT-Pluginz/info-command
Browse files Browse the repository at this point in the history
Added /cl info command
  • Loading branch information
TubYoub authored Apr 30, 2024
2 parents a80e15b + 21d8a2f commit 8495e59
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ This Minecraft Plugin punishes people when they leave the Server while they are
- Ally with another Player, so when you hit each-other the Timer won't start `/cl ally` (requires Permission: `combatlogger.ally`, `default: player`)
- `/cl ally add <player>` to add someone as an ally
- `/cl ally remove <player>` to remove an ally
- Help command `/cl help` displays all the commands a player has permission to use
- List Plugin info's using `/cl info` (requires Permission: `combatlogger.info`, `default: player`)
- Help command `/cl help` displays all the commands a player has permission to use (requires Permission: `combatlogger.help`, `default: player`)
## Permission
- `combatlogger.start`: Allows players to start combat for a specific player (`default: op`)
- `combatlogger.stop`: Allows players to stop combat for a specific player (`default: op`)
- `combatlogger.list`: Allows players to list all players currently in combat (`default: op`)
- `combatlogger.settimer`: Allows players to set the combat timer (`default: op`)
- `combatlogger.reload`: Allows Players to reload the config and allys (`default: op`)
- `combatlogger.ally`: Allows players to ally with other players (`default: player`)
- `combatlogger.info`: Allows Players to use the info command (`default: player`)
- `combatlogger.help`: Allows Players to use the help command (`default: player`)
## Installation
To install the plugin, simply download the latest release file and place it in your server's plugins folder. Then, restart your server.
## Support
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/dev/pluginz/combatlogger/CombatLoggerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
Expand Down Expand Up @@ -66,7 +65,9 @@ public void onEnable() {
this.combatManager = new CombatManager(this);
if (configManager.isCheckVersion()) {
newVersion = VersionChecker.isNewVersionAvailable(version);
this.getLogger().warning("There is a new Version available for BT's CombatLogger");
if (newVersion) {
this.getLogger().warning("There is a new Version available for BT's CombatLogger");
}
}

File allyFile = new File("plugins/CombatLogger/allies.yml");
Expand All @@ -86,7 +87,6 @@ public void onEnable() {

getCommand("combatlogger").setExecutor(new CLCommand(combatManager,this));
getCommand("combatlogger").setTabCompleter(new CLTabCompleter(this));
//getCommand("combatLogger".setTabCompleter(new CLTabCompleter()), this);
}

public CombatManager getCombatManager() {
Expand All @@ -112,10 +112,20 @@ public void sendPluginMessages(CommandSender sender, String type) {
public String getPluginPrefix() {
return ChatColor.WHITE + "[" + ChatColor.RED + "BTCL" + ChatColor.WHITE + "] ";
}
public String getVersion(){
return version;
}
public boolean isNewVersion(){
return newVersion;
}

@Override
public void onDisable() {
configManager.saveConfig();
this.getLogger().info("-----");
this.getLogger().info(" ");
this.getLogger().warning("If this is a reload please note that this could break the Plugin");
this.getLogger().info(" ");
this.getLogger().info("-----");
}
}
40 changes: 38 additions & 2 deletions src/main/java/dev/pluginz/combatlogger/commands/CLCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import dev.pluginz.combatlogger.managers.CombatManager;
import dev.pluginz.combatlogger.CombatLoggerPlugin;
import dev.pluginz.combatlogger.utils.List;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
Expand All @@ -49,8 +51,8 @@ public CLCommand(CombatManager combatManager, CombatLoggerPlugin plugin) {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0 || args[0].equalsIgnoreCase("reload")) {
reloadPlugin(sender);
if (args.length == 0) {
sendHelp(sender);
return true;
}

Expand All @@ -70,6 +72,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
case "ally":
handleAlly(sender, args);
return true;
case "info":
infoCommand(sender);
return true;
case "reload":
reloadPlugin(sender);
return true;
default:
sendHelp(sender);
return true;
Expand Down Expand Up @@ -196,6 +204,33 @@ private void handleAlly(CommandSender sender, String[] args) {
sender.sendMessage(plugin.getPluginPrefix() + "Invalid command. Usage: /cl ally <add|remove <player>");
}
}
public void infoCommand(CommandSender sender) {
plugin.sendPluginMessages(sender, "title");
sender.sendMessage(ChatColor.GREEN + "Author: BTPluginz");
sender.sendMessage(ChatColor.GREEN + "Version: " + plugin.getVersion());
if (plugin.getConfigManager().isCheckVersion()) {
if (plugin.isNewVersion()) {
sender.sendMessage(ChatColor.YELLOW + "A new version is available! Update at: " + ChatColor.UNDERLINE + "https://modrinth.com/project/bts-combatlogger");
} else {
sender.sendMessage(ChatColor.GREEN + "You are using the latest version!");
}
} else {
sender.sendMessage("Version checking is disabled!");
}
TextComponent githubLink = new TextComponent(ChatColor.DARK_GRAY + "" + ChatColor.UNDERLINE + "GitHub");
githubLink.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/BT-Pluginz/CombatLogger"));
githubLink.setUnderlined(true);
sender.spigot().sendMessage(githubLink);

TextComponent discordLink = new TextComponent(ChatColor.BLUE + "" + ChatColor.UNDERLINE + "Discord");
discordLink.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.pluginz.dev"));
discordLink.setUnderlined(true);
sender.spigot().sendMessage(discordLink);

sender.sendMessage("If you have any issues please report them on GitHub or on the Discord.");
plugin.sendPluginMessages(sender,"line");

}
private void sendHelp(CommandSender sender) {
plugin.sendPluginMessages(sender,"title");
if (sender.hasPermission("combatlogger.start") || sender.hasPermission("combatlogger.stop") || sender.hasPermission("combatlogger.list") || sender.hasPermission("combatlogger.settimer") || sender.hasPermission("combatlogger.ally")) {
Expand All @@ -215,6 +250,7 @@ private void sendHelp(CommandSender sender) {
if (sender.hasPermission("combatlogger.ally")){
sender.sendMessage("/cl ally <add|remove <player>");
}
sender.sendMessage("/cl info - Get Infos about the Plugin");
sender.sendMessage("/cl help - Show this message.");
plugin.sendPluginMessages(sender, "line");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public CLTabCompleter(CombatLoggerPlugin plugin) {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
List<String> completions = new ArrayList<>();
List<String> commands = Arrays.asList("start", "stop", "list", "settimer", "ally", "reload");
List<String> commands = Arrays.asList("start", "stop", "list", "settimer", "ally", "reload", "help", "info");

if (args.length == 1) {
for (String cmd : commands) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ permissions:
default: op
combatlogger.ally:
description: Allows players to ally with other players
default: true
combatlogger.help:
description: Allows Players to use the help command
default: true
combatlogger.info:
description: Allows Players to use the info command
default: true

0 comments on commit 8495e59

Please sign in to comment.