-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added sounds to events of the game (join, leave, watch, teleport, victory, death) * Every command and subcommand is now editable * Added config to block commands for EVERYONE during a game * Added ACTION BAR message with the remaining opponents count when a player dies * Added Russian translation * Added new game mode: Elimination Tournament * Added config for enabling/disabling Killer on games * Added prizes for first, second, third place and killer * Broadcasts can be disabled if the message is empty * Fixed events * Removed Vault support * Added support for PlaceholderAPI * Clears the inventory before giving kit * Teleports dead players to the watchroom * Gets messages from English if not found in others * Added killer to ParticipantDeathEvent * Adds countdown title before battle * Changes sound config to use ENUMs * Warns of invalid sounds * Adds hidden config for disabling ff messages * Sorts the game configuration alphabetically for better reading * Removes built-in support for Factions * Adds ability to run commands before/after fights * Adds option to disable PvP in games
- Loading branch information
1 parent
3f75f6e
commit 6983d35
Showing
50 changed files
with
2,040 additions
and
1,582 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
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
Binary file not shown.
Binary file not shown.
94 changes: 94 additions & 0 deletions
94
src/main/java/me/roinujnosde/titansbattle/TBExpansion.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,94 @@ | ||
package me.roinujnosde.titansbattle; | ||
|
||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import me.roinujnosde.titansbattle.dao.GameConfigurationDao; | ||
import me.roinujnosde.titansbattle.types.GameConfiguration; | ||
import me.roinujnosde.titansbattle.types.Winners; | ||
import org.bukkit.OfflinePlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class TBExpansion extends PlaceholderExpansion { | ||
|
||
private final TitansBattle plugin; | ||
private static final Pattern PREFIX_PATTERN = Pattern.compile("(?<game>^[A-Za-z]+)_(?<type>winner|killer)_prefix"); | ||
|
||
public TBExpansion(TitansBattle plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean persist() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean canRegister() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public @NotNull String getIdentifier() { | ||
return plugin.getName().toLowerCase(); | ||
} | ||
|
||
@Override | ||
public @NotNull String getAuthor() { | ||
return plugin.getDescription().getAuthors().toString(); | ||
} | ||
|
||
@Override | ||
public @NotNull String getVersion() { | ||
return plugin.getDescription().getVersion(); | ||
} | ||
|
||
@Override | ||
public String onRequest(OfflinePlayer player, @NotNull String params) { | ||
Matcher matcher = PREFIX_PATTERN.matcher(params); | ||
if (player != null && matcher.find()) { | ||
String game = matcher.group("game"); | ||
String type = matcher.group("type").toLowerCase(); | ||
switch (type) { | ||
case "killer": | ||
return getKillerPrefix(player, game); | ||
case "winner": | ||
return getWinnerPrefix(player, game); | ||
} | ||
} | ||
return ""; | ||
} | ||
|
||
@NotNull | ||
public String getWinnerPrefix(@NotNull OfflinePlayer player, @NotNull String game) { | ||
GameConfiguration gameConfig = GameConfigurationDao.getInstance(plugin).getGameConfiguration(game); | ||
if (gameConfig == null) { | ||
return ""; | ||
} | ||
Winners latestWinners = plugin.getDatabaseManager().getLatestWinners(); | ||
List<UUID> playerWinners = latestWinners.getPlayerWinners(game); | ||
if (playerWinners == null || !playerWinners.contains(player.getUniqueId())) { | ||
return ""; | ||
} | ||
String prefix = gameConfig.getWinnerPrefix(); | ||
return prefix != null ? prefix : ""; | ||
} | ||
|
||
@NotNull | ||
public String getKillerPrefix(@NotNull OfflinePlayer player, @NotNull String game) { | ||
GameConfiguration gameConfig = GameConfigurationDao.getInstance(plugin).getGameConfiguration(game); | ||
if (gameConfig == null) { | ||
return ""; | ||
} | ||
Winners latestWinners = plugin.getDatabaseManager().getLatestWinners(); | ||
UUID killerUuid = latestWinners.getKiller(game); | ||
if (killerUuid == null || !killerUuid.equals(player.getUniqueId())) { | ||
return ""; | ||
} | ||
String prefix = gameConfig.getKillerPrefix(); | ||
return prefix != null ? prefix : ""; | ||
} | ||
} |
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.