Skip to content

Instantly share code, notes, and snippets.

@scarabcoder
Created May 24, 2018 16:20
Show Gist options
  • Save scarabcoder/54903c370c9c5b191aa6a8dfd3598bd7 to your computer and use it in GitHub Desktop.
Save scarabcoder/54903c370c9c5b191aa6a8dfd3598bd7 to your computer and use it in GitHub Desktop.
package net.yomnetwork.battleroyale2.player
import com.scarabcoder.commons.*
import com.scarabcoder.commons.config.configFriendlyName
import net.yomnetwork.battleroyale2.setup.DataFolders
import org.bukkit.configuration.file.FileConfiguration
import org.bukkit.configuration.file.YamlConfiguration
import java.io.File
enum class PlayerMessages(val default: String, vararg val placeholders: String) {
PLAYER_JOIN_LOBBY("${GREEN}{player} joined ({players}/{max})", "player", "players", "max"),
LOBBY_COUNTDOWN("${GREEN}Game starts in {time} seconds.", "time"),
STARTING_COUNTDOWN("${GREEN}Game starts in {time} seconds.", "time"),
LOOT_PERIOD_COUNTDOWN("${GREEN}PvP Enabled in {time} seconds.", "time"),
GAME_END_COUNTDOWN("${RED}GOvertime damage starts in {time} seconds!", "time"),
ALREADY_ON_TEAM("${RED}You must leave your current team before running this command!"),
MUST_BE_ON_TEAM("${RED}You must be on a team to use this command!"),
CREATED_TEAM("${RED}Created team {team}", "team"),
INVALID_COMMAND_MODE("${RED}You cannot use this command in {mode}.", "mode"),
AUTO_ADDED("${GREEN}You've automatically been added to the team {team}.", "team"),
LOOT_PERIOD_START("${GREEN}Grace period active! PvP enabled in {time}.", "time"),
LOOT_PERIOD_END("${RED}Loot period ended, PvP enabled!"),
OVERTIME_START("$RED${BOLD}Game has gone into overtime. Players will now start taking damage."),
GAME_OVER("$RED${BOLD}----- GAME OVER -----"),
WINNER_PLAYER("${DARK_AQUA}Player {player} eliminated all other players.", "player"),
WINNER_TEAM("${DARK_AQUA}Team {team} was victorious!", "team"),
REWARD("${GOLD}Win reward: {reward}", "reward"),
QUIT_LOBBY("$RED{player} left ({players}/{max})", "player", "players", "max"),
QUIT_INGAME("$RED{player} left the game.", "player"),
TEAM_CREATION_DISABLED("${RED}You cannot create teams in this mode."),
TEAM_INVITING_DISABLED("${RED}You cannot invite players to a team in this mode."),
TEAM_LEAVE_DISABLED("${RED}You cannot leave teams in this mode."),
TEAM_LEFT("${RED}Left team {team}.", "team"),
PLAYER_LEFT_TEAM("${RED}Player {player} left the team.", "player"),
CANNOT_USE_INGAME("${RED}You cannot run this command while ingame!"),
INVITED_PLAYER("${GREEN}You invited {player} to join {team}.", "player", "team"),
INVITED_BY_PLAYER("${GREEN}You were invited to join {team} by {player}", "team", "player"),
ALREADY_INVITED("${RED}You've already invited this player."),
TEAM_CHAT_ENABLED("${GREEN}Team chat toggled on."),
TEAM_CHAT_DISABLED("${RED}Team chat toggled off."),
LEADER_LEAVE_DISBAND("${RED}Team leader has left the team, disbanding the team."),
NEW_TEAM_LEADER("${GREEN}Team leader left the team, {player} has become team leader.", "player"),
LEAVE_BEFORE_JOIN("${RED}Leave your current team before joining another one."),
PLAYER_JOINED_TEAM("${GREEN}{player} joined your team.", "player"),
TEAM_MAX_CAPACITY("${RED}Cannot join this team, it has reached the maximum amount of members."),
JOINED_TEAM("${GREEN}You joined {team}.", "team"),
MAP_VOTES("${GREEN}This map has {votes} votes.", "votes"),
LEADER_ONLY("${RED}This command can only be used by the team leader."),
CANNOT_KICK_OTHER_PLAYER("${RED}{player} is not on your team.", "player"),
KICKED_PLAYER("${GREEN}Kicked {player} from the team.", "player"),
BEEN_KICKED("${RED}You've been kicked from the team."),
FORCE_MOVED("${GREEN}You were moved to {team} by a moderator.", "team"),
FORCE_REMOVE("${RED}You were taken out of your team by a moderator."),
GAME_PAUSED("${RED}${BOLD}The game has been paused by an admin."),
GAME_CONTINUED("${GREEN}The game has been continued!"),
KICK_SOON("${GOLD}You will be moved back to your previous server in {time} seconds...", "time"),
GANG_AUTO_INVITE("${GREEN}You've automatically been invited to your clan teammate {player}'s gang.", "player"),
AUTO_SENT_INVITE("${GREEN}Your clan teammate {member} has joined the game, an invite to your current team has been sent.", "member"),
KICKED_FOR_PRIORITY("${RED}You've been kicked to make room for a priority player."),
REFUNDED("${GREEN}You have been refunded \${amount}.", "amount"),
NOT_ENOUGH_PLAYERS("${RED}Not enough players to start game."),
ENOUGH_PLAYERS_IN_LOBBY("${GREEN}Player cap almost filled, timer decreased."),
MAP_VOTING_OVER("${GREEN}Map voting has finished, map {map} has been selected!", "map"),
NO_MAP_VOTING("${RED}You cannot vote for maps in this mode."),
TEAM_CREATE_DESC("Create a team."),
TEAM_INVITE_DESC("Invite a player to your team."),
TEAM_LEAVE_DESC("Leave your current team."),
TEAM_KICK("Kick a player from your team (leader only)."),
MAPVOTE_MAP("/mapvote");
fun build(vararg placeholders: Any): String {
var msg = default
for((index, placeholder) in this.placeholders.withIndex()){
msg = msg.replace("{$placeholder}", placeholders[index].toString())
}
return msg
}
companion object {
val msgFile = File(DataFolders.pluginFolder, "playermessages.yml")
val msgCfg: FileConfiguration
init {
if(!msgFile.exists()) msgFile.createNewFile()
msgCfg = YamlConfiguration.loadConfiguration(msgFile)
for(msg in PlayerMessages.values()){
msgCfg.addDefault(msg.name.configFriendlyName, msg.default)
}
msgCfg.options().copyDefaults(true)
msgCfg.save(msgFile)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment