Skip to content

Commit

Permalink
Merge pull request #178 from Braekpo1nt/dev
Browse files Browse the repository at this point in the history
Merge MCT 1 version release
  • Loading branch information
Braekpo1nt authored Apr 13, 2023
2 parents 4c1b5d9 + f484e82 commit 9aa3400
Show file tree
Hide file tree
Showing 45 changed files with 4,034 additions and 268 deletions.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
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*
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
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`*
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/redesign.md
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*
47 changes: 43 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Check out [MCT Official on YouTube](https://www.youtube.com/channel/UCDHWFMl0D8v

## Authors
- This plugin was programmed by Braekpo1nt. Find him on [YouTube](https://www.youtube.com/@braekpo1nt), [twitter](https://twitter.com/braekpo1nt), [facebook](https://www.facebook.com/Braekpo1nt/), or [instagram](https://www.instagram.com/braekpo1nt/).
- The event this plugin supports was created by SgtShotgun. Find them on [YouTube](https://www.youtube.com/@SgtShotgun) and [twitter](https://twitter.com/SgtShotgun1)
- The event this plugin supports was created by SgtShotgun. Find them on [YouTube](https://www.youtube.com/@SgtShotgun) and [twitter](https://twitter.com/SgtShotgun1)

## Discord
Ask the authors for access to the discord
Expand All @@ -29,15 +29,14 @@ Required plugins. Read this or you will get errors.

# Running the event

## Participants
In order to host an event, you need to [add participants](#adding-a-new-participant) (the plugin has to know who is a participant and who is an admin).

### Starting a game
You can start a game with the following command:

- `/mct game start <game>`
- `<game>` the game to start. Must be a valid game name in the event. See [list of games](#games-list)

You can also start a game with a [vote](#voting)

### Stopping a game
If a game is running, you can manually stop a game with the following command:

Expand All @@ -46,6 +45,14 @@ If a game is running, you can manually stop a game with the following command:
This will stop the game, and return all players to the beginning. As of the time of writing this, the points for playing the game will be retained.
- `[true|false]` This is an optional argument (defaults to true). If you provide false, the teleport to the hub will be cancelled. This is a debugging feature, and players will often not be reset properly after a game ends.

### Voting

You can initiate a vote for all online participants. You must specify the games you want to be voted for (must be at least one):

- `/mct game vote [one or more games]`

for example: `/mct game vote spleef foot-race mecha` will show all players a voting gui with those three games, and no others.

### Adding a new team
Every participant must be on a team, so you must first have at least one team. To add a new team, use the following command:

Expand All @@ -57,6 +64,10 @@ Every participant must be on a team, so you must first have at least one team. T
### Removing a team
You can remove a team entirely. Points are lost and team members are removed, also losing their points, as if you [removed them manually](#removing-a-participant)


## Participants
In order to host an event, you need to [add participants](#adding-a-new-participant) (the plugin has to know who is a participant and who is an admin).

### Adding a new participant
Participants must be on a team, so you must first [add a new team](#adding-a-new-team)

Expand All @@ -75,6 +86,34 @@ The only way to remove a participant is to leave them from their team:

Note: This will delete a participants points, but as of right now doesn't remove those points from the team they used to be on

### Listing teams and scores

You can list the teams, their participants, and their scores with the following command:

- `/mct team list [true|false]`
- `[true|false]` whether or not to display the teams to all participants. Defaults to false. If you specify true, it will display the team list to all participants.

This will show the team list and the players on the teams and all scores.

### Modifying scores

You can add, subtract, or set the scores of players and teams with the following command:

- `/mct team score <add|subtract|set> <player|team> <playerName|teamName> <value>`
- `<add|subtract|set>`
- `add` add the `value`
- `subtract` subtract the `value`
- `set` set the score to the `value`
- `<player|team>` specify player or team
- `<playerName|teamName>` If you specified `player` above, enter the `playerName` of the player whose score you want to modify. If you specified `team` above, enter the `teamName` of the team whose score you want to modify.
- `<value>` the value you want to `add`/`subtract`/`set`.
- Must be an integer.
- Can be negative for `add`/`subtract`
- If you add a negative number it's subtracted, if you subtract a negative number it's added.
- Must be positive for `set`.
- You can't modify a score so that it's less than 0. If you try to subtract a number from a score that would cause it to go negative, the score is simply set to 0.


## Games List
This is a list of the currently implemented games. See above for how to [start a game](#starting-a-game) or [stop a game](#stopping-a-game)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'org.braekpo1nt'
version = '0.3.0-alpha'
version = '0.4.0-alpha'

repositories {
mavenCentral()
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/braekpo1nt/mctmanager/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import org.braekpo1nt.mctmanager.commands.MCTCommand;
import org.braekpo1nt.mctmanager.commands.MCTDebugCommand;
import org.braekpo1nt.mctmanager.games.GameManager;
import org.braekpo1nt.mctmanager.hub.HubManager;
import org.braekpo1nt.mctmanager.listeners.BlockEffectsListener;
import org.braekpo1nt.mctmanager.hub.HubBoundaryListener;
import org.braekpo1nt.mctmanager.listeners.PlayerJoinListener;
import org.braekpo1nt.mctmanager.ui.FastBoardManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
Expand Down Expand Up @@ -39,10 +37,8 @@ public void onEnable() {
Main.multiverseCore = ((MultiverseCore) multiversePlugin);

Scoreboard mctScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();

HubManager hubManager = new HubManager(this, mctScoreboard);

gameManager = new GameManager(this, mctScoreboard, hubManager);
gameManager = new GameManager(this, mctScoreboard);
try {
gameManager.loadGameState();
} catch (IOException e) {
Expand Down Expand Up @@ -80,6 +76,8 @@ public void run() {
public void onDisable() {
if (saveGameStateOnDisable && gameManager != null) {
gameManager.cancelFastBoardManager();
gameManager.cancelVote();
gameManager.cancelReturnToHub();
try {
gameManager.saveGameState();
if (gameManager.gameIsRunning()) {
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/org/braekpo1nt/mctmanager/color/ColorMap.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.braekpo1nt.mctmanager.color;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;

public class ColorMap {

Expand Down Expand Up @@ -60,6 +62,26 @@ public class ColorMap {
CHAT_COLOR_MAP.put("yellow", ChatColor.YELLOW);
}

private static final Map<String, Material> POWDER_TYPE_MAP = new HashMap<>();
static {
POWDER_TYPE_MAP.put("aqua", Material.LIGHT_BLUE_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("black", Material.BLACK_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("dark_aqua", Material.CYAN_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("dark_blue", Material.BLUE_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("dark_gray", Material.GRAY_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("dark_green", Material.GREEN_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("dark_purple", Material.PURPLE_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("dark_red", Material.RED_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("gold", Material.ORANGE_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("gray", Material.LIGHT_GRAY_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("green", Material.LIME_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("light_purple", Material.PINK_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("red", Material.MAGENTA_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("white", Material.WHITE_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("blue", Material.BROWN_CONCRETE_POWDER);
POWDER_TYPE_MAP.put("yellow", Material.YELLOW_CONCRETE_POWDER);
}

public static NamedTextColor getNamedTextColor(String colorString) {
NamedTextColor color = NAMED_TEXT_COLOR_MAP.get(colorString.toLowerCase());
return color != null ? color : NamedTextColor.WHITE;
Expand All @@ -85,4 +107,12 @@ public static ChatColor getChatColor(String colorString) {
ChatColor color = CHAT_COLOR_MAP.get(colorString.toLowerCase());
return color != null ? color : ChatColor.WHITE;
}

public static List<Material> getAllConcretePowderColors() {
return POWDER_TYPE_MAP.values().stream().toList();
}

public static Material getConcretePowderColor(String colorString) {
return POWDER_TYPE_MAP.getOrDefault(colorString, Material.WHITE_CONCRETE_POWDER);
}
}
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;
}
}
40 changes: 5 additions & 35 deletions src/main/java/org/braekpo1nt/mctmanager/commands/MCTCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.braekpo1nt.mctmanager.commands;

import net.kyori.adventure.text.Component;
import org.braekpo1nt.mctmanager.Main;
import org.braekpo1nt.mctmanager.commands.game.GameSubCommand;
import org.braekpo1nt.mctmanager.commands.team.TeamSubCommand;
Expand All @@ -24,10 +25,8 @@
* The super command for all MCT related commands.
* Everything should start with /mct _____, where _____ is a sub command
*/
public class MCTCommand implements TabExecutor {
public class MCTCommand extends CommandManager {

private final Map<String, CommandExecutor> subCommands = new HashMap<>();

public MCTCommand(Main plugin, GameManager gameManager, HubBoundaryListener hubBoundaryListener, BlockEffectsListener blockEffectsListener) {
plugin.getCommand("mct").setExecutor(this);
subCommands.put("game", new GameSubCommand(gameManager));
Expand Down Expand Up @@ -55,38 +54,9 @@ public MCTCommand(Main plugin, GameManager gameManager, HubBoundaryListener hubB
});
}


@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (args.length < 1) {
sender.sendMessage("Usage: /mct <option>");
return false;
}
String subCommandName = args[0];
if (!subCommands.containsKey(subCommandName)) {
sender.sendMessage(String.format("Argument %s is not recognized.", subCommandName));
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;
protected Component getUsageMessage() {
return Component.text("Usage: /mct <option>");
}
}
Loading

0 comments on commit 9aa3400

Please sign in to comment.