Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tb insert command and new placeholders #112

Merged
merged 32 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
407437c
webhook system in start a game
thiagogebrimm Jul 15, 2022
761d456
Correção para poder customizar a mensagem em cada evento
thiagogebrimm Jul 15, 2022
bd5ef3a
Fixed async and removed unusable imports
thiagogebrimm Jul 15, 2022
4faad44
'-' fix
thiagogebrimm Jul 15, 2022
d8ac671
Removed inused import
thiagogebrimm Jul 15, 2022
7fd4b95
moved to the Game class
thiagogebrimm Jul 15, 2022
2cab483
correções a pedido do roj
thiagogebrimm Jul 16, 2022
e9ae084
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Jul 19, 2022
f77abdc
Removido o inutilizado da class
thiagogebrimm Jul 19, 2022
b9ee397
Update language-en.yml
RoinujNosde Jul 19, 2022
d89a5b4
Removido inutilizados da class
thiagogebrimm Jul 19, 2022
988379c
Removido inutilizados da class
thiagogebrimm Jul 19, 2022
62e88ef
Merge remote-tracking branch 'origin/master'
thiagogebrimm Jul 19, 2022
7cd0f35
Removido inutilizados da class
thiagogebrimm Jul 19, 2022
6e62e4d
Added args to discordAnnounce
RoinujNosde Jul 19, 2022
09babe0
Updated config description
RoinujNosde Jul 19, 2022
47569f4
Moved DiscordWebhook to discord package
RoinujNosde Jul 19, 2022
31698ce
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Jul 19, 2022
e4ebb25
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Jan 23, 2023
b7ca103
feat: added message for sending game won in Discord
thiagogebrimm Jan 23, 2023
dbf63fe
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Jan 23, 2023
8d894f7
feat: added message for sending game killer in Discord
thiagogebrimm Apr 28, 2023
6a32959
feat: added kills in message for sending game killer in Discord
thiagogebrimm Apr 28, 2023
f2cd360
fix: Fixed killer kill counter in discord message
thiagogebrimm Apr 28, 2023
ad13856
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Jun 21, 2023
fb3405f
Update nbt-api for works in 1.20
thiagogebrimm Jun 21, 2023
579b6b6
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Aug 13, 2023
a3adc47
feat: add /tb insert command
thiagogebrimm Aug 13, 2023
f907a07
remove anotations
thiagogebrimm Aug 16, 2023
084ec27
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Sep 11, 2023
993da1e
Merge branch 'RoinujNosde:master' into master
thiagogebrimm Oct 5, 2023
006dfef
removi o insert e deixei apenas as placeholders para poder separar em…
thiagogebrimm Oct 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.roinujnosde.titansbattle.TitansBattle;
import me.roinujnosde.titansbattle.games.Game;
import me.roinujnosde.titansbattle.managers.DatabaseManager;
import me.roinujnosde.titansbattle.types.GameConfiguration;
import me.roinujnosde.titansbattle.types.Group;
Expand All @@ -24,17 +25,21 @@ public class TBExpansion extends PlaceholderExpansion {
private final TitansBattle plugin;

private static final List<String> PLACEHOLDERS;
private static final Pattern PARTICIPANTS_SIZE;
private static final Pattern GROUPS_SIZE;
private static final Pattern ARENA_IN_USE_PATTERN;
private static final Pattern LAST_WINNER_GROUP_PATTERN;
private static final Pattern LAST_WINNER_KILLER_PATTERN;
private static final Pattern PREFIX_PATTERN;

static {
PARTICIPANTS_SIZE = Pattern.compile("participants_size");
GROUPS_SIZE = Pattern.compile("groups_size");
ARENA_IN_USE_PATTERN = Pattern.compile("arena_in_use_(?<arena>\\S+)");
LAST_WINNER_GROUP_PATTERN = Pattern.compile("last_winner_group_(?<game>\\S+)");
LAST_WINNER_KILLER_PATTERN = Pattern.compile("last_(?<type>winner|killer)_(?<game>\\S+)");
PREFIX_PATTERN = Pattern.compile("(?<game>^\\S+)_(?<type>winner|killer)_prefix");
PLACEHOLDERS = Arrays.asList("%titansbattle_arena_in_use_<arena>%", "%titansbattle_last_winner_group_<game>%",
PLACEHOLDERS = Arrays.asList("%titansbattle_groups_size%" ,"%titansbattle_participants_size%" ,"%titansbattle_arena_in_use_<arena>%", "%titansbattle_last_winner_group_<game>%",
"%titansbattle_last_<killer|winner>_<game>%", "%titansbattle_<game>_<killer|winner>_prefix%",
"%titansbattle_group_total_victories%", "%titansbattle_total_kills%", "%titansbattle_total_deaths%");
}
Expand Down Expand Up @@ -75,6 +80,21 @@ public boolean canRegister() {

@Override
public String onRequest(OfflinePlayer player, @NotNull String params) {

Matcher participantsSizeMatcher = PARTICIPANTS_SIZE.matcher(params);
if (participantsSizeMatcher.matches()) {
Optional<Game> currentGame = plugin.getGameManager().getCurrentGame();
return currentGame.map(game -> String.valueOf(game.getParticipants().size()))
.orElse("0");
}

Matcher groupsSizeMatcher = GROUPS_SIZE.matcher(params);
if (groupsSizeMatcher.matches()) {
Optional<Game> currentGame = plugin.getGameManager().getCurrentGame();
return currentGame.map(game -> String.valueOf(game.getGroupParticipants().size()))
.orElse("0");
}

Matcher arenaInUse = ARENA_IN_USE_PATTERN.matcher(params);
if (arenaInUse.find()) {
String arenaName = arenaInUse.group("arena");
Expand Down