diff --git a/build.gradle.kts b/build.gradle.kts index 91e888f36..61bcfcbe9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -44,7 +44,7 @@ dependencies { implementation("com.github.shynixn.mcutils:common:2024.19") implementation("com.github.shynixn.mcutils:packet:2024.32") implementation("com.github.shynixn.mcutils:database:2024.2") - implementation("com.github.shynixn.mcutils:sign:2024.2") + implementation("com.github.shynixn.mcutils:sign:2024.3") implementation("com.github.shynixn.mcutils:guice:2024.2") } @@ -207,20 +207,50 @@ tasks.register("pluginJarLegacy", ShadowJar::class.java) { tasks.register("languageFile") { val kotlinSrcFolder = project.sourceSets.toList()[0].allJava.srcDirs.first { e -> e.endsWith("java") } - val languageKotlinFile = kotlinSrcFolder.resolve("com/github/shynixn/blockball/BlockBallLanguage.kt") - val resourceFile = kotlinSrcFolder.parentFile.resolve("resources").resolve("lang").resolve("en_us.properties") - val bundle = FileInputStream(resourceFile).use { stream -> + + // Contract file + var languageKotlinFile = kotlinSrcFolder.resolve("com/github/shynixn/blockball/contract/BlockBallLanguage.kt") + var resourceFile = kotlinSrcFolder.parentFile.resolve("resources").resolve("lang").resolve("en_us.properties") + var bundle = FileInputStream(resourceFile).use { stream -> + PropertyResourceBundle(stream) + } + + var contents = ArrayList() + contents.add("package com.github.shynixn.blockball.contract") + contents.add("") + contents.add("interface BlockBallLanguage {") + for (key in bundle.keys) { + val value = bundle.getString(key) + contents.add(" /** $value **/") + contents.add(" var ${key} : String") + contents.add("") + } + contents.removeLast() + contents.add("}") + + languageKotlinFile.printWriter().use { out -> + for (line in contents) { + out.println(line) + } + } + + // Impl File + languageKotlinFile = kotlinSrcFolder.resolve("com/github/shynixn/blockball/BlockBallLanguageImpl.kt") + resourceFile = kotlinSrcFolder.parentFile.resolve("resources").resolve("lang").resolve("en_us.properties") + bundle = FileInputStream(resourceFile).use { stream -> PropertyResourceBundle(stream) } - val contents = ArrayList() + contents = ArrayList() contents.add("package com.github.shynixn.blockball") contents.add("") - contents.add("object BlockBallLanguage {") + contents.add("import com.github.shynixn.blockball.contract.BlockBallLanguage") + contents.add("") + contents.add("object BlockBallLanguageImpl : BlockBallLanguage {") for (key in bundle.keys) { val value = bundle.getString(key) contents.add(" /** $value **/") - contents.add(" var ${key} : String = \"$value\"") + contents.add(" override var ${key} : String = \"$value\"") contents.add("") } contents.removeLast() diff --git a/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt b/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt index 30e77eb88..c6f1b136f 100644 --- a/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt +++ b/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt @@ -2,7 +2,7 @@ package com.github.shynixn.blockball import com.fasterxml.jackson.core.type.TypeReference import com.github.shynixn.blockball.contract.* -import com.github.shynixn.blockball.entity.Arena +import com.github.shynixn.blockball.entity.SoccerArena import com.github.shynixn.blockball.entity.PlayerInformation import com.github.shynixn.blockball.impl.service.* import com.github.shynixn.mccoroutine.bukkit.launch @@ -54,14 +54,14 @@ class BlockBallDependencyInjectionModule( addService(plugin) // Repositories - val arenaRepository = YamlFileRepositoryImpl(plugin, "arena", + val arenaRepository = YamlFileRepositoryImpl(plugin, "soccerArena", listOf(Pair("arena_sample.yml", "arena_sample.yml")), listOf("arena_sample.yml"), - object : TypeReference() {} + object : TypeReference() {} ) val cacheArenaRepository = CachedRepositoryImpl(arenaRepository) - addService>(cacheArenaRepository) - addService>(cacheArenaRepository) + addService>(cacheArenaRepository) + addService>(cacheArenaRepository) val configSelectedPlayerDataRepository = ConfigSelectedRepositoryImpl( plugin, "BlockBall", @@ -75,9 +75,9 @@ class BlockBallDependencyInjectionModule( ) addService>(playerDataRepository) addService>(playerDataRepository) + addService(BlockBallLanguageImpl) // Services - addService() addService( com.github.shynixn.mcutils.common.command.CommandServiceImpl( object : CoroutineExecutor { @@ -94,9 +94,8 @@ class BlockBallDependencyInjectionModule( addService() addService(ItemServiceImpl()) addService(ChatMessageServiceImpl(plugin)) - addService() addService() - addService() + addService() addService() addService() diff --git a/src/main/java/com/github/shynixn/blockball/BlockBallLanguage.kt b/src/main/java/com/github/shynixn/blockball/BlockBallLanguage.kt deleted file mode 100644 index 2c0745f52..000000000 --- a/src/main/java/com/github/shynixn/blockball/BlockBallLanguage.kt +++ /dev/null @@ -1,162 +0,0 @@ -package com.github.shynixn.blockball - -object BlockBallLanguage { - /** &cTeam Red **/ - var teamRedDrawTitle : String = "&cTeam Red" - - /** %blockball_game_displayName% **/ - var teamSignLine2 : String = "%blockball_game_displayName%" - - /** %blockball_team_color%%blockball_team_name% **/ - var teamSignLine3 : String = "%blockball_team_color%%blockball_team_name%" - - /** %blockball_team_players%/%blockball_team_maxPlayers% **/ - var teamSignLine4 : String = "%blockball_team_players%/%blockball_team_maxPlayers%" - - /** &eMatch ended in a draw **/ - var teamBlueDrawSubTitle : String = "&eMatch ended in a draw" - - /** &lBlockBall **/ - var teamSignLine1 : String = "&lBlockBall" - - /** &a[Start spectating] **/ - var spectateJoinClick : String = "&a[Start spectating]" - - /** Rightclick on a sign. **/ - var rightClickOnSign : String = "Rightclick on a sign." - - /** &lBlockBall **/ - var joinSignLine1 : String = "&lBlockBall" - - /** %blockball_game_displayName% **/ - var joinSignLine2 : String = "%blockball_game_displayName%" - - /** &1Running **/ - var gameStatusRunning : String = "&1Running" - - /** &cTeam Red &ahas won the match **/ - var teamRedWinSubTitle : String = "&cTeam Red &ahas won the match" - - /** &9Team Blue **/ - var teamBlueWinTitle : String = "&9Team Blue" - - /** %blockball_game_stateDisplayName% **/ - var joinSignLine3 : String = "%blockball_game_stateDisplayName%" - - /** Save and reload to enable the sign. **/ - var saveAndReloadSign : String = "Save and reload to enable the sign." - - /** %blockball_game_players%/%blockball_game_maxPlayers% **/ - var joinSignLine4 : String = "%blockball_game_players%/%blockball_game_maxPlayers%" - - /** Stopped game %1$1s named %2$1s. **/ - var stopGameMessage : String = "Stopped game %1$1s named %2$1s." - - /** &c[Team Red] **/ - var hubGameJoinRed : String = "&c[Team Red]" - - /** &9 **/ - var teamBlueColor : String = "&9" - - /** &lBlockBall **/ - var leaveSignLine1 : String = "&lBlockBall" - - /** %blockball_game_displayName% **/ - var leaveSignLine2 : String = "%blockball_game_displayName%" - - /** &fLeave **/ - var leaveSignLine3 : String = "&fLeave" - - /** %blockball_game_players%/%blockball_game_maxPlayers% **/ - var leaveSignLine4 : String = "%blockball_game_players%/%blockball_game_maxPlayers%" - - /** &cYou do not have permission to join this game. **/ - var joinNoPermission : String = "&cYou do not have permission to join this game." - - /** &9Team Blue **/ - var teamBlueDrawTitle : String = "&9Team Blue" - - /** &9Team Blue &ahas won the match **/ - var teamBlueWinSubTitle : String = "&9Team Blue &ahas won the match" - - /** &cYou do not have permission to spectate this game. **/ - var spectateNoPermission : String = "&cYou do not have permission to spectate this game." - - /** &aWaiting for players... **/ - var bungeeCordMotdJoinAble : String = "&aWaiting for players..." - - /** Click on the team to join the match. **/ - var hubGameJoinHeader : String = "Click on the team to join the match." - - /** &cTeam Red %blockball_game_redScore% : &9%blockball_game_blueScore% Team Blue **/ - var bossBarMessage : String = "&cTeam Red %blockball_game_redScore% : &9%blockball_game_blueScore% Team Blue" - - /** Shynixn **/ - var translator : String = "Shynixn" - - /** You have left the game. **/ - var bungeeCordLeaveMessage : String = "You have left the game." - - /** &aJoin **/ - var gameStatusJoinAble : String = "&aJoin" - - /** &aWaiting for &c %blockball_game_remainingPlayers% &a more player(s)... **/ - var miniGameRemainingPlayers : String = "&aWaiting for &c %blockball_game_remainingPlayers% &a more player(s)..." - - /** &eMatch ended in a draw **/ - var teamRedDrawSubTitle : String = "&eMatch ended in a draw" - - /** &9[Team Blue] **/ - var hubGameJoinBlue : String = "&9[Team Blue]" - - /** You have joined the game for %blockball_team_color%%blockball_team_name%. **/ - var joinSuccessMessage : String = "You have joined the game for %blockball_team_color%%blockball_team_name%." - - /** &0&l[&f&lBlockBall&0&l]&7 You have left the game. **/ - var leaveMessage : String = "&0&l[&f&lBlockBall&0&l]&7 You have left the game." - - /** &cTeam Red **/ - var teamRedWinTitle : String = "&cTeam Red" - - /** &9%blockball_game_blueScore% : &c%blockball_game_redScore% **/ - var teamBlueScoreTitle : String = "&9%blockball_game_blueScore% : &c%blockball_game_redScore%" - - /** &9%blockball_game_lastHitPlayerName% scored for %blockball_game_blueName% **/ - var teamBlueScoreSubTitle : String = "&9%blockball_game_lastHitPlayerName% scored for %blockball_game_blueName%" - - /** &9Ingame% **/ - var bungeeCordMotdRunning : String = "&9Ingame%" - - /** &cRestarting... **/ - var bungeeCordMotdRestarting : String = "&cRestarting..." - - /** Team Red **/ - var teamRedDisplayName : String = "Team Red" - - /** &c **/ - var teamRedColor : String = "&c" - - /** &4Disabled **/ - var gameStatusDisabled : String = "&4Disabled" - - /** &cTeam Red %blockball_game_redScore% : &9Team Blue %blockball_game_blueScore% **/ - var hologramMessage : String = "&cTeam Red %blockball_game_redScore% : &9Team Blue %blockball_game_blueScore%" - - /** &0&l[&f&lBlockBall&0&l]&7 &aReloaded BlockBall. **/ - var reloadMessage : String = "&0&l[&f&lBlockBall&0&l]&7 &aReloaded BlockBall." - - /** &c%blockball_game_redScore% : &9%blockball_game_blueScore% **/ - var teamRedScoreTitle : String = "&c%blockball_game_redScore% : &9%blockball_game_blueScore%" - - /** &c%blockball_game_lastHitPlayerName% scored for %blockball_game_redName% **/ - var teamRedScoreSubTitle : String = "&c%blockball_game_lastHitPlayerName% scored for %blockball_game_redName%" - - /** Game is full! Do you want to spectate? **/ - var spectateJoinHeader : String = "Game is full! Do you want to spectate?" - - /** Team Blue **/ - var teamBlueDisplayName : String = "Team Blue" - - /** Server is already full. **/ - var bungeeCordKickMessage : String = "Server is already full." -} diff --git a/src/main/java/com/github/shynixn/blockball/BlockBallLanguageImpl.kt b/src/main/java/com/github/shynixn/blockball/BlockBallLanguageImpl.kt new file mode 100644 index 000000000..91db0f01c --- /dev/null +++ b/src/main/java/com/github/shynixn/blockball/BlockBallLanguageImpl.kt @@ -0,0 +1,173 @@ +package com.github.shynixn.blockball + +import com.github.shynixn.blockball.contract.BlockBallLanguage + +object BlockBallLanguageImpl : BlockBallLanguage { + /** %2$1s scored for &cTeam Red. **/ + override var scoreRedSubTitle : String = "%2$1s scored for &cTeam Red." + + /** &9&l%1$1s **/ + override var scoreBlueTitle : String = "&9&l%1$1s" + + /** &cTeam Red **/ + override var winRedTitle : String = "&cTeam Red" + + /** &0&l[&f&lBlockBall&0&l]&c Game %1$1s already exists. **/ + override var gameAlreadyExistsMessage : String = "&0&l[&f&lBlockBall&0&l]&c Game %1$1s already exists." + + /** &0&l[&f&lBlockBall&0&l]&7 Successfully joined team blue. **/ + override var joinTeamBlueMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Successfully joined team blue." + + /** &0&l[&f&lBlockBall&0&l]&c Team %1$1s does not exist. **/ + override var teamDoesNotExistMessage : String = "&0&l[&f&lBlockBall&0&l]&c Team %1$1s does not exist." + + /** &0&l[&f&lBlockBall&0&l]&7 Reloaded game %1$1s. **/ + override var reloadedGameMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Reloaded game %1$1s." + + /** &0&l[&f&lBlockBall&0&l]&7 A sign was added to the game. **/ + override var addedSignMessage : String = "&0&l[&f&lBlockBall&0&l]&7 A sign was added to the game." + + /** &9Team Blue &ahas won the match **/ + override var winBlueSubTitle : String = "&9Team Blue &ahas won the match" + + /** &0&l[&f&lBlockBall&0&l]&7 Left the game. **/ + override var leftGameMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Left the game." + + /** &0&l[&f&lBlockBall&0&l]&7 Reloaded all games. **/ + override var reloadedAllGamesMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Reloaded all games." + + /** 20 **/ + override var scoreRedFadeIn : String = "20" + + /** &1Running **/ + override var gameStatusRunning : String = "&1Running" + + /** &0&l[&f&lBlockBall&0&l]&c You do not have permission to join game %1$1s. **/ + override var noPermissionForGameMessage : String = "&0&l[&f&lBlockBall&0&l]&c You do not have permission to join game %1$1s." + + /** &0&l[&f&lBlockBall&0&l]&7 Updated armor of game. **/ + override var updatedArmorMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Updated armor of game." + + /** 20 **/ + override var winBlueFadeOut : String = "20" + + /** &0&l[&f&lBlockBall&0&l]&7 Use /blockball help to see more info about the plugin. **/ + override var commandUsage : String = "&0&l[&f&lBlockBall&0&l]&7 Use /blockball help to see more info about the plugin." + + /** &0&l[&f&lBlockBall&0&l]&7 RightClick on a sign to convert it into a game sign. **/ + override var rightClickOnSignMessage : String = "&0&l[&f&lBlockBall&0&l]&7 RightClick on a sign to convert it into a game sign." + + /** &c&l%1$1s **/ + override var scoreRedTitle : String = "&c&l%1$1s" + + /** &c[Team Red] **/ + override var hubGameJoinRed : String = "&c[Team Red]" + + /** 20 **/ + override var winRedFadeIn : String = "20" + + /** 60 **/ + override var winBlueStay : String = "60" + + /** &0&l[&f&lBlockBall&0&l]&7 Created game %1$1s. **/ + override var gameCreatedMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Created game %1$1s." + + /** 20 **/ + override var winDrawFadeOut : String = "20" + + /** 20 **/ + override var scoreBlueFadeOut : String = "20" + + /** 20 **/ + override var scoreRedFadeOut : String = "20" + + /** 20 **/ + override var winBlueFadeIn : String = "20" + + /** 60 **/ + override var winRedStay : String = "60" + + /** 60 **/ + override var scoreRedStay : String = "60" + + /** All commands for the BlockBall plugin. **/ + override var commandDescription : String = "All commands for the BlockBall plugin." + + /** &0&l[&f&lBlockBall&0&l]&c This location type is not known. For more locations, open the arena.yml. **/ + override var locationTypeDoesNotExistMessage : String = "&0&l[&f&lBlockBall&0&l]&c This location type is not known. For more locations, open the arena.yml." + + /** &0&l[&f&lBlockBall&0&l]&c You do not have permission. **/ + override var noPermissionMessage : String = "&0&l[&f&lBlockBall&0&l]&c You do not have permission." + + /** &0&l[&f&lBlockBall&0&l]&7 Game enable state was set to %1$1s. **/ + override var enabledArenaMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Game enable state was set to %1$1s." + + /** &cTeam Red &ahas won the match **/ + override var winRedSubTitle : String = "&cTeam Red &ahas won the match" + + /** Click on the team to join the match. **/ + override var hubGameJoinHeader : String = "Click on the team to join the match." + + /** &0&l[&f&lBlockBall&0&l]&c The text length has to be less than 20 characters. **/ + override var maxLength20Characters : String = "&0&l[&f&lBlockBall&0&l]&c The text length has to be less than 20 characters." + + /** &0&l[&f&lBlockBall&0&l]&c This sign type is not known. **/ + override var signTypeDoesNotExistMessage : String = "&0&l[&f&lBlockBall&0&l]&c This sign type is not known." + + /** %2$1s scored for &9Team Blue. **/ + override var scoreBlueSubTitle : String = "%2$1s scored for &9Team Blue." + + /** &0&l[&f&lBlockBall&0&l]&7 Successfully joined team red. **/ + override var joinTeamRedMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Successfully joined team red." + + /** &aJoin **/ + override var gameStatusJoinAble : String = "&aJoin" + + /** &0&l[&f&lBlockBall&0&l]&c Game %1$1s does not exist. **/ + override var gameDoesNotExistMessage : String = "&0&l[&f&lBlockBall&0&l]&c Game %1$1s does not exist." + + /** &0&l[&f&lBlockBall&0&l]&7 Deleted game %1$1s. **/ + override var deletedGameMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Deleted game %1$1s." + + /** &0&l[&f&lBlockBall&0&l]&c Game is already full. **/ + override var gameIsFullMessage : String = "&0&l[&f&lBlockBall&0&l]&c Game is already full." + + /** &9[Team Blue] **/ + override var hubGameJoinBlue : String = "&9[Team Blue]" + + /** &9Team Blue **/ + override var winBlueTitle : String = "&9Team Blue" + + /** 60 **/ + override var winDrawStay : String = "60" + + /** &4Disabled **/ + override var gameStatusDisabled : String = "&4Disabled" + + /** &0&l[&f&lBlockBall&0&l]&7 Updated inventory of game. **/ + override var updatedInventoryMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Updated inventory of game." + + /** &0&l[&f&lBlockBall&0&l]&7 Location %1$1s was set on %2$1s. **/ + override var spawnPointSetMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Location %1$1s was set on %2$1s." + + /** 20 **/ + override var scoreBlueFadeIn : String = "20" + + /** &aThe game has ended in a draw **/ + override var winDrawSubTitle : String = "&aThe game has ended in a draw" + + /** &0&l[&f&lBlockBall&0&l]&c The command sender has to be a player! **/ + override var commandSenderHasToBePlayer : String = "&0&l[&f&lBlockBall&0&l]&c The command sender has to be a player!" + + /** 20 **/ + override var winRedFadeOut : String = "20" + + /** 20 **/ + override var winDrawFadeIn : String = "20" + + /** &fDraw **/ + override var winDrawTitle : String = "&fDraw" + + /** 60 **/ + override var scoreBlueStay : String = "60" +} diff --git a/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt b/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt index 5d0d013a8..241b9a657 100644 --- a/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt +++ b/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt @@ -1,24 +1,28 @@ package com.github.shynixn.blockball -import com.github.shynixn.blockball.contract.CommandService import com.github.shynixn.blockball.contract.GameService +import com.github.shynixn.blockball.contract.PlaceHolderService +import com.github.shynixn.blockball.contract.SoccerBallFactory import com.github.shynixn.blockball.entity.PlayerInformation -import com.github.shynixn.blockball.impl.commandexecutor.* +import com.github.shynixn.blockball.entity.SoccerArena +import com.github.shynixn.blockball.impl.commandexecutor.BlockBallCommandExecutor import com.github.shynixn.blockball.impl.listener.* import com.github.shynixn.mccoroutine.bukkit.launch import com.github.shynixn.mcutils.common.ChatColor import com.github.shynixn.mcutils.common.ConfigurationService import com.github.shynixn.mcutils.common.Version import com.github.shynixn.mcutils.common.reloadTranslation +import com.github.shynixn.mcutils.common.repository.Repository import com.github.shynixn.mcutils.database.api.CachePlayerRepository import com.github.shynixn.mcutils.database.api.PlayerDataRepository import com.github.shynixn.mcutils.guice.DependencyInjectionModule import com.github.shynixn.mcutils.packet.api.PacketInType import com.github.shynixn.mcutils.packet.api.PacketService +import com.github.shynixn.mcutils.sign.SignService import kotlinx.coroutines.runBlocking import org.bstats.bukkit.Metrics import org.bukkit.Bukkit -import org.bukkit.configuration.MemorySection +import org.bukkit.plugin.ServicePriority import org.bukkit.plugin.java.JavaPlugin import java.util.logging.Level @@ -27,11 +31,7 @@ import java.util.logging.Level * @author Shynixn */ class BlockBallPlugin : JavaPlugin() { - companion object { - /** Final Prefix of BlockBall in the console */ - val PREFIX_CONSOLE: String = ChatColor.BLUE.toString() + "[BlockBall] " - } - + private val prefix: String = ChatColor.BLUE.toString() + "[BlockBall] " private val bstatsPluginId = 1317 private lateinit var module: DependencyInjectionModule private var immidiateDisable = false @@ -40,7 +40,7 @@ class BlockBallPlugin : JavaPlugin() { * Enables the plugin BlockBall. */ override fun onEnable() { - Bukkit.getServer().consoleSender.sendMessage(PREFIX_CONSOLE + ChatColor.GREEN + "Loading BlockBall ...") + Bukkit.getServer().consoleSender.sendMessage(prefix + ChatColor.GREEN + "Loading BlockBall ...") this.saveDefaultConfig() val versions = if (BlockBallDependencyInjectionModule.areLegacyVersionsIncluded) { arrayOf( @@ -91,6 +91,9 @@ class BlockBallPlugin : JavaPlugin() { this.module = BlockBallDependencyInjectionModule(this).build() this.reloadConfig() + // Register Packet + module.getService().registerPacketListening(PacketInType.USEENTITY) + // Register Listeners Bukkit.getPluginManager().registerEvents(module.getService(), this) Bukkit.getPluginManager().registerEvents(module.getService(), this) @@ -99,37 +102,33 @@ class BlockBallPlugin : JavaPlugin() { Bukkit.getPluginManager().registerEvents(module.getService(), this) Bukkit.getPluginManager().registerEvents(module.getService(), this) - val configurationService = module.getService() - val enableMetrics = configurationService.findValue("metrics") - // Register CommandExecutor - val commandService = module.getService() - commandService.registerCommandExecutor("blockballstop", module.getService()) - commandService.registerCommandExecutor("blockballreload", module.getService()) - commandService.registerCommandExecutor("blockball", module.getService()) - commandService.registerCommandExecutor( - (config.get("global-spectate") as MemorySection).getValues(false) as Map, - module.getService() - ) - commandService.registerCommandExecutor( - (config.get("global-leave") as MemorySection).getValues(false) as Map, - module.getService() - ) - commandService.registerCommandExecutor( - (config.get("global-join") as MemorySection).getValues(false) as Map, - module.getService() + module.getService() + + // Service dependencies + Bukkit.getServicesManager().register( + SoccerBallFactory::class.java, + module.getService(), + this, + ServicePriority.Normal ) - - if (enableMetrics) { - Metrics(this, bstatsPluginId) - } - - module.getService().registerPacketListening(PacketInType.USEENTITY) + Bukkit.getServicesManager() + .register(GameService::class.java, module.getService(), this, ServicePriority.Normal) val plugin = this plugin.launch { + val configurationService = module.getService() + + // Enable Metrics + val enableMetrics = configurationService.findValue("metrics") + + if (enableMetrics) { + Metrics(plugin, bstatsPluginId) + } + + // Load Language val language = configurationService.findValue("language") - plugin.reloadTranslation(language, BlockBallLanguage::class.java, "en_us") + plugin.reloadTranslation(language, BlockBallLanguageImpl::class.java, "en_us") logger.log(Level.INFO, "Loaded language file $language.properties.") // Load Games @@ -147,13 +146,57 @@ class BlockBallPlugin : JavaPlugin() { return@launch } + // Load Signs + val placeHolderService = module.getService() + val signService = module.getService() + val arenaService = module.getService>() + signService.onSignDestroy = { signMeta -> + plugin.launch { + val arenas = arenaService.getAll() + for (arena in arenas) { + for (signToRemove in arena.meta.lobbyMeta.joinSigns.filter { e -> e.isSameSign(signMeta) }) { + arena.meta.lobbyMeta.joinSigns.remove(signToRemove) + arenaService.save(arena) + } + for (signToRemove in arena.meta.lobbyMeta.leaveSigns.filter { e -> e.isSameSign(signMeta) }) { + arena.meta.lobbyMeta.leaveSigns.remove(signToRemove) + arenaService.save(arena) + } + for (signToRemove in arena.meta.redTeamMeta.teamSigns.filter { e -> e.isSameSign(signMeta) }) { + arena.meta.lobbyMeta.joinSigns.remove(signToRemove) + arenaService.save(arena) + } + for (signToRemove in arena.meta.blueTeamMeta.teamSigns.filter { e -> e.isSameSign(signMeta) }) { + arena.meta.lobbyMeta.leaveSigns.remove(signToRemove) + arenaService.save(arena) + } + } + } + } + signService.onPlaceHolderResolve = { signMeta, text -> + var resolvedText: String? = null + + if (signMeta.tag != null) { + val game = gameService.getByName(signMeta.tag!!) + if (game != null) { + resolvedText = placeHolderService.replacePlaceHolders(text, null, game) + } + } + + if (resolvedText == null) { + resolvedText = placeHolderService.replacePlaceHolders(text) + } + + resolvedText + } + val playerDataRepository = module.getService>() for (player in Bukkit.getOnlinePlayers()) { playerDataRepository.getByPlayer(player) } Bukkit.getServer() - .consoleSender.sendMessage(PREFIX_CONSOLE + ChatColor.GREEN + "Enabled BlockBall " + plugin.description.version + " by Shynixn") + .consoleSender.sendMessage(prefix + ChatColor.GREEN + "Enabled BlockBall " + plugin.description.version + " by Shynixn") } } @@ -180,11 +223,4 @@ class BlockBallPlugin : JavaPlugin() { // Ignored. } } - - /** - * Shutdowns the server. - */ - fun shutdownServer() { - Bukkit.getServer().shutdown() - } } diff --git a/src/main/java/com/github/shynixn/blockball/contract/BlockBallLanguage.kt b/src/main/java/com/github/shynixn/blockball/contract/BlockBallLanguage.kt new file mode 100644 index 000000000..31bab7f6d --- /dev/null +++ b/src/main/java/com/github/shynixn/blockball/contract/BlockBallLanguage.kt @@ -0,0 +1,171 @@ +package com.github.shynixn.blockball.contract + +interface BlockBallLanguage { + /** %2$1s scored for &cTeam Red. **/ + var scoreRedSubTitle : String + + /** &9&l%1$1s **/ + var scoreBlueTitle : String + + /** &cTeam Red **/ + var winRedTitle : String + + /** &0&l[&f&lBlockBall&0&l]&c Game %1$1s already exists. **/ + var gameAlreadyExistsMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 Successfully joined team blue. **/ + var joinTeamBlueMessage : String + + /** &0&l[&f&lBlockBall&0&l]&c Team %1$1s does not exist. **/ + var teamDoesNotExistMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 Reloaded game %1$1s. **/ + var reloadedGameMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 A sign was added to the game. **/ + var addedSignMessage : String + + /** &9Team Blue &ahas won the match **/ + var winBlueSubTitle : String + + /** &0&l[&f&lBlockBall&0&l]&7 Left the game. **/ + var leftGameMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 Reloaded all games. **/ + var reloadedAllGamesMessage : String + + /** 20 **/ + var scoreRedFadeIn : String + + /** &1Running **/ + var gameStatusRunning : String + + /** &0&l[&f&lBlockBall&0&l]&c You do not have permission to join game %1$1s. **/ + var noPermissionForGameMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 Updated armor of game. **/ + var updatedArmorMessage : String + + /** 20 **/ + var winBlueFadeOut : String + + /** &0&l[&f&lBlockBall&0&l]&7 Use /blockball help to see more info about the plugin. **/ + var commandUsage : String + + /** &0&l[&f&lBlockBall&0&l]&7 RightClick on a sign to convert it into a game sign. **/ + var rightClickOnSignMessage : String + + /** &c&l%1$1s **/ + var scoreRedTitle : String + + /** &c[Team Red] **/ + var hubGameJoinRed : String + + /** 20 **/ + var winRedFadeIn : String + + /** 60 **/ + var winBlueStay : String + + /** &0&l[&f&lBlockBall&0&l]&7 Created game %1$1s. **/ + var gameCreatedMessage : String + + /** 20 **/ + var winDrawFadeOut : String + + /** 20 **/ + var scoreBlueFadeOut : String + + /** 20 **/ + var scoreRedFadeOut : String + + /** 20 **/ + var winBlueFadeIn : String + + /** 60 **/ + var winRedStay : String + + /** 60 **/ + var scoreRedStay : String + + /** All commands for the BlockBall plugin. **/ + var commandDescription : String + + /** &0&l[&f&lBlockBall&0&l]&c This location type is not known. For more locations, open the arena.yml. **/ + var locationTypeDoesNotExistMessage : String + + /** &0&l[&f&lBlockBall&0&l]&c You do not have permission. **/ + var noPermissionMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 Game enable state was set to %1$1s. **/ + var enabledArenaMessage : String + + /** &cTeam Red &ahas won the match **/ + var winRedSubTitle : String + + /** Click on the team to join the match. **/ + var hubGameJoinHeader : String + + /** &0&l[&f&lBlockBall&0&l]&c The text length has to be less than 20 characters. **/ + var maxLength20Characters : String + + /** &0&l[&f&lBlockBall&0&l]&c This sign type is not known. **/ + var signTypeDoesNotExistMessage : String + + /** %2$1s scored for &9Team Blue. **/ + var scoreBlueSubTitle : String + + /** &0&l[&f&lBlockBall&0&l]&7 Successfully joined team red. **/ + var joinTeamRedMessage : String + + /** &aJoin **/ + var gameStatusJoinAble : String + + /** &0&l[&f&lBlockBall&0&l]&c Game %1$1s does not exist. **/ + var gameDoesNotExistMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 Deleted game %1$1s. **/ + var deletedGameMessage : String + + /** &0&l[&f&lBlockBall&0&l]&c Game is already full. **/ + var gameIsFullMessage : String + + /** &9[Team Blue] **/ + var hubGameJoinBlue : String + + /** &9Team Blue **/ + var winBlueTitle : String + + /** 60 **/ + var winDrawStay : String + + /** &4Disabled **/ + var gameStatusDisabled : String + + /** &0&l[&f&lBlockBall&0&l]&7 Updated inventory of game. **/ + var updatedInventoryMessage : String + + /** &0&l[&f&lBlockBall&0&l]&7 Location %1$1s was set on %2$1s. **/ + var spawnPointSetMessage : String + + /** 20 **/ + var scoreBlueFadeIn : String + + /** &aThe game has ended in a draw **/ + var winDrawSubTitle : String + + /** &0&l[&f&lBlockBall&0&l]&c The command sender has to be a player! **/ + var commandSenderHasToBePlayer : String + + /** 20 **/ + var winRedFadeOut : String + + /** 20 **/ + var winDrawFadeIn : String + + /** &fDraw **/ + var winDrawTitle : String + + /** 60 **/ + var scoreBlueStay : String +} diff --git a/src/main/java/com/github/shynixn/blockball/contract/BlockBallMiniGame.kt b/src/main/java/com/github/shynixn/blockball/contract/BlockBallMiniGame.kt deleted file mode 100644 index 8edac94e9..000000000 --- a/src/main/java/com/github/shynixn/blockball/contract/BlockBallMiniGame.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.github.shynixn.blockball.contract - -import org.bukkit.entity.Player - -interface BlockBallMiniGame : BlockBallGame { - /** - * Actual game coutndown. - */ - var gameCountdown: Int - - /** - * List of players which are spectating the game. - */ - val spectatorPlayers: List - - /** - * Index of the current match time. - */ - var matchTimeIndex: Int - - /** - * Actives the next match time. Closes the match if no match time is available. - */ - fun switchToNextMatchTime() - - /** - * Lets the given [player] leave spectate the given [game]. - * Does nothing if the player is already spectating a Game. - */ - fun spectate(player: Player) -} diff --git a/src/main/java/com/github/shynixn/blockball/contract/CommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/contract/CommandExecutor.kt deleted file mode 100644 index 75af6577e..000000000 --- a/src/main/java/com/github/shynixn/blockball/contract/CommandExecutor.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.github.shynixn.blockball.contract - -import org.bukkit.command.CommandSender - -interface CommandExecutor { - /** - * Gets called when the given [source] executes the defined command with the given [args]. - */ - fun onExecuteCommand(source: CommandSender, args: Array): Boolean -} diff --git a/src/main/java/com/github/shynixn/blockball/contract/CommandService.kt b/src/main/java/com/github/shynixn/blockball/contract/CommandService.kt deleted file mode 100644 index 74093a914..000000000 --- a/src/main/java/com/github/shynixn/blockball/contract/CommandService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.shynixn.blockball.contract - -interface CommandService { - /** - * Registers a command executor from a pre defined [command] with gets executed by the [commandExecutor]. - */ - fun registerCommandExecutor(command: String, commandExecutor: CommandExecutor) - - /** - * Registers a command executor from new [commandConfiguration] with gets executed by the [commandExecutor]. - */ - fun registerCommandExecutor(commandConfiguration: Map, commandExecutor: CommandExecutor) -} diff --git a/src/main/java/com/github/shynixn/blockball/contract/GameService.kt b/src/main/java/com/github/shynixn/blockball/contract/GameService.kt index d43ef5380..9e77f30f5 100644 --- a/src/main/java/com/github/shynixn/blockball/contract/GameService.kt +++ b/src/main/java/com/github/shynixn/blockball/contract/GameService.kt @@ -1,41 +1,36 @@ package com.github.shynixn.blockball.contract -import org.bukkit.Location +import com.github.shynixn.blockball.entity.SoccerArena import org.bukkit.entity.Player -interface GameService : AutoCloseable { +interface GameService { /** * Reloads all games. */ suspend fun reloadAll() /** - * Returns the game if the given [player] is playing a game. + * Reloads the specific game. */ - fun getGameFromPlayer(player: Player): BlockBallGame? + suspend fun reload(arena: SoccerArena) /** - * Returns the game if the given [player] is spectating a game. + * Gets all running games. */ - fun getGameFromSpectatingPlayer(player: Player):BlockBallGame? + fun getAll(): List /** - * Returns the game at the given location. + * Tries to locate a game this player is playing. */ - fun getGameFromLocation(location: Location): BlockBallGame? + fun getByPlayer(player: Player): SoccerGame? /** - * Returns the game with the given name or displayName. + * Tries to locate a game of the given name. */ - fun getGameFromName(name: String): BlockBallGame? + fun getByName(name: String): SoccerGame? /** - * Returns all currently loaded games on the server. + * Disposes all running games. */ - fun getAllGames(): List - - /** - * Closes all games permanently and should be executed on server shutdown. - */ - override fun close() + fun close() } diff --git a/src/main/java/com/github/shynixn/blockball/contract/PlaceHolderService.kt b/src/main/java/com/github/shynixn/blockball/contract/PlaceHolderService.kt index 5d0c846d6..6000e8923 100644 --- a/src/main/java/com/github/shynixn/blockball/contract/PlaceHolderService.kt +++ b/src/main/java/com/github/shynixn/blockball/contract/PlaceHolderService.kt @@ -7,5 +7,5 @@ interface PlaceHolderService { /** * Replaces the given text with properties from the given [game], optional [teamMeta] and optional size. */ - fun replacePlaceHolders(text: String, player : Player? = null, game: BlockBallGame? = null, teamMeta: TeamMeta? = null, currentTeamSize: Int? = null): String + fun replacePlaceHolders(text: String, player : Player? = null, game: SoccerGame? = null, teamMeta: TeamMeta? = null, currentTeamSize: Int? = null): String } diff --git a/src/main/java/com/github/shynixn/blockball/contract/RightclickManageService.kt b/src/main/java/com/github/shynixn/blockball/contract/RightclickManageService.kt deleted file mode 100644 index 75447bab5..000000000 --- a/src/main/java/com/github/shynixn/blockball/contract/RightclickManageService.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.github.shynixn.blockball.contract - -import org.bukkit.Location -import org.bukkit.entity.Player - -interface RightclickManageService { - /** - * Gets called one time when a location gets rightlicked by [player]. - */ - fun watchForNextRightClickSign(player: Player, f: (Location) -> Unit) - - /** - * Executes the watcher for the given [player] if he has registered one. - * Returns if watchers has been executed. - */ - fun executeWatchers(player: Player, location: Location): Boolean - - /** - * Clears all resources this [player] has allocated from this service. - */ - fun cleanResources(player: Player) -} diff --git a/src/main/java/com/github/shynixn/blockball/contract/Ball.kt b/src/main/java/com/github/shynixn/blockball/contract/SoccerBall.kt similarity index 93% rename from src/main/java/com/github/shynixn/blockball/contract/Ball.kt rename to src/main/java/com/github/shynixn/blockball/contract/SoccerBall.kt index 0fa18cc50..99d820746 100644 --- a/src/main/java/com/github/shynixn/blockball/contract/Ball.kt +++ b/src/main/java/com/github/shynixn/blockball/contract/SoccerBall.kt @@ -3,13 +3,12 @@ package com.github.shynixn.blockball.contract import com.github.shynixn.blockball.entity.BallMeta import org.bukkit.Location import org.bukkit.entity.Player -import org.bukkit.util.EulerAngle import org.bukkit.util.Vector /** - * Ball interface of the complex ball entity. + * SoccerBall interface of the complex ball entity. */ -interface Ball { +interface SoccerBall { /** * Gets the meta data. */ diff --git a/src/main/java/com/github/shynixn/blockball/contract/BallEntityService.kt b/src/main/java/com/github/shynixn/blockball/contract/SoccerBallFactory.kt similarity index 50% rename from src/main/java/com/github/shynixn/blockball/contract/BallEntityService.kt rename to src/main/java/com/github/shynixn/blockball/contract/SoccerBallFactory.kt index 476c88f10..0132bba9a 100644 --- a/src/main/java/com/github/shynixn/blockball/contract/BallEntityService.kt +++ b/src/main/java/com/github/shynixn/blockball/contract/SoccerBallFactory.kt @@ -3,25 +3,24 @@ package com.github.shynixn.blockball.contract import com.github.shynixn.blockball.entity.BallMeta import org.bukkit.Location -interface BallEntityService : AutoCloseable{ +interface SoccerBallFactory : AutoCloseable { /** - * Spawns a temporary ball. - * Returns a ball or null if the ball spawn event was cancelled. + * Creates a new SoccerBall. */ - fun spawnTemporaryBall(location: Location, meta: BallMeta): Ball? + fun createSoccerBall(location: Location, meta: BallMeta): SoccerBall /** * Tries to locate the ball by the given id. */ - fun findBallByEntityId(id: Int): Ball? + fun findBallByEntityId(id: Int): SoccerBall? /** * Disables a ball from tracking. */ - fun removeTrackedBall(ball: Ball) + fun removeTrackedBall(ball: SoccerBall) /** * Returns all balls managed by the plugin. */ - fun getAllBalls(): List + fun getAllBalls(): List } diff --git a/src/main/java/com/github/shynixn/blockball/contract/BlockBallGame.kt b/src/main/java/com/github/shynixn/blockball/contract/SoccerGame.kt similarity index 85% rename from src/main/java/com/github/shynixn/blockball/contract/BlockBallGame.kt rename to src/main/java/com/github/shynixn/blockball/contract/SoccerGame.kt index d8c5d967a..54e350747 100644 --- a/src/main/java/com/github/shynixn/blockball/contract/BlockBallGame.kt +++ b/src/main/java/com/github/shynixn/blockball/contract/SoccerGame.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.contract -import com.github.shynixn.blockball.entity.Arena +import com.github.shynixn.blockball.entity.SoccerArena import com.github.shynixn.blockball.entity.GameStorage import com.github.shynixn.blockball.enumeration.GameState import com.github.shynixn.blockball.enumeration.JoinResult @@ -8,16 +8,16 @@ import com.github.shynixn.blockball.enumeration.LeaveResult import com.github.shynixn.blockball.enumeration.Team import org.bukkit.entity.Player -interface BlockBallGame { +interface SoccerGame { /** * Player who was the last one to hit the ball. */ var lastHitPlayer: Player? /** - * Gets the arena. + * Gets the soccerArena. */ - val arena: Arena + val arena: SoccerArena /** * RedScore. @@ -29,12 +29,6 @@ interface BlockBallGame { */ var blueScore: Int - /** - * Marks the game for being closed and will automatically - * switch to close state once the resources are cleard. - */ - var closing: Boolean - /** * Ingame scoreboard. */ @@ -60,26 +54,33 @@ interface BlockBallGame { */ val blueTeam: List - /** - * Is the game closed. - */ - var closed: Boolean - /** * Status. */ var status: GameState /** - * Ball. + * SoccerBall. */ - var ball: Ball? + var ball: SoccerBall? /** * The last interacted entity with the ball. Can also be a non player. */ var lastInteractedEntity: Any? + /** + * Marks the game for being closed and will automatically + * switch to close state once the resources are cleard. + */ + var closing: Boolean + + /** + * Marks the game for being closed and will automatically + * switch to close state once the resources are cleard. + */ + var closed: Boolean + /** * Contains players which are in cooldown by doublejump. */ @@ -91,13 +92,13 @@ interface BlockBallGame { val ingamePlayersStorage: MutableMap /** - * Ball bumper counter + * SoccerBall bumper counter */ var ballBumperCounter: Int /** * Lets the given [player] leave join. Optional can the prefered - * [team] be specified but the team can still change because of arena settings. + * [team] be specified but the team can still change because of soccerArena settings. * Does nothing if the player is already in a Game. */ fun join(player: Player, team: Team? = null): JoinResult @@ -130,7 +131,12 @@ interface BlockBallGame { fun notifyBallInGoal(team: Team) /** - * Closes the given game and all underlying resources. + * Cancels the game. */ fun close() + + /** + * Gets all players. + */ + fun getPlayers(): Set } diff --git a/src/main/java/com/github/shynixn/blockball/contract/BlockBallHubGame.kt b/src/main/java/com/github/shynixn/blockball/contract/SoccerHubGame.kt similarity index 52% rename from src/main/java/com/github/shynixn/blockball/contract/BlockBallHubGame.kt rename to src/main/java/com/github/shynixn/blockball/contract/SoccerHubGame.kt index ef5007ef9..a6823572c 100644 --- a/src/main/java/com/github/shynixn/blockball/contract/BlockBallHubGame.kt +++ b/src/main/java/com/github/shynixn/blockball/contract/SoccerHubGame.kt @@ -1,4 +1,4 @@ package com.github.shynixn.blockball.contract -interface BlockBallHubGame : BlockBallGame { +interface SoccerHubGame : SoccerGame { } diff --git a/src/main/java/com/github/shynixn/blockball/contract/SoccerMiniGame.kt b/src/main/java/com/github/shynixn/blockball/contract/SoccerMiniGame.kt new file mode 100644 index 000000000..931dbdf61 --- /dev/null +++ b/src/main/java/com/github/shynixn/blockball/contract/SoccerMiniGame.kt @@ -0,0 +1,18 @@ +package com.github.shynixn.blockball.contract + +interface SoccerMiniGame : SoccerGame { + /** + * Actual game coutndown. + */ + var gameCountdown: Int + + /** + * Index of the current match time. + */ + var matchTimeIndex: Int + + /** + * Actives the next match time. Closes the match if no match time is available. + */ + fun switchToNextMatchTime() +} diff --git a/src/main/java/com/github/shynixn/blockball/entity/ArenaMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/ArenaMeta.kt index 1352f3cfc..5f35a182f 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/ArenaMeta.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/ArenaMeta.kt @@ -2,6 +2,7 @@ package com.github.shynixn.blockball.entity import com.github.shynixn.blockball.enumeration.BallActionType import com.github.shynixn.mcutils.common.sound.SoundMeta +import com.github.shynixn.mcutils.sign.SignMeta class ArenaMeta { /** Meta data for spectating setting. */ @@ -23,9 +24,6 @@ class ArenaMeta { /** Meta data of the minigame lobby. */ val minigameMeta: MinigameLobbyMeta = MinigameLobbyMeta() - /** Meta data of the bungeecord lobby. */ - val bungeeCordMeta: BungeeCordMeta = BungeeCordMeta() - /** Meta data of the doubleJump. */ val doubleJumpMeta: DoubleJumpMeta = DoubleJumpMeta() @@ -42,28 +40,10 @@ class ArenaMeta { val ballMeta: BallMeta = BallMeta() /** Meta data of the blueTeam. */ - val blueTeamMeta: TeamMeta = TeamMeta( - "%blockball_lang_teamBlueDisplayName%", - "%blockball_lang_teamBlueColor%", - "%blockball_lang_teamBlueScoreTitle%", - "%blockball_lang_teamBlueScoreSubTitle%", - "%blockball_lang_teamBlueWinTitle%", - "%blockball_lang_teamBlueWinSubTitle%", - "%blockball_lang_teamBlueDrawTitle%", - "%blockball_lang_teamBlueDrawSubTitle%" - ) + val blueTeamMeta: TeamMeta = TeamMeta() /** Meta data of the redTeam. */ - val redTeamMeta: TeamMeta = TeamMeta( - "%blockball_lang_teamRedDisplayName%", - "%blockball_lang_teamRedColor%", - "%blockball_lang_teamRedScoreTitle%", - "%blockball_lang_teamRedScoreSubTitle%", - "%blockball_lang_teamRedWinTitle%", - "%blockball_lang_teamRedWinSubTitle%", - "%blockball_lang_teamRedDrawTitle%", - "%blockball_lang_teamRedDrawSubTitle%" - ) + val redTeamMeta: TeamMeta = TeamMeta() private val internalHologramMetas: ArrayList = ArrayList() @@ -75,4 +55,17 @@ class ArenaMeta { ballMeta.soundEffects[BallActionType.ONKICK] = soundMetaKick } + + /** + * Compatibility until signs are refactored to external addon. + */ + fun getAllSigns(): List { + val signs = ArrayList() + signs.addAll(lobbyMeta.joinSigns) + signs.addAll(lobbyMeta.leaveSigns) + signs.addAll(redTeamMeta.teamSigns) + signs.addAll(blueTeamMeta.teamSigns) + return signs + } + } diff --git a/src/main/java/com/github/shynixn/blockball/entity/BallMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/BallMeta.kt index 4b8ac9a22..4e8ae0629 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/BallMeta.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/BallMeta.kt @@ -69,11 +69,6 @@ class BallMeta { */ var hitBoxRelocation: Double = 0.0 - /** - * Should the ball always bounce of walls? - */ - var alwaysBounce: Boolean = true - /** * Movement modifier. */ diff --git a/src/main/java/com/github/shynixn/blockball/entity/BungeeCordMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/BungeeCordMeta.kt deleted file mode 100644 index b73b380cb..000000000 --- a/src/main/java/com/github/shynixn/blockball/entity/BungeeCordMeta.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.github.shynixn.blockball.entity - - -class BungeeCordMeta { - /** - * FallBack server when a player executes the leave command. - */ - var fallbackServer: String = "" -} diff --git a/src/main/java/com/github/shynixn/blockball/entity/ChatBuilder.kt b/src/main/java/com/github/shynixn/blockball/entity/ChatBuilder.kt deleted file mode 100644 index 623f7cdaa..000000000 --- a/src/main/java/com/github/shynixn/blockball/entity/ChatBuilder.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.github.shynixn.blockball.entity - -import com.github.shynixn.mcutils.common.chat.* - -class ChatBuilder { - private val components = ArrayList() - - /** - * Creates a new component with the given [text]. - */ - fun component(text: String): ChatBuilderComponent { - val component = ChatBuilderComponent(this, text) - this.components.add(component) - return component - } - - /** - * Appends a line break. - */ - fun nextLine(): ChatBuilder { - this.components.add(ChatBuilderComponent(this, "\n")) - return this - } - - /** - * Appends text to the builder. - */ - fun text(text: String): ChatBuilder { - this.components.add(ChatBuilderComponent(this, text)) - return this - } - - /** - * Compatibility layer. Will be removed in a future update. - */ - fun convertToTextComponent(): TextComponent { - val rootComponent = TextComponent() - rootComponent.text = "" - - for (component in this.components) { - val subComponent = TextComponent().also { - it.text = component.text.toString() - it.color = component.color - } - rootComponent.components.add(subComponent) - - if (component.clickAction != null) { - subComponent.clickEvent = - ClickEvent(ClickEventType.valueOf(component.clickAction!!.name), component.clickActionData!!) - } - - if (component.hoverActionData != null) { - subComponent.hoverEvent = HoverEvent(HoverEventType.SHOW_TEXT, TextComponent().also { - it.text = component.hoverActionData!!.text.toString() - it.color = component.hoverActionData!!.color - }) - } - } - - return rootComponent - } -} diff --git a/src/main/java/com/github/shynixn/blockball/entity/ChatBuilderComponent.kt b/src/main/java/com/github/shynixn/blockball/entity/ChatBuilderComponent.kt deleted file mode 100644 index 2a3e23cfc..000000000 --- a/src/main/java/com/github/shynixn/blockball/entity/ChatBuilderComponent.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.github.shynixn.blockball.entity - -import com.github.shynixn.blockball.enumeration.ChatClickAction -import com.github.shynixn.mcutils.common.ChatColor - -class ChatBuilderComponent(private val builder: ChatBuilder, payloadtext: String) { - val text = StringBuilder() - var clickAction: ChatClickAction? = null - var clickActionData: String? = null - var hoverActionData: ChatBuilderComponent? = null - var color: ChatColor? = null - - init { - text.append(payloadtext) - } - - /** - * Gets the root builder of the component. - */ - fun builder(): ChatBuilder { - return builder - } - - /** - * Sets the click action. - */ - fun setClickAction(clickAction: ChatClickAction, payload: String): ChatBuilderComponent { - this.clickAction = clickAction - this.clickActionData = payload - return this - } - - /** - * Sets the hover text. - */ - fun setHoverText(text: String): ChatBuilderComponent { - this.hoverActionData = ChatBuilderComponent(this.builder, text) - return this - } - - /** - * Sets the color of the text. - */ - fun setColor(color: ChatColor): ChatBuilderComponent { - this.color = color - return this - } -} diff --git a/src/main/java/com/github/shynixn/blockball/entity/GameStorage.kt b/src/main/java/com/github/shynixn/blockball/entity/GameStorage.kt index 5296ec795..1bd3801ce 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/GameStorage.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/GameStorage.kt @@ -44,11 +44,6 @@ class GameStorage{ */ var hunger: Int = 10 - /** - * Storage belongs to this [GameType]. - */ - var gameType: GameType = GameType.HUBGAME - /** * Gamemode of the player. */ diff --git a/src/main/java/com/github/shynixn/blockball/entity/HubLobbyMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/HubLobbyMeta.kt index 07559c706..25687b95e 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/HubLobbyMeta.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/HubLobbyMeta.kt @@ -1,17 +1,10 @@ package com.github.shynixn.blockball.entity class HubLobbyMeta { - /** Join asking message. */ - var joinMessage: MutableList = arrayListOf( - "%blockball_lang_hubGameJoinHeader%", - "%blockball_lang_hubGameJoinRed%", - "%blockball_lang_hubGameJoinBlue%" - ) - /** Allows to instantly play in games by running into the forcefield.*/ var instantForcefieldJoin: Boolean = false - /** Should the arena be reset when nobody is playing? */ + /** Should the soccerArena be reset when nobody is playing? */ var resetArenaOnEmpty: Boolean = false /** Should the player be teleported to the spawnpoint when joining?*/ diff --git a/src/main/java/com/github/shynixn/blockball/entity/LobbyMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/LobbyMeta.kt index cf05b5f2f..a5d221eb4 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/LobbyMeta.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/LobbyMeta.kt @@ -1,43 +1,25 @@ package com.github.shynixn.blockball.entity import com.github.shynixn.mcutils.common.Vector3d +import com.github.shynixn.mcutils.sign.SignMeta import org.bukkit.GameMode class LobbyMeta { - /** Max score of a team until the match ends and the arena gets reset. */ + /** Max score of a team until the match ends and the soccerArena gets reset. */ var maxScore: Int = 10 /** Should players automatically join the other team to even out them?*/ var onlyAllowEventTeams: Boolean = false /** List of signs which can be clicked to join the game. */ - val joinSigns: MutableList - get() = sign.joinSigns - - /** Lines displayed on the sign for leaving the match. */ - var joinSignLines: List = arrayListOf( - "%blockball_lang_joinSignLine1%", - "%blockball_lang_joinSignLine2%", - "%blockball_lang_joinSignLine3%", - "%blockball_lang_joinSignLine4%" - ) - - var leaveSignLines: List = arrayListOf( - "%blockball_lang_leaveSignLine1%", - "%blockball_lang_leaveSignLine2%", - "%blockball_lang_leaveSignLine3%", - "%blockball_lang_leaveSignLine4%" - ) + val joinSigns = ArrayList() /** List of signs which can be clicked to leave the game. */ - val leaveSigns: MutableList - get() = sign.leaveSigns + val leaveSigns = ArrayList() /** Spawnpoint when someone leaves the hub game. */ var leaveSpawnpoint: Vector3d? = null /** Minecraft gamemode (Survival, Adventure, Creative) the players should be */ var gamemode: GameMode = GameMode.ADVENTURE - - private val sign: SignCollection = SignCollection() } diff --git a/src/main/java/com/github/shynixn/blockball/entity/Offset.kt b/src/main/java/com/github/shynixn/blockball/entity/Offset.kt deleted file mode 100644 index 83c2b57fa..000000000 --- a/src/main/java/com/github/shynixn/blockball/entity/Offset.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.github.shynixn.blockball.entity - - -class Offset { - /** - * Offset x. - */ - var x: Double = 1.0 - - /** - * Offset y. - */ - var y: Double = 1.0 - - /** - * Offset z. - */ - var z: Double = 1.0 -} diff --git a/src/main/java/com/github/shynixn/blockball/entity/Selection.kt b/src/main/java/com/github/shynixn/blockball/entity/Selection.kt index e79ee0b41..c4631e227 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/Selection.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/Selection.kt @@ -8,15 +8,15 @@ import com.github.shynixn.mcutils.packet.api.meta.enumeration.BlockDirection @JsonIgnoreProperties("center", "offsetX", "offsetY", "offsetZ") open class Selection { - /** [upperCorner] of the selected square arena. */ + /** [upperCorner] of the selected square soccerArena. */ @JsonProperty("corner1") final var upperCorner: Vector3d = Vector3d() - /** [lowerCorner] of the selected square arena. */ + /** [lowerCorner] of the selected square soccerArena. */ @JsonProperty("corner2") final var lowerCorner: Vector3d = Vector3d() - /** [center] of the arena */ + /** [center] of the soccerArena */ val center: Vector3d get() { return Vector3d( @@ -68,8 +68,8 @@ open class Selection { } /** - * If the given location is outside the arena it returns the block direction - * in which the arena can be reached. + * If the given location is outside the soccerArena it returns the block direction + * in which the soccerArena can be reached. */ fun getRelativeBlockDirectionToLocation(location: Vector3d): BlockDirection { if (location.blockX >= upperCorner.blockX && this.upperCorner.z >= location.z && this.lowerCorner.z <= location.z) { diff --git a/src/main/java/com/github/shynixn/blockball/entity/SignCollection.kt b/src/main/java/com/github/shynixn/blockball/entity/SignCollection.kt deleted file mode 100644 index aa4dcd88a..000000000 --- a/src/main/java/com/github/shynixn/blockball/entity/SignCollection.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.shynixn.blockball.entity - -import com.github.shynixn.mcutils.common.Vector3d - - -class SignCollection { - /** List of signs which can be clicked to join the game. */ - val joinSigns: MutableList = ArrayList() - /** List of signs which can be clicked to leave the game. */ - val leaveSigns: MutableList = ArrayList() -} diff --git a/src/main/java/com/github/shynixn/blockball/entity/Arena.kt b/src/main/java/com/github/shynixn/blockball/entity/SoccerArena.kt similarity index 63% rename from src/main/java/com/github/shynixn/blockball/entity/Arena.kt rename to src/main/java/com/github/shynixn/blockball/entity/SoccerArena.kt index 085579bfc..fd0584c55 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/Arena.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/SoccerArena.kt @@ -5,19 +5,19 @@ import com.github.shynixn.blockball.enumeration.GameType import com.github.shynixn.mcutils.common.repository.Element @JsonPropertyOrder("name", "displayName", "enabled", "gameType", "corner1", "corner2", "meta") -class Arena : Selection(), Element{ - /** Unique [name] of the arena. */ +class SoccerArena : Selection(), Element{ + /** Unique [name] of the soccerArena. */ override var name: String = "" - /** [displayName] of the arena on signs or messages. */ + /** [displayName] of the soccerArena on signs or messages. */ var displayName: String = "" - /** Is the arena ready to be placed. */ + /** Is the soccerArena ready to be placed. */ var enabled: Boolean = true - /** [gameType] of the arena */ + /** [gameType] of the soccerArena */ var gameType: GameType = GameType.HUBGAME - /** Collection of the arena meta data. */ + /** Collection of the soccerArena meta data. */ val meta: ArenaMeta = ArenaMeta() } diff --git a/src/main/java/com/github/shynixn/blockball/entity/SpectatorMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/SpectatorMeta.kt index 365542ce0..ead28c6e4 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/SpectatorMeta.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/SpectatorMeta.kt @@ -1,6 +1,5 @@ package com.github.shynixn.blockball.entity -import com.github.shynixn.mcutils.common.Vector3d class SpectatorMeta { /** @@ -8,22 +7,7 @@ class SpectatorMeta { */ var notifyNearbyPlayers: Boolean = false /** - * The radius from the center of the arena a player has to be in order to get notified when [notifyNearbyPlayers] is enabled. + * The radius from the center of the soccerArena a player has to be in order to get notified when [notifyNearbyPlayers] is enabled. */ var notificationRadius: Int = 50 - - /** - * Should the spectator mode be enabled for this arena? - */ - var spectatorModeEnabled: Boolean = true - - /** - * Spectate asking message. - */ - var spectateStartMessage: MutableList = arrayListOf("%blockball_lang_spectateJoinHeader%", "%blockball_lang_spectateJoinClick%") - - /** - * Spawnpoint of the spectatorPlayers. - */ - var spectateSpawnpoint: Vector3d? = null } diff --git a/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt index 80663fed2..7c875cec3 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt @@ -1,27 +1,10 @@ package com.github.shynixn.blockball.entity -import com.fasterxml.jackson.annotation.JsonProperty import com.github.shynixn.mcutils.common.Vector3d import com.github.shynixn.mcutils.common.command.CommandMeta +import com.github.shynixn.mcutils.sign.SignMeta -class TeamMeta( - /** DisplayName of the team which gets used in the placeholder or . */ - var displayName: String = "", - /** Prefix of the team which gets used in the placeholder or . */ - var prefix: String = "", - /** Title of the message getting played when a player scores a goal. */ - var scoreMessageTitle: String = "", - /** Subtitle of the message getting played when a player scores a goal. */ - var scoreMessageSubTitle: String = "", - /** Title of the message getting played when this team wins a match. */ - var winMessageTitle: String = "", - /** Subtitle of the message getting played when this team wins a match. */ - var winMessageSubTitle: String = "", - /** Title of the message getting played when the match ends in a draw.*/ - var drawMessageTitle: String = "", - /** Subtitle of the message getting played when the match ends in a draw. */ - var drawMessageSubTitle: String = "" -) { +class TeamMeta { /** Amount of points this team receives when a goal gets scored. */ var pointsPerGoal: Int = 1 @@ -29,8 +12,7 @@ class TeamMeta( var pointsPerEnemyDeath: Int = 0 /** List of signs which can be clicked to join the team.*/ - val signs: MutableList - get() = this.internalSigns + val teamSigns = ArrayList() /** Min amount of players in this team to start the match for this team. */ var minAmount: Int = 0 @@ -47,37 +29,11 @@ class TeamMeta( /** WalkingSpeed of the players in this team. */ var walkingSpeed: Double = 0.2 - /** Message getting played when a player joins a match.*/ - var joinMessage: String = "%blockball_lang_joinSuccessMessage%" - - /** Message getting played when a player leave a match.*/ - var leaveMessage: String = "%blockball_lang_leaveMessage%" - - /** Lines displayed on the sign for joining the team. */ - var signLines: List = arrayListOf( - "%blockball_lang_teamSignLine1%", - "%blockball_lang_teamSignLine2%", - "%blockball_lang_teamSignLine3%", - "%blockball_lang_teamSignLine4%", - ) - var armor: Array = arrayOfNulls(4) var inventory: Array = arrayOfNulls(36) - var scoreMessageFadeIn: Int = 20 - var scoreMessageStay: Int = 60 - var scoreMessageFadeOut: Int = 20 - - var winMessageFadeIn: Int = 20 - var winMessageStay: Int = 60 - var winMessageFadeOut: Int = 20 - - var drawMessageFadeIn: Int = 20 - var drawMessageStay: Int = 60 - var drawMessageFadeOut: Int = 20 - - /** Spawnpoint of the team inside the arena. */ + /** Spawnpoint of the team inside the soccerArena. */ var spawnpoint: Vector3d? = null /** Optional lobby spawnpoint */ @@ -112,7 +68,4 @@ class TeamMeta( * Commands executed on player leave. */ var leaveCommands: List = ArrayList() - - /** List of signs for this team */ - private var internalSigns: MutableList = ArrayList() } diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/BallActionType.kt b/src/main/java/com/github/shynixn/blockball/enumeration/BallActionType.kt index 63c6ddf14..31e613f86 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/BallActionType.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/BallActionType.kt @@ -6,32 +6,32 @@ package com.github.shynixn.blockball.enumeration */ enum class BallActionType { /** - * Ball Pass. + * SoccerBall Pass. */ ONPASS, /** - * Ball Kick. + * SoccerBall Kick. */ ONKICK, /** - * Ball Touch. + * SoccerBall Touch. */ ONINTERACTION, /** - * Ball Spawn. + * SoccerBall Spawn. */ ONSPAWN, /** - * Ball Score. + * SoccerBall Score. */ ONGOAL, /** - * Ball Move. + * SoccerBall Move. */ ONMOVE, diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/BallSize.kt b/src/main/java/com/github/shynixn/blockball/enumeration/BallSize.kt index c03d59fd0..c11e917ac 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/BallSize.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/BallSize.kt @@ -1,32 +1,5 @@ package com.github.shynixn.blockball.enumeration -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ enum class BallSize { /** * Standard siue. diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/BossBarFlag.kt b/src/main/java/com/github/shynixn/blockball/enumeration/BossBarFlag.kt index 068bc1d17..127f01768 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/BossBarFlag.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/BossBarFlag.kt @@ -1,32 +1,5 @@ package com.github.shynixn.blockball.enumeration -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ enum class BossBarFlag { /** * No Flag. diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/BossbarColor.kt b/src/main/java/com/github/shynixn/blockball/enumeration/BossbarColor.kt index 446aa00cc..e41cf3154 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/BossbarColor.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/BossbarColor.kt @@ -1,32 +1,5 @@ package com.github.shynixn.blockball.enumeration -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ enum class BossbarColor { /** * Color Pink. diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/BossbarStyle.kt b/src/main/java/com/github/shynixn/blockball/enumeration/BossbarStyle.kt index 989898b6a..8424b0bbf 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/BossbarStyle.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/BossbarStyle.kt @@ -1,32 +1,5 @@ package com.github.shynixn.blockball.enumeration -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ enum class BossbarStyle { /** * Segmented Style 6. diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/ChatClickAction.kt b/src/main/java/com/github/shynixn/blockball/enumeration/ChatClickAction.kt deleted file mode 100644 index 50113c02e..000000000 --- a/src/main/java/com/github/shynixn/blockball/enumeration/ChatClickAction.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.github.shynixn.blockball.enumeration - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -enum class ChatClickAction { - /** - * Opens a URL. - */ - OPEN_URL, - /** - * Opens a file. - */ - OPEN_FILE, - /** - * Runs a command. - */ - RUN_COMMAND, - /** - * Suggests a command. - */ - SUGGEST_COMMAND, - /** - * Changes page. - */ - CHANGE_PAGE, -} diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/LocationType.kt b/src/main/java/com/github/shynixn/blockball/enumeration/LocationType.kt new file mode 100644 index 000000000..6fd6fb56d --- /dev/null +++ b/src/main/java/com/github/shynixn/blockball/enumeration/LocationType.kt @@ -0,0 +1,13 @@ +package com.github.shynixn.blockball.enumeration + +enum class LocationType(val id: String) { + LOBBY_RED("lobbyRed"), + LOBBY_BLUE("lobbyBlue"), + LEAVE("leave"), + SPAWN_RED_1("spawnRed1"), + SPAWN_BLUE_1("spawnBlue1"), + CORNER_RED_1("cornerRed1"), + CORNER_RED_2("cornerRed2"), + CORNER_BLUE_1("cornerBlue1"), + CORNER_BLUE_2("cornerBlue2"), +} diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/MatchTimeCloseType.kt b/src/main/java/com/github/shynixn/blockball/enumeration/MatchTimeCloseType.kt index 8ce6af536..36abc3687 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/MatchTimeCloseType.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/MatchTimeCloseType.kt @@ -1,32 +1,5 @@ package com.github.shynixn.blockball.enumeration -/** - * Created by Shynixn 2020. - *

- * Version 1.5 - *

- * MIT License - *

- * Copyright (c) 2020 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ enum class MatchTimeCloseType { TIME_OVER, NEXT_GOAL diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/MenuClickableItem.kt b/src/main/java/com/github/shynixn/blockball/enumeration/MenuClickableItem.kt deleted file mode 100644 index 855c86126..000000000 --- a/src/main/java/com/github/shynixn/blockball/enumeration/MenuClickableItem.kt +++ /dev/null @@ -1,59 +0,0 @@ -package com.github.shynixn.blockball.enumeration - -import com.github.shynixn.mcutils.common.ChatColor - -enum class MenuClickableItem( - /*** Returns the displayed text of the component.*/ - val text: String, - /*** Returns the displayed color of the component.*/ - val color: ChatColor -) { - /** - * Clickable Edit. - */ - EDIT(" [edit..]", ChatColor.GREEN), - /** - * Clickable copy armor. - */ - COPY_ARMOR(" [copy armor..]", ChatColor.GOLD), - /** - * Clickable copy inventory. - */ - COPY_INVENTORY(" [copy inventory..]", ChatColor.GOLD), - /** - * Clickable page. - */ - PAGE(" [page..]", ChatColor.YELLOW), - /** - * Clickable preview. - */ - PREVIEW(" [preview..]", ChatColor.GRAY), - /** - * Clickable add. - */ - ADD(" [add..]", ChatColor.BLUE), - /** - * Clickable delete. - */ - DELETE(" [delete..]", ChatColor.DARK_RED), - /** - * Clickable select. - */ - SELECT(" [select..]", ChatColor.AQUA), - /** - * Clickable selection. - */ - SELECTION(" [selection..]", ChatColor.GOLD), - /** - * Clickable location. - */ - LOCATION(" [location..]", ChatColor.BLUE), - /** - * Clickable invalid. - */ - INVALID(" [page..]", ChatColor.BLACK), - /** - * Clickable toggle. - */ - TOGGLE(" [toggle..]", ChatColor.LIGHT_PURPLE); -} diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/MenuCommand.kt b/src/main/java/com/github/shynixn/blockball/enumeration/MenuCommand.kt deleted file mode 100644 index 8acb2566d..000000000 --- a/src/main/java/com/github/shynixn/blockball/enumeration/MenuCommand.kt +++ /dev/null @@ -1,286 +0,0 @@ -package com.github.shynixn.blockball.enumeration - -/** - * Created by Shynixn 2019. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2019 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -enum class MenuCommand(val key: MenuPageKey, private val internalCommand: String) { - BACK(MenuPageKey.OPEN, "back"), - CLOSE(MenuPageKey.OPEN, "close"), - OPEN(MenuPageKey.OPEN, ""), - ARENA_RELOAD(MenuPageKey.MAINCONFIGURATION, "reload"), - OPEN_EDIT_ARENA(MenuPageKey.OPEN, "edit-arenas"), - OPEN_CREATE_ARENA(MenuPageKey.OPEN, "create-arena"), - OPEN_DELETE_ARENA(MenuPageKey.OPEN, "delete-arenas"), - - ARENA_CREATE(MenuPageKey.MAINCONFIGURATION, "create-arena"), - ARENA_EDIT(MenuPageKey.MAINCONFIGURATION, "edit-arena"), - ARENA_DELETE(MenuPageKey.MAINCONFIGURATION, "delete-arena"), - - ARENA_MAINCONFIGURATION(MenuPageKey.MAINCONFIGURATION, "main-configuration"), - ARENA_SETDISPLAYNAME(MenuPageKey.MAINCONFIGURATION, "set-displayname"), - ARENA_ENABLE(MenuPageKey.MAINCONFIGURATION, "set-enable"), - ARENA_SETBALLSPAWNPOINT(MenuPageKey.MAINCONFIGURATION, "set-ballspawnpoint"), - - ARENA_SETAREA(MenuPageKey.MAINCONFIGURATION, "set-area"), - ARENA_SETGOALRED(MenuPageKey.MAINCONFIGURATION, "set-goalred"), - ARENA_SETGOALBLUE(MenuPageKey.MAINCONFIGURATION, "set-goalblue"), - ARENA_SAVE(MenuPageKey.MAINCONFIGURATION, "save-arena"), - - SETTINGS_OPEN(MenuPageKey.MAINSETTING, "open_settings"), - - MATCHTIMES_OPEN(MenuPageKey.MATCHTIMES, "open_matcht"), - MATCHTIMES_CALLBACK(MenuPageKey.MATCHTIMES, "callback"), - MATCHTIMES_CALLBACKCLOSETYPE(MenuPageKey.MATCHTIMES, "callbclot"), - MATCHTIMES_CREATE(MenuPageKey.MATCHTIMES, "create"), - MATCHTIMES_DELETE(MenuPageKey.MATCHTIMES, "del"), - MATCHTIMES_DURATION(MenuPageKey.MATCHTIMES, "dur"), - MATCHTIMES_SWITCHGOAL(MenuPageKey.MATCHTIMES, "swgo"), - MATCHTIMES_CLOSECONDITION(MenuPageKey.MATCHTIMES, "clc"), - MATCHTIMES_BALLAVAILABLE(MenuPageKey.MATCHTIMES, "bav"), - MATCHTIMES_RESPAWN(MenuPageKey.MATCHTIMES, "res"), - MATCHTIMES_STARTSUBTITLEMESSAGE(MenuPageKey.MATCHTIMES, "sstlm"), - MATCHTIMES_STARTTITLEMESSAGE(MenuPageKey.MATCHTIMES, "stlm"), - - TEAM_RED_CONFIGURE(MenuPageKey.TEAMMETA, "team_red"), - TEAM_BLUE_CONFIGURE(MenuPageKey.TEAMMETA, "team_blue"), - - TEAM_NAME(MenuPageKey.TEAMMETA, "name"), - TEAM_PREFIX(MenuPageKey.TEAMMETA, "prefix"), - TEAM_SPAWNPOINT(MenuPageKey.TEAMMETA, "spawnpoint"), - TEAM_LOBBY(MenuPageKey.TEAMMETA, "lobby"), - TEAM_MINAMOUNT(MenuPageKey.TEAMMETA, "mina"), - TEAM_MAXAMOUNT(MenuPageKey.TEAMMETA, "maxa"), - TEAM_ARMOR(MenuPageKey.TEAMMETA, "armor"), - TEAM_INVENTORY(MenuPageKey.TEAMMETA, "invent"), - TEAM_WALKSPEED(MenuPageKey.TEAMMETA, "wspeed"), - TEAM_POINTSGOAL(MenuPageKey.TEAMMETA, "ppgoal"), - TEAM_POINTSDEATH(MenuPageKey.TEAMMETA, "ppdeath"), - - TEAM_SIGN(MenuPageKey.TEAMMETA, "sign"), - - TEAM_MSGLEAVE(MenuPageKey.TEAMMETA, "mleave"), - TEAM_MSGJOIN(MenuPageKey.TEAMMETA, "mjoin"), - - TEAM_SCORETITLE(MenuPageKey.TEAMMETA, "sct"), - TEAM_SCORESUBTITLE(MenuPageKey.TEAMMETA, "scst"), - TEAM_WINTITLE(MenuPageKey.TEAMMETA, "wct"), - TEAM_WINSUBTITLE(MenuPageKey.TEAMMETA, "wcst"), - - EFFECTS_OPEN(MenuPageKey.EFFECTS, "general"), - EFFECTS_BOSSBAR(MenuPageKey.EFFECTS, "bossbar"), - EFFECTS_HOLOGRAMS(MenuPageKey.EFFECTS, "holograms"), - EFFECTS_SCOREBOARD(MenuPageKey.EFFECTS, "scoreboard"), - - MULTILINES_ANY(MenuPageKey.MULTIPLELINES, "any"), - MULTILINES_ADD(MenuPageKey.MULTIPLELINES, "add"), - MULTILINES_SET(MenuPageKey.MULTIPLELINES, "set"), - MULTILINES_REMOVE(MenuPageKey.MULTIPLELINES, "rmv"), - MULTILINES_SCOREBOARD(MenuPageKey.MULTIPLELINES, "show_scoreboard"), - MULTILINES_HOLOGRAM(MenuPageKey.MULTIPLELINES, "show_hologram"), - MULTILINES_TEAMSIGNTEMPLATE(MenuPageKey.MULTIPLELINES, "show_teamsign"), - MULTILINES_HUBGAMEJOINMESSAGE(MenuPageKey.MULTIPLELINES, "hubgame_join"), - MULTILINES_SPECTATEJOINMESSAGE(MenuPageKey.MULTIPLELINES, "minigame_spectate"), - - BALL_OPEN(MenuPageKey.BALL, "open"), - BALL_SIZE_CALLBACK(MenuPageKey.BALL, "size-callback"), - BALL_PARTICLEACTION_CALLBACK(MenuPageKey.BALL, "part-callback"), - BALL_SOUNDACTION_CALLBACK(MenuPageKey.BALL, "sound-callback"), - - BALL_SKIN(MenuPageKey.BALL, "skin"), - BALL_SLIME(MenuPageKey.BALL, "slimev"), - BALL_INTERACTION_HITBOX(MenuPageKey.BALL, "inhitbox"), - BALL_KICKPASS_HITBOX(MenuPageKey.BALL, "kphitbox"), - BALL_TOGGLE_CARRYABLE(MenuPageKey.BALL, "tgl-car"), - BALL_TOGGLE_ALWAYSBOUNCE(MenuPageKey.BALL, "tgl-bounce"), - BALL_TOGGLE_ROTATING(MenuPageKey.BALL, "tgl-rotate"), - BALL_INTERACT_COOLDOWN(MenuPageKey.BALL, "intrkp"), - BALL_KICKPASS_DELAY(MenuPageKey.BALL, "kpdelay"), - - BALLMOD_OPEN(MenuPageKey.BALLMODIFIER, "open"), - BALLMOD_HORIZONTALTOUCH(MenuPageKey.BALLMODIFIER, "touch-horizontal"), - BALLMOD_VERTICALTOUCH(MenuPageKey.BALLMODIFIER, "touch-vertical"), - BALLMOD_SHOTVELOCITY(MenuPageKey.BALLMODIFIER, "shot-velocity"), - BALLMOD_PASSVELOCITY(MenuPageKey.BALLMODIFIER, "pass-velocity"), - BALLMOD_MAXSPIN(MenuPageKey.BALLMODIFIER, "max-spin"), - BALLMOD_MAXPITCH(MenuPageKey.BALLMODIFIER, "max-pitch"), - BALLMOD_MINPITCH(MenuPageKey.BALLMODIFIER, "min-pitch"), - BALLMOD_DEFAULTPITCH(MenuPageKey.BALLMODIFIER, "default-pitch"), - BALLMOD_GRAVITY(MenuPageKey.BALLMODIFIER, "gravity"), - BALLMOD_AIRRESISTANCE(MenuPageKey.BALLMODIFIER, "air-resistance"), - BALLMOD_ROLLINGRESISTANCE(MenuPageKey.BALLMODIFIER, "rolling-resistance"), - - MULTIPLEITEMS_BOSSBAR(MenuPageKey.MULTIPLEITEMS, "show_bossbar"), - MULTIPLEITEMS_OPEN(MenuPageKey.MULTIPLEITEMS, "open"), - MULTIPLEITEMS_REMOVE(MenuPageKey.MULTIPLEITEMS, "rmv"), - - SCOREBOARD_OPEN(MenuPageKey.SCOREBOARD, "open"), - SCOREBOARD_TOGGLE(MenuPageKey.SCOREBOARD, "tgl"), - SCOREBOARD_TITLE(MenuPageKey.SCOREBOARD, "title"), - - ABILITIES_OPEN(MenuPageKey.ABILITIES, "open"), - - DOUBLEJUMP_OPEN(MenuPageKey.DOUBLEJUMP, "open"), - DOUBLEJUMP_TOGGLE(MenuPageKey.DOUBLEJUMP, "tgl"), - DOUBLEJUMP_COOLDOWN(MenuPageKey.DOUBLEJUMP, "cool"), - DOUBLEJUMP_VERTICAL_STRENGTH(MenuPageKey.DOUBLEJUMP, "vstr"), - DOUBLEJUMP_HORIZONTAL_STRENGTH(MenuPageKey.DOUBLEJUMP, "hstr"), - - HOLOGRAM_OPEN(MenuPageKey.HOLOGRAM, "open"), - HOLOGRAM_CALLBACK(MenuPageKey.HOLOGRAM, "callback"), - HOLOGRAM_CREATE(MenuPageKey.HOLOGRAM, "create"), - HOLOGRAM_DELETE(MenuPageKey.HOLOGRAM, "del"), - HOLOGRAM_LOCATION(MenuPageKey.HOLOGRAM, "loc"), - HOLOGRAM_TOGGLE(MenuPageKey.HOLOGRAM, "tgl"), - - BOSSBAR_OPEN(MenuPageKey.BOSSBAR, "open"), - BOSSBAR_MESSAGE(MenuPageKey.BOSSBAR, "msg"), - BOSSBAR_PERCENT(MenuPageKey.BOSSBAR, "prc"), - BOSSBAR_TOGGLE(MenuPageKey.BOSSBAR, "tgl"), - BOSSBAR_CALLBACKFLAGS(MenuPageKey.BOSSBAR, "fla"), - BOSSBAR_CALLBACKCOLORS(MenuPageKey.BOSSBAR, "colo"), - - GAMESETTINGS_CALLBACK_BUKKITGAMEMODES(MenuPageKey.GAMESETTINGS, "bukkitgame"), - GAMESETTINGS_OPEN(MenuPageKey.GAMESETTINGS, "open"), - GAMESETTINGS_MAXSCORE(MenuPageKey.GAMESETTINGS, "maxscore"), - GAMESETTINGS_MAXDURATION(MenuPageKey.GAMESETTINGS, "matchduration"), - GAMESETTINGS_LOBBYDURATION(MenuPageKey.GAMESETTINGS, "lobbyduration"), - GAMESETTINGS_BUNGEEKICKMESSAGE(MenuPageKey.GAMESETTINGS, "kickmes"), - GAMESETTINGS_BUNGEELEAVEKICKMESSAGE(MenuPageKey.GAMESETTINGS, "levkikmes"), - GAMESETTINGS_BUNGEEFALLBACKSERVER(MenuPageKey.GAMESETTINGS, "falbac"), - GAMESETTINGS_REMAININGPLAYERSMESSAGE(MenuPageKey.GAMESETTINGS, "remainmes"), - GAMESETTINGS_LEAVESPAWNPOINT(MenuPageKey.GAMESETTINGS, "lspawn"), - GAMESETTINGS_LOBBYSPAWNPOINT(MenuPageKey.GAMESETTINGS, "lobspawn"), - GAMESETTINGS_JOINMESSAGE(MenuPageKey.GAMESETTINGS, "joinm"), - GAMESETTINGS_TOGGLE_EVENTEAMS(MenuPageKey.GAMESETTINGS, "tlgeven"), - GAMESETTINGS_TOGGLE_RESETEMPTY(MenuPageKey.GAMESETTINGS, "resemp"), - GAMESETTINGS_TOGGLE_INSTATFORCEFIELD(MenuPageKey.GAMESETTINGS, "iforce"), - GAMESETTINGS_TOGGLE_TELEPORTONJOIN(MenuPageKey.GAMESETTINGS, "tglteleport"), - - SIGNS_OPEN(MenuPageKey.SIGNS, "open"), - SIGNS_ADDTEAMRED(MenuPageKey.SIGNS, "adteamr"), - SIGNS_ADDJOINANY(MenuPageKey.SIGNS, "addjoin"), - SIGNS_LEAVE(MenuPageKey.SIGNS, "leave"), - SIGNS_ADDTEAMBLUE(MenuPageKey.SIGNS, "adteamb"), - - SOUND_DOUBLEJUMP(MenuPageKey.SOUNDEFFECTS, "doub"), - - SOUND_BALL(MenuPageKey.SOUNDEFFECTS, "ball-sound"), - SOUND_OPEN(MenuPageKey.SOUNDEFFECTS, "open"), - SOUND_EFFECTING(MenuPageKey.SOUNDEFFECTS, "ef"), - SOUND_TYPE(MenuPageKey.SOUNDEFFECTS, "type"), - SOUND_VOLUME(MenuPageKey.SOUNDEFFECTS, "volume"), - SOUND_PITCH(MenuPageKey.SOUNDEFFECTS, "pitch"), - SOUND_CALLBACK_EFFECTING(MenuPageKey.SOUNDEFFECTS, "caleffecting"), - SOUND_CALLBACK_TYPE(MenuPageKey.SOUNDEFFECTS, "caltype"), - - SPECTATOR_OPEN(MenuPageKey.SPECTATING, "open"), - - SPECTATE_OPEN(MenuPageKey.SPECTATE, "open"), - SPECTATE_TOGGLE(MenuPageKey.SPECTATE, "tgl-sp"), - SPECTATE_SPAWNPOINT(MenuPageKey.SPECTATE, "spawn"), - - MISC_OPEN(MenuPageKey.MISC, "open"), - - GAMEPROPERTIES_OPEN(MenuPageKey.GAMEEXTENSIONS, "open"), - GAMEPROPERTIES_TOGGLE_BALLFORCEFIELD(MenuPageKey.GAMEEXTENSIONS, "tglbaf"), - GAMEPROPERTIES_TOGGLE_DAMAGE(MenuPageKey.GAMEEXTENSIONS, "tglda"), - GAMEPROPERTIES_TOGGLE_EVENTEAMS(MenuPageKey.GAMEEXTENSIONS, "tgle"), - GAMEPROPERTIES_TOGGLE_TELEPORTBACK(MenuPageKey.GAMEEXTENSIONS, "tgltelback"), - GAMEPROPERTIES_TOGGLE_KEEPINVENTORY(MenuPageKey.GAMEEXTENSIONS, "tglkeepinv"), - GAMEPROPERTIES_TELEPORTBACKDELAY(MenuPageKey.GAMEEXTENSIONS, "telbackdelay"), - - NOTIFICATIONS_OPEN(MenuPageKey.NOTIFICATIONS, "open"), - NOTIFICATIONS_TOGGLE(MenuPageKey.NOTIFICATIONS, "togl"), - NOTIFICATIONS_RADIUS(MenuPageKey.NOTIFICATIONS, "radius"), - - AREAPROTECTION_OPEN(MenuPageKey.AREAPROTECTION, "open"), - AREAPROTECTION_TOGGLE_ENTITYFORCEFIELD(MenuPageKey.AREAPROTECTION, "enforce"), - AREAPROTECTION_SET_ENTITYFORCEFIELD(MenuPageKey.AREAPROTECTION, "enprot"), - AREAPROTECTION_TOGGLE_PLAYERJOINFORCEFIELD(MenuPageKey.AREAPROTECTION, "plforce"), - AREAPROTECTION_SET_PLAYERJOINFORCEFIELD(MenuPageKey.AREAPROTECTION, "plprot"), - - TEXTBOOK_OPEN(MenuPageKey.TEAMTEXTBOOK, "open"), - TEXTBOOK_JOINMESSAGE(MenuPageKey.TEAMTEXTBOOK, "join"), - TEXTBOOK_LEAVEMESSAGE(MenuPageKey.TEAMTEXTBOOK, "leave"), - TEXTBOOK_SCORETIELE(MenuPageKey.TEAMTEXTBOOK, "scoretitle"), - TEXTBOOK_SCORESUBTITLE(MenuPageKey.TEAMTEXTBOOK, "scorestitle"), - TEXTBOOK_WINTIELE(MenuPageKey.TEAMTEXTBOOK, "wintitle"), - TEXTBOOK_WINSUBTITLE(MenuPageKey.TEAMTEXTBOOK, "winstitle"), - TEXTBOOK_DRAWTIELE(MenuPageKey.TEAMTEXTBOOK, "drawtitle"), - TEXTBOOK_DRAWSUBTITLE(MenuPageKey.TEAMTEXTBOOK, "drawstitle"), - - LIST_TEMPLATES(MenuPageKey.LISTABLE, "show_templates"), - LIST_BUKKITGAMESMODES(MenuPageKey.LISTABLE, "show_bukkitgamemodes"), - LIST_BALL_SOUNDEFFECTS(MenuPageKey.LISTABLE, "show_ballsounds"), - LIST_BALL_PARTICLEFFECTS(MenuPageKey.LISTABLE, "show_ballparticles"), - LIST_LINES(MenuPageKey.LISTABLE, "show_lines"), - LIST_COMMANDMODES(MenuPageKey.LISTABLE, "show_commandmodes"), - LIST_BALLSIZES(MenuPageKey.LISTABLE, "show_ballsizes"), - LIST_PARTICLE_EFFECTINGTYPES(MenuPageKey.LISTABLE, "particlef"), - LIST_PARTICLE_TYPES(MenuPageKey.LISTABLE, "particles"), - LIST_SOUND_TYPES(MenuPageKey.LISTABLE, "sounds"), - LIST_REWARDED_MONEY(MenuPageKey.LISTABLE, "rewmoney"), - LIST_REWARDED_COMMAND(MenuPageKey.LISTABLE, "recommand"), - LIST_SOUND_EFFECTINGTYPES(MenuPageKey.LISTABLE, "soundf"), - LIST_BOSSBARFLAGS(MenuPageKey.LISTABLE, "show_bossbarflags"), - LIST_BOSSBARSTYLES(MenuPageKey.LISTABLE, "show_bossbarstyles"), - LIST_BOSSBARCOLORS(MenuPageKey.LISTABLE, "show_bossbarcolors"), - LIST_HOLOGRAMS(MenuPageKey.LISTABLE, "show_holograms"), - LIST_GAMETYPES(MenuPageKey.LISTABLE, "show_gametypes"), - LIST_MATCHTIMES(MenuPageKey.LISTABLE, "show_matchtimes"), - LIST_MATCHCLOSETYPES(MenuPageKey.LISTABLE, "show_closetypes") - ; - - /** - * Gets the command. - */ - val command: String - get() { - return "/blockball " + this.key.key + ' '.toString() + this.internalCommand + ' '.toString() - } - - companion object { - /** - * Generates a menu command from args. - */ - fun from(args: Array): MenuCommand? { - if (args.isEmpty()) { - return OPEN - } - - if (args.isNotEmpty()) { - for (command in MenuCommand.values()) { - if (command.key.key.equals(args[0], ignoreCase = true) && command.internalCommand.equals(args[1], ignoreCase = true)) { - return command - } - } - } - - return null - } - } -} diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/MenuCommandResult.kt b/src/main/java/com/github/shynixn/blockball/enumeration/MenuCommandResult.kt deleted file mode 100644 index 08eb73800..000000000 --- a/src/main/java/com/github/shynixn/blockball/enumeration/MenuCommandResult.kt +++ /dev/null @@ -1,52 +0,0 @@ -package com.github.shynixn.blockball.enumeration - -/** - * Created by Shynixn 2019. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2019 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -enum class MenuCommandResult( - /** - * Gets the message result. - */ - val message: String? -) { - SUCCESS(null), - CANCEL_MESSAGE(null), - BACK(null), - - WESELECTIONHEIGHTGOAL_TOSMALL("The height of the goal is less than 3 blocks. Select a cube instead of a square!"), - WESELECTIONXAXEGOAL_TOSMALL("The x-axe size of the goal is less than 3 blocks. Select a cube instead of a square!"), - WESELECTIONZAXEGOAL_TOSMALL("The z-axe size of the goal is less than 3 blocks. Select a cube instead of a square!"), - - WESELECTION_TOSMALL("The height of the arena is less than 10 blocks. Select a cube instead of a square!"), - WESELECTION_MISSING("Please select an area via the wand!"), - MINIGAMEARENA_NOTVALID("Please set the center, goal1, goal2, ball spawpoint, lobby spawnpoint and leave spawnpoint before saving!"), - ARENA_NOTVALID("Please set the center, goal1, goal2 and ball spawpoint before saving!"), - - MAX_PLAYERS("Max amount of players cannot be lower than min amount of players!"), - MINPLAYERS("Min amount of players cannot be bigger than max amount of players!"), - EXIT_COMP(null) -} diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/MenuPageKey.kt b/src/main/java/com/github/shynixn/blockball/enumeration/MenuPageKey.kt deleted file mode 100644 index 4e3e8b3b4..000000000 --- a/src/main/java/com/github/shynixn/blockball/enumeration/MenuPageKey.kt +++ /dev/null @@ -1,63 +0,0 @@ -package com.github.shynixn.blockball.enumeration - -/** - * Created by Shynixn 2019. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2019 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -enum class MenuPageKey( - /** - * Page key. - */ - val key: String -) { - OPEN("open"), - MAINSETTING("mset"), - LISTABLE("labl"), - TEAMMETA("tma"), - EFFECTS("ef"), - SCOREBOARD("scor"), - BOSSBAR("boss"), - HOLOGRAM("holog"), - SIGNS("sign"), - DOUBLEJUMP("doubl"), - ABILITIES("abi"), - MULTIPLELINES("mlin"), - SOUNDEFFECTS("sound"), - MISC("misc"), - AREAPROTECTION("aprot"), - GAMEEXTENSIONS("gameex"), - MULTIPLEITEMS("mitem"), - GAMESETTINGS("gameset"), - MATCHTIMES("mats"), - COMMANDPAGE("com"), - SPECTATING("spect"), - SPECTATE("specta"), - BALL("ball"), - NOTIFICATIONS("notif"), - BALLMODIFIER("ballmod"), - TEAMTEXTBOOK("teamtext"), - MAINCONFIGURATION("mcf"); -} diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/Permission.kt b/src/main/java/com/github/shynixn/blockball/enumeration/Permission.kt index f52f0420d..8886008fe 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/Permission.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/Permission.kt @@ -1,60 +1,17 @@ package com.github.shynixn.blockball.enumeration -/** - * Static BlockBall permissions. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018-2019 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -enum class Permission( - /** - * Permission string. - */ - val permission: String -) { +enum class Permission(val permission: String) { + COMMAND("blockball.command"), + EDIT_GAME("blockball.edit"), + JOIN("blockball.join.[name]"), + /** * Permission for staff to allow executing commands while ingame. */ - STAFF("blockball.command.staff"), + OBSOLETE_STAFF("blockball.command.staff"), /** * Permission for users to allow opening and clicking their inventory while ingame. */ - INVENTORY("blockball.game.inventory"), - - /** - * Permission for admins to configure and execute commands. - */ - ADMIN("blockball.command.admin"), - - /** - * Permission for users to spectate games. - */ - SPECTATE("blockball.game.spectate"), - - /** - * Permission for users to join games. - */ - JOIN("blockball.game.join") + OBSOLETE_INVENTORY("blockball.game.inventory"), } diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/PlaceHolder.kt b/src/main/java/com/github/shynixn/blockball/enumeration/PlaceHolder.kt index f84928d85..3eaacd47e 100644 --- a/src/main/java/com/github/shynixn/blockball/enumeration/PlaceHolder.kt +++ b/src/main/java/com/github/shynixn/blockball/enumeration/PlaceHolder.kt @@ -19,14 +19,6 @@ enum class PlaceHolder( GAME_BLUE_SCORE("%blockball_game_blueScore%"), - GAME_TEAM_RED_NAME("%blockball_game_redName%"), - - GAME_TEAM_BLUE_NAME("%blockball_game_blueName%"), - - GAME_TEAM_RED_COLOR("%blockball_game_redColor%"), - - GAME_TEAM_BLUE_COLOR("%blockball_game_blueColor%"), - GAME_TIME("%blockball_game_time%"), GAME_LASTHITPLAYER_NAME("%blockball_game_lastHitPlayerName%"), diff --git a/src/main/java/com/github/shynixn/blockball/enumeration/SignType.kt b/src/main/java/com/github/shynixn/blockball/enumeration/SignType.kt new file mode 100644 index 000000000..1413b8d15 --- /dev/null +++ b/src/main/java/com/github/shynixn/blockball/enumeration/SignType.kt @@ -0,0 +1,8 @@ +package com.github.shynixn.blockball.enumeration + +enum class SignType { + JOIN, + LEAVE, + TEAM_RED, + TEAM_BLUE +} diff --git a/src/main/java/com/github/shynixn/blockball/event/BallEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallEvent.kt index e1e382d82..a103fd751 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallEvent.kt @@ -1,14 +1,14 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall /** - * Base Event for all Ball events. + * Base Event for all SoccerBall events. */ open class BallEvent( /** - * Ball. + * SoccerBall. */ - val ball: Ball + val ball: SoccerBall ) : BlockBallEvent() diff --git a/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt index ba1e0306a..a2b9856ea 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall import org.bukkit.entity.Player import org.bukkit.util.Vector @@ -8,7 +8,7 @@ import org.bukkit.util.Vector * Event which gets called when the ball is kicked. */ class BallLeftClickEvent( - ball: Ball, + ball: SoccerBall, player: Player, velocity: Vector ) : BallTouchPlayerEvent(ball, player, velocity) diff --git a/src/main/java/com/github/shynixn/blockball/event/BallRayTraceEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallRayTraceEvent.kt index 7dda21aff..30dbcb3e4 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallRayTraceEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallRayTraceEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall import com.github.shynixn.mcutils.packet.api.meta.enumeration.BlockDirection import org.bukkit.Location @@ -13,9 +13,9 @@ import org.bukkit.Location */ class BallRayTraceEvent( /** - * Ball. + * SoccerBall. */ - ball: Ball, + ball: SoccerBall, /** * Modifies if the raytrace has ended in a block hit. */ diff --git a/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt index 93eed1819..d6963c338 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt @@ -1,9 +1,9 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall /** * Event which gets sent when the ball is requested to get removed. */ -class BallRemoveEvent(ball: Ball) : BallEvent(ball) +class BallRemoveEvent(ball: SoccerBall) : BallEvent(ball) diff --git a/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt index ccee12f89..abaf38158 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall import org.bukkit.entity.Player import org.bukkit.util.Vector @@ -8,7 +8,7 @@ import org.bukkit.util.Vector * Event which gets called when the ball is passed. */ class BallRightClickEvent( - ball: Ball, + ball: SoccerBall, player: Player, velocity: Vector ) : BallTouchPlayerEvent(ball, player, velocity) diff --git a/src/main/java/com/github/shynixn/blockball/event/BallSpawnEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallSpawnEvent.kt index 1ce548d49..17b4dc12b 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallSpawnEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallSpawnEvent.kt @@ -1,5 +1,5 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall -class BallSpawnEvent(ball: Ball) : BallEvent(ball) +class BallSpawnEvent(ball: SoccerBall) : BallEvent(ball) diff --git a/src/main/java/com/github/shynixn/blockball/event/BallTeleportEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallTeleportEvent.kt index 14ebef1df..d81d0d825 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallTeleportEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallTeleportEvent.kt @@ -1,9 +1,9 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall import org.bukkit.Location /** * Event which gets called when the ball is teleporting. */ -class BallTeleportEvent(ball: Ball, var targetLocation : Location) : BallEvent(ball) +class BallTeleportEvent(ball: SoccerBall, var targetLocation : Location) : BallEvent(ball) diff --git a/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt b/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt index d3c3b3ebc..e1bddc8a7 100644 --- a/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall import org.bukkit.entity.Player import org.bukkit.util.Vector @@ -9,7 +9,7 @@ import org.bukkit.util.Vector * Event which gets called when the ball is touched. */ open class BallTouchPlayerEvent( - ball: Ball, + ball: SoccerBall, /** * Interacting player. */ diff --git a/src/main/java/com/github/shynixn/blockball/event/GameEndEvent.kt b/src/main/java/com/github/shynixn/blockball/event/GameEndEvent.kt index a085901ab..9a6441ebc 100644 --- a/src/main/java/com/github/shynixn/blockball/event/GameEndEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/GameEndEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.BlockBallGame +import com.github.shynixn.blockball.contract.SoccerGame import com.github.shynixn.blockball.enumeration.Team @@ -11,5 +11,5 @@ class GameEndEvent( /** * Winning [Team]. Is null when the match ended in a draw. */ - val winningTeam: Team?, game: BlockBallGame + val winningTeam: Team?, game: SoccerGame ) : GameEvent(game) diff --git a/src/main/java/com/github/shynixn/blockball/event/GameEvent.kt b/src/main/java/com/github/shynixn/blockball/event/GameEvent.kt index 09b09e231..a701013f3 100644 --- a/src/main/java/com/github/shynixn/blockball/event/GameEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/GameEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.BlockBallGame +import com.github.shynixn.blockball.contract.SoccerGame /** @@ -10,5 +10,5 @@ open class GameEvent( /** * Game firing this event. */ - val game: BlockBallGame + val game: SoccerGame ) : BlockBallEvent() diff --git a/src/main/java/com/github/shynixn/blockball/event/GameGoalEvent.kt b/src/main/java/com/github/shynixn/blockball/event/GameGoalEvent.kt index f6f00e626..4e6a03db6 100644 --- a/src/main/java/com/github/shynixn/blockball/event/GameGoalEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/GameGoalEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.BlockBallGame +import com.github.shynixn.blockball.contract.SoccerGame import com.github.shynixn.blockball.enumeration.Team import org.bukkit.entity.Player @@ -15,5 +15,5 @@ class GameGoalEvent( /** * Team scoring the goal. */ - val team: Team, game: BlockBallGame + val team: Team, game: SoccerGame ) : GameEvent(game) diff --git a/src/main/java/com/github/shynixn/blockball/event/GameJoinEvent.kt b/src/main/java/com/github/shynixn/blockball/event/GameJoinEvent.kt index 5317415b5..bb598311f 100644 --- a/src/main/java/com/github/shynixn/blockball/event/GameJoinEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/GameJoinEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.BlockBallGame +import com.github.shynixn.blockball.contract.SoccerGame import org.bukkit.entity.Player /** @@ -10,5 +10,5 @@ class GameJoinEvent( /** * Player joining the game. */ - val player: Player, game: BlockBallGame + val player: Player, game: SoccerGame ) : GameEvent(game) diff --git a/src/main/java/com/github/shynixn/blockball/event/GameLeaveEvent.kt b/src/main/java/com/github/shynixn/blockball/event/GameLeaveEvent.kt index 04b3f8182..bf54df51a 100644 --- a/src/main/java/com/github/shynixn/blockball/event/GameLeaveEvent.kt +++ b/src/main/java/com/github/shynixn/blockball/event/GameLeaveEvent.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.event -import com.github.shynixn.blockball.contract.BlockBallGame +import com.github.shynixn.blockball.contract.SoccerGame import org.bukkit.entity.Player /** @@ -10,5 +10,5 @@ class GameLeaveEvent( /** * Player joining the game. */ - val player: Player, game: BlockBallGame + val player: Player, game: SoccerGame ) : GameEvent(game) diff --git a/src/main/java/com/github/shynixn/blockball/impl/BallDesignEntity.kt b/src/main/java/com/github/shynixn/blockball/impl/BallDesignEntity.kt index 86e21e100..be1e16128 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BallDesignEntity.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/BallDesignEntity.kt @@ -2,7 +2,7 @@ package com.github.shynixn.blockball.impl -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall import com.github.shynixn.blockball.enumeration.BallSize import com.github.shynixn.mcutils.common.Vector3d import com.github.shynixn.mcutils.common.item.ItemService @@ -34,7 +34,7 @@ class BallDesignEntity(val entityId: Int) { /** * Reference. */ - lateinit var ball: Ball + lateinit var ball: SoccerBall /** * Spawns the ball for the given player. diff --git a/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt b/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt index 6f8d85c19..524b5cfb1 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt @@ -82,14 +82,14 @@ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) { lateinit var packetService: PacketService /** - * Ball Proxy. + * SoccerBall Proxy. */ - lateinit var ball: BallCrossPlatformProxy + lateinit var ball: SoccerBallCrossPlatformProxy lateinit var plugin: Plugin /** - * Ball Meta. + * SoccerBall Meta. */ val meta: BallMeta get() { @@ -272,7 +272,7 @@ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) { return } - // Reduce hitbox size in order to stay compatible to old arena files. + // Reduce hitbox size in order to stay compatible to old soccerArena files. val hitboxSize = (meta.interactionHitBoxSize - 1) for (player in players) { diff --git a/src/main/java/com/github/shynixn/blockball/impl/BallCrossPlatformProxy.kt b/src/main/java/com/github/shynixn/blockball/impl/SoccerBallCrossPlatformProxy.kt similarity index 97% rename from src/main/java/com/github/shynixn/blockball/impl/BallCrossPlatformProxy.kt rename to src/main/java/com/github/shynixn/blockball/impl/SoccerBallCrossPlatformProxy.kt index b6aba16e3..eda066e5f 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BallCrossPlatformProxy.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/SoccerBallCrossPlatformProxy.kt @@ -2,7 +2,7 @@ package com.github.shynixn.blockball.impl -import com.github.shynixn.blockball.contract.Ball +import com.github.shynixn.blockball.contract.SoccerBall import com.github.shynixn.blockball.entity.BallMeta import com.github.shynixn.blockball.event.BallRemoveEvent import com.github.shynixn.blockball.event.BallTeleportEvent @@ -16,12 +16,12 @@ import org.bukkit.plugin.Plugin import org.bukkit.util.Vector import java.util.logging.Level -class BallCrossPlatformProxy( +class SoccerBallCrossPlatformProxy( override val meta: BallMeta, private val ballDesignEntity: BallDesignEntity, private val ballHitBoxEntity: BallHitboxEntity, private val plugin: Plugin, -) : Ball { +) : SoccerBall { private var allPlayerTracker: AllPlayerTracker = AllPlayerTracker( { ballHitBoxEntity.position diff --git a/src/main/java/com/github/shynixn/blockball/impl/BlockBallGameImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/SoccerGameImpl.kt similarity index 76% rename from src/main/java/com/github/shynixn/blockball/impl/BlockBallGameImpl.kt rename to src/main/java/com/github/shynixn/blockball/impl/SoccerGameImpl.kt index 67a32fd20..f571a6891 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BlockBallGameImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/SoccerGameImpl.kt @@ -1,12 +1,10 @@ package com.github.shynixn.blockball.impl -import com.github.shynixn.blockball.BlockBallLanguage import com.github.shynixn.blockball.contract.* import com.github.shynixn.blockball.entity.* import com.github.shynixn.blockball.enumeration.* import com.github.shynixn.blockball.event.GameEndEvent import com.github.shynixn.blockball.event.GameGoalEvent -import com.github.shynixn.blockball.impl.extension.setSignLines import com.github.shynixn.mccoroutine.bukkit.launch import com.github.shynixn.mccoroutine.bukkit.ticks import com.github.shynixn.mcutils.common.* @@ -21,31 +19,30 @@ import org.bukkit.entity.ItemFrame import org.bukkit.entity.Player import org.bukkit.plugin.Plugin import org.bukkit.scoreboard.Scoreboard -import java.util.logging.Level -abstract class BlockBallGameImpl( +abstract class SoccerGameImpl( /** - * Gets the arena. + * Gets the soccerArena. */ - override val arena: Arena, - val gameService: GameService, + override val arena: SoccerArena, private val placeHolderService: PlaceHolderService, private val packetService: PacketService, private val plugin: Plugin, private val bossBarService: BossBarService, private val scoreboardService: ScoreboardService, - private val ballEntityService: BallEntityService, + private val soccerBallFactory: SoccerBallFactory, private val chatMessageService: ChatMessageService, private val commandService: CommandService, + private val language: BlockBallLanguage, private val playerDataRepository: PlayerDataRepository -) : BlockBallGame { +) : SoccerGame { /** * Is the ball spawning? */ private var ballSpawning: Boolean = false /** - * Ball spawn counter. + * SoccerBall spawn counter. */ private var ballSpawnCounter: Int = 0 @@ -69,6 +66,14 @@ abstract class BlockBallGameImpl( */ override var scoreboard: Any? = null + /** + * Marks the game for being closed and will automatically + * switch to close state once the resources are cleard. + */ + override var closing: Boolean = false + + override var closed: Boolean = false + /** * Ingame bossbar. */ @@ -89,26 +94,15 @@ abstract class BlockBallGameImpl( */ override var blueScore: Int = 0 - /** - * Marks the game for being closed and will automatically - * switch to close state once the resources are cleard. - */ - override var closing: Boolean = false - - /** - * Is the game closed. - */ - override var closed: Boolean = false - /** * Status. */ override var status: GameState = GameState.JOINABLE /** - * Ball. + * SoccerBall. */ - override var ball: Ball? = null + override var ball: SoccerBall? = null /** * Contains players which are in cooldown by doublejump. @@ -121,7 +115,7 @@ abstract class BlockBallGameImpl( var playing: Boolean = false /** - * Ball bumper counter + * SoccerBall bumper counter */ override var ballBumperCounter: Int = 0 @@ -168,7 +162,6 @@ abstract class BlockBallGameImpl( } this.kickUnwantedEntitiesOutOfForcefield() - this.onUpdateSigns() this.updateScoreboard() this.updateBossBar() this.updateDoubleJumpCooldown() @@ -222,7 +215,7 @@ abstract class BlockBallGameImpl( /** * Gets called when the given [game] gets win by the given [team]. */ - fun onWin(team: Team, teamMeta: TeamMeta) { + fun onWin(team: Team) { val event = GameEndEvent(team, this) Bukkit.getPluginManager().callEvent(event) @@ -230,40 +223,35 @@ abstract class BlockBallGameImpl( return } - val winMessageTitle = teamMeta.winMessageTitle - val winMessageSubTitle = teamMeta.winMessageSubTitle - val players = ArrayList(inTeamPlayers) val additionalPlayers = getNofifiedPlayers() players.addAll(additionalPlayers.filter { pair -> pair.second }.map { p -> p.first as Player }) - players.forEach { p -> - require(p is Player) - chatMessageService.sendTitleMessage( - p, - placeHolderService.replacePlaceHolders(winMessageTitle, p, this), - placeHolderService.replacePlaceHolders(winMessageSubTitle, p, this), - teamMeta.winMessageFadeIn, - teamMeta.winMessageStay, - teamMeta.winMessageFadeOut, - ) + for (player in players) { + if (team == Team.RED) { + chatMessageService.sendTitleMessage( + player, + placeHolderService.replacePlaceHolders(language.winRedTitle, player, this), + placeHolderService.replacePlaceHolders(language.winRedSubTitle, player, this), + language.winRedFadeIn.toIntOrNull() ?: 20, + language.winRedStay.toIntOrNull() ?: 20, + language.winRedFadeOut.toIntOrNull() ?: 20, + ) + } else { + chatMessageService.sendTitleMessage( + player, + placeHolderService.replacePlaceHolders(language.winBlueTitle, player, this), + placeHolderService.replacePlaceHolders(language.winBlueSubTitle, player, this), + language.winBlueFadeIn.toIntOrNull() ?: 20, + language.winBlueStay.toIntOrNull() ?: 20, + language.winBlueFadeOut.toIntOrNull() ?: 20, + ) + } } closing = true } - /** - * Returns if the given [player] is allowed to join the match. - */ - protected fun isAllowedToJoinWithPermissions(player: Player): Boolean { - if (player.hasPermission(Permission.JOIN.permission + ".all") || player.hasPermission(Permission.JOIN.permission + "." + arena.name)) { - return true - } - - player.sendMessage(BlockBallLanguage.joinNoPermission) - return false - } - /** * Lets the given [player] in the given [game] respawn at the specified spawnpoint. */ @@ -305,7 +293,7 @@ abstract class BlockBallGameImpl( ball!!.remove() } - ball = ballEntityService.spawnTemporaryBall( + ball = soccerBallFactory.createSoccerBall( arena.meta.ballMeta.spawnpoint!!.toLocation(), arena.meta.ballMeta ) ballSpawning = false @@ -320,74 +308,7 @@ abstract class BlockBallGameImpl( } /** - * Gets called when the signs should be updated in the game lifecycle. - */ - protected fun onUpdateSigns() { - try { - for (i in arena.meta.redTeamMeta.signs.indices) { - val position = arena.meta.redTeamMeta.signs[i] - - if (!replaceTextOnSign( - position, arena.meta.redTeamMeta.signLines, arena.meta.redTeamMeta - ) - ) { - arena.meta.redTeamMeta.signs.removeAt(i) - return - } - } - for (i in arena.meta.blueTeamMeta.signs.indices) { - val position = arena.meta.blueTeamMeta.signs[i] - - if (!replaceTextOnSign( - position, arena.meta.blueTeamMeta.signLines, arena.meta.blueTeamMeta - ) - ) { - arena.meta.blueTeamMeta.signs.removeAt(i) - return - } - } - for (i in arena.meta.lobbyMeta.joinSigns.indices) { - val position = arena.meta.lobbyMeta.joinSigns[i] - - if (!replaceTextOnSign(position, arena.meta.lobbyMeta.joinSignLines, null)) { - arena.meta.lobbyMeta.joinSigns.removeAt(i) - return - } - } - for (i in arena.meta.lobbyMeta.leaveSigns.indices) { - val position = arena.meta.lobbyMeta.leaveSigns[i] - - if (!replaceTextOnSign(position, arena.meta.lobbyMeta.leaveSignLines, null)) { - arena.meta.lobbyMeta.leaveSigns.removeAt(i) - return - } - } - } catch (e: Exception) { // Removing sign task could clash with updating signs. - plugin.logger.log(Level.SEVERE, "Sign update was cached.", e) - } - } - - /** - * Replaces the text on the sign. - */ - private fun replaceTextOnSign( - signPosition: Vector3d, lines: List, teamMeta: TeamMeta? - ): Boolean { - var players = redTeam - - if (arena.meta.blueTeamMeta == teamMeta) { - players = blueTeam - } - - val location = signPosition.toLocation() - val placeHolderReplacedLines = - lines.map { l -> placeHolderService.replacePlaceHolders(l, null, this, teamMeta, players.size) } - - return location.setSignLines(placeHolderReplacedLines) - } - - /** - * Kicks entities out of the arena. + * Kicks entities out of the soccerArena. */ private fun kickUnwantedEntitiesOutOfForcefield() { if (!arena.meta.protectionMeta.entityProtectionEnabled) { @@ -597,36 +518,18 @@ abstract class BlockBallGameImpl( * Gets called when the given [game] ends with a draw. */ fun onDraw() { - val additionalPlayers = getNofifiedPlayers().filter { pair -> pair.second }.map { p -> p.first as Player } - additionalPlayers.forEach { p -> - chatMessageService.sendTitleMessage( - p, - placeHolderService.replacePlaceHolders(arena.meta.redTeamMeta.drawMessageTitle, p, this), - placeHolderService.replacePlaceHolders(arena.meta.redTeamMeta.drawMessageSubTitle, p, this), - arena.meta.redTeamMeta.drawMessageFadeIn, - arena.meta.redTeamMeta.drawMessageStay, - arena.meta.redTeamMeta.drawMessageFadeOut, - ) - } + val players = HashSet() + players.addAll(getNofifiedPlayers().filter { pair -> pair.second }.map { p -> p.first as Player }) + players.addAll(getPlayers()) - redTeam.forEach { p -> + for (player in players) { chatMessageService.sendTitleMessage( - p, - placeHolderService.replacePlaceHolders(arena.meta.redTeamMeta.drawMessageTitle, p, this), - placeHolderService.replacePlaceHolders(arena.meta.redTeamMeta.drawMessageSubTitle, p, this), - arena.meta.redTeamMeta.drawMessageFadeIn, - arena.meta.redTeamMeta.drawMessageStay, - arena.meta.redTeamMeta.drawMessageFadeOut, - ) - } - blueTeam.forEach { p -> - chatMessageService.sendTitleMessage( - p, - placeHolderService.replacePlaceHolders(arena.meta.blueTeamMeta.drawMessageTitle, p, this), - placeHolderService.replacePlaceHolders(arena.meta.blueTeamMeta.drawMessageSubTitle, p, this), - arena.meta.blueTeamMeta.drawMessageFadeIn, - arena.meta.blueTeamMeta.drawMessageStay, - arena.meta.blueTeamMeta.drawMessageFadeOut, + player, + placeHolderService.replacePlaceHolders(language.winDrawTitle, player, this), + placeHolderService.replacePlaceHolders(language.winDrawSubTitle, player, this), + language.winDrawFadeIn.toIntOrNull() ?: 20, + language.winDrawStay.toIntOrNull() ?: 60, + language.winDrawFadeOut.toIntOrNull() ?: 20, ) } } @@ -651,13 +554,13 @@ abstract class BlockBallGameImpl( if (teamOfGoal == Team.RED) { blueScore += arena.meta.blueTeamMeta.pointsPerGoal - onScore(Team.BLUE, arena.meta.blueTeamMeta) + onScore(Team.BLUE) onScoreReward(Team.BLUE, blueTeam) relocatePlayersAndBall() if (blueScore >= arena.meta.lobbyMeta.maxScore) { onMatchEnd(Team.BLUE) - onWin(Team.BLUE, arena.meta.blueTeamMeta) + onWin(Team.BLUE) } return @@ -665,13 +568,13 @@ abstract class BlockBallGameImpl( if (teamOfGoal == Team.BLUE) { redScore += arena.meta.redTeamMeta.pointsPerGoal - onScore(Team.RED, arena.meta.redTeamMeta) + onScore(Team.RED) onScoreReward(Team.BLUE, redTeam) relocatePlayersAndBall() if (redScore >= arena.meta.lobbyMeta.maxScore) { onMatchEnd(Team.RED) - onWin(Team.RED, arena.meta.redTeamMeta) + onWin(Team.RED) } } } @@ -697,7 +600,7 @@ abstract class BlockBallGameImpl( /** * Gets called when a goal gets scored on the given [game] by the given [team]. */ - private fun onScore(team: Team, teamMeta: TeamMeta) { + private fun onScore(team: Team) { var interactionEntity: Player? = null if (lastInteractedEntity != null && lastInteractedEntity is Player) { @@ -720,9 +623,6 @@ abstract class BlockBallGameImpl( return } - val scoreMessageTitle = teamMeta.scoreMessageTitle - val scoreMessageSubTitle = teamMeta.scoreMessageSubTitle - val players = ArrayList(inTeamPlayers) val additionalPlayers = getNofifiedPlayers() players.addAll(additionalPlayers.filter { pair -> pair.second }.map { p -> p.first as Player }) @@ -739,16 +639,28 @@ abstract class BlockBallGameImpl( null } - players.forEach { p -> - require(p is Player) - chatMessageService.sendTitleMessage( - p, - placeHolderService.replacePlaceHolders(scoreMessageTitle, p, this, scoreTeamMeta), - placeHolderService.replacePlaceHolders(scoreMessageSubTitle, p, this, scoreTeamMeta), - teamMeta.scoreMessageFadeIn, - teamMeta.scoreMessageStay, - teamMeta.scoreMessageFadeOut - ) + if (team == Team.RED) { + for (player in players) { + chatMessageService.sendTitleMessage( + player, + placeHolderService.replacePlaceHolders(language.scoreRedTitle, player, this, scoreTeamMeta), + placeHolderService.replacePlaceHolders(language.scoreRedSubTitle, player, this, scoreTeamMeta), + language.scoreRedFadeIn.toIntOrNull() ?: 20, + language.scoreRedStay.toIntOrNull() ?: 60, + language.scoreRedFadeOut.toIntOrNull() ?: 20 + ) + } + } else { + for (player in players) { + chatMessageService.sendTitleMessage( + player, + placeHolderService.replacePlaceHolders(language.scoreBlueTitle, player, this, scoreTeamMeta), + placeHolderService.replacePlaceHolders(language.scoreBlueSubTitle, player, this, scoreTeamMeta), + language.scoreBlueFadeIn.toIntOrNull() ?: 20, + language.scoreBlueStay.toIntOrNull() ?: 60, + language.scoreBlueFadeOut.toIntOrNull() ?: 20 + ) + } } plugin.launch { @@ -829,4 +741,14 @@ abstract class BlockBallGameImpl( return arena.meta.blueTeamMeta } + + /** + * Gets all players. + */ + override fun getPlayers(): Set { + val players = HashSet() + players.addAll(redTeam) + players.addAll(blueTeam) + return players + } } diff --git a/src/main/java/com/github/shynixn/blockball/impl/BlockBallHubGameImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/SoccerHubGameImpl.kt similarity index 88% rename from src/main/java/com/github/shynixn/blockball/impl/BlockBallHubGameImpl.kt rename to src/main/java/com/github/shynixn/blockball/impl/SoccerHubGameImpl.kt index b44c3aa8c..3630e41da 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BlockBallHubGameImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/SoccerHubGameImpl.kt @@ -17,49 +17,39 @@ import org.bukkit.entity.Player import org.bukkit.plugin.Plugin import org.bukkit.scoreboard.Scoreboard -class BlockBallHubGameImpl( - override val arena: Arena, - gameService: GameService, +class SoccerHubGameImpl( + arena: SoccerArena, private val playerDataRepository: PlayerDataRepository, private val plugin: Plugin, private val placeHolderService: PlaceHolderService, private val bossBarService: BossBarService, + private val language: BlockBallLanguage, packetService: PacketService, scoreboardService: ScoreboardService, - ballEntityService: BallEntityService, + soccerBallFactory: SoccerBallFactory, chatMessageService: ChatMessageService, commandService: CommandService -) : BlockBallGameImpl( +) : SoccerGameImpl( arena, - gameService, placeHolderService, packetService, plugin, bossBarService, scoreboardService, - ballEntityService, + soccerBallFactory, chatMessageService, commandService, + language, playerDataRepository ), - BlockBallHubGame { + SoccerHubGame { /** * Lets the given [player] leave join. Optional can the prefered - * [team] be specified but the team can still change because of arena settings. + * [team] be specified but the team can still change because of soccerArena settings. * Does nothing if the player is already in a Game. */ override fun join(player: Player, team: Team?): JoinResult { - if (!isAllowedToJoinWithPermissions(player)) { - return JoinResult.NO_PERMISSION - } - - val otherGame = gameService.getGameFromPlayer(player) - - if (otherGame != null) { - leave(player) - } - val event = GameJoinEvent(player, this) Bukkit.getPluginManager().callEvent(event) @@ -154,28 +144,19 @@ class BlockBallHubGameImpl( if (stats.team == Team.RED) { executeCommandsWithPlaceHolder(listOf(player), arena.meta.redTeamMeta.leaveCommands) - player.sendMessage( - placeHolderService.replacePlaceHolders( - arena.meta.redTeamMeta.leaveMessage, - player, - this, - null, - null - ) - ) } else if (stats.team == Team.BLUE) { executeCommandsWithPlaceHolder(listOf(player), arena.meta.blueTeamMeta.leaveCommands) - player.sendMessage( - placeHolderService.replacePlaceHolders( - arena.meta.redTeamMeta.leaveMessage, - player, - this, - null, - null - ) - ) } + player.sendMessage( + placeHolderService.replacePlaceHolders( + language.leftGameMessage, + player, + this, + null, + null + ) + ) ingamePlayersStorage.remove(player) if (arena.meta.lobbyMeta.leaveSpawnpoint != null) { @@ -193,7 +174,6 @@ class BlockBallHubGameImpl( // Handle HubGame ticking. if (!arena.enabled || closing) { status = GameState.DISABLED - onUpdateSigns() close() if (ingamePlayersStorage.isNotEmpty()) { closing = true @@ -213,7 +193,7 @@ class BlockBallHubGameImpl( closing = true } - // Handle Ball. + // Handle SoccerBall. this.fixBallPositionSpawn() if (ticks >= 20) { this.handleBallSpawning() @@ -306,7 +286,12 @@ class BlockBallHubGameImpl( player.velocity = velocityIntoArena } - val message = placeHolderService.replacePlaceHolders(teamMeta.joinMessage, player, this, teamMeta, 0) + val message = if(team == Team.RED) { + placeHolderService.replacePlaceHolders(language.joinTeamRedMessage, player, this, teamMeta, 0) + }else{ + placeHolderService.replacePlaceHolders(language.joinTeamBlueMessage, player, this, teamMeta, 0) + } + player.sendMessage(message) } } diff --git a/src/main/java/com/github/shynixn/blockball/impl/BlockBallMiniGameImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/SoccerMiniGameImpl.kt similarity index 81% rename from src/main/java/com/github/shynixn/blockball/impl/BlockBallMiniGameImpl.kt rename to src/main/java/com/github/shynixn/blockball/impl/SoccerMiniGameImpl.kt index 2d1bfe3e7..7d9b4fb38 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BlockBallMiniGameImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/SoccerMiniGameImpl.kt @@ -1,6 +1,5 @@ package com.github.shynixn.blockball.impl -import com.github.shynixn.blockball.BlockBallLanguage import com.github.shynixn.blockball.contract.* import com.github.shynixn.blockball.entity.* import com.github.shynixn.blockball.enumeration.* @@ -23,9 +22,8 @@ import org.bukkit.entity.Player import org.bukkit.plugin.Plugin import org.bukkit.scoreboard.Scoreboard -class BlockBallMiniGameImpl constructor( - override val arena: Arena, - gameService: GameService, +class SoccerMiniGameImpl constructor( + arena: SoccerArena, private val playerDataRepository: PlayerDataRepository, private val plugin: Plugin, private val placeHolderService: PlaceHolderService, @@ -33,23 +31,24 @@ class BlockBallMiniGameImpl constructor( private val chatMessageService: ChatMessageService, private val configurationService: ConfigurationService, private val soundService: SoundService, + private val language: BlockBallLanguage, packetService: PacketService, scoreboardService: ScoreboardService, commandService: CommandService, - ballEntityService: BallEntityService -) : BlockBallGameImpl( + soccerBallFactory: SoccerBallFactory +) : SoccerGameImpl( arena, - gameService, placeHolderService, packetService, plugin, bossBarService, scoreboardService, - ballEntityService, + soccerBallFactory, chatMessageService, commandService, + language, playerDataRepository -), BlockBallMiniGame { +), SoccerMiniGame { /** * Is the lobby countdown active. @@ -85,19 +84,6 @@ class BlockBallMiniGameImpl constructor( return false } - /** - * Storage for [spectatorPlayers], - */ - val spectatorPlayersStorage: MutableMap = HashMap() - - /** - * List of players which are spectating the game. - */ - override val spectatorPlayers: List - get() { - return spectatorPlayersStorage.keys.toList() - } - /** * Returns the bling sound. */ @@ -107,47 +93,12 @@ class BlockBallMiniGameImpl constructor( it.pitch = 2.0 } - /** - * Lets the given [player] leave spectate the given [game]. - * Does nothing if the player is already spectating a Game. - */ - override fun spectate(player: Player) { - if (spectatorPlayers.contains(player)) { - return - } - - if (!isAllowedToSpectateWithPermissions(player)) { - return - } - - val storage = createPlayerStorage(player) - spectatorPlayersStorage[player] = storage - player.gameMode = GameMode.SPECTATOR - player.isFlying = true - - if (arena.meta.spectatorMeta.spectateSpawnpoint != null) { - player.teleport(arena.meta.spectatorMeta.spectateSpawnpoint!!.toLocation()) - } else { - player.teleport(arena.meta.ballMeta.spawnpoint!!.toLocation()) - } - } - /** * Lets the given [player] leave join. Optional can the prefered - * [team] be specified but the team can still change because of arena settings. + * [team] be specified but the team can still change because of soccerArena settings. * Does nothing if the player is already in a Game. */ override fun join(player: Player, team: Team?): JoinResult { - if (!isAllowedToJoinWithPermissions(player)) { - return JoinResult.NO_PERMISSION - } - - val otherGame = gameService.getGameFromPlayer(player) - - if (otherGame != null) { - leave(player) - } - val event = GameJoinEvent(player, this) Bukkit.getPluginManager().callEvent(event) @@ -156,19 +107,6 @@ class BlockBallMiniGameImpl constructor( } if (playing || isLobbyFull) { - val b = ChatBuilder().text( - placeHolderService.replacePlaceHolders( - arena.meta.spectatorMeta.spectateStartMessage[0], player, this - ) - ).nextLine().component( - placeHolderService.replacePlaceHolders( - arena.meta.spectatorMeta.spectateStartMessage[1], player, this - ) - ).setClickAction( - ChatClickAction.RUN_COMMAND, - "/" + configurationService.findValue("global-spectate.command") + " " + arena.name - ).setHoverText(" ").builder() - chatMessageService.sendChatMessage(player, b.convertToTextComponent()) return JoinResult.GAME_FULL } @@ -205,13 +143,6 @@ class BlockBallMiniGameImpl constructor( * Leaves the given player. */ override fun leave(player: Player): LeaveResult { - if (spectatorPlayers.contains(player)) { - resetStorage(player, spectatorPlayersStorage[player]!!) - spectatorPlayersStorage.remove(player) - player.teleport(arena.meta.lobbyMeta.leaveSpawnpoint!!.toLocation()) - return LeaveResult.SUCCESS - } - if (!ingamePlayersStorage.containsKey(player)) { return LeaveResult.NOT_IN_MATCH } @@ -245,28 +176,19 @@ class BlockBallMiniGameImpl constructor( if (storage.team == Team.RED) { executeCommandsWithPlaceHolder(listOf(player), arena.meta.redTeamMeta.leaveCommands) - player.sendMessage( - placeHolderService.replacePlaceHolders( - arena.meta.redTeamMeta.leaveMessage, - player, - this, - null, - null - ) - ) } else if (storage.team == Team.BLUE) { executeCommandsWithPlaceHolder(listOf(player), arena.meta.blueTeamMeta.leaveCommands) - player.sendMessage( - placeHolderService.replacePlaceHolders( - arena.meta.redTeamMeta.leaveMessage, - player, - this, - null, - null - ) - ) } + player.sendMessage( + placeHolderService.replacePlaceHolders( + language.leftGameMessage, + player, + this, + null, + null + ) + ) ingamePlayersStorage.remove(player) } @@ -284,7 +206,6 @@ class BlockBallMiniGameImpl constructor( // Handle HubGame ticking. if (!arena.enabled || closing) { status = GameState.DISABLED - onUpdateSigns() close() if (ingamePlayersStorage.isNotEmpty()) { closing = true @@ -408,7 +329,7 @@ class BlockBallMiniGameImpl constructor( } } - // Handle Ball. + // Handle SoccerBall. this.fixBallPositionSpawn() if (ticks >= 20) { this.handleBallSpawning() @@ -425,11 +346,6 @@ class BlockBallMiniGameImpl constructor( if (closed) { return } - - spectatorPlayers.forEach { p -> - leave(p) - } - status = GameState.DISABLED closed = true ingamePlayersStorage.keys.toTypedArray().forEach { p -> @@ -490,11 +406,19 @@ class BlockBallMiniGameImpl constructor( executeCommandsWithPlaceHolder(listOf(player), teamMeta.joinCommands) - player.sendMessage( - placeHolderService.replacePlaceHolders( - teamMeta.joinMessage, player, this, teamMeta, players.size + if (team == Team.RED) { + player.sendMessage( + placeHolderService.replacePlaceHolders( + language.joinTeamRedMessage, player, this, teamMeta, players.size + ) ) - ) + } else { + player.sendMessage( + placeHolderService.replacePlaceHolders( + language.joinTeamBlueMessage, player, this, teamMeta, players.size + ) + ) + } } @@ -638,12 +562,12 @@ class BlockBallMiniGameImpl constructor( redScore > blueScore -> { onMatchEnd(Team.RED) - onWin(Team.RED, arena.meta.redTeamMeta) + onWin(Team.RED) } else -> { onMatchEnd(Team.BLUE) - onWin(Team.BLUE, arena.meta.blueTeamMeta) + onWin(Team.BLUE) } } @@ -651,7 +575,6 @@ class BlockBallMiniGameImpl constructor( closing = false } - /** * Returns if the lobby countdown can already be started. * @return canStart @@ -665,22 +588,4 @@ class BlockBallMiniGameImpl constructor( return false } - - - /** - * Returns if the given [player] is allowed to spectate the match. - */ - private fun isAllowedToSpectateWithPermissions(player: Player): Boolean { - val hasSpectatingPermission = - player.hasPermission(Permission.SPECTATE.permission + ".all") || player.hasPermission( - Permission.SPECTATE.permission + "." + arena.name - ) - - if (hasSpectatingPermission) { - return true - } - - player.sendMessage(BlockBallLanguage.spectateNoPermission) - return false - } } diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/ArenaCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/ArenaCommandExecutor.kt deleted file mode 100644 index f098ac2bb..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/ArenaCommandExecutor.kt +++ /dev/null @@ -1,201 +0,0 @@ -package com.github.shynixn.blockball.impl.commandexecutor - -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.ChatClickAction -import com.github.shynixn.blockball.enumeration.MenuCommand -import com.github.shynixn.blockball.enumeration.MenuCommandResult -import com.github.shynixn.blockball.impl.commandmenu.* -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.chat.ChatMessageService -import com.google.inject.Inject -import org.bukkit.command.CommandSender -import org.bukkit.entity.Player -import org.bukkit.plugin.Plugin -import java.util.logging.Level - -class ArenaCommandExecutor @Inject constructor( - private val plugin: Plugin, - private val chatMessageService: ChatMessageService, - openPage: OpenPage, - mainConfigurationPage: MainConfigurationPage, - spectatePage: SpectatePage, - mainSettingsPage: MainSettingsPage, - ballSettingsPage: BallSettingsPage, - ballModifierPage: BallModifierSettingsPage, - listablePage: ListablePage, - teamSettingsPage: TeamSettingsPage, - effectsSettingsPage: EffectsSettingsPage, - multipleLinesPage: MultipleLinesPage, - hologramsPage: HologramPage, - scoreboardPage: ScoreboardPage, - bossbarPage: BossbarPage, - signSettingsPage: SignSettingsPage, - soundsPage: SoundEffectPage, - abilitiesPage: AbilitiesSettingsPage, - doubleJumpPage: DoubleJumpPage, - miscPage: MiscSettingsPage, - gamePropertiesPage: GamePropertiesPage, - areaProtectionPage: AreaProtectionPage, - teamTextBookPage: TeamTextBookPage, - gameSettingsPage: GameSettingsPage, - spectatingSettingsPage: SpectatingSettingsPage, - notificationPage: NotificationPage, - matchtimesPage: MatchTimesPage -) : CommandExecutor { - - - companion object { - private val HEADER_STANDARD = - ChatColor.WHITE.toString() + "" + ChatColor.BOLD + "" + ChatColor.UNDERLINE + " BlockBall " - private val FOOTER_STANDARD = - ChatColor.WHITE.toString() + "" + ChatColor.BOLD + "" + ChatColor.UNDERLINE + " ┌1/1┐ " - } - - private val cache = HashMap>() - private var pageCache: MutableList = arrayListOf( - openPage, - mainConfigurationPage, - spectatePage, - mainSettingsPage, - ballSettingsPage, - ballModifierPage, - listablePage, - teamSettingsPage, - effectsSettingsPage, - multipleLinesPage, - hologramsPage, - scoreboardPage, - bossbarPage, - signSettingsPage, - soundsPage, - abilitiesPage, - doubleJumpPage, - miscPage, - gamePropertiesPage, - areaProtectionPage, - teamTextBookPage, - gameSettingsPage, - spectatingSettingsPage, - notificationPage, - matchtimesPage - ) - - /** - * Gets called when the given [source] executes the defined command with the given [args]. - */ - override fun onExecuteCommand(source: CommandSender, args: Array): Boolean { - try { - for (i in 0..19) { - source.sendMessage("") - } - source.sendMessage(HEADER_STANDARD) - source.sendMessage("\n") - if (!this.cache.containsKey(source)) { - val anyArray = arrayOfNulls(8) - this.cache[source] = anyArray - } - val cache: Array? = this.cache[source] - val command = MenuCommand.from(args) - ?: throw IllegalArgumentException("Command is not registered!") - var usedPage: Page? = null - for (page in this.pageCache) { - if (page.getCommandKey() === command.key) { - usedPage = page - if (command == MenuCommand.BACK) { - val newPage = this.getPageById(Integer.parseInt(args[2])) - val b = newPage.buildPage(cache!!)!! - if (source is Player) { - chatMessageService.sendChatMessage(source, b.convertToTextComponent()) - } - } else if (command == MenuCommand.CLOSE) { - this.cache.remove(source) - for (i in 0..19) { - source.sendMessage("") - } - return true - } else { - @Suppress("UNCHECKED_CAST") val result = - page.execute(source, command, cache!!, args as Array) - if (result == MenuCommandResult.BACK) { - if (source is Player) { - source.performCommand("blockball open back " + usedPage.getPreviousIdFrom(cache)) - } - return true - } - if (result == MenuCommandResult.EXIT_COMP) { - return true - } - if (result != MenuCommandResult.SUCCESS && result != MenuCommandResult.CANCEL_MESSAGE) { - source.sendMessage(ChatColor.RED.toString() + result.message) - } - if (result != MenuCommandResult.CANCEL_MESSAGE) { - val b = page.buildPage(cache)!! - if (source is Player) { - chatMessageService.sendChatMessage(source, b.convertToTextComponent()) - } - } - } - break - } - } - if (usedPage == null) - throw IllegalArgumentException("Cannot find page with key " + command.key) - val builder = ChatBuilder() - .text(ChatColor.STRIKETHROUGH.toString() + "----------------------------------------------------") - .nextLine() - .component(" >>Save<< ") - .setColor(ChatColor.GREEN) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_SAVE.command) - .setHoverText("Saves the current arena if possible.") - .builder() - if (usedPage is ListablePage) { - builder.component(">>Back<<") - .setColor(ChatColor.RED) - .setClickAction(ChatClickAction.RUN_COMMAND, (cache!![3] as MenuCommand).command) - .setHoverText("Goes back to the previous page.") - .builder() - } else { - builder.component(">>Back<<") - .setColor(ChatColor.RED) - .setClickAction( - ChatClickAction.RUN_COMMAND, - MenuCommand.BACK.command + usedPage.getPreviousIdFrom(cache!!) - ) - .setHoverText("Goes back to the previous page.") - .builder() - } - val b = builder.component(" >>Save and reload<<") - .setColor(ChatColor.BLUE) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_RELOAD.command) - .setHoverText("Saves the current arena and reloads all games on the server.") - .builder() - - if (source is Player) { - chatMessageService.sendChatMessage(source, b.convertToTextComponent()) - source.sendMessage(FOOTER_STANDARD) - } - } catch (e: Exception) { - plugin.logger.log(Level.WARNING, "Command completion failed.", e) - source.sendMessage("[BlockBall] Cannot find command.") - val data = StringBuilder() - args.map { d -> data.append(d).append(" ") } - plugin.logger.log(Level.INFO, "Cannot find command for args $data.") - } - - return true - } - - /** - * Returns the [Page] with the given [id] and throws - * a [RuntimeException] if the page is not found. - */ - private fun getPageById(id: Int): Page { - for (page in this.pageCache) { - if (page.id == id) { - return page - } - } - throw RuntimeException("Page does not exist!") - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/BlockBallCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/BlockBallCommandExecutor.kt new file mode 100644 index 000000000..c11723922 --- /dev/null +++ b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/BlockBallCommandExecutor.kt @@ -0,0 +1,490 @@ +package com.github.shynixn.blockball.impl.commandexecutor + +import com.github.shynixn.blockball.BlockBallLanguageImpl +import com.github.shynixn.blockball.contract.BlockBallLanguage +import com.github.shynixn.blockball.contract.GameService +import com.github.shynixn.blockball.entity.SoccerArena +import com.github.shynixn.blockball.entity.TeamMeta +import com.github.shynixn.blockball.enumeration.* +import com.github.shynixn.blockball.impl.exception.SoccerGameException +import com.github.shynixn.mccoroutine.bukkit.launch +import com.github.shynixn.mcutils.common.* +import com.github.shynixn.mcutils.common.chat.ChatMessageService +import com.github.shynixn.mcutils.common.command.CommandBuilder +import com.github.shynixn.mcutils.common.command.CommandMeta +import com.github.shynixn.mcutils.common.command.CommandType +import com.github.shynixn.mcutils.common.command.Validator +import com.github.shynixn.mcutils.common.repository.CacheRepository +import com.github.shynixn.mcutils.sign.SignService +import com.google.inject.Inject +import org.bukkit.command.CommandSender +import org.bukkit.configuration.file.YamlConfiguration +import org.bukkit.entity.Player +import org.bukkit.plugin.Plugin +import java.util.* +import java.util.logging.Level + +class BlockBallCommandExecutor @Inject constructor( + private val arenaRepository: CacheRepository, + private val gameService: GameService, + private val plugin: Plugin, + private val configurationService: ConfigurationService, + private val language: BlockBallLanguage, + private val signService: SignService, + chatMessageService: ChatMessageService +) { + private val arenaTabs: suspend (s: CommandSender) -> List = { + arenaRepository.getAll().map { e -> e.name } + } + private val coroutineExecutor = object : CoroutineExecutor { + override fun execute(f: suspend () -> Unit) { + plugin.launch { + f.invoke() + } + } + } + + private val remainingStringValidator = object : Validator { + override suspend fun transform(sender: CommandSender, prevArgs: List, openArgs: List): String { + return openArgs.joinToString(" ") + } + } + private val maxLengthValidator = object : Validator { + override suspend fun validate( + sender: CommandSender, + prevArgs: List, + argument: String, + openArgs: List + ): Boolean { + return argument.length < 20 + } + + override suspend fun message(sender: CommandSender, prevArgs: List, openArgs: List): String { + return language.maxLength20Characters + } + } + private val gameMustNotExistValidator = object : Validator { + override suspend fun validate( + sender: CommandSender, + prevArgs: List, + argument: String, + openArgs: List + ): Boolean { + val existingArenas = arenaRepository.getAll() + return existingArenas.firstOrNull { e -> e.name.equals(argument, true) } == null + } + + override suspend fun message(sender: CommandSender, prevArgs: List, openArgs: List): String { + return language.gameAlreadyExistsMessage.format(openArgs[0]) + } + } + private val gameMustExistValidator = object : Validator { + override suspend fun transform( + sender: CommandSender, prevArgs: List, openArgs: List + ): SoccerArena? { + val existingArenas = arenaRepository.getAll() + return existingArenas.firstOrNull { e -> e.name.equals(openArgs[0], true) } + } + + override suspend fun message(sender: CommandSender, prevArgs: List, openArgs: List): String { + return language.gameDoesNotExistMessage.format(openArgs[0]) + } + } + private val teamValidator = object : Validator { + override suspend fun transform( + sender: CommandSender, prevArgs: List, openArgs: List + ): Team? { + return try { + Team.valueOf(openArgs[0].uppercase(Locale.ENGLISH)) + } catch (e: Exception) { + return null + } + } + + override suspend fun message(sender: CommandSender, prevArgs: List, openArgs: List): String { + return language.teamDoesNotExistMessage.format(openArgs[0]) + } + } + + private val teamMetaValidator = object : Validator { + override suspend fun transform( + sender: CommandSender, prevArgs: List, openArgs: List + ): TeamMeta? { + val team: Team = try { + Team.valueOf(openArgs[0].uppercase(Locale.ENGLISH)) + } catch (e: Exception) { + return null + } + val arena = prevArgs[prevArgs.size - 1] as SoccerArena + val teamMeta = if (team == Team.RED) { + arena.meta.redTeamMeta + } else { + arena.meta.blueTeamMeta + } + return teamMeta + } + + override suspend fun message(sender: CommandSender, prevArgs: List, openArgs: List): String { + return language.teamDoesNotExistMessage.format(openArgs[0]) + } + } + + private val locationTypeValidator = object : Validator { + override suspend fun transform( + sender: CommandSender, prevArgs: List, openArgs: List + ): LocationType? { + return LocationType.values().firstOrNull { e -> e.id.equals(openArgs[0], true) } + } + + override suspend fun message(sender: CommandSender, prevArgs: List, openArgs: List): String { + return language.locationTypeDoesNotExistMessage + } + } + private val signTypeValidator = object : Validator { + override suspend fun transform( + sender: CommandSender, prevArgs: List, openArgs: List + ): SignType? { + return SignType.values().firstOrNull { e -> e.name.equals(openArgs[0], true) } + } + + override suspend fun message(sender: CommandSender, prevArgs: List, openArgs: List): String { + return language.signTypeDoesNotExistMessage + } + } + + init { + val mcCart = CommandBuilder(plugin, coroutineExecutor, "blockball", chatMessageService) { + usage(language.commandUsage.translateChatColors()) + description(language.commandDescription) + aliases(plugin.config.getStringList("commands.blockball.aliases")) + permission(Permission.COMMAND) + permissionMessage(language.noPermissionMessage.translateChatColors()) + subCommand("create") { + permission(Permission.EDIT_GAME) + builder().argument("name").validator(maxLengthValidator).validator(maxLengthValidator) + .validator(gameMustNotExistValidator).tabs { listOf("") }.argument("displayName") + .validator(remainingStringValidator).tabs { listOf("") } + .execute { sender, name, displayName -> createArena(sender, name, displayName) } + } + subCommand("delete") { + permission(Permission.EDIT_GAME) + builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .execute { sender, arena -> deleteArena(sender, arena) } + } + subCommand("list") { + permission(Permission.EDIT_GAME) + builder().execute { sender -> listArena(sender) } + } + subCommand("toggle") { + permission(Permission.EDIT_GAME) + builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .execute { sender, arena -> toggleGame(sender, arena) } + } + subCommand("join") { + noPermission() + builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .executePlayer({ language.commandSenderHasToBePlayer }) { sender, arena -> + joinGame( + sender, arena.name + ) + }.argument("team").validator(teamValidator).tabs { listOf("red", "blue") } + .executePlayer({ language.commandSenderHasToBePlayer }) { sender, arena, team -> + joinGame(sender, arena.name, team) + } + } + subCommand("leave") { + noPermission() + builder().executePlayer({ language.commandSenderHasToBePlayer }) { sender -> leaveGame(sender) } + } + helpCommand() + subCommand("location") { + permission(Permission.EDIT_GAME) + builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .argument("type").validator(locationTypeValidator).tabs { LocationType.values().map { e -> e.id } } + .executePlayer({ language.commandSenderHasToBePlayer }) { player, arena, locationType -> + setLocation(player, arena, locationType) + } + } + subCommand("inventory") { + permission(Permission.EDIT_GAME) + builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .argument("team").validator(teamMetaValidator).tabs { listOf("red", "blue") } + .executePlayer({ language.commandSenderHasToBePlayer }) { player, arena, meta -> + setInventory(player, arena, meta) + } + } + subCommand("armor") { + permission(Permission.EDIT_GAME) + builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .argument("team").validator(teamMetaValidator).tabs { listOf("red", "blue") } + .executePlayer({ language.commandSenderHasToBePlayer }) { player, arena, meta -> + setArmor(player, arena, meta) + } + } + subCommand("sign") { + permission(Permission.EDIT_GAME) + builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .argument("type").validator(signTypeValidator).tabs { listOf("join", "leave") } + .executePlayer({ language.commandSenderHasToBePlayer }) { player, arena, signType -> + setSign(player, arena, signType) + } + } + subCommand("reload") { + permission(Permission.EDIT_GAME) + builder() + .execute { sender -> + reloadArena(sender, null) + } + .argument("name").validator(gameMustExistValidator).tabs(arenaTabs) + .execute { sender, arena -> + reloadArena(sender, arena) + } + } + + } + mcCart.build() + } + + private suspend fun createArena(sender: CommandSender, name: String, displayName: String) { + val arena = SoccerArena() + arena.name = name + arena.displayName = displayName + arenaRepository.save(arena) + sender.sendMessage(language.gameCreatedMessage.format(name)) + } + + private suspend fun deleteArena(sender: CommandSender, arena: SoccerArena) { + val runningGame = gameService.getAll().firstOrNull { e -> e.arena.name.equals(arena.name, true) } + runningGame?.close() + arenaRepository.delete(arena) + sender.sendMessage(language.deletedGameMessage.format(arena.name)) + } + + private suspend fun toggleGame(sender: CommandSender, arena: SoccerArena) { + try { + arena.enabled = !arena.enabled + gameService.reload(arena) + sender.sendMessage(language.enabledArenaMessage.format(arena.enabled.toString())) + } catch (e: SoccerGameException) { + arena.enabled = !arena.enabled + sender.sendMessage(ChatColor.RED.toString() + "Failed to reload soccerArena ${e.arena.name}.") + sender.sendMessage(e.message) + return + } + arenaRepository.save(arena) + sender.sendMessage(language.reloadedGameMessage.format(arena.name)) + } + + private suspend fun setInventory(player: Player, arena: SoccerArena, teamMetadata: TeamMeta) { + teamMetadata.inventory = player.inventory.contents.clone().map { e -> + val yamlConfiguration = YamlConfiguration() + yamlConfiguration.set("item", e) + yamlConfiguration.saveToString() + }.toTypedArray() + arenaRepository.save(arena) + player.sendMessage(language.updatedInventoryMessage) + } + + private suspend fun setArmor(player: Player, arena: SoccerArena, teamMeta: TeamMeta) { + teamMeta.armor = player.inventory.armorContents.clone().map { e -> + val yamlConfiguration = YamlConfiguration() + yamlConfiguration.set("item", e) + yamlConfiguration.saveToString() + }.toTypedArray() + arenaRepository.save(arena) + player.sendMessage(language.updatedArmorMessage) + } + + private fun CommandBuilder.permission(permission: Permission) { + this.permission(permission.permission) + } + + private suspend fun listArena(sender: CommandSender) { + val existingArenas = arenaRepository.getAll() + + sender.sendMessage("---------BlockBall---------") + for (arena in existingArenas) { + if (arena.enabled) { + sender.sendMessage(ChatColor.GRAY.toString() + arena.name + " [${arena.displayName.translateChatColors()}" + ChatColor.GRAY + "] " + ChatColor.GREEN + "[enabled]") + } else { + sender.sendMessage(ChatColor.GRAY.toString() + arena.name + " [${arena.displayName.translateChatColors()}" + ChatColor.GRAY + "] " + ChatColor.RED + "[disabled]") + + } + + sender.sendMessage() + } + sender.sendMessage("----------┌1/1┐----------") + } + + private fun joinGame(player: Player, name: String, team: Team? = null) { + for (game in gameService.getAll()) { + if (game.getPlayers().contains(player)) { + if (game.arena.name.equals(name, true)) { + // Do not leave, if it is the same game. + return + } + + game.leave(player) + } + } + + val game = gameService.getByName(name) + + if (game == null) { + player.sendMessage(language.gameDoesNotExistMessage.format(name)) + return + } + + if (!player.hasPermission( + Permission.JOIN.permission.replace( + "[name]", + game.arena.name + ) + ) && !player.hasPermission(Permission.JOIN.permission.replace("[name]", "*")) + ) { + player.sendMessage(language.noPermissionForGameMessage.format(game.arena.name)) + return + } + + val joinResult = game.join(player, team) + + if (team != null && joinResult == JoinResult.TEAM_FULL) { + if (team == Team.BLUE) { + return joinGame(player, name, Team.RED) + } else { + return joinGame(player, name, Team.BLUE) + } + } + + if (joinResult == JoinResult.GAME_FULL || joinResult == JoinResult.GAME_ALREADY_RUNNING) { + player.sendMessage(language.gameIsFullMessage) + return + } + + if (joinResult == JoinResult.SUCCESS_BLUE) { + player.sendMessage(language.joinTeamBlueMessage) + } else if (joinResult == JoinResult.SUCCESS_RED) { + player.sendMessage(language.joinTeamRedMessage) + } + } + + private fun leaveGame(player: Player) { + var leftGame = false + + for (game in gameService.getAll()) { + if (game.getPlayers().contains(player)) { + game.leave(player) + leftGame = true + } + } + + if (leftGame) { + player.sendMessage(language.leftGameMessage) + } + } + + private suspend fun setLocation(player: Player, arena: SoccerArena, locationType: LocationType) { + if (locationType == LocationType.LOBBY_RED) { + arena.meta.redTeamMeta.lobbySpawnpoint = player.location.toVector3d() + } + arenaRepository.save(arena) + player.sendMessage(language.spawnPointSetMessage.format(locationType.name.uppercase(), player.location)) + } + + private suspend fun setSign(sender: Player, arena: SoccerArena, signType: SignType) { + if (signType == SignType.JOIN) { + sender.sendMessage(language.rightClickOnSignMessage) + signService.addSignByRightClick(sender) { sign -> + sign.let { + it.line1 = "%mctennis_lang_joinSignLine1%" + it.line2 = "%mctennis_lang_joinSignLine2%" + it.line3 = "%mctennis_lang_joinSignLine3%" + it.line4 = "%mctennis_lang_joinSignLine4%" + it.cooldown = 20 + it.update = 40 + it.commands = mutableListOf(CommandMeta().also { + it.command = "/mctennis join ${arena.name}" + it.type = CommandType.PER_PLAYER + }) + } + + if (arena.meta.lobbyMeta.joinSigns.firstOrNull { e -> e.isSameSign(sign) } == null) { + arena.meta.lobbyMeta.joinSigns.add(sign) + } + + plugin.launch { + arenaRepository.save(arena) + gameService.reload(arena) + sender.sendMessage(language.addedSignMessage) + } + } + } else if (signType == SignType.LEAVE) { + sender.sendMessage(language.rightClickOnSignMessage) + signService.addSignByRightClick(sender) { sign -> + sign.let { + it.line1 = "%mctennis_lang_leaveSignLine1%" + it.line2 = "%mctennis_lang_leaveSignLine2%" + it.line3 = "%mctennis_lang_leaveSignLine3%" + it.line4 = "%mctennis_lang_leaveSignLine4%" + it.cooldown = 20 + it.update = 40 + it.commands = mutableListOf(CommandMeta().also { + it.command = "/mctennis leave" + it.type = CommandType.PER_PLAYER + }) + } + + if (arena.meta.lobbyMeta.joinSigns.firstOrNull { e -> e.isSameSign(sign) } == null) { + arena.meta.lobbyMeta.joinSigns.add(sign) + } + + plugin.launch { + arenaRepository.save(arena) + gameService.reload(arena) + sender.sendMessage(language.addedSignMessage) + } + } + } + } + + + private suspend fun reloadArena(sender: CommandSender, arena: SoccerArena?) { + try { + arenaRepository.clearCache() + } catch (e: SoccerGameException) { + sender.sendMessage(ChatColor.RED.toString() + "Failed to reload arenas.") + sender.sendMessage(e.message) + return + } + + if (arena == null) { + plugin.reloadConfig() + val languageDef = configurationService.findValue("language") + plugin.reloadTranslation(languageDef, BlockBallLanguageImpl::class.java, "en_us") + plugin.logger.log(Level.INFO, "Loaded language file $languageDef.properties.") + + try { + arenaRepository.clearCache() + gameService.reloadAll() + } catch (e: SoccerGameException) { + sender.sendMessage(ChatColor.RED.toString() + "Failed to reload soccerArena ${e.arena.name}.") + sender.sendMessage(e.message) + return + } + + sender.sendMessage(language.reloadedAllGamesMessage) + return + } + + try { + arenaRepository.clearCache() + gameService.reload(arena) + } catch (e: SoccerGameException) { + sender.sendMessage(ChatColor.RED.toString() + "Failed to reload soccerArena ${e.arena.name}.") + sender.sendMessage(e.message) + return + } + sender.sendMessage(language.reloadedGameMessage.format(arena.name)) + return + } +} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/JoinCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/JoinCommandExecutor.kt deleted file mode 100644 index dc340c133..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/JoinCommandExecutor.kt +++ /dev/null @@ -1,73 +0,0 @@ -package com.github.shynixn.blockball.impl.commandexecutor - -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.contract.GameService -import com.github.shynixn.blockball.enumeration.Team -import com.github.shynixn.blockball.impl.extension.mergeArgs -import com.github.shynixn.blockball.impl.extension.stripChatColors -import com.github.shynixn.mcutils.common.translateChatColors -import com.google.inject.Inject -import org.bukkit.command.CommandSender -import org.bukkit.entity.Player - -class JoinCommandExecutor @Inject constructor( - private val gameService: GameService -) : CommandExecutor { - /** - * Gets called when the given [source] executes the defined command with the given [args]. - */ - override fun onExecuteCommand(source: CommandSender, args: Array): Boolean { - if (args.isEmpty()) { - return false - } - - if (source !is Player) { - return false - } - - val mergedArgs = mergeArgs(0, args.size, args) - gameService.getAllGames().forEach { g -> - if (g.arena.name.equals(mergedArgs, true)) { - g.join(source) - return true - } else if (g.arena.displayName.translateChatColors().stripChatColors() - .equals(mergedArgs, true) - ) { - g.join(source) - return true - } - } - - val success = attemptJoiningGame(source, mergedArgs.split("|")) - if (!success) { - attemptJoiningGame(source, mergedArgs.split("/")) - } - - return true - } - - /** - * Tries to join the player with the given arguments. - * Returns true if successful. - */ - private fun attemptJoiningGame(player: Player, args: List): Boolean { - gameService.getAllGames().forEach { g -> - if (g.arena.name == args[0] || g.arena.displayName.translateChatColors().stripChatColors() - .equals(args[0], true) - ) { - var team: Team? = null - // TODO: Work around will be removed with the command rework - if (args[1].equals("team red", true) || args[1].equals("red", true)) { - team = Team.RED - } else if (args[1].equals("team blue", true) || args[1].equals("blue", true)) { - team = Team.BLUE - } - - g.join(player, team) - return true - } - } - - return false - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/LeaveCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/LeaveCommandExecutor.kt deleted file mode 100644 index 449a3efff..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/LeaveCommandExecutor.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.github.shynixn.blockball.impl.commandexecutor - -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.contract.GameService -import com.google.inject.Inject -import org.bukkit.command.CommandSender -import org.bukkit.entity.Player - -class LeaveCommandExecutor @Inject constructor( - private val gameService: GameService -) : CommandExecutor { - /** - * Gets called when the given [source] executes the defined command with the given [args]. - */ - override fun onExecuteCommand(source: CommandSender, args: Array): Boolean { - if (source !is Player) { - return false - } - - val playerGame = gameService.getGameFromPlayer(source) - - if (playerGame != null) { - playerGame.leave(source) - } - - val spectatorGame = gameService.getGameFromSpectatingPlayer(source) - - if (spectatorGame != null) { - spectatorGame.leave(source) - } - - return true - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/ReloadCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/ReloadCommandExecutor.kt deleted file mode 100644 index ef878d921..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/ReloadCommandExecutor.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.github.shynixn.blockball.impl.commandexecutor - -import com.github.shynixn.blockball.BlockBallLanguage -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.contract.GameService -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.mccoroutine.bukkit.launch -import com.github.shynixn.mcutils.common.ConfigurationService -import com.github.shynixn.mcutils.common.reloadTranslation -import com.github.shynixn.mcutils.common.repository.CacheRepository -import com.google.inject.Inject -import org.bukkit.command.CommandSender -import org.bukkit.plugin.Plugin - -class ReloadCommandExecutor @Inject constructor( - private val gameService: GameService, - private val configurationService: ConfigurationService, - private val plugin: Plugin, - private val arenaRepository : CacheRepository -) : CommandExecutor { - /** - * Gets called when the given [source] executes the defined command with the given [args]. - */ - override fun onExecuteCommand(source: CommandSender, args: Array): Boolean { - configurationService.reload() - val language = configurationService.findValue("language") - plugin.launch { - arenaRepository.clearCache() - plugin.reloadTranslation(language, BlockBallLanguage::class.java, "en_us") - gameService.reloadAll() - source.sendMessage(BlockBallLanguage.reloadMessage) - } - return true - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/SpectateCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/SpectateCommandExecutor.kt deleted file mode 100644 index 1c50e5c68..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/SpectateCommandExecutor.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.github.shynixn.blockball.impl.commandexecutor - - -import com.github.shynixn.blockball.contract.BlockBallMiniGame -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.contract.GameService -import com.github.shynixn.blockball.impl.extension.mergeArgs -import com.github.shynixn.blockball.impl.extension.stripChatColors -import com.github.shynixn.mcutils.common.translateChatColors -import com.google.inject.Inject -import org.bukkit.command.CommandSender -import org.bukkit.entity.Player - -class SpectateCommandExecutor @Inject constructor( - private val gameService: GameService -) : CommandExecutor { - /** - * Gets called when the given [source] executes the defined command with the given [args]. - */ - override fun onExecuteCommand(source: CommandSender, args: Array): Boolean { - if (args.isEmpty()) { - return false - } - - if (source !is Player) { - return false - } - - if (gameService.getGameFromPlayer(source) != null) { - return true - } - - val mergedArgs = mergeArgs(0, args.size, args) - - gameService.getAllGames().filter { g -> g.arena.meta.spectatorMeta.spectatorModeEnabled }.forEach { g -> - if (g is BlockBallMiniGame) { - if (g.arena.name.equals(mergedArgs, true)) { - g.spectate(source) - return true - } else if (g.arena.displayName.translateChatColors().stripChatColors().equals(mergedArgs, true)) { - g.spectate(source) - return true - } - } - } - - return true - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/StopCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/StopCommandExecutor.kt deleted file mode 100644 index e79db6c36..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/StopCommandExecutor.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.shynixn.blockball.impl.commandexecutor - -import com.github.shynixn.blockball.BlockBallLanguage -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.contract.GameService -import com.github.shynixn.blockball.impl.extension.mergeArgs -import com.github.shynixn.blockball.impl.extension.stripChatColors -import com.github.shynixn.mcutils.common.translateChatColors -import com.google.inject.Inject -import org.bukkit.command.CommandSender - -class StopCommandExecutor @Inject constructor( - private val gameService: GameService, -) : CommandExecutor { - /** - * Gets called when the given [source] executes the defined command with the given [args]. - */ - override fun onExecuteCommand(source: CommandSender, args: Array): Boolean { - val mergedArgs = mergeArgs(0, args.size, args) - - for (game in gameService.getAllGames()) { - if (game.arena.name.equals(mergedArgs, true)) { - game.closing = true - source.sendMessage( - BlockBallLanguage.stopGameMessage.format( - game.arena.name + 1, - game.arena.displayName.translateChatColors() - ) - ) - return true - } else if (game.arena.displayName.translateChatColors().stripChatColors().equals(mergedArgs, true)) { - game.closing = true - source.sendMessage( - BlockBallLanguage.stopGameMessage.format( - game.arena.name + 1, - game.arena.displayName.translateChatColors() - ) - ) - return true - } - } - - return true - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/AbilitiesSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/AbilitiesSettingsPage.kt deleted file mode 100644 index 71216d96f..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/AbilitiesSettingsPage.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.ChatClickAction -import com.github.shynixn.blockball.enumeration.MenuClickableItem -import com.github.shynixn.blockball.enumeration.MenuCommand -import com.github.shynixn.blockball.enumeration.MenuPageKey - -class AbilitiesSettingsPage : Page(AbilitiesSettingsPage.ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 19 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.ABILITIES - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - return ChatBuilder() - .component("- DoubleJump:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.DOUBLEJUMP_OPEN.command) - .setHoverText("Configure the double jump options for the players.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/AreaProtectionPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/AreaProtectionPage.kt deleted file mode 100644 index ad873fe74..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/AreaProtectionPage.kt +++ /dev/null @@ -1,82 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.Vector3d - -class AreaProtectionPage : Page(AreaProtectionPage.ID, MiscSettingsPage.ID) { - companion object { - /** Id of the page. */ - const val ID = 26 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.AREAPROTECTION - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - if (command == MenuCommand.AREAPROTECTION_TOGGLE_ENTITYFORCEFIELD) { - arena.meta.protectionMeta.entityProtectionEnabled = !arena.meta.protectionMeta.entityProtectionEnabled - } else if (command == MenuCommand.AREAPROTECTION_TOGGLE_PLAYERJOINFORCEFIELD) { - arena.meta.protectionMeta.rejoinProtectionEnabled = !arena.meta.protectionMeta.rejoinProtectionEnabled - } else if (command == MenuCommand.AREAPROTECTION_SET_ENTITYFORCEFIELD && args.size >= 5 - && args[2].toDoubleOrNull() != null && args[3].toDoubleOrNull() != null && args[4].toDoubleOrNull() != null - ) { - arena.meta.protectionMeta.entityProtection = Vector3d( args[2].toDouble(), args[3].toDouble(), args[4].toDouble()) - } else if (command == MenuCommand.AREAPROTECTION_SET_PLAYERJOINFORCEFIELD && args.size >= 5 - && args[2].toDoubleOrNull() != null && args[3].toDoubleOrNull() != null && args[4].toDoubleOrNull() != null - ) { - arena.meta.protectionMeta.rejoinProtection = Vector3d(args[2].toDouble(), args[3].toDouble(), args[4].toDouble()) - } - return super.execute(player, command, cache, args) - } - - /** - * Builds this page for the player. - * - * @return page - */ - override fun buildPage(cache: Array): ChatBuilder? { - val arena = cache[0] as Arena - val meta = arena.meta.protectionMeta - return ChatBuilder() - .component("- Animal and Monster protection enabled: " + meta.entityProtectionEnabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.AREAPROTECTION_TOGGLE_ENTITYFORCEFIELD.command) - .setHoverText("Toggles allowing animals and monsters to run inside of the arena.") - .builder().nextLine() - .component("- Animal and Monster protection velocity: " + meta.entityProtection).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.AREAPROTECTION_SET_ENTITYFORCEFIELD.command) - .setHoverText( - "Changes the velocity being applied to animals and monsters when they try to enter the arena." + - "\nEnter 3 values when using this command.\n/blockball aprot enprot " - ) - .builder().nextLine() - .component("- Join protection enabled: " + meta.rejoinProtectionEnabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.AREAPROTECTION_TOGGLE_PLAYERJOINFORCEFIELD.command) - .setHoverText("Toggles the protection to move players outside of the arena.") - .builder().nextLine() - .component("- Join protection velocity: " + meta.rejoinProtection).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.AREAPROTECTION_SET_PLAYERJOINFORCEFIELD.command) - .setHoverText( - "Changes the velocity being applied to players when they try to enter the arena." + - "\nEnter 3 values when using this command.\n/blockball aprot plprot " - ) - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BallModifierSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BallModifierSettingsPage.kt deleted file mode 100644 index 8bae14d5d..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BallModifierSettingsPage.kt +++ /dev/null @@ -1,126 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* - -class BallModifierSettingsPage : Page(BallModifierSettingsPage.ID, BallSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 31 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.BALLMODIFIER - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - val ballMeta = (cache[0] as Arena).meta.ballMeta.movementModifier - if (command == MenuCommand.BALLMOD_HORIZONTALTOUCH && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.horizontalTouchModifier = args[2].toDouble() - } else if (command == MenuCommand.BALLMOD_VERTICALTOUCH && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.verticalTouchModifier = args[2].toDouble() - } else if (command == MenuCommand.BALLMOD_SHOTVELOCITY && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.shotVelocity = args[2].toDouble() - } else if (command == MenuCommand.BALLMOD_PASSVELOCITY && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.passVelocity = args[2].toDouble() - } else if (command == MenuCommand.BALLMOD_MAXSPIN && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.maximumSpinVelocity = args[2].toDouble() - } else if (command == MenuCommand.BALLMOD_MAXPITCH && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.maximumPitch = args[2].toInt() - } else if (command == MenuCommand.BALLMOD_MINPITCH && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.minimumPitch = args[2].toInt() - } else if (command == MenuCommand.BALLMOD_DEFAULTPITCH && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.defaultPitch = args[2].toInt() - } else if (command == MenuCommand.BALLMOD_ROLLINGRESISTANCE && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.rollingResistance = args[2].toDouble() - } else if (command == MenuCommand.BALLMOD_AIRRESISTANCE && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.airResistance = args[2].toDouble() - } else if (command == MenuCommand.BALLMOD_GRAVITY && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.gravityModifier = args[2].toDouble() - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val ballMeta = (cache[0] as Arena).meta.ballMeta.movementModifier - return ChatBuilder() - .component("- Touch Strength (Horizontal): " + ballMeta.horizontalTouchModifier).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_HORIZONTALTOUCH.command) - .setHoverText("Changes the horizontal speed modifier when a player touches the ball.") - .builder().nextLine() - .component("- Touch Strength (Vertical): " + ballMeta.verticalTouchModifier).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_VERTICALTOUCH.command) - .setHoverText("Changes the vertical speed modifier when a player touches the ball.") - .builder().nextLine() - .component("- Shoot Strength: " + ballMeta.shotVelocity).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_SHOTVELOCITY.command) - .setHoverText("Changes the power of shooting when a player left-click the ball.") - .builder().nextLine() - .component("- Pass Strength: " + ballMeta.passVelocity).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_PASSVELOCITY.command) - .setHoverText("Changes the power of passing when a player right-click the ball.") - .builder().nextLine() - .component("- Maximum Spin Velocity: " + ballMeta.maximumSpinVelocity).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_MAXSPIN.command) - .setHoverText("The maximum strength of spin that you can apply to the ball. Tilt your head left/right after shooting to make it curve.") - .builder().nextLine() - .component("- Maximum Pitch (Vertical): " + ballMeta.maximumPitch).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_MAXPITCH.command) - .setHoverText("Changes the maximum angle of fire when a player kick or throws the ball.") - .builder().nextLine() - .component("- Minimum Pitch (Vertical): " + ballMeta.minimumPitch).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_MINPITCH.command) - .setHoverText("Changes the minimum angle of fire when a player kick or throws the ball.") - .builder().nextLine() - .component("- Standard Pitch (Vertical): " + ballMeta.defaultPitch).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_DEFAULTPITCH.command) - .setHoverText("Changes the angle of fire when a player kick or throws the ball without tilting his head up or down.") - .builder().nextLine() - .component("- Air Resistance: " + ballMeta.airResistance).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_AIRRESISTANCE.command) - .setHoverText("A value from 0.0 - 1.0 which reduces the speed in the air.") - .builder().nextLine() - .component("- Rolling Resistance: " + ballMeta.rollingResistance).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_ROLLINGRESISTANCE.command) - .setHoverText("A value from 0.0 - 1.0 which reduces the speed on the ground.") - .builder().nextLine() - .component("- Gravity Modifier: " + ballMeta.gravityModifier).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALLMOD_GRAVITY.command) - .setHoverText("Changes gravity modifier which decides how fast a ball falls onto the ground. Negative values will cause the ball to float upwards.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BallSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BallSettingsPage.kt deleted file mode 100644 index 02eb4df42..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BallSettingsPage.kt +++ /dev/null @@ -1,137 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.sound.SoundMeta - -class BallSettingsPage : Page(BallSettingsPage.ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 30 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.BALL - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - val ballMeta = (cache[0] as Arena).meta.ballMeta - if (command == MenuCommand.BALL_OPEN) { - cache[5] = null - } else if (command == MenuCommand.BALL_SKIN && args.size == 3) { - ballMeta.item.skinBase64 = args[2] - } else if (command == MenuCommand.BALL_SIZE_CALLBACK && args.size == 3) { - ballMeta.size = BallSize.values()[args[2].toInt()] - } else if (command == MenuCommand.BALL_SLIME) { - ballMeta.isSlimeVisible = !ballMeta.isSlimeVisible - } else if (command == MenuCommand.BALL_INTERACTION_HITBOX && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.interactionHitBoxSize = args[2].toDouble() - } else if (command == MenuCommand.BALL_KICKPASS_HITBOX && args.size == 3 && args[2].toDoubleOrNull() != null) { - ballMeta.kickPassHitBoxSize = args[2].toDouble() - } else if (command == MenuCommand.BALL_INTERACT_COOLDOWN && args.size == 3 && args[2].toIntOrNull() != null) { - ballMeta.interactionCoolDown = args[2].toInt() - } else if (command == MenuCommand.BALL_KICKPASS_DELAY && args.size == 3 && args[2].toIntOrNull() != null) { - ballMeta.kickPassDelay = args[2].toInt() - } else if (command == MenuCommand.BALL_TOGGLE_ALWAYSBOUNCE) { - ballMeta.alwaysBounce = !ballMeta.alwaysBounce - } else if (command == MenuCommand.BALL_TOGGLE_ROTATING) { - ballMeta.rotating = !ballMeta.rotating - } else if (command == MenuCommand.BALL_SOUNDACTION_CALLBACK && args.size == 3) { - cache[5] = ballMeta.soundEffects[BallActionType.values()[args[2].toInt()]] - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val ballMeta = (cache[0] as Arena).meta.ballMeta - val builder = ChatBuilder() - .component("- Skin: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(ballMeta.item.skinBase64!!).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALL_SKIN.command) - .setHoverText("Changes the skin of the ball. Needs to be a Base64Encoded Skin URL.") - .builder().nextLine() - .component("- Skin Size: " + ballMeta.size.name).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_BALLSIZES.command) - .setHoverText("Opens the selectionbox for ball sizes.") - .builder().nextLine() - .component("- Slime Visible: " + ballMeta.isSlimeVisible).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.BALL_SLIME.command) - .setHoverText("Toggles if the slime hitbox is rendered instead of the ball helmet.") - .builder().nextLine() - .component("- Interaction Hitbox Size: " + ballMeta.interactionHitBoxSize).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALL_INTERACTION_HITBOX.command) - .setHoverText("Changes the hitbox size when running into the ball.") - .builder().nextLine() - .component("- KickPass Hitbox Size: " + ballMeta.kickPassHitBoxSize).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALL_KICKPASS_HITBOX.command) - .setHoverText("Changes the hitbox size when left or rightclicking the ball.") - .builder().nextLine() - .component("- Always Bounce: " + ballMeta.alwaysBounce).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.BALL_TOGGLE_ALWAYSBOUNCE.command) - .setHoverText("Should the ball always bounce of surfaces?") - .builder().nextLine() - .component("- Rotation Animation: " + ballMeta.rotating).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.BALL_TOGGLE_ROTATING.command) - .setHoverText("Should the ball play a rotation animation?") - .builder().nextLine() - .component("- KickPass Delay: " + ballMeta.kickPassDelay).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALL_KICKPASS_DELAY.command) - .setHoverText("Delay in ticks until a kick or pass is executed.") - .builder().nextLine() - .component("- Interaction Cooldown: " + ballMeta.interactionCoolDown).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BALL_INTERACT_COOLDOWN.command) - .setHoverText("Cooldown in ticks until the next player can interact with the ball again.") - .builder().nextLine() - .component("- Ball Modifiers: ").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.BALLMOD_OPEN.command) - .setHoverText("Opens the page for ball modifiers.") - .builder().nextLine() - .component("- Sound Effect: ").builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_BALL_SOUNDEFFECTS.command) - .setHoverText("Opens the selection page for action binders.") - .builder().nextLine() - if (cache[5] != null && cache[5] is SoundMeta) { - builder.component("- Selected Sound-effect: ").builder().component(MenuClickableItem.PAGE.text) - .setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SOUND_BALL.command) - .setHoverText("Opens the page for editing sound effects.") - .builder().nextLine() - } - return builder - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BossbarPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BossbarPage.kt deleted file mode 100644 index a4d451dee..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/BossbarPage.kt +++ /dev/null @@ -1,128 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class BossbarPage : Page(BossbarPage.ID, EffectsSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 9 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.BOSSBAR - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - val arena = cache[0] as Arena - val bossbar = arena.meta.bossBarMeta - cache[5] = bossbar.flags.map { p -> p.name } - if (command == MenuCommand.BOSSBAR_OPEN && args.size == 3) { - bossbar.style = BossbarStyle.values()[args[2].toInt()] - } else if (command == MenuCommand.BOSSBAR_CALLBACKCOLORS && args.size == 3) { - bossbar.color = BossbarColor.values()[args[2].toInt()] - } else if (command == MenuCommand.BOSSBAR_CALLBACKFLAGS && args.size == 3) { - bossbar.flags.clear() - bossbar.flags.add(BossBarFlag.values()[args[2].toInt()]) - } else if (command == MenuCommand.BOSSBAR_MESSAGE) { - bossbar.message = this.mergeArgs(2, args) - } else if (command == MenuCommand.BOSSBAR_TOGGLE) { - bossbar.enabled = !bossbar.enabled - } else if (command == MenuCommand.BOSSBAR_PERCENT) { - val result = args[2].toDoubleOrNull() - if (result != null) { - bossbar.percentage = result - } - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - val bossbar = arena.meta.bossBarMeta - if (bossbar.flags.isEmpty()) - bossbar.flags.add(BossBarFlag.NONE) - val builder = ChatBuilder() - .component("- Message: " + bossbar.message).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BOSSBAR_MESSAGE.command) - .setHoverText("Edit the message of the bossbar.") - .builder().nextLine() - .component("- Enabled: " + bossbar.enabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.BOSSBAR_TOGGLE.command) - .setHoverText("Toggle the bossbar.") - .builder().nextLine() - .component("- Percentage: " + bossbar.percentage).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.BOSSBAR_PERCENT.command) - .setHoverText("Edit the amount of percentage the bossbar is filled.") - .builder() - .nextLine().component("- Color: " + bossbar.color).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_BOSSBARCOLORS.command) - .setHoverText("Opens the selectionbox for colors.") - .builder().nextLine() - .component("- Style: " + bossbar.style).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_BOSSBARSTYLES.command) - .setHoverText("Opens the selectionbox for styles.") - .builder().nextLine() - .component("- Flags: " + bossbar.flags[0]).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_BOSSBARFLAGS.command) - .setHoverText("Opens the selectionbox for flags.") - .builder().nextLine() - return builder - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/DoubleJumpPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/DoubleJumpPage.kt deleted file mode 100644 index a9e96db1d..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/DoubleJumpPage.kt +++ /dev/null @@ -1,102 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class DoubleJumpPage : Page(DoubleJumpPage.ID, OpenPage.ID) { - companion object { - /** Id of the page. */ - const val ID = 18 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.DOUBLEJUMP - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - if (command == MenuCommand.DOUBLEJUMP_TOGGLE) { - arena.meta.doubleJumpMeta.enabled = !arena.meta.doubleJumpMeta.enabled - } else if (command == MenuCommand.DOUBLEJUMP_COOLDOWN && args[2].toIntOrNull() != null) { - arena.meta.doubleJumpMeta.cooldown = args[2].toInt() - } else if (command == MenuCommand.DOUBLEJUMP_VERTICAL_STRENGTH && args[2].toDoubleOrNull() != null) { - arena.meta.doubleJumpMeta.verticalStrength = args[2].toDouble() - } else if (command == MenuCommand.DOUBLEJUMP_HORIZONTAL_STRENGTH && args[2].toDoubleOrNull() != null) { - arena.meta.doubleJumpMeta.horizontalStrength = args[2].toDouble() - } - return super.execute(player, command, cache, args) - } - - /** - * Builds this page for the player. - * - * @return page - */ - override fun buildPage(cache: Array): ChatBuilder? { - val arena = cache[0] as Arena - val meta = arena.meta.doubleJumpMeta - return ChatBuilder() - .component("- Enabled: " + meta.enabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.DOUBLEJUMP_TOGGLE.command) - .setHoverText("Toggles the double jump.") - .builder().nextLine() - .component("- Cooldown: " + meta.cooldown).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.DOUBLEJUMP_COOLDOWN.command) - .setHoverText("Changes the cooldown between double jumps.") - .builder().nextLine() - .component("- Vertical strength: " + meta.verticalStrength).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.DOUBLEJUMP_VERTICAL_STRENGTH.command) - .setHoverText("Changes the vertical strength modifier a player is flying.") - .builder().nextLine() - .component("- Horizontal strength: " + meta.horizontalStrength).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.DOUBLEJUMP_HORIZONTAL_STRENGTH.command) - .setHoverText("Changes the horizontal strength modifier a player is flying.") - .builder().nextLine() - .component("- Soundeffect:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SOUND_DOUBLEJUMP.command) - .setHoverText("Opens the soundEffect page.").builder() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/EffectsSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/EffectsSettingsPage.kt deleted file mode 100644 index e2d47273b..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/EffectsSettingsPage.kt +++ /dev/null @@ -1,76 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.ChatClickAction -import com.github.shynixn.blockball.enumeration.MenuClickableItem -import com.github.shynixn.blockball.enumeration.MenuCommand -import com.github.shynixn.blockball.enumeration.MenuPageKey - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class EffectsSettingsPage : Page(EffectsSettingsPage.ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 7 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.EFFECTS - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - return ChatBuilder() - .component("- Scoreboard:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SCOREBOARD_OPEN.command) - .setHoverText("Configure the scoreboard of players.") - .builder().nextLine() - .component("- Bossbar:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.BOSSBAR_OPEN.command) - .setHoverText("Configure the bossbar for players.") - .builder().nextLine() - .component("- Holograms:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.HOLOGRAM_OPEN.command) - .setHoverText("Configure the holograms for players.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/GamePropertiesPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/GamePropertiesPage.kt deleted file mode 100644 index 984319907..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/GamePropertiesPage.kt +++ /dev/null @@ -1,119 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class GamePropertiesPage : Page(GamePropertiesPage.ID, MiscSettingsPage.ID) { - companion object { - /** Id of the page. */ - const val ID = 25 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.GAMEEXTENSIONS - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - - if (command == MenuCommand.GAMEPROPERTIES_TOGGLE_DAMAGE) { - arena.meta.customizingMeta.damageEnabled = !arena.meta.customizingMeta.damageEnabled - } else if (command == MenuCommand.GAMEPROPERTIES_TOGGLE_TELEPORTBACK) { - arena.meta.customizingMeta.backTeleport = !arena.meta.customizingMeta.backTeleport - } else if (command == MenuCommand.GAMEPROPERTIES_TELEPORTBACKDELAY && args.size == 3 && args[2].toIntOrNull() != null) { - arena.meta.customizingMeta.backTeleportDelay = args[2].toInt() - } else if (command == MenuCommand.GAMEPROPERTIES_TOGGLE_BALLFORCEFIELD) { - arena.meta.customizingMeta.ballForceField = !arena.meta.customizingMeta.ballForceField - } else if (command == MenuCommand.GAMEPROPERTIES_TOGGLE_KEEPINVENTORY) { - arena.meta.customizingMeta.keepInventoryEnabled = !arena.meta.customizingMeta.keepInventoryEnabled - } - - return super.execute(player, command, cache, args) - } - - /** - * Builds this page for the player. - * - * @return page - */ - override fun buildPage(cache: Array): ChatBuilder? { - val arena = cache[0] as Arena - val meta = arena.meta.customizingMeta - return ChatBuilder() - .component("- Ball forcefield enabled: " + meta.ballForceField).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction( - ChatClickAction.RUN_COMMAND, - MenuCommand.GAMEPROPERTIES_TOGGLE_BALLFORCEFIELD.command - ) - .setHoverText("Toggles the ball forcefield.") - .builder().nextLine() - .component("- Damage enabled: " + meta.damageEnabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMEPROPERTIES_TOGGLE_DAMAGE.command) - .setHoverText("Toggles the dealing damage in the arena.") - .builder().nextLine() - .component("- Score teleport back: " + meta.backTeleport).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction( - ChatClickAction.RUN_COMMAND, - MenuCommand.GAMEPROPERTIES_TOGGLE_TELEPORTBACK.command - ) - .setHoverText("Toggles if players should be teleported back to their game spawnpoint after anyone scores a point.") - .builder().nextLine() - .component("- Score teleport back delay: " + arena.meta.customizingMeta.backTeleportDelay).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction( - ChatClickAction.SUGGEST_COMMAND, - MenuCommand.GAMEPROPERTIES_TELEPORTBACKDELAY.command - ) - .setHoverText("Delay after the players get teleported back to their game spawnpoint.") - .builder().nextLine() - .component("- Keep inventory: " + meta.keepInventoryEnabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction( - ChatClickAction.RUN_COMMAND, - MenuCommand.GAMEPROPERTIES_TOGGLE_KEEPINVENTORY.command - ) - .setHoverText("Toggles if players should keep their current inventory when they join a match.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/GameSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/GameSettingsPage.kt deleted file mode 100644 index 785d7a968..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/GameSettingsPage.kt +++ /dev/null @@ -1,191 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.toVector3d -import org.bukkit.GameMode -import org.bukkit.entity.Player - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERwwt - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class GameSettingsPage : - Page(ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 29 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.GAMESETTINGS - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - val arena = cache[0] as Arena - require(player is Player) - - if (command == MenuCommand.GAMESETTINGS_LEAVESPAWNPOINT) { - arena.meta.lobbyMeta.leaveSpawnpoint = player.location.toVector3d() - } else if (command == MenuCommand.GAMESETTINGS_LOBBYSPAWNPOINT) { - arena.meta.minigameMeta.lobbySpawnpoint = player.location.toVector3d() - } else if (command == MenuCommand.GAMESETTINGS_TOGGLE_EVENTEAMS) { - arena.meta.lobbyMeta.onlyAllowEventTeams = !arena.meta.lobbyMeta.onlyAllowEventTeams - } else if (command == MenuCommand.GAMESETTINGS_TOGGLE_INSTATFORCEFIELD) { - arena.meta.hubLobbyMeta.instantForcefieldJoin = !arena.meta.hubLobbyMeta.instantForcefieldJoin - } else if (command == MenuCommand.GAMESETTINGS_TOGGLE_RESETEMPTY) { - arena.meta.hubLobbyMeta.resetArenaOnEmpty = !arena.meta.hubLobbyMeta.resetArenaOnEmpty - } else if (command == MenuCommand.GAMESETTINGS_BUNGEEFALLBACKSERVER && args.size >= 3) { - arena.meta.bungeeCordMeta.fallbackServer = mergeArgs(2, args) - } else if (command == MenuCommand.GAMESETTINGS_MAXSCORE && args.size == 3 && args[2].toIntOrNull() != null) { - arena.meta.lobbyMeta.maxScore = args[2].toInt() - } else if (command == MenuCommand.GAMESETTINGS_LOBBYDURATION && args.size == 3 && args[2].toIntOrNull() != null) { - arena.meta.minigameMeta.lobbyDuration = args[2].toInt() - } else if (command == MenuCommand.GAMESETTINGS_CALLBACK_BUKKITGAMEMODES && args.size == 3 && args[2].toIntOrNull() != null) { - arena.meta.lobbyMeta.gamemode = GameMode.values()[args[2].toInt()] - } else if (command == MenuCommand.GAMESETTINGS_REMAININGPLAYERSMESSAGE && args.size > 3) { - arena.meta.minigameMeta.playersRequiredToStartMessage = mergeArgs(2, args) - } else if (command == MenuCommand.GAMESETTINGS_TOGGLE_TELEPORTONJOIN) { - arena.meta.hubLobbyMeta.teleportOnJoin = !arena.meta.hubLobbyMeta.teleportOnJoin - - if (!arena.meta.hubLobbyMeta.teleportOnJoin) { - arena.meta.hubLobbyMeta.instantForcefieldJoin = true - } - } - - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - - var leaveSpawnpoint = "none" - if (arena.meta.lobbyMeta.leaveSpawnpoint != null) { - leaveSpawnpoint = arena.meta.lobbyMeta.leaveSpawnpoint!!.toString() - } - var lobbySpawnpoint = "none" - if (arena.meta.minigameMeta.lobbySpawnpoint != null) { - lobbySpawnpoint = arena.meta.minigameMeta.lobbySpawnpoint!!.toString() - } - val builder = ChatBuilder() - .component("- Max Score: " + arena.meta.lobbyMeta.maxScore).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.GAMESETTINGS_MAXSCORE.command) - .setHoverText("Amount of goals a team has to score in order to win.") - .builder().nextLine() - .component("- Leave Spawnpoint: $leaveSpawnpoint").builder() - .component(MenuClickableItem.LOCATION.text).setColor(MenuClickableItem.LOCATION.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMESETTINGS_LEAVESPAWNPOINT.command) - .setHoverText("Sets the spawnpoint for people who leave the match.") - .builder().nextLine() - .component("- Gamemode: " + arena.meta.lobbyMeta.gamemode.name).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_BUKKITGAMESMODES.command) - .setHoverText("Minecraft gamemode (Survival, Adventure, Creative) the players will be inside of a game.") - .builder().nextLine() - .component("- Even teams enabled: " + arena.meta.lobbyMeta.onlyAllowEventTeams).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMESETTINGS_TOGGLE_EVENTEAMS.command) - .setHoverText("Forces players to join the other team regardless of their choice to have the same amount of players on both teams.") - .builder().nextLine() - - if (arena.gameType == GameType.MINIGAME) { - builder.component("- Match Times:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MATCHTIMES_OPEN.command) - .setHoverText("Opens the match times page.").builder().nextLine() - builder.component("- Lobby Duration: " + arena.meta.minigameMeta.lobbyDuration).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.GAMESETTINGS_LOBBYDURATION.command) - .setHoverText("Amount of seconds until a lobby is going to start when it reached its min amount of red and blue players.") - .builder().nextLine() - .component("- Lobby Spawnpoint: $lobbySpawnpoint").builder() - .component(MenuClickableItem.LOCATION.text).setColor(MenuClickableItem.LOCATION.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMESETTINGS_LOBBYSPAWNPOINT.command) - .setHoverText("Sets the spawnpoint for people who join the lobby.") - .builder().nextLine() - builder.component("- Remaining Players Message:").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.minigameMeta.playersRequiredToStartMessage).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction( - ChatClickAction.SUGGEST_COMMAND, - MenuCommand.GAMESETTINGS_REMAININGPLAYERSMESSAGE.command - ) - .setHoverText(ChatColor.UNDERLINE.toString() + "Minigame exclusive\n" + ChatColor.RESET + "Message being send to the action bar of players who wait for more players in the lobby.") - .builder().nextLine() - } - if (arena.gameType == GameType.HUBGAME) { - builder.component("- Join Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.hubLobbyMeta.joinMessage.toSingleLine()).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_HUBGAMEJOINMESSAGE.command) - .setHoverText(ChatColor.UNDERLINE.toString() + "HubGame exclusive\n" + ChatColor.RESET + "Message being send to players who touch the forcefield.") - .builder().nextLine() - .component("- Reset on empty: " + arena.meta.hubLobbyMeta.resetArenaOnEmpty).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMESETTINGS_TOGGLE_RESETEMPTY.command) - .setHoverText(ChatColor.UNDERLINE.toString() + "HubGame exclusive\n" + ChatColor.RESET + "Should the HubGame game be reset to it's starting stage when everyone has left the game?") - .builder().nextLine() - .component("- Teleport on join: " + arena.meta.hubLobbyMeta.teleportOnJoin).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMESETTINGS_TOGGLE_TELEPORTONJOIN.command) - .setHoverText(ChatColor.UNDERLINE.toString() + "HubGame exclusive\n" + ChatColor.RESET + "Should players be teleported to the spawnpoint on join? Automatically enables instant forcefield join when being disabled.") - .builder().nextLine() - .component("- Instant forcefield join: " + arena.meta.hubLobbyMeta.instantForcefieldJoin).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMESETTINGS_TOGGLE_INSTATFORCEFIELD.command) - .setHoverText(ChatColor.UNDERLINE.toString() + "HubGame exclusive\n" + ChatColor.RESET + "Should players join the game immediately after running into the forcefield? Teams get automatically selected.") - .builder().nextLine() - } - return builder - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/HologramPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/HologramPage.kt deleted file mode 100644 index e3f048c2f..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/HologramPage.kt +++ /dev/null @@ -1,115 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.entity.HologramMeta -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.toVector3d -import com.google.inject.Inject -import org.bukkit.entity.Player - -class HologramPage @Inject constructor() : Page(HologramPage.ID, EffectsSettingsPage.ID) { - companion object { - /** Id of the page. */ - const val ID = 17 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.HOLOGRAM - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - require(player is Player) - val arena = cache[0] as Arena - val holograms = arena.meta.hologramMetas - if (command == MenuCommand.HOLOGRAM_OPEN) { - cache[5] = null - } - if (command == MenuCommand.HOLOGRAM_CREATE) { - val builder = HologramMeta() - builder.position = player.location.toVector3d() - holograms.add(builder) - cache[5] = builder - } - if (command == MenuCommand.HOLOGRAM_CALLBACK && args.size >= 3) { - val range = args[2].toInt() - if (range >= 0 && range < holograms.size) { - cache[5] = holograms[range] - } - } - if (command == MenuCommand.HOLOGRAM_DELETE) { - holograms.remove(cache[5]) - cache[5] = null - } - if (command == MenuCommand.HOLOGRAM_LOCATION) { - val hologram = cache[5] as HologramMeta - hologram.position = player.location.toVector3d() - } - cache[2] = holograms.map { p -> p.position!!.toString() } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - val selectedHologram = cache[5] - var selectedHologramText = "none" - var selectedHologramHover = "none" - val hologramListText = arena.meta.hologramMetas.map { p -> p.position!!.toString() }.toSingleLine() - if (selectedHologram != null) { - selectedHologramText = (selectedHologram as HologramMeta).position!!.toString() - selectedHologramHover = selectedHologram.lines.toSingleLine() - cache[2] = selectedHologram.lines - } - val builder = ChatBuilder() - .component("- Holograms: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(hologramListText) - .builder().component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_HOLOGRAMS.command) - .setHoverText("Opens the selectionbox for existing holograms.") - .builder().component(" [add by location..]").setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.HOLOGRAM_CREATE.command) - .setHoverText("Creates a new hologram at your current location and select it.") - .builder().nextLine() - - if (selectedHologram != null) { - builder.component("- Selected hologram: $selectedHologramText").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(selectedHologramHover).builder() - .component(MenuClickableItem.DELETE.text).setColor(MenuClickableItem.DELETE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.HOLOGRAM_DELETE.command) - .setHoverText("Deletes the selected hologram.") - .builder().nextLine() - .component("- Location: $selectedHologramText").builder() - .component(" [location..]").setColor(ChatColor.BLUE) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.HOLOGRAM_LOCATION.command) - .setHoverText("Sets the location of the hologram to your current location.") - .builder().nextLine() - .component("- Lines:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_HOLOGRAM.command) - .setHoverText("Configure the lines of the hologram.") - .builder().nextLine() - - } - - return builder - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/ListablePage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/ListablePage.kt deleted file mode 100644 index 07dbf1fab..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/ListablePage.kt +++ /dev/null @@ -1,107 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.EffectTargetType -import com.google.inject.Inject -import org.bukkit.GameMode - -class ListablePage @Inject constructor( -) : Page(MainSettingsPage.ID, MainConfigurationPage.ID) { - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.LISTABLE - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - when (command) { - MenuCommand.LIST_GAMETYPES -> { - cache[2] = GameType.values().map { p -> p.name } - cache[3] = MenuCommand.SETTINGS_OPEN - } - MenuCommand.LIST_BUKKITGAMESMODES -> { - cache[2] = GameMode.values().map { e -> e.name }.filterNot { g -> g == "SPECTATOR" } - cache[3] = MenuCommand.GAMESETTINGS_CALLBACK_BUKKITGAMEMODES - } - MenuCommand.LIST_BALL_PARTICLEFFECTS -> { - cache[2] = BallActionType.values().map { p -> p.name } - cache[3] = MenuCommand.BALL_PARTICLEACTION_CALLBACK - } - MenuCommand.LIST_BALL_SOUNDEFFECTS -> { - cache[2] = BallActionType.values().map { p -> p.name } - cache[3] = MenuCommand.BALL_SOUNDACTION_CALLBACK - } - MenuCommand.LIST_BALLSIZES -> { - cache[2] = BallSize.values().map { p -> p.name } - cache[3] = MenuCommand.BALL_SIZE_CALLBACK - } - MenuCommand.LIST_SOUND_TYPES -> { - cache[2] = org.bukkit.Sound.values().map { s -> s.name } - cache[3] = MenuCommand.SOUND_CALLBACK_TYPE - } - MenuCommand.LIST_SOUND_EFFECTINGTYPES -> { - cache[2] = EffectTargetType.values().map { p -> p.name } - cache[3] = MenuCommand.SOUND_CALLBACK_EFFECTING - } - MenuCommand.LIST_LINES -> cache[3] = MenuCommand.MULTILINES_ANY - MenuCommand.LIST_BOSSBARSTYLES -> { - cache[2] = BossbarStyle.values().map { p -> p.name } - cache[3] = MenuCommand.BOSSBAR_OPEN - } - MenuCommand.LIST_BOSSBARFLAGS -> { - cache[2] = BossBarFlag.values().map { p -> p.name } - cache[3] = MenuCommand.BOSSBAR_CALLBACKFLAGS - } - MenuCommand.LIST_BOSSBARCOLORS -> { - cache[2] = BossbarColor.values().map { p -> p.name } - cache[3] = MenuCommand.BOSSBAR_CALLBACKCOLORS - } - MenuCommand.LIST_MATCHCLOSETYPES -> { - cache[2] = MatchTimeCloseType.values().map { p -> p.name } - cache[3] = MenuCommand.MATCHTIMES_CALLBACKCLOSETYPE - } - MenuCommand.LIST_HOLOGRAMS -> cache[3] = MenuCommand.HOLOGRAM_CALLBACK - MenuCommand.LIST_MATCHTIMES -> cache[3] = MenuCommand.MATCHTIMES_CALLBACK - else -> { - } - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val infoList = cache[2] as ArrayList<*> - val callBackCommand = cache[3] as MenuCommand - val builder = ChatBuilder() - - if (infoList.size == 0) { - builder.text("No data found.") - } else { - infoList.forEachIndexed { index, p -> - builder.component((index + 1).toString() + ": [$p]") - .setClickAction(ChatClickAction.RUN_COMMAND, callBackCommand.command + index) - .setHoverText("").builder().nextLine().nextLine() - } - } - return builder - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MainConfigurationPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MainConfigurationPage.kt deleted file mode 100644 index 21f733e91..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MainConfigurationPage.kt +++ /dev/null @@ -1,280 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - - -import com.github.shynixn.blockball.contract.BlockSelectionService -import com.github.shynixn.blockball.contract.GameService -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mccoroutine.bukkit.launch -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.chat.ChatMessageService -import com.github.shynixn.mcutils.common.repository.CacheRepository -import com.github.shynixn.mcutils.common.toVector3d -import com.google.inject.Inject -import kotlinx.coroutines.runBlocking -import org.bukkit.entity.Player -import org.bukkit.plugin.Plugin -import java.util.logging.Level -import kotlin.math.abs - -class MainConfigurationPage @Inject constructor( - private val arenaRepository: CacheRepository, - private val blockSelectionService: BlockSelectionService, - private val gameService: GameService, - private val plugin: Plugin, - private val chatMessageService: ChatMessageService -) : Page(ID, OpenPage.ID) { - companion object { - /** Id of the page. */ - const val ID = 2 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.MAINCONFIGURATION - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - if (player !is Player) { - return MenuCommandResult.BACK - } - - if (command == MenuCommand.ARENA_CREATE) { - - } else if (command == MenuCommand.ARENA_EDIT) { - plugin.launch { - val arenas = arenaRepository.getAll() - cache[0] = arenas.single { b -> b.name.equals(args[2], true) } - } - } else if (command == MenuCommand.ARENA_DELETE) { - plugin.launch { - cache[0] = arenaRepository.getAll().single { b -> b.name.equals(args[2], true) } - arenaRepository.delete(cache[0] as Arena) - gameService.reloadAll() - } - cache[0] = null - return MenuCommandResult.BACK - } else if (command == MenuCommand.ARENA_ENABLE) { - val arena = cache[0] as Arena - arena.enabled = !arena.enabled - } else if (command == MenuCommand.ARENA_SETBALLSPAWNPOINT) { - val arena = cache[0] as Arena - arena.meta.ballMeta.spawnpoint = player.location.toVector3d() - } else if (command == MenuCommand.ARENA_SETDISPLAYNAME) { - val arena = cache[0] as Arena - arena.displayName = this.mergeArgs(2, args) - } else if (command == MenuCommand.ARENA_SETAREA) { - val arena = cache[0] as Arena - blockSelectionService.setSelectionToolForPlayer(player) - val left = blockSelectionService.getLeftClickLocation(player) - val right = blockSelectionService.getRightClickLocation(player) - if (left.isPresent && right.isPresent) { - val leftPosition = left.get().toVector3d() - val rightPosition = right.get().toVector3d() - val yDistance = abs(leftPosition.y - rightPosition.y) - - if (yDistance < 10) { - return MenuCommandResult.WESELECTION_TOSMALL - } - - arena.setCorners(leftPosition, rightPosition) - } else { - return MenuCommandResult.WESELECTION_MISSING - } - } else if (command == MenuCommand.ARENA_SETGOALRED) { - val arena = cache[0] as Arena - - blockSelectionService.setSelectionToolForPlayer(player) - val left = blockSelectionService.getLeftClickLocation(player) - val right = blockSelectionService.getRightClickLocation(player) - if (left.isPresent && right.isPresent) { - val leftPosition = left.get().toVector3d() - val rightPosition =right.get().toVector3d() - val xDistance = abs(leftPosition.x - rightPosition.x) - val yDistance = abs(leftPosition.y - rightPosition.y) - val zDistance = abs(leftPosition.z - rightPosition.z) - - if (yDistance < 2) { - return MenuCommandResult.WESELECTIONHEIGHTGOAL_TOSMALL - } - - if (zDistance < 2) { - return MenuCommandResult.WESELECTIONZAXEGOAL_TOSMALL - } - - if (xDistance < 2) { - return MenuCommandResult.WESELECTIONXAXEGOAL_TOSMALL - } - - arena.meta.redTeamMeta.goal.setCorners(leftPosition, rightPosition) - } else { - return MenuCommandResult.WESELECTION_MISSING - } - } else if (command == MenuCommand.ARENA_SETGOALBLUE) { - val arena = cache[0] as Arena - - blockSelectionService.setSelectionToolForPlayer(player) - val left = blockSelectionService.getLeftClickLocation(player) - val right = blockSelectionService.getRightClickLocation(player) - if (left.isPresent && right.isPresent) { - val leftPosition = left.get().toVector3d() - val rightPosition = right.get().toVector3d() - val xDistance = abs(leftPosition.x - rightPosition.x) - val yDistance = abs(leftPosition.y - rightPosition.y) - val zDistance = abs(leftPosition.z - rightPosition.z) - - if (yDistance < 2) { - return MenuCommandResult.WESELECTIONHEIGHTGOAL_TOSMALL - } - - if (zDistance < 2) { - return MenuCommandResult.WESELECTIONZAXEGOAL_TOSMALL - } - - if (xDistance < 2) { - return MenuCommandResult.WESELECTIONXAXEGOAL_TOSMALL - } - - arena.meta.blueTeamMeta.goal.setCorners(leftPosition, rightPosition) - } else { - return MenuCommandResult.WESELECTION_MISSING - } - } else if (command == MenuCommand.ARENA_SAVE) { - if (cache[0] == null || cache[0] !is Arena) { - val b = ChatBuilder().text("- ") - .text(ChatColor.RED.toString() + "Please select an arena to perform this action.") - chatMessageService.sendChatMessage(player, b.convertToTextComponent()) - return MenuCommandResult.CANCEL_MESSAGE - } - - val arena = cache[0] as Arena - if (arena.lowerCorner.world != null && arena.meta.blueTeamMeta.goal.lowerCorner.world != null && arena.meta.redTeamMeta.goal.lowerCorner.world != null - && arena.meta.ballMeta.spawnpoint != null - ) { - if (arena.gameType === GameType.HUBGAME || (arena.meta.minigameMeta.lobbySpawnpoint != null && arena.meta.lobbyMeta.leaveSpawnpoint != null)) { - plugin.launch { - arenaRepository.save(arena) - } - } else { - return MenuCommandResult.MINIGAMEARENA_NOTVALID - } - } else { - return MenuCommandResult.ARENA_NOTVALID - } - } else if (command == MenuCommand.ARENA_RELOAD) { - if (cache[0] == null || cache[0] !is Arena) { - val b = ChatBuilder().text("- ") - .text(ChatColor.RED.toString() + "Please select an arena to perform this action.") - chatMessageService.sendChatMessage(player, b.convertToTextComponent()) - - // TODO: Should be replaced in command rework. - runBlocking { - gameService.reloadAll() - } - - return MenuCommandResult.CANCEL_MESSAGE - } - - val arena = cache[0] as Arena - if (arena.lowerCorner.world != null && arena.meta.blueTeamMeta.goal.lowerCorner.world != null && arena.meta.redTeamMeta.goal.lowerCorner.world != null - && arena.meta.ballMeta.spawnpoint != null - ) { - if (arena.gameType === GameType.HUBGAME || (arena.meta.minigameMeta.lobbySpawnpoint != null && arena.meta.lobbyMeta.leaveSpawnpoint != null)) { - val name = arena.name - plugin.launch { - try { - arenaRepository.save(arena) - gameService.reloadAll() - cache[0] = arenaRepository.getAll().single { a -> a.name == name } - } catch (e: Exception) { - plugin.logger.log(Level.SEVERE, "Failed persistence arena.", e) - } - } - } else { - return MenuCommandResult.MINIGAMEARENA_NOTVALID - } - } else { - return MenuCommandResult.ARENA_NOTVALID - } - } - return super.execute(player, command, cache, args) - } - - /** - * Builds this page for the player. - * - * @return page - */ - override fun buildPage(cache: Array): ChatBuilder? { - val arena = cache[0] as Arena - var corners = "none" - var goal1 = "none" - var goal2 = "none" - var ballSpawn = "none" - if (arena.upperCorner.world != null && arena.lowerCorner.world != null) { - corners = arena.center.toString() - } - if (arena.meta.redTeamMeta.goal.lowerCorner.world != null) { - goal1 = arena.meta.redTeamMeta.goal.center.toString() - } - if (arena.meta.blueTeamMeta.goal.lowerCorner.world != null) { - goal2 = arena.meta.blueTeamMeta.goal.center.toString() - } - if (arena.meta.ballMeta.spawnpoint != null) { - ballSpawn = arena.meta.ballMeta.spawnpoint!!.toString() - } - return ChatBuilder() - .component("- Id: " + arena.name) - .setColor(ChatColor.GRAY) - .builder() - .component(", " + arena.displayName).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.ARENA_SETDISPLAYNAME.command) - .setHoverText("Edit the name of the arena.") - .builder().nextLine() - .component("- Enabled: " + arena.enabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_ENABLE.command) - .setHoverText("Toggle the arena.") - .builder().nextLine() - .component("- Field: $corners").builder() - .component(MenuClickableItem.SELECTION.text).setColor(ChatColor.GOLD) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_SETAREA.command) - .setHoverText("Uses the selected blocks to span the field of the arena.") - .builder().nextLine() - .component("- Goal Red: $goal1").builder() - .component(MenuClickableItem.SELECTION.text).setColor(ChatColor.GOLD) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_SETGOALRED.command) - .setHoverText("Uses the selected blocks to span the goal for the red team.") - .builder().nextLine() - .component("- Goal Blue: $goal2").builder() - .component(MenuClickableItem.SELECTION.text).setColor(ChatColor.GOLD) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_SETGOALBLUE.command) - .setHoverText("Uses the selected blocks to span the goal for the blue team.") - .builder().nextLine() - .component("- Ball spawnpoint: $ballSpawn").builder() - .component(" [location..]").setColor(ChatColor.BLUE) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_SETBALLSPAWNPOINT.command) - .setHoverText("Uses your current location to set the spawnpoint of the ball.") - .builder().nextLine() - .component("- Settings:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SETTINGS_OPEN.command) - .setHoverText("Opens the settings page.").builder() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MainSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MainSettingsPage.kt deleted file mode 100644 index 4c38dbc40..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MainSettingsPage.kt +++ /dev/null @@ -1,95 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.ChatColor - -class MainSettingsPage : Page(MainSettingsPage.ID, MainConfigurationPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 3 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.MAINSETTING - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - if (command == MenuCommand.SETTINGS_OPEN && args.size == 3) { - val arena = cache[0] as Arena - arena.gameType = GameType.values()[args[2].toInt()] - } - - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - return ChatBuilder() - .component("- GameType: " + arena.gameType.name).builder() - .component(" [select..]") - .setColor(ChatColor.AQUA) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_GAMETYPES.command) - .setHoverText("Opens the selectionbox for game modes.") - .builder().nextLine() - .component("- Game Settings:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMESETTINGS_OPEN.command) - .setHoverText("Common and exclusive Game Settings for this GameType.") - .builder().nextLine() - .component("- Ball Settings:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.BALL_OPEN.command) - .setHoverText("Opens the settings page for the ball.") - .builder().nextLine() - .component("- Team Red:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.TEAM_RED_CONFIGURE.command) - .setHoverText("Opens the settings page for the red team.") - .builder().nextLine() - .component("- Team Blue:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.TEAM_BLUE_CONFIGURE.command) - .setHoverText("Opens the settings page for the blue team.") - .builder().nextLine() - .component("- Signs:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_OPEN.command) - .setHoverText("Configure all signs for this gamemode.").builder().nextLine() - .component("- Effects:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.EFFECTS_OPEN.command) - .setHoverText("Opens the settings page for effects like scoreboard, bossbar and holograms.").builder().nextLine() - .component("- Abilities:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ABILITIES_OPEN.command) - .setHoverText("Opens the settings page for double jumps and boost effects.").builder().nextLine() - .component("- Spectating:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SPECTATOR_OPEN.command) - .setHoverText("Opens the settings page for spectating.") - .builder().nextLine() - .component("- Misc:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MISC_OPEN.command) - .setHoverText("Opens the settings page for other settings.").builder() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MatchTimesPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MatchTimesPage.kt deleted file mode 100644 index ca663926a..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MatchTimesPage.kt +++ /dev/null @@ -1,191 +0,0 @@ -@file:Suppress("UNCHECKED_CAST") - -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.entity.MatchTimeMeta -import com.github.shynixn.blockball.enumeration.* -import com.google.inject.Inject - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERwwt - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class MatchTimesPage @Inject constructor() : Page(ID, GameSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 34 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.MATCHTIMES - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - val arena = cache[0] as Arena - - if (command == MenuCommand.MATCHTIMES_OPEN) { - cache[5] = null - } else if (command == MenuCommand.MATCHTIMES_CREATE) { - val matchTime = MatchTimeMeta() - arena.meta.minigameMeta.matchTimes.add(matchTime) - cache[5] = matchTime - } else if (command == MenuCommand.MATCHTIMES_CALLBACK && args.size >= 3) { - val index = args[2].toInt() - if (index >= 0 && index < arena.meta.minigameMeta.matchTimes.size) { - cache[5] = arena.meta.minigameMeta.matchTimes[index] - } - } else if (command == MenuCommand.MATCHTIMES_DELETE) { - arena.meta.minigameMeta.matchTimes.remove(cache[5]) - cache[5] = null - } else if (command == MenuCommand.MATCHTIMES_DURATION && args[2].toIntOrNull() != null) { - val matchTime = cache[5] as MatchTimeMeta - matchTime.duration = args[2].toInt() - } else if (command == MenuCommand.MATCHTIMES_SWITCHGOAL) { - val matchTime = cache[5] as MatchTimeMeta - matchTime.isSwitchGoalsEnabled = !matchTime.isSwitchGoalsEnabled - } else if (command == MenuCommand.MATCHTIMES_BALLAVAILABLE) { - val matchTime = cache[5] as MatchTimeMeta - matchTime.playAbleBall = !matchTime.playAbleBall - } else if (command == MenuCommand.MATCHTIMES_RESPAWN) { - val matchTime = cache[5] as MatchTimeMeta - matchTime.respawnEnabled = !matchTime.respawnEnabled - } else if (command == MenuCommand.MATCHTIMES_STARTTITLEMESSAGE && args.size >= 3) { - val matchTime = cache[5] as MatchTimeMeta - matchTime.startMessageTitle = mergeArgs(2, args) - } else if (command == MenuCommand.MATCHTIMES_STARTSUBTITLEMESSAGE && args.size >= 3) { - val matchTime = cache[5] as MatchTimeMeta - matchTime.startMessageSubTitle = mergeArgs(2, args) - } else if (command == MenuCommand.MATCHTIMES_CALLBACKCLOSETYPE) { - val index = args[2].toInt() - val matchTime = cache[5] as MatchTimeMeta - if (index >= 0 && index < MatchTimeCloseType.values().size) { - matchTime.closeType = MatchTimeCloseType.values()[index] - } - } - - cache[2] = - arena.meta.minigameMeta.matchTimes.mapIndexed { index, e -> (index + 1).toString() + ". ${e.closeType.name}\\nDuration: ${e.duration} seconds"} - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - val selectedMatchTime = cache[5] - val matchTimeListText = (cache[2] as List).toSingleLine() - - val builder = ChatBuilder() - .component("- Match Times:").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(matchTimeListText) - .builder().component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_MATCHTIMES.command) - .setHoverText("Opens the selectionbox for existing match times.") - .builder().component(" [add..]").setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MATCHTIMES_CREATE.command) - .setHoverText("Adds a new match time and selects it.") - .builder().nextLine() - - if (selectedMatchTime != null && selectedMatchTime is MatchTimeMeta) { - val index = (arena.meta.minigameMeta.matchTimes.indexOf(selectedMatchTime) + 1).toString() - val selectedMatchTimeText = "Number $index" - val selectedMatchTimeHover = - index + ". ${selectedMatchTime.closeType.name}\\nDuration: ${selectedMatchTime.duration} seconds\\nSwitch goals: ${selectedMatchTime.isSwitchGoalsEnabled}" - - builder.component("- Selected match time: $selectedMatchTimeText").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(selectedMatchTimeHover).builder() - .component(MenuClickableItem.DELETE.text).setColor(MenuClickableItem.DELETE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MATCHTIMES_DELETE.command) - .setHoverText("Deletes the selected match time.") - .builder().nextLine() - .component("- Close Condition: " + selectedMatchTime.closeType.name).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_MATCHCLOSETYPES.command) - .setHoverText("Opens the selectionbox for close conditions.") - .builder().nextLine() - .component("- Duration: " + selectedMatchTime.duration + " seconds").builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.MATCHTIMES_DURATION.command) - .setHoverText("Changes the duration (seconds) of this part of the match.") - .builder().nextLine() - .component("- Switch goals: " + selectedMatchTime.isSwitchGoalsEnabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MATCHTIMES_SWITCHGOAL.command) - .setHoverText("Toggles if the team should switch goals when this match time starts.") - .builder().nextLine() - .component("- Playable Ball: " + selectedMatchTime.playAbleBall).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MATCHTIMES_BALLAVAILABLE.command) - .setHoverText("Toggles if the ball should be spawned during this match time.") - .builder().nextLine() - .component("- Respawn: " + selectedMatchTime.respawnEnabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MATCHTIMES_RESPAWN.command) - .setHoverText("Toggles if players should respawn when this match time starts.") - .builder().nextLine() - .component("- StartTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(selectedMatchTime.startMessageTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.MATCHTIMES_STARTTITLEMESSAGE.command) - .setHoverText("Changes the title message getting played when the match time starts.") - .builder().nextLine() - .component("- StartSubTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(selectedMatchTime.startMessageSubTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.MATCHTIMES_STARTSUBTITLEMESSAGE.command) - .setHoverText("Changes the subtitle message getting played when the match time starts.") - .builder() - } - - return builder - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MiscSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MiscSettingsPage.kt deleted file mode 100644 index 4d7a20204..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MiscSettingsPage.kt +++ /dev/null @@ -1,71 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.ChatClickAction -import com.github.shynixn.blockball.enumeration.MenuClickableItem -import com.github.shynixn.blockball.enumeration.MenuCommand -import com.github.shynixn.blockball.enumeration.MenuPageKey - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class MiscSettingsPage : Page(MiscSettingsPage.ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 24 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.MISC - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - return ChatBuilder() - .component("- Game Properties:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.GAMEPROPERTIES_OPEN.command) - .setHoverText("Additional properties to configure for the game.") - .builder().nextLine() - .component("- Arena Protection:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.AREAPROTECTION_OPEN.command) - .setHoverText("Options to protect the arena from intruders.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MultipleLinesPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MultipleLinesPage.kt deleted file mode 100644 index 580b92fe5..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/MultipleLinesPage.kt +++ /dev/null @@ -1,152 +0,0 @@ -@file:Suppress("UNCHECKED_CAST") - -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.translateChatColors - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class MultipleLinesPage : Page(MainSettingsPage.ID, MainConfigurationPage.ID) { - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.MULTIPLELINES - } - - override fun getPreviousIdFrom(cache: Array): Int { - return cache[4] as Int - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - if (command == MenuCommand.MULTILINES_SCOREBOARD) { - cache[4] = ScoreboardPage.ID - cache[3] = 0 - } else if (command == MenuCommand.MULTILINES_HUBGAMEJOINMESSAGE) { - cache[2] = (cache[0] as Arena).meta.hubLobbyMeta.joinMessage - cache[4] = GameSettingsPage.ID - cache[3] = 0 - } else if (command == MenuCommand.MULTILINES_HOLOGRAM) { - cache[4] = HologramPage.ID - cache[3] = 0 - } else if (command == MenuCommand.MULTILINES_SPECTATEJOINMESSAGE) { - cache[2] = (cache[0] as Arena).meta.spectatorMeta.spectateStartMessage - cache[4] = SpectatePage.ID - cache[3] = 0 - } else if (command == MenuCommand.MULTILINES_TEAMSIGNTEMPLATE) { - val arena = cache[0] as Arena - cache[4] = SignSettingsPage.ID - cache[3] = 0 - - when { - args[2] == "red" -> cache[2] = arena.meta.redTeamMeta.signLines - args[2] == "blue" -> cache[2] = arena.meta.blueTeamMeta.signLines - args[2] == "join" -> cache[2] = arena.meta.lobbyMeta.joinSignLines - args[2] == "leave" -> cache[2] = arena.meta.lobbyMeta.leaveSignLines - } - } else if (command == MenuCommand.MULTILINES_ADD) { - val dataList = cache[2] as ArrayList - dataList.add(this.mergeArgs(2, args)) - } else if (command == MenuCommand.MULTILINES_ANY) { - if (args.size >= 3) { - cache[3] = args[2].toInt() - } else { - cache[3] = 0 - } - } else if (command == MenuCommand.MULTILINES_SET) { - val dataList = cache[2] as ArrayList - val index = cache[3] as Int - if (index < dataList.size) { - dataList[index] = mergeArgs(2, args) - } else { - cache[3] = 0 - } - } else if (command == MenuCommand.MULTILINES_REMOVE) { - val dataList = cache[2] as ArrayList - - val index = cache[3] as Int - if (index < dataList.size) { - dataList.removeAt(cache[3] as Int) - } else { - cache[3] = 0 - } - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val infoList = cache[2] as ArrayList - var selectedLine = "none" - val index = cache[3] as Int - if (index < infoList.size) { - selectedLine = infoList[index] - } - return ChatBuilder() - .component("- Preview:").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(infoList.toSingleLine()) - .builder().nextLine() - .component("- Add line:").builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction( - ChatClickAction.SUGGEST_COMMAND, MenuCommand.MULTILINES_ADD.command) - .setHoverText("Adds a new line to the list.") - .builder().nextLine() - .component("- Edit a line:").builder() - .component(" [selected line..]").setColor(ChatColor.GRAY) - .setHoverText((index + 1).toString() + ": " + selectedLine.translateChatColors()).builder().nextLine() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_LINES.command) - .setHoverText("Select a different line.") - .builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.MULTILINES_SET.command) - .setHoverText("Changes the selected line.") - .builder() - .component(MenuClickableItem.DELETE.text).setColor(MenuClickableItem.DELETE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_REMOVE.command) - .setHoverText("Removes the selected line.").builder() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/NotificationPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/NotificationPage.kt deleted file mode 100644 index 17a8e0006..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/NotificationPage.kt +++ /dev/null @@ -1,91 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.blockball.enumeration.MenuClickableItem.* - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class NotificationPage : Page(ID, SpectatingSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 119 - } - - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.NOTIFICATIONS - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - - if (command == MenuCommand.NOTIFICATIONS_TOGGLE) { - arena.meta.spectatorMeta.notifyNearbyPlayers = !arena.meta.spectatorMeta.notifyNearbyPlayers - } else if (command == MenuCommand.NOTIFICATIONS_RADIUS && args[2].toIntOrNull() != null) { - arena.meta.spectatorMeta.notificationRadius = args[2].toInt() - } - - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - val meta = arena.meta.spectatorMeta - - return ChatBuilder() - .component("- Notifications enabled: " + meta.notifyNearbyPlayers).builder() - .component(TOGGLE.text).setColor(TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.NOTIFICATIONS_TOGGLE.command) - .setHoverText("Toggles the notifications for nearby players.") - .builder().nextLine() - .component("- Notification radius: " + meta.notificationRadius).builder() - .component(EDIT.text).setColor(EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.NOTIFICATIONS_RADIUS.command) - .setHoverText("The amount of blocks a players has to be near an arena to still receive notifications.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/OpenPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/OpenPage.kt deleted file mode 100644 index 47e8a17ff..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/OpenPage.kt +++ /dev/null @@ -1,169 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.ChatClickAction -import com.github.shynixn.blockball.enumeration.MenuCommand -import com.github.shynixn.blockball.enumeration.MenuCommandResult -import com.github.shynixn.blockball.enumeration.MenuPageKey -import com.github.shynixn.mccoroutine.bukkit.launch -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.chat.ChatMessageService -import com.github.shynixn.mcutils.common.repository.Repository -import com.google.inject.Inject -import kotlinx.coroutines.runBlocking -import org.bukkit.entity.Player -import org.bukkit.plugin.Plugin - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class OpenPage @Inject constructor( - private val plugin: Plugin, - private val arenaRepository: - Repository, - private val chatMessageService: ChatMessageService -) : - Page(OpenPage.ID, OpenPage.ID) { - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.OPEN - } - - companion object { - /** Id of the page. */ - const val ID = 1 - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - if (command == MenuCommand.OPEN_EDIT_ARENA) { - // TODO: Should be changed when reworking commands. - return runBlocking { - var builder: ChatBuilder? = null - for (arena in arenaRepository.getAll()) { - if (builder == null) { - builder = ChatBuilder() - } - builder.component("- Arena: Id: " + arena.name + " Name: " + arena.displayName).builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_EDIT.command + arena.name) - .setHoverText("Opens the arena with the id " + arena.name + ".").builder().nextLine() - } - - if (builder != null) { - require(player is Player) - chatMessageService.sendChatMessage(player, builder.convertToTextComponent()) - } - - return@runBlocking MenuCommandResult.CANCEL_MESSAGE - } - } else if (command == MenuCommand.OPEN_CREATE_ARENA) { - var idGen: Int - - runBlocking { - val arenas = arenaRepository.getAll() - idGen = arenas.size + 1 - - for (arena in arenas) { - if (arena.name == "arena_$idGen") { - idGen++ - } - } - } - - val arena = Arena() - arena.name = "arena_$idGen" - arena.displayName = "Arena $idGen" - cache[0] = arena - plugin.launch { - (player as Player).performCommand(MenuCommand.ARENA_CREATE.command.substring(1)) - } - - return MenuCommandResult.EXIT_COMP - } else if (command == MenuCommand.OPEN_DELETE_ARENA) { - // TODO: Should be changed when reworking commands. - return runBlocking { - var builder: ChatBuilder? = null - - for (arena in arenaRepository.getAll()) { - if (builder == null) { - builder = ChatBuilder() - } - builder!!.component("- Arena: Id: " + arena.name + " Name: " + arena.displayName).builder() - .component(" [delete..]").setColor(ChatColor.DARK_RED) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.ARENA_DELETE.command + arena.name) - .setHoverText("Deletes the arena with the id " + arena.name + ".").builder().nextLine() - } - - if (builder != null) { - require(player is Player) - chatMessageService.sendChatMessage(player, builder!!.convertToTextComponent()) - } - - return@runBlocking MenuCommandResult.CANCEL_MESSAGE - } - } - - return super.execute(player, command, cache, args) - } - - /** - * Builds this page for the player. - * - * @param cache cache. - * @return page - */ - override fun buildPage(cache: Array): ChatBuilder { - return ChatBuilder() - .component("- Create arena:").builder() - .component(" [create..]").setColor(ChatColor.AQUA) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.OPEN_CREATE_ARENA.command) - .setHoverText("Creates a new blockball arena.").builder().nextLine() - .component("- Edit arena:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.OPEN_EDIT_ARENA.command) - .setHoverText("Opens the arena selection list.").builder().nextLine() - .component("- Remove arena:").builder() - .component(" [page..]").setColor(ChatColor.YELLOW) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.OPEN_DELETE_ARENA.command) - .setHoverText("Deletes a blockball arena.").builder() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/Page.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/Page.kt deleted file mode 100644 index e62825960..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/Page.kt +++ /dev/null @@ -1,77 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.MenuCommand -import com.github.shynixn.blockball.enumeration.MenuCommandResult -import com.github.shynixn.blockball.enumeration.MenuPageKey -import com.github.shynixn.mcutils.common.ChatColor - -abstract class Page( - /** - * Page id. - */ - val id: Int, private val previousId: Int -) { - /** - * GetPrevious id. - */ - open fun getPreviousIdFrom(cache: Array): Int { - return previousId - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - abstract fun getCommandKey(): MenuPageKey - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - open fun buildPage(cache: Array): ChatBuilder? { - return null - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - open fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - return MenuCommandResult.SUCCESS - } - - /** - * Refactors a list to a single line. - */ - internal fun List.toSingleLine(): String { - val builder = StringBuilder() - this.forEachIndexed { index, p -> - builder.append(ChatColor.translateChatColorCodes('&', p)) - if (index + 1 != this.size) - builder.append('\n') - builder.append(ChatColor.RESET) - } - return builder.toString() - } - - /** - * Merges page arguments. - */ - internal fun mergeArgs(starting: Int, args: Array): String { - val builder = StringBuilder() - - for (i in starting until args.size) { - if (builder.isNotEmpty()) { - builder.append(' ') - } - builder.append(args[i]) - } - - return builder.toString() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/ScoreboardPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/ScoreboardPage.kt deleted file mode 100644 index bda6ad7fc..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/ScoreboardPage.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class ScoreboardPage : Page(ScoreboardPage.ID, EffectsSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 8 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.SCOREBOARD - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - val scoreboard = arena.meta.scoreboardMeta - cache[2] = scoreboard.lines - if (command == MenuCommand.SCOREBOARD_TITLE) { - scoreboard.title = this.mergeArgs(2, args) - } else if (command == MenuCommand.SCOREBOARD_TOGGLE) { - scoreboard.enabled = !scoreboard.enabled - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - val scoreboard = arena.meta.scoreboardMeta - return ChatBuilder() - .component("- Title: " + scoreboard.title).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.SCOREBOARD_TITLE.command) - .setHoverText("Edit the title of the scoreboard.") - .builder().nextLine() - .component("- Enabled: " + scoreboard.enabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SCOREBOARD_TOGGLE.command) - .setHoverText("Toggle the scoreboard.") - .builder().nextLine() - .component("- Lines:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_SCOREBOARD.command) - .setHoverText("Configure the lines of the scoreboard.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SignSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SignSettingsPage.kt deleted file mode 100644 index d7c604f50..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SignSettingsPage.kt +++ /dev/null @@ -1,207 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.BlockBallLanguage -import com.github.shynixn.blockball.contract.RightclickManageService -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.toVector3d -import com.google.inject.Inject -import org.bukkit.entity.Player - -class SignSettingsPage @Inject constructor( - private val rightclickManageService: RightclickManageService -) : Page(SignSettingsPage.ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 11 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.SIGNS - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - require(player is Player) - when (command) { - MenuCommand.SIGNS_ADDTEAMRED -> { - player.sendMessage(BlockBallLanguage.rightClickOnSign) - rightclickManageService.watchForNextRightClickSign(player) { location -> - arena.meta.redTeamMeta.signs.add(location.toVector3d()) - player.sendMessage(BlockBallLanguage.saveAndReloadSign) - } - } - MenuCommand.SIGNS_ADDTEAMBLUE -> { - player.sendMessage(BlockBallLanguage.rightClickOnSign) - rightclickManageService.watchForNextRightClickSign(player) { location -> - arena.meta.blueTeamMeta.signs.add(location.toVector3d()) - player.sendMessage(BlockBallLanguage.saveAndReloadSign) - } - } - MenuCommand.SIGNS_ADDJOINANY -> { - player.sendMessage(BlockBallLanguage.rightClickOnSign) - rightclickManageService.watchForNextRightClickSign(player) { location -> - arena.meta.lobbyMeta.joinSigns.add(location.toVector3d()) - player.sendMessage(BlockBallLanguage.saveAndReloadSign) - } - } - MenuCommand.SIGNS_LEAVE -> { - player.sendMessage(BlockBallLanguage.rightClickOnSign) - rightclickManageService.watchForNextRightClickSign(player) { location -> - arena.meta.lobbyMeta.leaveSigns.add(location.toVector3d()) - player.sendMessage(BlockBallLanguage.saveAndReloadSign) - } - } - else -> { - } - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - - val teamSignsRed = arena.meta.redTeamMeta.signs.map { p -> p.toString() } - val teamSignsBlue = arena.meta.blueTeamMeta.signs.map { p -> p.toString() } - val joinSigns = arena.meta.lobbyMeta.joinSigns.map { p -> p.toString() } - val leaveSigns = arena.meta.lobbyMeta.leaveSigns.map { p -> p.toString() } - - if (arena.gameType == GameType.HUBGAME) { - return ChatBuilder() - .component("- Signs Team Red: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamSignsRed.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_ADDTEAMRED.command) - .setHoverText(ChatColor.YELLOW.toString() + "Players clicking this sign automatically join the game and the red team.\n&6&m \n&rEnables the next sign to be added after you rightclicked it.\nDestroy the sign to remove it.") - .builder().nextLine() - .component("- Template Signs Team Red: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.redTeamMeta.signLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " red") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - .component("- Signs Team Blue: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamSignsBlue.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_ADDTEAMBLUE.command) - .setHoverText(ChatColor.YELLOW.toString() + "Players clicking this sign automatically join the game and the blue team.\n&6&m \n&rEnables the next sign to be added after you rightclicked it.\nDestroy the sign to remove it.") - .builder().nextLine() - .component("- Template Signs Team Blue: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.blueTeamMeta.signLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " blue") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - .component("- Signs Join any team: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(joinSigns.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_ADDJOINANY.command) - .setHoverText(ChatColor.YELLOW.toString() + "Players clicking this sign automatically join the game and team.\n&6&m \n&rEnables the next sign to be added after you rightclicked it.\nDestroy the sign to remove it.") - .builder().nextLine() - .component("- Template Signs Join: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.lobbyMeta.joinSignLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " join") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - .component("- Signs Leave: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(leaveSigns.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_LEAVE.command) - .setHoverText(ChatColor.YELLOW.toString() + "Players clicking this sign automatically leave the game.\n&6&m \n&rEnables the next sign to be added after you rightclicked it.\nDestroy the sign to remove it.") - .builder().nextLine() - .component("- Template Signs Leave: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.lobbyMeta.leaveSignLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " leave") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - } else if (arena.gameType == GameType.MINIGAME) { - return ChatBuilder() - .component("- Signs Team Red: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamSignsRed.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_ADDTEAMRED.command) - .setHoverText(ChatColor.WHITE.toString() + "Only players in Lobbies can click on this sign and will be queued for this team if the team has not reached it's max amount yet and even teams is disabled.") - .builder().nextLine() - .component("- Template Signs Team Red: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.redTeamMeta.signLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " red") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - .component("- Signs Team Blue: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamSignsBlue.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_ADDTEAMBLUE.command) - .setHoverText(ChatColor.WHITE.toString() + "Only players in Lobbies can click on this sign and will be queued for this team if the team has not reached it's max amount yet and even teams is disabled.") - .builder().nextLine() - .component("- Template Signs Team Blue: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.blueTeamMeta.signLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " blue") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - .component("- Signs Join any team: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(joinSigns.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_ADDJOINANY.command) - .setHoverText(ChatColor.WHITE.toString() + "Players clicking this sign automatically join the game lobby.") - .builder().nextLine() - .component("- Template Signs Join: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.lobbyMeta.joinSignLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " join") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - .component("- Signs Leave: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(leaveSigns.toSingleLine()) - .builder() - .component(MenuClickableItem.ADD.text).setColor(MenuClickableItem.ADD.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SIGNS_LEAVE.command) - .setHoverText(ChatColor.WHITE.toString() + "Players clicking this sign automatically leave the game or lobby.").builder().nextLine() - .component("- Template Signs Leave: ").builder().component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(arena.meta.lobbyMeta.leaveSignLines.toList().toSingleLine()).builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_TEAMSIGNTEMPLATE.command + " leave") - .setHoverText("Opens the page to change the template on signs to join this team.") - .builder().nextLine() - } - - return ChatBuilder() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SoundEffectPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SoundEffectPage.kt deleted file mode 100644 index b2bc15224..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SoundEffectPage.kt +++ /dev/null @@ -1,112 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.EffectTargetType -import com.github.shynixn.mcutils.common.sound.SoundMeta - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class SoundEffectPage : Page(SoundEffectPage.ID, MainConfigurationPage.ID) { - companion object { - /** Id of the page. */ - const val ID = 21 - } - - override fun getPreviousIdFrom(cache: Array): Int { - return cache[4] as Int - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.SOUNDEFFECTS - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - if (command == MenuCommand.SOUND_DOUBLEJUMP) { - cache[5] = arena.meta.doubleJumpMeta.soundEffect - cache[4] = DoubleJumpPage.ID - } else if (command == MenuCommand.SOUND_BALL) { - cache[4] = BallSettingsPage.ID - } else if (command == MenuCommand.SOUND_CALLBACK_TYPE) { - val soundEffect = cache[5] as SoundMeta - soundEffect.name = args[2] - } else if (command == MenuCommand.SOUND_CALLBACK_EFFECTING && args.size >= 3 && args[2].toIntOrNull() != null) { - val soundEffect = cache[5] as SoundMeta - soundEffect.effectType = EffectTargetType.values()[args[2].toInt()] - } else if (command == MenuCommand.SOUND_PITCH && args[2].toDoubleOrNull() != null) { - val soundEffect = cache[5] as SoundMeta - soundEffect.pitch = args[2].toDouble() - } else if (command == MenuCommand.SOUND_VOLUME && args[2].toDoubleOrNull() != null) { - val soundEffect = cache[5] as SoundMeta - soundEffect.volume = args[2].toDouble() - } - return super.execute(player, command, cache, args) - } - - /** - * Builds this page for the player. - * - * @return page - */ - override fun buildPage(cache: Array): ChatBuilder? { - val soundEffect = cache[5] as SoundMeta - return ChatBuilder() - .component("- Effecting: " + soundEffect.effectType).builder() - .component(MenuClickableItem.SELECT.text).setColor(MenuClickableItem.SELECT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.LIST_SOUND_EFFECTINGTYPES.command) - .setHoverText("Opens the selectionbox for effecting types.") - .builder().nextLine() - .component("- Type: " + soundEffect.name).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.SOUND_CALLBACK_TYPE.command) - .setHoverText("Changes the name of the sound.") - .builder().nextLine() - .component("- Volume: " + soundEffect.volume).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.SOUND_VOLUME.command) - .setHoverText("Changes the volume of the sound.") - .builder().nextLine() - .component("- Pitch: " + soundEffect.pitch).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.SOUND_PITCH.command) - .setHoverText("Changes the pitch of the sound.") - .builder() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SpectatePage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SpectatePage.kt deleted file mode 100644 index 6f2e19ef8..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SpectatePage.kt +++ /dev/null @@ -1,106 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.toVector3d -import com.google.inject.Inject -import org.bukkit.entity.Player - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class SpectatePage @Inject constructor() : Page(ID, SpectatePage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 120 - } - - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.SPECTATE - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - val arena = cache[0] as Arena - require(player is Player) - - if (command == MenuCommand.SPECTATE_TOGGLE) { - arena.meta.spectatorMeta.spectatorModeEnabled = !arena.meta.spectatorMeta.spectatorModeEnabled - } else if (command == MenuCommand.SPECTATE_SPAWNPOINT) { - arena.meta.spectatorMeta.spectateSpawnpoint = player.location.toVector3d() - } - - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - val meta = arena.meta.spectatorMeta - - var spectatorSpawnpoint = "none" - if (meta.spectateSpawnpoint != null) { - spectatorSpawnpoint = meta.spectateSpawnpoint!!.toString() - } - - return ChatBuilder() - .component("- Spectator mode enabled: " + meta.spectatorModeEnabled).builder() - .component(MenuClickableItem.TOGGLE.text).setColor(MenuClickableItem.TOGGLE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SPECTATE_TOGGLE.command) - .setHoverText("Toggles the spectator mode to spectate games.") - .builder().nextLine() - .component("- Spectate Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color).setHoverText(meta.spectateStartMessage.toSingleLine()) - .builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.MULTILINES_SPECTATEJOINMESSAGE.command) - .setHoverText("Message being send to players who try to join a full game.") - .builder().nextLine() - .component("- Spectator Spawnpoint: $spectatorSpawnpoint").builder() - .component(MenuClickableItem.LOCATION.text).setColor(MenuClickableItem.LOCATION.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SPECTATE_SPAWNPOINT.command) - .setHoverText("Sets the spawnpoint for people who spectate the game.") - .builder().nextLine() - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SpectatingSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SpectatingSettingsPage.kt deleted file mode 100644 index a41323499..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/SpectatingSettingsPage.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.enumeration.* - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class SpectatingSettingsPage : Page(ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 118 - } - - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.SPECTATING - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - val arena = cache[0] as Arena - - if (arena.gameType != GameType.HUBGAME) { - return ChatBuilder() - .component("- Notifications:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.NOTIFICATIONS_OPEN.command) - .setHoverText("Configure the notifications nearby players do receive.") - .builder().nextLine() - .component("- Spectatormode:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.SPECTATE_OPEN.command) - .setHoverText("Configure the spectator mode.") - .builder().nextLine() - } else { - return ChatBuilder() - .component("- Notifications:").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.NOTIFICATIONS_OPEN.command) - .setHoverText("Configure the notifications nearby players do receive.") - .builder().nextLine() - } - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamSettingsPage.kt deleted file mode 100644 index b8b8d4e1d..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamSettingsPage.kt +++ /dev/null @@ -1,207 +0,0 @@ -@file:Suppress("UNCHECKED_CAST") - -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.entity.TeamMeta -import com.github.shynixn.blockball.enumeration.* -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.toVector3d -import com.google.inject.Inject -import org.bukkit.configuration.file.YamlConfiguration -import org.bukkit.entity.Player - -class TeamSettingsPage @Inject constructor() : - Page(TeamSettingsPage.ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 5 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.TEAMMETA - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute( - player: P, - command: MenuCommand, - cache: Array, - args: Array - ): MenuCommandResult { - require(player is Player) - if (command == MenuCommand.TEAM_RED_CONFIGURE) { - cache[2] = 0 - } - if (command == MenuCommand.TEAM_BLUE_CONFIGURE) { - cache[2] = 1 - } else if (command == MenuCommand.TEAM_SPAWNPOINT) { - val teamMeta = getTeamMeta(cache) - teamMeta.spawnpoint = player.location.toVector3d() - } else if (command == MenuCommand.TEAM_LOBBY) { - val teamMeta = getTeamMeta(cache) - teamMeta.lobbySpawnpoint = player.location.toVector3d() - } else if (command == MenuCommand.TEAM_NAME) { - val teamMeta = getTeamMeta(cache) - val name = mergeArgs(2, args) - teamMeta.displayName = name - } else if (command == MenuCommand.TEAM_PREFIX) { - val teamMeta = getTeamMeta(cache) - val name = mergeArgs(2, args) - teamMeta.prefix = name - } else if (command == MenuCommand.TEAM_MINAMOUNT) { - val teamMeta = getTeamMeta(cache) - val amount = args[2].toIntOrNull() - if (amount != null) { - if (amount > teamMeta.maxAmount) { - return MenuCommandResult.MAX_PLAYERS - } - teamMeta.minAmount = amount - } - } else if (command == MenuCommand.TEAM_MAXAMOUNT) { - val teamMeta = getTeamMeta(cache) - val amount = args[2].toIntOrNull() - if (amount != null) { - if (amount < teamMeta.minAmount) { - return MenuCommandResult.MINPLAYERS - } - teamMeta.maxAmount = amount - } - } else if (command == MenuCommand.TEAM_POINTSGOAL) { - val teamMeta = getTeamMeta(cache) - val amount = args[2].toIntOrNull() - if (amount != null) { - teamMeta.pointsPerGoal = amount - } - } else if (command == MenuCommand.TEAM_POINTSDEATH) { - val teamMeta = getTeamMeta(cache) - val amount = args[2].toIntOrNull() - if (amount != null) { - teamMeta.pointsPerEnemyDeath = amount - } - } else if (command == MenuCommand.TEAM_WALKSPEED) { - val teamMeta = getTeamMeta(cache) - val amount = args[2].toDoubleOrNull() - if (amount != null) { - teamMeta.walkingSpeed = amount - } - } else if (command == MenuCommand.TEAM_ARMOR) { - val teamMeta = getTeamMeta(cache) - teamMeta.armor = player.inventory.armorContents.clone().map { e -> - val yamlConfiguration = YamlConfiguration() - yamlConfiguration.set("item", e) - yamlConfiguration.saveToString() - }.toTypedArray() - } else if (command == MenuCommand.TEAM_INVENTORY) { - val teamMeta = getTeamMeta(cache) - teamMeta.inventory = player.inventory.contents.clone().map { e -> - val yamlConfiguration = YamlConfiguration() - yamlConfiguration.set("item", e) - yamlConfiguration.saveToString() - }.toTypedArray() - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder { - var spawnpoint = "none" - val teamMeta = getTeamMeta(cache) - if (teamMeta.spawnpoint != null) { - spawnpoint = teamMeta.spawnpoint!!.toString() - } - var lobby = "none" - if (teamMeta.lobbySpawnpoint != null) { - lobby = teamMeta.lobbySpawnpoint!!.toString() - } - - return ChatBuilder() - .component("- Name: " + teamMeta.displayName).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEAM_NAME.command) - .setHoverText("Edit the name of the team.") - .builder().nextLine() - .component("- Color: " + teamMeta.prefix + "Color").builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEAM_PREFIX.command) - .setHoverText("Edit the prefix of the team.") - .builder().nextLine() - .component("- Min amount: " + teamMeta.minAmount).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEAM_MINAMOUNT.command) - .setHoverText("Edit the min amount of players required to start a match.") - .builder().nextLine() - .component("- Max amount: " + teamMeta.maxAmount).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEAM_MAXAMOUNT.command) - .setHoverText("Edit the max amount of players which can join this team.") - .builder().nextLine() - .component("- Armor").builder() - .component(MenuClickableItem.COPY_ARMOR.text).setColor(MenuClickableItem.COPY_ARMOR.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.TEAM_ARMOR.command) - .setHoverText("Copies your current equipped armor to the team's armor.") - .builder().nextLine() - .component("- Inventory").builder() - .component(MenuClickableItem.COPY_INVENTORY.text).setColor(MenuClickableItem.COPY_INVENTORY.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.TEAM_INVENTORY.command) - .setHoverText("Copies your current your inventory to the team's inventory.") - .builder().nextLine() - .component("- Walking Speed: " + teamMeta.walkingSpeed).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEAM_WALKSPEED.command) - .setHoverText("Edit the speed each player of this team is going to walk. (default: 0.2)") - .builder().nextLine() - .component("- Points per goal: " + teamMeta.pointsPerGoal).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEAM_POINTSGOAL.command) - .setHoverText("Edit the amount of points this team gets when a goal gets scored. (default: 1)") - .builder().nextLine() - .component("- Points per opponent death: " + teamMeta.pointsPerEnemyDeath).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEAM_POINTSDEATH.command) - .setHoverText("Edit the amount of points this team gets when a player of the opponent team dies. (default: 0)") - .builder().nextLine() - .component("- Spawnpoint: $spawnpoint").builder() - .component(" [location..]").setColor(ChatColor.BLUE) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.TEAM_SPAWNPOINT.command) - .setHoverText("If this spawnpoint is set the team will spawn at this location instead of the spawning location of the ball.") - .builder().nextLine() - .component("- Lobby: $lobby").builder() - .component(" [location..]").setColor(ChatColor.BLUE) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.TEAM_LOBBY.command) - .setHoverText("If this spawnpoint is set the team will spawn in its own lobby.") - .builder().nextLine() - .component("- Textbook: ").builder() - .component(MenuClickableItem.PAGE.text).setColor(MenuClickableItem.PAGE.color) - .setClickAction(ChatClickAction.RUN_COMMAND, MenuCommand.TEXTBOOK_OPEN.command) - .setHoverText("Opens the messages and texts specific for this team.") - .builder().nextLine() - } - - private fun getTeamMeta(cache: Array?): TeamMeta { - val arena = cache!![0] as Arena - val type = cache[2] as Int - return if (type == 0) { - arena.meta.redTeamMeta - } else { - arena.meta.blueTeamMeta - } - } - -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamTextBookPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamTextBookPage.kt deleted file mode 100644 index 34f3fc513..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamTextBookPage.kt +++ /dev/null @@ -1,166 +0,0 @@ -package com.github.shynixn.blockball.impl.commandmenu - -import com.github.shynixn.blockball.entity.Arena -import com.github.shynixn.blockball.entity.ChatBuilder -import com.github.shynixn.blockball.entity.TeamMeta -import com.github.shynixn.blockball.enumeration.* - -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class TeamTextBookPage : Page(TeamTextBookPage.ID, MainSettingsPage.ID) { - - companion object { - /** Id of the page. */ - const val ID = 27 - } - - /** - * Returns the key of the command when this page should be executed. - * - * @return key - */ - override fun getCommandKey(): MenuPageKey { - return MenuPageKey.TEAMTEXTBOOK - } - - /** - * Executes actions for this page. - * - * @param cache cache - */ - override fun

execute(player: P, command: MenuCommand, cache: Array, args: Array): MenuCommandResult { - if (command == MenuCommand.TEXTBOOK_OPEN) { - cache[5] = cache[2] - val teamMeta = getTeamMeta(cache) - cache[2] = teamMeta.signLines - } else if (command == MenuCommand.TEXTBOOK_JOINMESSAGE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.joinMessage = mergeArgs(2, args) - } else if (command == MenuCommand.TEXTBOOK_LEAVEMESSAGE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.leaveMessage = mergeArgs(2, args) - } else if (command == MenuCommand.TEXTBOOK_SCORETIELE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.scoreMessageTitle = mergeArgs(2, args) - } else if (command == MenuCommand.TEXTBOOK_SCORESUBTITLE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.scoreMessageSubTitle = mergeArgs(2, args) - } else if (command == MenuCommand.TEXTBOOK_WINTIELE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.winMessageTitle = mergeArgs(2, args) - } else if (command == MenuCommand.TEXTBOOK_WINSUBTITLE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.winMessageSubTitle = mergeArgs(2, args) - } else if (command == MenuCommand.TEXTBOOK_DRAWTIELE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.drawMessageTitle = mergeArgs(2, args) - } else if (command == MenuCommand.TEXTBOOK_DRAWSUBTITLE && args.size >= 3) { - val teamMeta = getTeamMeta(cache) - teamMeta.drawMessageSubTitle = mergeArgs(2, args) - } - return super.execute(player, command, cache, args) - } - - /** - * Builds the page content. - * - * @param cache cache - * @return content - */ - override fun buildPage(cache: Array): ChatBuilder? { - val teamMeta = getTeamMeta(cache) - return ChatBuilder() - .component("- Join Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.joinMessage).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_JOINMESSAGE.command) - .setHoverText("Changes the message being played when a player joins this team.") - .builder().nextLine() - .component("- Leave Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.leaveMessage).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_LEAVEMESSAGE.command) - .setHoverText("Changes the message being played when a player leaves this team.") - .builder().nextLine() - .component("- ScoreTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.scoreMessageTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_SCORETIELE.command) - .setHoverText("Changes the title message getting played when a player scores a goal.") - .builder().nextLine() - .component("- ScoreSubTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.scoreMessageSubTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_SCORESUBTITLE.command) - .setHoverText("Changes the subtitle message getting played when a player scores a goal.") - .builder().nextLine() - .component("- WinTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.winMessageTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_WINTIELE.command) - .setHoverText("Changes the title message getting played when the team wins the match.") - .builder().nextLine() - .component("- WinSubTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.winMessageSubTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_WINSUBTITLE.command) - .setHoverText("Changes the subtitle message getting played when the team wins the match.") - .builder().nextLine() - .component("- DrawTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.drawMessageTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_DRAWTIELE.command) - .setHoverText("Changes the title message getting played when the match ends in a draw.") - .builder().nextLine() - .component("- DrawSubTitle Message: ").builder() - .component(MenuClickableItem.PREVIEW.text).setColor(MenuClickableItem.PREVIEW.color) - .setHoverText(teamMeta.drawMessageSubTitle).builder() - .component(MenuClickableItem.EDIT.text).setColor(MenuClickableItem.EDIT.color) - .setClickAction(ChatClickAction.SUGGEST_COMMAND, MenuCommand.TEXTBOOK_DRAWSUBTITLE.command) - .setHoverText("Changes the subtitle message getting played when the match ends in a draw.") - .builder() - } - - private fun getTeamMeta(cache: Array?): TeamMeta { - val arena = cache!![0] as Arena - val type = cache[5] as Int - return if (type == 0) { - arena.meta.redTeamMeta - } else { - arena.meta.blueTeamMeta - } - } - -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/exception/SoccerGameException.kt b/src/main/java/com/github/shynixn/blockball/impl/exception/SoccerGameException.kt new file mode 100644 index 000000000..61d2303e2 --- /dev/null +++ b/src/main/java/com/github/shynixn/blockball/impl/exception/SoccerGameException.kt @@ -0,0 +1,7 @@ +package com.github.shynixn.blockball.impl.exception + +import com.github.shynixn.blockball.entity.SoccerArena + +class SoccerGameException(val arena: SoccerArena, message: String) : RuntimeException(message) { + +} diff --git a/src/main/java/com/github/shynixn/blockball/impl/extension/ExtensionMethod.kt b/src/main/java/com/github/shynixn/blockball/impl/extension/ExtensionMethod.kt deleted file mode 100644 index 959584e7d..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/extension/ExtensionMethod.kt +++ /dev/null @@ -1,71 +0,0 @@ -@file:Suppress("DEPRECATION") - -package com.github.shynixn.blockball.impl.extension - -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.enumeration.Permission -import com.github.shynixn.mcutils.common.ChatColor -import com.github.shynixn.mcutils.common.sound.SoundMeta -import org.bukkit.Location -import org.bukkit.block.Sign -import org.bukkit.entity.Player - -/** - * Returns if the given [player] has got this [Permission]. - */ -internal fun Permission.hasPermission(player: Player): Boolean { - return player.hasPermission(this.permission) -} - -/** - * Strips the chat colors from the string. - */ -fun String.stripChatColors(): String { - return ChatColor.stripChatColors(this) -} - -fun Location.setSignLines(lines: List): Boolean { - val location = this - - if (!location.world!!.isChunkLoaded(location.blockX shr 4, location.blockZ shr 4)) { - return true - } - - if (location.block.state !is Sign) { - return false - } - - val sign = location.block.state as Sign - - for (i in lines.indices) { - val text = lines[i] - sign.setLine(i, text) - } - - sign.update(true) - return true -} - -/** - * Merges arguments starting from [starting] to [amount] from the given [args]. - */ -fun CommandExecutor.mergeArgs(starting: Int, amount: Int, args: Array): String { - val builder = StringBuilder() - var counter = 0 - var i = starting - - while (counter < amount) { - if (builder.isNotEmpty()) { - builder.append(' ') - } - - if (i < args.size) { - builder.append(args[i].stripChatColors()) - } - - counter++ - i++ - } - - return builder.toString() -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt b/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt index 5d68bdf5e..941655c38 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt @@ -1,7 +1,7 @@ package com.github.shynixn.blockball.impl.listener -import com.github.shynixn.blockball.contract.Ball -import com.github.shynixn.blockball.contract.BallEntityService +import com.github.shynixn.blockball.contract.SoccerBall +import com.github.shynixn.blockball.contract.SoccerBallFactory import com.github.shynixn.blockball.enumeration.BallActionType import com.github.shynixn.blockball.event.* import com.github.shynixn.mcutils.common.sound.SoundService @@ -13,7 +13,7 @@ import org.bukkit.event.Listener * Handles common ball events. */ class BallListener @Inject constructor( - private val ballEntityService: BallEntityService, + private val soccerBallFactory: SoccerBallFactory, private val soundService: SoundService ) : Listener { /** @@ -31,7 +31,7 @@ class BallListener @Inject constructor( */ @EventHandler fun ballDeathEvent(event: BallRemoveEvent) { - this.ballEntityService.removeTrackedBall(event.ball) + this.soccerBallFactory.removeTrackedBall(event.ball) } /** @@ -85,7 +85,7 @@ class BallListener @Inject constructor( /** * Plays effects. */ - private fun playEffects(ball: Ball, actionEffect: BallActionType) { + private fun playEffects(ball: SoccerBall, actionEffect: BallActionType) { if (ball.meta.soundEffects.containsKey(actionEffect)) { this.soundService.playSound( ball.getLocation(), diff --git a/src/main/java/com/github/shynixn/blockball/impl/listener/DoubleJumpListener.kt b/src/main/java/com/github/shynixn/blockball/impl/listener/DoubleJumpListener.kt index e92550b88..acde14bb2 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/listener/DoubleJumpListener.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/listener/DoubleJumpListener.kt @@ -25,7 +25,7 @@ class DoubleJumpListener @Inject constructor( return } - val game = gameService.getGameFromPlayer(event.player) ?: return + val game = gameService.getByPlayer(event.player) ?: return if (game.arena.meta.doubleJumpMeta.enabled) { event.player.allowFlight = true @@ -42,7 +42,7 @@ class DoubleJumpListener @Inject constructor( return } - val game = gameService.getGameFromPlayer(event.player) ?: return + val game = gameService.getByPlayer(event.player) ?: return if (!game.arena.meta.doubleJumpMeta.enabled) { return diff --git a/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt b/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt index 7a70f9b6f..7af3c42ca 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt @@ -1,12 +1,13 @@ package com.github.shynixn.blockball.impl.listener -import com.github.shynixn.blockball.contract.* +import com.github.shynixn.blockball.contract.GameService +import com.github.shynixn.blockball.contract.SoccerBallFactory +import com.github.shynixn.blockball.contract.SoccerHubGame import com.github.shynixn.blockball.entity.PlayerInformation import com.github.shynixn.blockball.enumeration.Permission import com.github.shynixn.blockball.enumeration.Team import com.github.shynixn.blockball.event.BallRayTraceEvent import com.github.shynixn.blockball.event.BallTouchPlayerEvent -import com.github.shynixn.blockball.impl.extension.hasPermission import com.github.shynixn.mccoroutine.bukkit.launch import com.github.shynixn.mccoroutine.bukkit.ticks import com.github.shynixn.mcutils.common.toLocation @@ -18,11 +19,9 @@ import com.github.shynixn.mcutils.packet.api.meta.enumeration.InteractionType import com.github.shynixn.mcutils.packet.api.packet.PacketInInteractEntity import com.google.inject.Inject import kotlinx.coroutines.delay -import org.bukkit.block.Sign import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.Listener -import org.bukkit.event.block.Action import org.bukkit.event.entity.EntityDamageEvent import org.bukkit.event.entity.FoodLevelChangeEvent import org.bukkit.event.entity.PlayerDeathEvent @@ -36,8 +35,7 @@ import org.bukkit.plugin.Plugin */ class GameListener @Inject constructor( private val gameService: GameService, - private val rightClickManageService: RightclickManageService, - private val ballEntityService: BallEntityService, + private val soccerBallFactory: SoccerBallFactory, private val plugin: Plugin, private val playerDataRepository: CachePlayerRepository ) : Listener { @@ -53,10 +51,10 @@ class GameListener @Inject constructor( } plugin.launch { - val game = gameService.getGameFromPlayer(event.player) ?: return@launch + val game = gameService.getByPlayer(event.player) ?: return@launch val packet = event.packet as PacketInInteractEntity - val ball = ballEntityService.findBallByEntityId(packet.entityId) ?: return@launch + val ball = soccerBallFactory.findBallByEntityId(packet.entityId) ?: return@launch if (game.ball != ball) { return@launch @@ -77,14 +75,12 @@ class GameListener @Inject constructor( fun onPlayerQuitEvent(event: PlayerQuitEvent) { val player = event.player - val playerGame = gameService.getGameFromPlayer(player) + val playerGame = gameService.getByPlayer(player) playerGame?.leave(player) - val spectateGame = gameService.getGameFromSpectatingPlayer(player) + val spectateGame = gameService.getByPlayer(player) spectateGame?.leave(player) - rightClickManageService.cleanResources(player) - plugin.launch { val existingPlayerData = playerDataRepository.getByPlayer(player) @@ -119,9 +115,9 @@ class GameListener @Inject constructor( return } - val game = gameService.getGameFromPlayer(event.player) ?: return + val game = gameService.getByPlayer(event.player) ?: return - if (game !is BlockBallHubGame) { + if (game !is SoccerHubGame) { return } @@ -137,7 +133,7 @@ class GameListener @Inject constructor( */ @EventHandler fun onPlayerHungerEvent(event: FoodLevelChangeEvent) { - val game = gameService.getGameFromPlayer(event.entity as Player) + val game = gameService.getByPlayer(event.entity as Player) if (game != null) { event.isCancelled = true @@ -149,9 +145,9 @@ class GameListener @Inject constructor( */ @EventHandler fun onPlayerClickInventoryEvent(event: InventoryClickEvent) { - val game = gameService.getGameFromPlayer(event.whoClicked as Player) + val game = gameService.getByPlayer(event.whoClicked as Player) - if (game != null && !Permission.INVENTORY.hasPermission(event.whoClicked as Player)) { + if (game != null && !(event.whoClicked as Player).hasPermission(Permission.OBSOLETE_INVENTORY.permission)) { event.isCancelled = true event.whoClicked.closeInventory() } @@ -162,9 +158,9 @@ class GameListener @Inject constructor( */ @EventHandler fun onPlayerOpenInventoryEvent(event: InventoryOpenEvent) { - val game = gameService.getGameFromPlayer(event.player as Player) + val game = gameService.getByPlayer(event.player as Player) - if (game != null && !Permission.INVENTORY.hasPermission(event.player as Player)) { + if (game != null && !(event.player).hasPermission(Permission.OBSOLETE_INVENTORY.permission)) { event.isCancelled = true } } @@ -174,9 +170,9 @@ class GameListener @Inject constructor( */ @EventHandler fun onPlayerDropItemEvent(event: PlayerDropItemEvent) { - val game = gameService.getGameFromPlayer(event.player) + val game = gameService.getByPlayer(event.player) - if (game != null && !Permission.INVENTORY.hasPermission(event.player)) { + if (game != null && !(event.player).hasPermission(Permission.OBSOLETE_INVENTORY.permission)) { event.isCancelled = true plugin.launch { @@ -191,7 +187,7 @@ class GameListener @Inject constructor( */ @EventHandler fun onPlayerRespawnEvent(event: PlayerRespawnEvent) { - val game = gameService.getGameFromPlayer(event.player) ?: return + val game = gameService.getByPlayer(event.player) ?: return val team = game.ingamePlayersStorage[event.player]!!.goalTeam @@ -213,7 +209,7 @@ class GameListener @Inject constructor( */ @EventHandler fun onPlayerDeathEvent(event: PlayerDeathEvent) { - val game = gameService.getGameFromPlayer(event.entity) ?: return + val game = gameService.getByPlayer(event.entity) ?: return if (playerCache.contains(event.entity)) { return @@ -232,7 +228,7 @@ class GameListener @Inject constructor( } val player = event.entity as Player - val game = gameService.getGameFromPlayer(player) ?: return + val game = gameService.getByPlayer(player) ?: return if (event.cause == EntityDamageEvent.DamageCause.FALL) { event.isCancelled = true @@ -267,7 +263,7 @@ class GameListener @Inject constructor( */ @EventHandler fun onBallInteractEvent(event: BallTouchPlayerEvent) { - val game = gameService.getAllGames().find { p -> p.ball != null && p.ball!! == event.ball } + val game = gameService.getAll().find { p -> p.ball != null && p.ball!! == event.ball } if (game != null) { game.lastInteractedEntity = event.player @@ -276,11 +272,11 @@ class GameListener @Inject constructor( /** * Is called when the ball requests to move to a target position. - * Handles the ball forceField of the arena. + * Handles the ball forceField of the soccerArena. */ @EventHandler fun onBallRayTraceEvent(event: BallRayTraceEvent) { - for (game in gameService.getAllGames()) { + for (game in gameService.getAll()) { if (game.ball == event.ball) { val targetPosition = event.targetLocation.toVector3d() val sourcePosition = event.ball.getLocation().toVector3d() @@ -323,44 +319,4 @@ class GameListener @Inject constructor( } } } - - /** - * Handles clicking and joining on signs. - */ - @EventHandler - fun onClickOnPlacedSign(event: PlayerInteractEvent) { - if (event.action != Action.RIGHT_CLICK_BLOCK) { - return - } - - if (event.clickedBlock!!.state !is Sign) { - return - } - - val location = event.clickedBlock!!.location.toVector3d() - - if (rightClickManageService.executeWatchers(event.player, event.clickedBlock!!.location)) { - return - } - - for (game in gameService.getAllGames()) { - when { - game.arena.meta.lobbyMeta.joinSigns.contains(location) -> { - game.join(event.player) - } - - game.arena.meta.redTeamMeta.signs.contains(location) -> { - game.join(event.player, Team.RED) - } - - game.arena.meta.blueTeamMeta.signs.contains(location) -> { - game.join(event.player, Team.BLUE) - } - - game.arena.meta.lobbyMeta.leaveSigns.contains(location) -> { - game.leave(event.player) - } - } - } - } } diff --git a/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt b/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt index 5a3c9fc9a..431e0911c 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt @@ -1,12 +1,11 @@ package com.github.shynixn.blockball.impl.listener -import com.github.shynixn.blockball.contract.BlockBallMiniGame +import com.github.shynixn.blockball.contract.SoccerMiniGame import com.github.shynixn.blockball.contract.GameService import com.github.shynixn.blockball.enumeration.GameType import com.github.shynixn.blockball.enumeration.MatchTimeCloseType import com.github.shynixn.blockball.enumeration.Permission import com.github.shynixn.blockball.event.GameGoalEvent -import com.github.shynixn.blockball.impl.extension.hasPermission import com.github.shynixn.mcutils.common.ConfigurationService import com.google.inject.Inject import org.bukkit.event.EventHandler @@ -20,15 +19,11 @@ class MinigameListener @Inject constructor( ) : Listener { /** - * Cancels actions in minigame and bungeecord games to restrict destroying the arena. + * Cancels actions in minigame and bungeecord games to restrict destroying the soccerArena. */ @EventHandler fun onPlayerInteractEvent(event: PlayerInteractEvent) { - var game = gameService.getGameFromPlayer(event.player) - - if (game == null) { - game = gameService.getGameFromSpectatingPlayer(event.player) - } + val game = gameService.getByPlayer(event.player) if (game != null && game.arena.enabled && (game.arena.gameType == GameType.MINIGAME)) { event.isCancelled = true @@ -42,7 +37,7 @@ class MinigameListener @Inject constructor( fun onPlayerGoalEvent(event: GameGoalEvent) { val game = event.game - if (game !is BlockBallMiniGame) { + if (game !is SoccerMiniGame) { return } @@ -60,23 +55,19 @@ class MinigameListener @Inject constructor( } /** - * Cancels commands in minigame and bungeecord games to restrict destroying the arena. + * Cancels commands in minigame and bungeecord games to restrict destroying the soccerArena. */ @EventHandler fun onPlayerExecuteCommand(event: PlayerCommandPreprocessEvent) { if (event.message.startsWith("/blockball") - || event.message.startsWith("/" + configurationService.findValue("global-leave.command")) - || Permission.STAFF.hasPermission(event.player) || Permission.ADMIN.hasPermission(event.player) + || event.player.hasPermission(Permission.OBSOLETE_STAFF.permission) || event.player.hasPermission(Permission.EDIT_GAME.permission) || event.player.isOp ) { return } - var game = gameService.getGameFromPlayer(event.player) - if (game != null) { - game = gameService.getGameFromSpectatingPlayer(event.player) - } + val game = gameService.getByPlayer(event.player) if (game != null && game.arena.enabled && (game.arena.gameType == GameType.MINIGAME)) { event.isCancelled = true diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/BlockSelectionServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/BlockSelectionServiceImpl.kt index 03826f67c..2bed5e7ea 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/BlockSelectionServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/BlockSelectionServiceImpl.kt @@ -4,7 +4,6 @@ package com.github.shynixn.blockball.impl.service import com.github.shynixn.blockball.contract.BlockSelectionService import com.github.shynixn.blockball.enumeration.Permission -import com.github.shynixn.blockball.impl.extension.stripChatColors import com.github.shynixn.mccoroutine.bukkit.launch import com.github.shynixn.mccoroutine.bukkit.ticks import com.github.shynixn.mcutils.common.ChatColor @@ -102,7 +101,7 @@ class BlockSelectionServiceImpl @Inject constructor( * Select location and returns if success. */ private fun selectLocation(player: Player, location: Location, index: Int): Boolean { - if (!player.hasPermission(Permission.ADMIN.permission)) { + if (!player.hasPermission(Permission.EDIT_GAME.permission)) { return false } @@ -123,7 +122,7 @@ class BlockSelectionServiceImpl @Inject constructor( return false } - if (itemMeta.displayName.stripChatColors() != this.axeName.stripChatColors()) { + if (org.bukkit.ChatColor.stripColor(itemMeta.displayName) != org.bukkit.ChatColor.stripColor(this.axeName)) { return false } @@ -149,7 +148,7 @@ class BlockSelectionServiceImpl @Inject constructor( if (itemMeta != null) { if (itemMeta.displayName != null - && itemMeta.displayName.stripChatColors() == this.axeName.stripChatColors() + && org.bukkit.ChatColor.stripColor(itemMeta.displayName) == org.bukkit.ChatColor.stripColor(this.axeName) ) { return } diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/BossBarServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/BossBarServiceImpl.kt index c536ea586..0ae79fff0 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/BossBarServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/BossBarServiceImpl.kt @@ -11,33 +11,6 @@ import org.bukkit.entity.Player import java.lang.reflect.Array import java.lang.reflect.Method -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ class BossBarServiceImpl @Inject constructor() : BossBarService { /** diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/CommandServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/CommandServiceImpl.kt deleted file mode 100644 index 907d1d4ec..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/service/CommandServiceImpl.kt +++ /dev/null @@ -1,127 +0,0 @@ -package com.github.shynixn.blockball.impl.service - -import com.github.shynixn.blockball.contract.CommandExecutor -import com.github.shynixn.blockball.contract.CommandService -import com.github.shynixn.mcutils.common.Version -import com.google.inject.Inject -import org.bukkit.Bukkit -import org.bukkit.command.Command -import org.bukkit.command.CommandSender -import org.bukkit.command.SimpleCommandMap -import org.bukkit.command.defaults.BukkitCommand -import org.bukkit.plugin.Plugin -import org.bukkit.plugin.java.JavaPlugin -import java.util.ArrayList - -/** - * Created by Shynixn 2019. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2019 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -class CommandServiceImpl @Inject constructor(private val plugin: Plugin) : CommandService, org.bukkit.command.CommandExecutor { - private var commandExecutor: CommandExecutor? = null - - /** - * Creates an unmanaged instance for handling internal commands. - */ - constructor(plugin: Plugin, commandExecutorInstance: CommandExecutor) : this(plugin) { - this.commandExecutor = commandExecutorInstance - } - - /** - * Handles command events from bukkit. - */ - override fun onCommand(commandSender: CommandSender, command: Command, s: String, args: Array): Boolean { - if (commandExecutor == null) { - return false - } - - return this.commandExecutor!!.onExecuteCommand(commandSender, args) - } - - /** - * Registers a command executor from new [commandConfiguration] with gets executed by the [commandExecutor]. - */ - override fun registerCommandExecutor(commandConfiguration: Map, commandExecutor: CommandExecutor) { - if (plugin !is JavaPlugin) { - throw IllegalArgumentException("Plugin has to be a JavaPlugin!") - } - - val command = commandConfiguration["command"] as String - val description = commandConfiguration["description"] as String - val usage = commandConfiguration["useage"] as String - val permission = commandConfiguration["permission"] as String - val permissionMessage = commandConfiguration["permission-message"] as String - - val internalExecutor = InternalBukkitCommand(command, description, usage, permission, permissionMessage, commandExecutor) - val clazz = Version.findClass("org.bukkit.craftbukkit.VERSION.CraftServer") - val server = clazz.cast(Bukkit.getServer()) - val map = server.javaClass.getDeclaredMethod("getCommandMap").invoke(server) as SimpleCommandMap - map.register(command, internalExecutor) - } - - /** - * Registers a command executor from a pre-defined [command] with gets executed by the [commandExecutor]. - */ - override fun registerCommandExecutor(command: String, commandExecutor: CommandExecutor) { - if (plugin !is JavaPlugin) { - throw IllegalArgumentException("Plugin has to be a JavaPlugin!") - } - - plugin.getCommand(command)!!.setExecutor(CommandServiceImpl(plugin, commandExecutor)) - } - - /** - * Handles internal bukkit registration. - */ - private class InternalBukkitCommand( - command: String, - description: String, - usage: String, - permission: String, - permissionMessage: String, - private val commandExecutor: CommandExecutor - ) : BukkitCommand(command) { - init { - this.setDescription(description) - this.usage = usage - this.permission = permission - this.permissionMessage = permissionMessage - this.aliases = ArrayList() - } - - /** - * Gets called when the user enters a command. - */ - override fun execute(commandSender: CommandSender, alias: String, args: Array): Boolean { - if (!commandSender.hasPermission(this.permission!!)) { - commandSender.sendMessage(this.permissionMessage!!) - return true - } - - return this.commandExecutor.onExecuteCommand(commandSender, args) - } - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/DependencyPlaceHolderServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/DependencyPlaceHolderServiceImpl.kt index 6a97a9066..17bf4c59c 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/DependencyPlaceHolderServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/DependencyPlaceHolderServiceImpl.kt @@ -1,6 +1,6 @@ package com.github.shynixn.blockball.impl.service -import com.github.shynixn.blockball.contract.BlockBallGame +import com.github.shynixn.blockball.contract.SoccerGame import com.github.shynixn.blockball.contract.GameService import com.github.shynixn.blockball.contract.PlaceHolderService import com.github.shynixn.blockball.entity.PlayerInformation @@ -18,7 +18,7 @@ import org.bukkit.plugin.Plugin class DependencyPlaceHolderServiceImpl @Inject constructor( private val plugin: Plugin, private val gameService: GameService, - private val cachePlayerRepository: CachePlayerRepository, + cachePlayerRepository: CachePlayerRepository, ) : PlaceholderExpansion(), PlaceHolderService { private val placeHolderService = PlaceHolderServiceImpl(gameService, cachePlayerRepository) private var registered: Boolean = false @@ -82,7 +82,7 @@ class DependencyPlaceHolderServiceImpl @Inject constructor( } } - var selectedGame = gameService.getGameFromName(gamePart.toString()) + val selectedGame = gameService.getByName(gamePart.toString()) if (selectedGame != null) { val teamPair = if (player != null && selectedGame.redTeam.contains(player)) { Pair(selectedGame.arena.meta.redTeamMeta, selectedGame.redTeam.size) @@ -97,7 +97,7 @@ class DependencyPlaceHolderServiceImpl @Inject constructor( } if (player != null) { - val optSelectedGame = gameService.getGameFromPlayer(player) + val optSelectedGame = gameService.getByPlayer(player) if (optSelectedGame != null) { val teamPair = if (optSelectedGame.redTeam.contains(player)) { @@ -122,7 +122,7 @@ class DependencyPlaceHolderServiceImpl @Inject constructor( * Replaces the given text with properties from the given [game], optional [teamMeta] and optional size. */ override fun replacePlaceHolders( - text: String, player: Player?, game: BlockBallGame?, teamMeta: TeamMeta?, currentTeamSize: Int? + text: String, player: Player?, game: SoccerGame?, teamMeta: TeamMeta?, currentTeamSize: Int? ): String { val replacedInput = placeHolderService.replacePlaceHolders(text, player, game, teamMeta, currentTeamSize) return PlaceholderAPI.setPlaceholders(player, replacedInput) diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/GameServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/GameServiceImpl.kt index ec00af051..02b065ef4 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/GameServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/GameServiceImpl.kt @@ -3,8 +3,9 @@ package com.github.shynixn.blockball.impl.service import com.github.shynixn.blockball.contract.* import com.github.shynixn.blockball.entity.* import com.github.shynixn.blockball.enumeration.GameType -import com.github.shynixn.blockball.impl.BlockBallHubGameImpl -import com.github.shynixn.blockball.impl.BlockBallMiniGameImpl +import com.github.shynixn.blockball.impl.SoccerHubGameImpl +import com.github.shynixn.blockball.impl.SoccerMiniGameImpl +import com.github.shynixn.blockball.impl.exception.SoccerGameException import com.github.shynixn.mcutils.common.ConfigurationService import com.github.shynixn.mcutils.common.chat.ChatMessageService import com.github.shynixn.mcutils.common.command.CommandService @@ -13,8 +14,9 @@ import com.github.shynixn.mcutils.common.sound.SoundService import com.github.shynixn.mcutils.common.toVector3d import com.github.shynixn.mcutils.database.api.PlayerDataRepository import com.github.shynixn.mcutils.packet.api.PacketService +import com.github.shynixn.mcutils.sign.SignService import com.google.inject.Inject -import org.bukkit.Bukkit +import kotlinx.coroutines.runBlocking import org.bukkit.Location import org.bukkit.entity.Player import org.bukkit.plugin.Plugin @@ -22,7 +24,7 @@ import java.util.* import java.util.logging.Level class GameServiceImpl @Inject constructor( - private val arenaRepository: Repository, + private val arenaRepository: Repository, private val configurationService: ConfigurationService, private val plugin: Plugin, private val playerDataRepository: PlayerDataRepository, @@ -33,9 +35,11 @@ class GameServiceImpl @Inject constructor( private val packetService: PacketService, private val scoreboardService: ScoreboardService, private val commandService: CommandService, - private val ballEntityService: BallEntityService + private val soccerBallFactory: SoccerBallFactory, + private val language: BlockBallLanguage, + private val signService: SignService ) : GameService, Runnable { - private val games = ArrayList() + private val games = ArrayList() private var ticks: Int = 0 /** @@ -52,12 +56,74 @@ class GameServiceImpl @Inject constructor( */ override suspend fun reloadAll() { close() - configurationService.reload() val arenas = arenaRepository.getAll() for (arena in arenas) { - initGame(arena) + reload(arena) + } + } + + /** + * Reloads the specific game. + */ + override suspend fun reload(arena: SoccerArena) { + // A game with the same arena name is currently running. Stop it and reboot it. + val existingGame = getByName(arena.name) + + if (existingGame != null) { + existingGame.close() + games.remove(existingGame) + plugin.logger.log(Level.INFO, "Stopped game '" + arena.name + "'.") + } + + // Enable signs, if they are already added, the call does nothing. + for (sign in arena.meta.getAllSigns()) { + sign.tag = arena.name + signService.addSign(sign) + } + + if (arena.enabled) { + validateGame(arena) + + val game: SoccerGame = when (arena.gameType) { + GameType.HUBGAME -> SoccerHubGameImpl( + arena, + playerDataRepository, + plugin, + placeHolderService, + bossBarService, + language, + packetService, + scoreboardService, + soccerBallFactory, + chatMessageService, + commandService + ) + + GameType.MINIGAME -> SoccerMiniGameImpl( + arena, + playerDataRepository, + plugin, + placeHolderService, + bossBarService, + chatMessageService, + configurationService, + soundService, + language, + packetService, + scoreboardService, + commandService, + soccerBallFactory + ) + + else -> throw RuntimeException("GameType ${arena.gameType} not supported!") + } + + games.add(game) + plugin.logger.log(Level.INFO, "Game '" + arena.name + "' is ready.") + } else { + plugin.logger.log(Level.INFO, "Cannot boot game '" + arena.name + "' because it is not enabled.") } } @@ -76,8 +142,9 @@ class GameServiceImpl @Inject constructor( override fun run() { games.toTypedArray().forEach { game -> if (game.closed) { - games.remove(game) - initGame(game.arena) + runBlocking { + reload(game.arena) + } } else { game.handle(ticks) } @@ -91,22 +158,16 @@ class GameServiceImpl @Inject constructor( } /** - * Returns the game with the given name or displayName. + * Returns all currently loaded games on the server. */ - override fun getGameFromName(name: String): BlockBallGame? { - for (game in games) { - if (game.arena.name.equals(name, true) || game.arena.displayName.equals(name, true)) { - return game - } - } - - return null + override fun getAll(): List { + return games } /** - * Returns the game if the given [player] is playing a game. + * Tries to locate a game this player is playing. */ - override fun getGameFromPlayer(player: Player): BlockBallGame? { + override fun getByPlayer(player: Player): SoccerGame? { for (game in games) { if (game.ingamePlayersStorage.containsKey(player)) { return game @@ -117,28 +178,11 @@ class GameServiceImpl @Inject constructor( } /** - * Returns the game if the given [player] is spectating a game. + * Tries to locate a game of the given name. */ - override fun getGameFromSpectatingPlayer(player: Player): BlockBallGame? { - for (g in this.games) { - if (g is BlockBallMiniGame) { - if (g.spectatorPlayers.contains(player)) { - return g - } - } - } - - return null - } - - /** - * Returns the game at the given location. - */ - override fun getGameFromLocation(location: Location): BlockBallGame? { - val position = location.toVector3d() - + override fun getByName(name: String): SoccerGame? { for (game in games) { - if (game.arena.isLocationInSelection(position)) { + if (game.arena.name.equals(name, true)) { return game } } @@ -146,13 +190,6 @@ class GameServiceImpl @Inject constructor( return null } - /** - * Returns all currently loaded games on the server. - */ - override fun getAllGames(): List { - return games.filter { g -> (!g.closing && !g.closed) } - } - /** * Closes all games permanently and should be executed on server shutdown. */ @@ -168,48 +205,10 @@ class GameServiceImpl @Inject constructor( games.clear() } - /** - * Initialises a new game from the given arena. - */ - private fun initGame(arena: Arena) { - if (arena.name.isBlank()) { - throw Exception("Arena(s) cannot be loaded! If you have an obsolete arena file format, convert your arenas using the plugin found here https://github.com/Shynixn/BlockBall/releases/tag/conversion or delete your BlockBall folder.") - } - val game: BlockBallGame = when (arena.gameType) { - GameType.HUBGAME -> BlockBallHubGameImpl( - arena, - this, - playerDataRepository, - plugin, - placeHolderService, - bossBarService, - packetService, - scoreboardService, - ballEntityService, - chatMessageService, - commandService - ) - - GameType.MINIGAME -> BlockBallMiniGameImpl( - arena, - this, - playerDataRepository, - plugin, - placeHolderService, - bossBarService, - chatMessageService, - configurationService, - soundService, - packetService, - scoreboardService, - commandService, - ballEntityService - ) - - else -> throw RuntimeException("GameType ${arena.gameType} not supported!") + private fun validateGame(arena: SoccerArena) { + if (arena.meta.ballMeta.spawnpoint == null) { + throw SoccerGameException(arena, "Set the leave spawnpoint values in arena ${arena.name}!") } - - games.add(game) } } diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/HubGameForcefieldServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/HubGameForcefieldServiceImpl.kt index b251c72f4..37ac7860b 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/HubGameForcefieldServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/HubGameForcefieldServiceImpl.kt @@ -1,13 +1,15 @@ package com.github.shynixn.blockball.impl.service -import com.github.shynixn.blockball.contract.* -import com.github.shynixn.blockball.entity.ChatBuilder +import com.github.shynixn.blockball.contract.BlockBallLanguage +import com.github.shynixn.blockball.contract.GameService +import com.github.shynixn.blockball.contract.HubGameForcefieldService +import com.github.shynixn.blockball.contract.PlaceHolderService import com.github.shynixn.blockball.entity.InteractionCache -import com.github.shynixn.blockball.enumeration.ChatClickAction import com.github.shynixn.blockball.enumeration.GameType -import com.github.shynixn.blockball.impl.extension.stripChatColors -import com.github.shynixn.mcutils.common.ConfigurationService import com.github.shynixn.mcutils.common.chat.ChatMessageService +import com.github.shynixn.mcutils.common.chat.ClickEvent +import com.github.shynixn.mcutils.common.chat.ClickEventType +import com.github.shynixn.mcutils.common.chat.TextComponent import com.github.shynixn.mcutils.common.toLocation import com.github.shynixn.mcutils.common.toVector import com.github.shynixn.mcutils.common.toVector3d @@ -19,7 +21,7 @@ import org.bukkit.entity.Player class HubGameForcefieldServiceImpl @Inject constructor( private val gameService: GameService, private val placeholderService: PlaceHolderService, - private val configurationService: ConfigurationService, + private val language: BlockBallLanguage, private val chatMessageService: ChatMessageService ) : HubGameForcefieldService { private val cache = HashMap() @@ -30,7 +32,7 @@ class HubGameForcefieldServiceImpl @Inject constructor( */ override fun checkForForcefieldInteractions(player: Player, location: Location) { val interactionCache = getInteractionCache(player) - val gameInternal = gameService.getGameFromPlayer(player) + val gameInternal = gameService.getByPlayer(player) if (gameInternal != null) { if (gameInternal.arena.gameType == GameType.HUBGAME && !gameInternal.arena.isLocationInSelection( @@ -44,7 +46,7 @@ class HubGameForcefieldServiceImpl @Inject constructor( var inArea = false - gameService.getAllGames().forEach { game -> + gameService.getAll().forEach { game -> if (game.arena.enabled && game.arena.gameType == GameType.HUBGAME && game.arena.isLocationInSelection( location.toVector3d() ) @@ -74,56 +76,45 @@ class HubGameForcefieldServiceImpl @Inject constructor( player.allowFlight = true if (!interactionCache.toggled) { - val joinCommand = configurationService.findValue("global-join.command") - - val b = - ChatBuilder().text( - placeholderService.replacePlaceHolders( - game.arena.meta.hubLobbyMeta.joinMessage[0], - player, - game, - null, - null - ) - ) - .nextLine() - .component( - placeholderService.replacePlaceHolders( - game.arena.meta.hubLobbyMeta.joinMessage[1], + chatMessageService.sendChatMessage(player, TextComponent().also { + it.components = mutableListOf( + TextComponent().also { + it.text = placeholderService.replacePlaceHolders( + language.hubGameJoinHeader, player, game, - game.arena.meta.redTeamMeta - ) - ) - .setClickAction( - ChatClickAction.RUN_COMMAND, - placeholderService.replacePlaceHolders( - "/" + joinCommand + " " + game.arena.name + "|" + game.arena.meta.redTeamMeta.displayName.stripChatColors(), + null, + null + ) + "\n" + }, + TextComponent().also { + it.text = placeholderService.replacePlaceHolders( + language.hubGameJoinRed, player, - game + game, + null, + null + ) + "\n" + it.clickEvent = ClickEvent( + ClickEventType.RUN_COMMAND, + "/blockball join ${game.arena.name} red" ) - ) - .setHoverText(" ") - .builder().text(" ") - .component( - placeholderService.replacePlaceHolders( - game.arena.meta.hubLobbyMeta.joinMessage[2], + }, + TextComponent().also { + it.text = placeholderService.replacePlaceHolders( + language.hubGameJoinBlue, player, game, - game.arena.meta.blueTeamMeta + null, + null ) - ) - .setClickAction( - ChatClickAction.RUN_COMMAND, - placeholderService.replacePlaceHolders( - "/" + joinCommand + " " + game.arena.name + "|" + game.arena.meta.blueTeamMeta.displayName.stripChatColors(), - player, - game + it.clickEvent = ClickEvent( + ClickEventType.RUN_COMMAND, + "/blockball join ${game.arena.name} blue" ) - ) - .setHoverText(" ") - .builder() - chatMessageService.sendChatMessage(player, b.convertToTextComponent()) + } + ) + }) interactionCache.toggled = true } } diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/PlaceHolderServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/PlaceHolderServiceImpl.kt index feb22468b..c49aad677 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/PlaceHolderServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/PlaceHolderServiceImpl.kt @@ -1,9 +1,9 @@ package com.github.shynixn.blockball.impl.service import com.github.shynixn.blockball.BlockBallDependencyInjectionModule -import com.github.shynixn.blockball.BlockBallLanguage -import com.github.shynixn.blockball.contract.BlockBallGame -import com.github.shynixn.blockball.contract.BlockBallMiniGame +import com.github.shynixn.blockball.BlockBallLanguageImpl +import com.github.shynixn.blockball.contract.SoccerGame +import com.github.shynixn.blockball.contract.SoccerMiniGame import com.github.shynixn.blockball.contract.GameService import com.github.shynixn.blockball.contract.PlaceHolderService import com.github.shynixn.blockball.entity.PlayerInformation @@ -18,8 +18,8 @@ import org.bukkit.entity.Player class PlaceHolderServiceImpl @Inject constructor( private val gameService: GameService, private val playerDataRepository: CachePlayerRepository ) : PlaceHolderService { - private val gamePlayerHolderFunctions = HashMap String)>() - private val teamPlaceHolderFunctions = HashMap String)>() + private val gamePlayerHolderFunctions = HashMap String)>() + private val teamPlaceHolderFunctions = HashMap String)>() private val playerPlaceHolderFunctions = HashMap String)>() private val langPlaceHolderFunctions = HashMap String)>() private val placeHolders = HashMap() @@ -29,7 +29,7 @@ class PlaceHolderServiceImpl @Inject constructor( placeHolders[placeHolder.fullPlaceHolder] = placeHolder } - for (field in BlockBallLanguage::class.java.declaredFields) { + for (field in BlockBallLanguageImpl::class.java.declaredFields) { field.isAccessible = true langPlaceHolderFunctions["%blockball_lang_${field.name}%"] = { field.get(null) as String } } @@ -43,13 +43,8 @@ class PlaceHolderServiceImpl @Inject constructor( { game -> (game.ingamePlayersStorage.size).toString() } gamePlayerHolderFunctions[PlaceHolder.GAME_RED_SCORE] = { game -> game.redScore.toString() } gamePlayerHolderFunctions[PlaceHolder.GAME_BLUE_SCORE] = { game -> game.blueScore.toString() } - gamePlayerHolderFunctions[PlaceHolder.GAME_TEAM_RED_NAME] = { game -> game.arena.meta.redTeamMeta.displayName } - gamePlayerHolderFunctions[PlaceHolder.GAME_TEAM_BLUE_NAME] = - { game -> game.arena.meta.blueTeamMeta.displayName } - gamePlayerHolderFunctions[PlaceHolder.GAME_TEAM_RED_COLOR] = { game -> game.arena.meta.redTeamMeta.prefix } - gamePlayerHolderFunctions[PlaceHolder.GAME_TEAM_BLUE_COLOR] = { game -> game.arena.meta.blueTeamMeta.prefix } gamePlayerHolderFunctions[PlaceHolder.GAME_TIME] = { game -> - if (game is BlockBallMiniGame) { + if (game is SoccerMiniGame) { game.gameCountdown.toString() } else { "∞" @@ -66,11 +61,11 @@ class PlaceHolderServiceImpl @Inject constructor( gamePlayerHolderFunctions[PlaceHolder.GAME_STATE] = { game -> game.status.name } gamePlayerHolderFunctions[PlaceHolder.GAME_STATE_DISPLAYNAME] = { game -> if (game.status == GameState.JOINABLE) { - BlockBallLanguage.gameStatusJoinAble + BlockBallLanguageImpl.gameStatusJoinAble } else if (game.status == GameState.DISABLED) { - BlockBallLanguage.gameStatusDisabled + BlockBallLanguageImpl.gameStatusDisabled } else { - BlockBallLanguage.gameStatusRunning + BlockBallLanguageImpl.gameStatusRunning } } gamePlayerHolderFunctions[PlaceHolder.GAME_REMAININGPLAYERS_TO_START] = { game -> @@ -84,12 +79,6 @@ class PlaceHolderServiceImpl @Inject constructor( } // Team PlaceHolders - teamPlaceHolderFunctions[PlaceHolder.TEAM_NAME] = { _, team, _ -> - team.displayName - } - teamPlaceHolderFunctions[PlaceHolder.TEAM_COLOR] = { _, team, _ -> - team.prefix - } teamPlaceHolderFunctions[PlaceHolder.TEAM_MAX_PLAYERS] = { _, team, _ -> team.maxAmount.toString() } @@ -102,15 +91,15 @@ class PlaceHolderServiceImpl @Inject constructor( player.name } playerPlaceHolderFunctions[PlaceHolder.PLAYER_IS_INGAME] = { player -> - val game = gameService.getGameFromPlayer(player) + val game = gameService.getByPlayer(player) game?.ingamePlayersStorage?.containsKey(player).toString() } playerPlaceHolderFunctions[PlaceHolder.PLAYER_IS_IN_TEAM_BLUE] = { player -> - val game = gameService.getGameFromPlayer(player) + val game = gameService.getByPlayer(player) game?.blueTeam?.contains(player).toString() } playerPlaceHolderFunctions[PlaceHolder.PLAYER_IS_IN_TEAM_RED] = { player -> - val game = gameService.getGameFromPlayer(player) + val game = gameService.getByPlayer(player) game?.redTeam?.contains(player).toString() } playerPlaceHolderFunctions[PlaceHolder.PLAYER_STATS_SCOREDGOALS] = { player -> @@ -235,7 +224,7 @@ class PlaceHolderServiceImpl @Inject constructor( * Replaces the given text with properties from the given [game], optional [teamMeta] and optional size. */ override fun replacePlaceHolders( - text: String, player: Player?, game: BlockBallGame?, teamMeta: TeamMeta?, currentTeamSize: Int? + text: String, player: Player?, game: SoccerGame?, teamMeta: TeamMeta?, currentTeamSize: Int? ): String { var output = text for (i in 0 until 4) { diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/RightclickManageServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/RightclickManageServiceImpl.kt deleted file mode 100644 index a90f9c95d..000000000 --- a/src/main/java/com/github/shynixn/blockball/impl/service/RightclickManageServiceImpl.kt +++ /dev/null @@ -1,52 +0,0 @@ -package com.github.shynixn.blockball.impl.service - -import com.github.shynixn.blockball.contract.RightclickManageService -import com.github.shynixn.blockball.impl.extension.setSignLines -import com.github.shynixn.mcutils.common.ChatColor -import com.google.inject.Inject -import org.bukkit.Location -import org.bukkit.entity.Player - -class RightclickManageServiceImpl @Inject constructor() : - RightclickManageService { - private val rightClickListener = HashMap Unit>() - - /** - * Gets called one time when a location gets rightlicked by [player]. - */ - override fun watchForNextRightClickSign(player: Player, f: (Location) -> Unit) { - rightClickListener[player] = f - } - - /** - * Executes the watcher for the given [player] if he has registered one. - * Returns if watchers has been executed. - */ - override fun executeWatchers(player: Player, location: Location): Boolean { - if (!rightClickListener.containsKey(player)) { - return false - } - - if (location.setSignLines( - listOf( - ChatColor.BOLD.toString() + "BlockBall", - ChatColor.GREEN.toString() + "Loading..." - ) - ) - ) { - rightClickListener[player]!!.invoke(location) - rightClickListener.remove(player) - } - - return true - } - - /** - * Clears all resources this [player] has allocated from this service. - */ - override fun cleanResources(player: Player) { - if (rightClickListener.containsKey(player)) { - rightClickListener.remove(player) - } - } -} diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/ScoreboardServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/ScoreboardServiceImpl.kt index c0c6f2c92..a1dd850ce 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/ScoreboardServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/ScoreboardServiceImpl.kt @@ -8,33 +8,6 @@ import org.bukkit.ChatColor import org.bukkit.scoreboard.DisplaySlot import org.bukkit.scoreboard.Scoreboard -/** - * Created by Shynixn 2018. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ class ScoreboardServiceImpl @Inject constructor() : ScoreboardService { companion object { private const val defaultObjective: String = "def_obj" diff --git a/src/main/java/com/github/shynixn/blockball/impl/service/BallEntityServiceImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/service/SoccerBallFactoryImpl.kt similarity index 78% rename from src/main/java/com/github/shynixn/blockball/impl/service/BallEntityServiceImpl.kt rename to src/main/java/com/github/shynixn/blockball/impl/service/SoccerBallFactoryImpl.kt index efa8286cc..bc0d140a3 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/service/BallEntityServiceImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/service/SoccerBallFactoryImpl.kt @@ -1,10 +1,10 @@ package com.github.shynixn.blockball.impl.service -import com.github.shynixn.blockball.contract.Ball -import com.github.shynixn.blockball.contract.BallEntityService +import com.github.shynixn.blockball.contract.SoccerBall +import com.github.shynixn.blockball.contract.SoccerBallFactory import com.github.shynixn.blockball.entity.BallMeta import com.github.shynixn.blockball.event.BallSpawnEvent -import com.github.shynixn.blockball.impl.BallCrossPlatformProxy +import com.github.shynixn.blockball.impl.SoccerBallCrossPlatformProxy import com.github.shynixn.blockball.impl.BallDesignEntity import com.github.shynixn.blockball.impl.BallHitboxEntity import com.github.shynixn.mccoroutine.bukkit.launch @@ -19,15 +19,15 @@ import org.bukkit.Bukkit import org.bukkit.Location import org.bukkit.plugin.Plugin -class BallEntityServiceImpl @Inject constructor( +class SoccerBallFactoryImpl @Inject constructor( private val packetService: PacketService, private val itemService: ItemService, private val rayTracingService: RayTracingService, private val plugin: Plugin -) : BallEntityService { +) : SoccerBallFactory { - private val ballHitBoxTracked = HashMap() - private val ballDesignTracked = HashMap() + private val ballHitBoxTracked = HashMap() + private val ballDesignTracked = HashMap() private var isDisposed = false init { @@ -42,10 +42,9 @@ class BallEntityServiceImpl @Inject constructor( } /** - * Spawns a temporary ball. - * Returns a ball or null if the ball spawn event was cancelled. + * Creates a new SoccerBall. */ - override fun spawnTemporaryBall(location: Location, meta: BallMeta): Ball? { + override fun createSoccerBall(location: Location, meta: BallMeta): SoccerBall { val position = location.toVector3d() position.yaw = 0.0 position.pitch = 0.0 @@ -59,7 +58,7 @@ class BallEntityServiceImpl @Inject constructor( ballDesignEntity.packetService = packetService ballDesignEntity.itemService = itemService - val ball = BallCrossPlatformProxy(meta, ballDesignEntity, ballHitBoxEntity, plugin) + val ball = SoccerBallCrossPlatformProxy(meta, ballDesignEntity, ballHitBoxEntity, plugin) ballDesignEntity.ball = ball ballHitBoxEntity.ball = ball ballHitBoxEntity.plugin = plugin @@ -67,10 +66,6 @@ class BallEntityServiceImpl @Inject constructor( val event = BallSpawnEvent(ball) Bukkit.getPluginManager().callEvent(event) - if (event.isCancelled) { - return null - } - ballHitBoxTracked[ballHitBoxEntity.entityId] = ball ballDesignTracked[ballDesignEntity.entityId] = ball @@ -80,7 +75,7 @@ class BallEntityServiceImpl @Inject constructor( /** * Tries to locate the ball by the given id. */ - override fun findBallByEntityId(id: Int): Ball? { + override fun findBallByEntityId(id: Int): SoccerBall? { if (ballDesignTracked.containsKey(id)) { return ballDesignTracked[id] } @@ -95,7 +90,7 @@ class BallEntityServiceImpl @Inject constructor( /** * Disables a ball from tracking. */ - override fun removeTrackedBall(ball: Ball) { + override fun removeTrackedBall(ball: SoccerBall) { if (ballDesignTracked.containsKey(ball.designEntityId)) { ballDesignTracked.remove(ball.designEntityId) } @@ -108,7 +103,7 @@ class BallEntityServiceImpl @Inject constructor( /** * Returns all balls managed by the plugin. */ - override fun getAllBalls(): List { + override fun getAllBalls(): List { return ballDesignTracked.values.toList() } diff --git a/src/main/resources/arena_sample.yml b/src/main/resources/arena_sample.yml index 8c0eb1ba6..7de8c8c24 100644 --- a/src/main/resources/arena_sample.yml +++ b/src/main/resources/arena_sample.yml @@ -1,7 +1,7 @@ # Unique identifier of a game. name: "1" # Arbitrary name which supports color codes and can be used as placeholder -displayName: "Arena 3" +displayName: "SoccerArena 3" # Is the game enabled or not. enabled: true # Type of game. Accepts HUBGAME, MINIGAME and BUNGEE @@ -414,7 +414,7 @@ meta: effectingType: "RELATED_PLAYER" # Spawn delay of the ball in ticks. delayInTicks: 0 - # Ball spawnpoint. + # SoccerBall spawnpoint. spawnpoint: x: 1625.4287132686636 y: 4.0 diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5e35bed93..2b4e32bc9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -4,14 +4,18 @@ ####################################################################### ############################ -# Notes +# Language settings ############################ -# You can find the permissions at https://shynixn.github.io/BlockBall/build/html/gettingstarted/permissions.html#permissionlist +language: "en_us" ############################ -# Language settings +# Command settings ############################ -language: "en_us" +commands: + blockball: + aliases: + - "soccer" + - "football" ############################ # Debug settings @@ -53,39 +57,10 @@ database: - "prepStmtCacheSize=250" - "prepStmtCacheSqlLimit=2048" -############################ -# Command settings -# Instead of setting the commands inside of the plugin.yml, I believe you should be able to customize -# the whole command by yourself. Name, description, permission customize it to your needs. -# global-join: Settings for the command to join games from any world on your server. -# global-leave: Settings for the command to leave games from any world on your server. -############################ -global-join: - enabled: true - command: bbjoin - useage: / - description: Join a game. - permission: blockball.command.use - permission-message: You don't have permission -global-spectate: - enabled: true - command: bbspectate - useage: / - description: Spectate a game. - permission: blockball.command.use - permission-message: You don't have permission -global-leave: - enabled: true - command: bbleave - useage: / - description: Leaves current game. - permission: blockball.command.use - permission-message: You don't have permission - ############################ # Security settings # Settings to adjust the position of players. -# fallback-spawnpoint: Spawnpoint for players who try to spawn in an blockball field. +# fallback-spawnpoint: Spawnpoint for players who try to spawn in a blockball field. ############################ security: fallback-spawnpoint: diff --git a/src/main/resources/lang/en_us.properties b/src/main/resources/lang/en_us.properties index 42056d83d..f8fa0f7a5 100644 --- a/src/main/resources/lang/en_us.properties +++ b/src/main/resources/lang/en_us.properties @@ -1,53 +1,56 @@ -translator=Shynixn +commandUsage=&0&l[&f&lBlockBall&0&l]&7 Use /blockball help to see more info about the plugin. +commandDescription=All commands for the BlockBall plugin. +gameAlreadyExistsMessage=&0&l[&f&lBlockBall&0&l]&c Game %1$1s already exists. +maxLength20Characters=&0&l[&f&lBlockBall&0&l]&c The text length has to be less than 20 characters. +gameDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c Game %1$1s does not exist. +teamDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c Team %1$1s does not exist. +locationTypeDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c This location type is not known. For more locations, open the arena.yml. +signTypeDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c This sign type is not known. +noPermissionForGameMessage=&0&l[&f&lBlockBall&0&l]&c You do not have permission to join game %1$1s. +noPermissionMessage=&0&l[&f&lBlockBall&0&l]&c You do not have permission. +commandSenderHasToBePlayer=&0&l[&f&lBlockBall&0&l]&c The command sender has to be a player! +gameCreatedMessage=&0&l[&f&lBlockBall&0&l]&7 Created game %1$1s. +deletedGameMessage=&0&l[&f&lBlockBall&0&l]&7 Deleted game %1$1s. +gameIsFullMessage=&0&l[&f&lBlockBall&0&l]&c Game is already full. +joinTeamRedMessage=&0&l[&f&lBlockBall&0&l]&7 Successfully joined team red. +joinTeamBlueMessage=&0&l[&f&lBlockBall&0&l]&7 Successfully joined team blue. +leftGameMessage=&0&l[&f&lBlockBall&0&l]&7 Left the game. +spawnPointSetMessage=&0&l[&f&lBlockBall&0&l]&7 Location %1$1s was set on %2$1s. +enabledArenaMessage=&0&l[&f&lBlockBall&0&l]&7 Game enable state was set to %1$1s. +reloadedAllGamesMessage=&0&l[&f&lBlockBall&0&l]&7 Reloaded all games. +reloadedGameMessage=&0&l[&f&lBlockBall&0&l]&7 Reloaded game %1$1s. +updatedInventoryMessage=&0&l[&f&lBlockBall&0&l]&7 Updated inventory of game. +updatedArmorMessage=&0&l[&f&lBlockBall&0&l]&7 Updated armor of game. +rightClickOnSignMessage=&0&l[&f&lBlockBall&0&l]&7 RightClick on a sign to convert it into a game sign. +addedSignMessage=&0&l[&f&lBlockBall&0&l]&7 A sign was added to the game. +scoreRedTitle=&c&l%1$1s +scoreRedSubTitle=%2$1s scored for &cTeam Red. +scoreRedFadeIn=20 +scoreRedStay=60 +scoreRedFadeOut=20 +scoreBlueTitle=&9&l%1$1s +scoreBlueSubTitle=%2$1s scored for &9Team Blue. +scoreBlueFadeIn=20 +scoreBlueStay=60 +scoreBlueFadeOut=20 +winRedTitle=&cTeam Red +winRedSubTitle=&cTeam Red &ahas won the match +winRedFadeIn=20 +winRedStay=60 +winRedFadeOut=20 +winBlueTitle=&9Team Blue +winBlueSubTitle=&9Team Blue &ahas won the match +winBlueFadeIn=20 +winBlueStay=60 +winBlueFadeOut=20 +winDrawTitle=&fDraw +winDrawSubTitle=&aThe game has ended in a draw +winDrawFadeIn=20 +winDrawStay=60 +winDrawFadeOut=20 gameStatusJoinAble=&aJoin gameStatusDisabled=&4Disabled gameStatusRunning=&1Running -teamBlueDisplayName=Team Blue -teamBlueColor=&9 -teamBlueScoreTitle=&9%blockball_game_blueScore% : &c%blockball_game_redScore% -teamBlueScoreSubTitle=&9%blockball_game_lastHitPlayerName% scored for %blockball_game_blueName% -teamBlueWinTitle=&9Team Blue -teamBlueWinSubTitle=&9Team Blue &ahas won the match -teamBlueDrawTitle=&9Team Blue -teamBlueDrawSubTitle=&eMatch ended in a draw -teamRedDisplayName=Team Red -teamRedColor=&c -teamRedScoreTitle=&c%blockball_game_redScore% : &9%blockball_game_blueScore% -teamRedScoreSubTitle=&c%blockball_game_lastHitPlayerName% scored for %blockball_game_redName% -teamRedWinTitle=&cTeam Red -teamRedWinSubTitle=&cTeam Red &ahas won the match -teamRedDrawTitle=&cTeam Red -teamRedDrawSubTitle=&eMatch ended in a draw -bungeeCordMotdRestarting=&cRestarting... -bungeeCordMotdJoinAble=&aWaiting for players... -bungeeCordMotdRunning=&9Ingame% -bungeeCordKickMessage=Server is already full. -bungeeCordLeaveMessage=You have left the game. -bossBarMessage=&cTeam Red %blockball_game_redScore% : &9%blockball_game_blueScore% Team Blue -hologramMessage=&cTeam Red %blockball_game_redScore% : &9Team Blue %blockball_game_blueScore% hubGameJoinHeader=Click on the team to join the match. hubGameJoinRed=&c[Team Red] hubGameJoinBlue=&9[Team Blue] -joinSignLine1=&lBlockBall -joinSignLine2=%blockball_game_displayName% -joinSignLine3=%blockball_game_stateDisplayName% -joinSignLine4=%blockball_game_players%/%blockball_game_maxPlayers% -leaveSignLine1=&lBlockBall -leaveSignLine2=%blockball_game_displayName% -leaveSignLine3=&fLeave -leaveSignLine4=%blockball_game_players%/%blockball_game_maxPlayers% -teamSignLine1=&lBlockBall -teamSignLine2=%blockball_game_displayName% -teamSignLine3=%blockball_team_color%%blockball_team_name% -teamSignLine4=%blockball_team_players%/%blockball_team_maxPlayers% -miniGameRemainingPlayers=&aWaiting for &c %blockball_game_remainingPlayers% &a more player(s)... -spectateJoinHeader=Game is full! Do you want to spectate? -spectateJoinClick=&a[Start spectating] -joinSuccessMessage=You have joined the game for %blockball_team_color%%blockball_team_name%. -leaveMessage=&0&l[&f&lBlockBall&0&l]&7 You have left the game. -reloadMessage=&0&l[&f&lBlockBall&0&l]&7 &aReloaded BlockBall. -stopGameMessage=Stopped game %1$1s named %2$1s. -rightClickOnSign=Rightclick on a sign. -saveAndReloadSign=Save and reload to enable the sign. -spectateNoPermission=&cYou do not have permission to spectate this game. -joinNoPermission=&cYou do not have permission to join this game. diff --git a/src/main/resources/plugin-legacy.yml b/src/main/resources/plugin-legacy.yml index d2e09a546..323fe4340 100644 --- a/src/main/resources/plugin-legacy.yml +++ b/src/main/resources/plugin-legacy.yml @@ -4,19 +4,3 @@ author: Shynixn website: https://www.spigotmc.org/members/shynixn.63455/ main: com.github.shynixn.blockball.BlockBallPlugin softdepend: [BossBarAPI, PlaceholderAPI, Vault] -commands: - blockball: - description: Opens the arena creation UI. - usage: / - permission: blockball.command.admin - permission-message: You don't have permission. - blockballstop: - description: Stops a running blockball game. - usage: / - permission: blockball.command.admin - permission-message: You don't have permission. - blockballreload: - description: Reloads Blockball configuration and restarts all games. - usage: / - permission: blockball.command.reload - permission-message: You don't have permission. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 717619123..840166d44 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -16,19 +16,3 @@ libraries: - org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23 - org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 - aopalliance:aopalliance:1.0 -commands: - blockball: - description: Opens the arena creation UI. - usage: / - permission: blockball.command.admin - permission-message: You don't have permission. - blockballstop: - description: Stops a running blockball game. - usage: / - permission: blockball.command.admin - permission-message: You don't have permission. - blockballreload: - description: Reloads Blockball configuration and restarts all games. - usage: / - permission: blockball.command.reload - permission-message: You don't have permission.