-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from Braekpo1nt/dev
Merge MCT 1 version release
- Loading branch information
Showing
45 changed files
with
4,034 additions
and
268 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Bug | ||
about: 'A bug that needs to be fixed. ' | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
## Describe the bug | ||
*A clear and concise description of what the bug is.* | ||
|
||
## To Reproduce | ||
*Steps to reproduce the behavior:* | ||
- Start game '...' | ||
- Kill player '....' | ||
- See error | ||
|
||
## Expected behavior | ||
*A clear and concise description of what you expected to happen.* | ||
|
||
## Suggested fix | ||
*suggestions for how to fix the bug* | ||
|
||
## Definition of Done | ||
*a detailed list of all tasks which must be completed for the issue to be called "done". Must use the checkbox bullet point `- [ ]`* | ||
- [ ] *task A* | ||
- [ ] *task B* | ||
|
||
## Related issues | ||
*if this is related to any issues, list them here using the issue notation #123* |
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,20 @@ | ||
--- | ||
name: Feature | ||
about: Issues that describe a new feature. An addition to the plugin, a feature of | ||
a game, a new game, etc. | ||
title: '' | ||
labels: feature | ||
assignees: '' | ||
|
||
--- | ||
|
||
## Description | ||
*a brief description of the feature from a bird's eye view* | ||
|
||
## Definition of Done | ||
*a detailed list of all tasks which must be completed for the issue to be called "done". Must use the checkbox bullet point `- [ ]`* | ||
- [ ] *task A* | ||
- [ ] *task B* | ||
|
||
## Related Issues | ||
*if this is related to any issues, list them here using the issue notation `#123`* |
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,25 @@ | ||
--- | ||
name: Redesign | ||
about: Redesign existing functionality. Refactor code, change feature, etc. | ||
title: '' | ||
labels: redesign | ||
assignees: '' | ||
|
||
--- | ||
|
||
## Description | ||
*a description of the redesign* | ||
|
||
## Reason for Redesign | ||
*why is this being redesigned?* | ||
|
||
## Proposed Redesign | ||
*describe how the redesign should be done* | ||
|
||
## Definition of Done | ||
*a detailed list of all tasks which must be completed for the issue to be called "done". Must use the checkbox bullet point `- [ ]`* | ||
- [ ] *task A* | ||
- [ ] *task B* | ||
|
||
## Related Issues | ||
*if this is related to any issues, list them here using the issue notation #123* |
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
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
68 changes: 68 additions & 0 deletions
68
src/main/java/org/braekpo1nt/mctmanager/commands/CommandManager.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,68 @@ | ||
package org.braekpo1nt.mctmanager.commands; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import net.kyori.adventure.text.format.TextDecoration; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabExecutor; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* A command that has other sub commands. | ||
* Add CommandExecutor implementing methods to the {@link CommandManager#subCommands} map to add executable sub commands. | ||
* Implement TabExecutor in your sub command to provide tab completion | ||
*/ | ||
public abstract class CommandManager implements TabExecutor { | ||
|
||
protected final Map<String, CommandExecutor> subCommands = new HashMap<>(); | ||
|
||
protected abstract Component getUsageMessage(); | ||
|
||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
if (args.length < 1) { | ||
sender.sendMessage(getUsageMessage()); | ||
return true; | ||
} | ||
String subCommandName = args[0]; | ||
if (!subCommands.containsKey(subCommandName)) { | ||
sender.sendMessage(Component.text("Argument ") | ||
.append(Component.text(subCommandName) | ||
.decorate(TextDecoration.BOLD)) | ||
.append(Component.text(" is not recognized.")) | ||
.color(NamedTextColor.RED)); | ||
return true; | ||
} | ||
|
||
return subCommands.get(subCommandName).onCommand(sender, command, label, Arrays.copyOfRange(args, 1, args.length)); | ||
} | ||
|
||
@Override | ||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
if (args.length == 1) { | ||
List<String> subCommandNames = subCommands.keySet().stream().sorted().toList(); | ||
return subCommandNames; | ||
} | ||
if (args.length > 1) { | ||
String subCommandName = args[0]; | ||
if (!subCommands.containsKey(subCommandName)) { | ||
return null; | ||
} | ||
CommandExecutor subCommand = subCommands.get(subCommandName); | ||
if (subCommand instanceof TabExecutor) { | ||
TabExecutor subTabCommand = ((TabExecutor) subCommand); | ||
return subTabCommand.onTabComplete(sender, command, label, Arrays.copyOfRange(args, 1, args.length)); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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
Oops, something went wrong.