Skip to content

Commit

Permalink
Merge pull request #45 from Shynixn/development
Browse files Browse the repository at this point in the history
Merge changes to master --release
  • Loading branch information
Shynixn authored Aug 24, 2024
2 parents 583f9c0 + 2df1df7 commit 8a76def
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 190 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.github.shynixn"
version = "1.7.0"
version = "1.8.0"

repositories {
mavenCentral()
Expand Down Expand Up @@ -38,10 +38,10 @@ dependencies {
implementation("com.google.code.gson:gson:2.8.6")

// Custom dependencies
implementation("com.github.shynixn.mcutils:common:2024.21")
implementation("com.github.shynixn.mcutils:guice:2024.2")
implementation("com.github.shynixn.mcutils:common:2024.23")
implementation("com.github.shynixn.mcutils:packet:2024.33")
implementation("com.github.shynixn.mcutils:sign:2024.3")
implementation("com.github.shynixn.mcutils:guice:2024.2")

// Test
testImplementation(kotlin("test"))
Expand Down
13 changes: 13 additions & 0 deletions docs/wiki/docs/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,16 @@ Execute the reload command to load your file changes.
```
/mctennis reload game1
```

### Changing the speed of the ball

Players can change the speed of the ball by pressing SHIFT. The amount of green power bars define how fast the ball flies.

However, the base speed of the ball may not fit the size of your arena. You should edit the following properties in your ``plugins/MCTennis/arena/<name>.yml`` file.

* horizontalBaseMultiplier
* verticalSpeedAbsolute
* gravityAbsolute

Try very minor adjustments (comma values), execute the reload command and rejoin your arena. Repeat until it works for you.

2 changes: 1 addition & 1 deletion docs/wiki/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ nav:
- 'MCTennis Wiki':
- Introduction: README.md
- Permission: permission.md
- Commands: commands.md
- Creating the game: game.md
- Interactions: interaction.md
- Commands: commands.md
- PlaceHolders: placeholders.md
- Developer Api: api.md
theme:
Expand Down
9 changes: 7 additions & 2 deletions src/main/kotlin/com/github/shynixn/mctennis/MCTennisPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.github.shynixn.mctennis.contract.TennisBallFactory
import com.github.shynixn.mctennis.entity.TennisArena
import com.github.shynixn.mctennis.enumeration.PluginDependency
import com.github.shynixn.mctennis.impl.commandexecutor.MCTennisCommandExecutor
import com.github.shynixn.mctennis.impl.exception.TennisGameException
import com.github.shynixn.mctennis.impl.listener.GameListener
import com.github.shynixn.mctennis.impl.listener.PacketListener
import com.github.shynixn.mctennis.impl.listener.TennisListener
Expand Down Expand Up @@ -116,12 +117,16 @@ class MCTennisPlugin : JavaPlugin() {
// Load Language
val configurationService = module.getService<ConfigurationService>()
val language = configurationService.findValue<String>("language")
reloadTranslation(language, MCTennisLanguage::class.java, "en_us")
reloadTranslation(language, MCTennisLanguage::class.java, "en_us", "es_es")
logger.log(Level.INFO, "Loaded language file $language.properties.")

// Load Games
val gameService = module.getService<GameService>()
gameService.reloadAll()
try {
gameService.reloadAll()
} catch (e: TennisGameException) {
plugin.logger.log(Level.WARNING, "Cannot start game of tennisArena ${e.arena.name}.", e)
}

// Load Signs
val placeHolderService = module.getService<PlaceHolderService>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TennisBallImpl(
private val bounceComponent: BounceComponent,
private val playerComponent: PlayerComponent,
private val entityComponent: ArmorstandEntityComponent?, // Armorstand is optional.
private val spinComponent: SpinComponent,
private val slimeEntityComponent: SlimeEntityComponent,
private val settings: TennisBallSettings,
private val plugin: Plugin,
Expand Down Expand Up @@ -103,7 +102,6 @@ class TennisBallImpl(
kickVector.y += settings.verticalSpeedAbsolute
setVelocity(kickVector.toVector())
delay(250)
spinComponent.setSpin(prevDirection, player.eyeLocation.direction.toVector3d())
}
}

Expand Down Expand Up @@ -135,7 +133,6 @@ class TennisBallImpl(
playerComponent.tickMinecraft()
entityComponent?.tickMinecraft()
slimeEntityComponent.tickMinecraft()
spinComponent.tickMinecraft()
}

/**
Expand All @@ -147,7 +144,6 @@ class TennisBallImpl(
playerComponent.tickPhysic()
entityComponent?.tickPhysic()
slimeEntityComponent.tickPhysic()
spinComponent.tickPhysic()
}

/**
Expand All @@ -159,7 +155,6 @@ class TennisBallImpl(
playerComponent.close()
entityComponent?.close()
slimeEntityComponent.close()
spinComponent.close()
isDead = true
game = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.github.shynixn.mctennis.enumeration.JoinResult
import com.github.shynixn.mctennis.enumeration.LocationType
import com.github.shynixn.mctennis.enumeration.Permission
import com.github.shynixn.mctennis.enumeration.Team
import com.github.shynixn.mctennis.impl.exception.TennisArenaException
import com.github.shynixn.mctennis.impl.exception.TennisGameException
import com.github.shynixn.mcutils.common.*
import com.github.shynixn.mcutils.common.chat.ChatMessageService
import com.github.shynixn.mcutils.common.command.CommandBuilder
Expand Down Expand Up @@ -277,7 +277,7 @@ class MCTennisCommandExecutor @Inject constructor(
arena.isEnabled = !arena.isEnabled
gameService.reload(arena)
sender.sendMessage(MCTennisLanguage.enabledArenaMessage.format(arena.isEnabled.toString()))
} catch (e: TennisArenaException) {
} catch (e: TennisGameException) {
arena.isEnabled = !arena.isEnabled
sender.sendMessage(fallBackPrefix + ChatColor.RED.toString() + "Failed to reload arena ${e.arena.name}.")
sender.sendMessage(fallBackPrefix + e.message)
Expand Down Expand Up @@ -314,18 +314,47 @@ class MCTennisCommandExecutor @Inject constructor(
private suspend fun listArena(sender: CommandSender) {
val existingArenas = arenaRepository.getAll()

sender.sendMessage("---------MCTennis---------")
val headerBuilder = StringBuilder()
headerBuilder.append(org.bukkit.ChatColor.GRAY)
headerBuilder.append(org.bukkit.ChatColor.STRIKETHROUGH)
for (i in 0 until (30 - plugin.name.length) / 2) {
headerBuilder.append(" ")
}
headerBuilder.append(org.bukkit.ChatColor.RESET)
headerBuilder.append(org.bukkit.ChatColor.WHITE)
headerBuilder.append(org.bukkit.ChatColor.BOLD)
headerBuilder.append(plugin.name)
headerBuilder.append(org.bukkit.ChatColor.RESET)
headerBuilder.append(org.bukkit.ChatColor.GRAY)
headerBuilder.append(org.bukkit.ChatColor.STRIKETHROUGH)
for (i in 0 until (30 - plugin.name.length) / 2) {
headerBuilder.append(" ")
}
sender.sendMessage(headerBuilder.toString())
for (arena in existingArenas) {
if (arena.isEnabled) {
sender.sendMessage(ChatColor.GRAY.toString() + arena.name + " [${arena.displayName.translateChatColors()}" + ChatColor.GRAY + "] " + ChatColor.GREEN + "[enabled]")
sender.sendMessage(ChatColor.YELLOW.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(ChatColor.YELLOW.toString() + arena.name + " [${arena.displayName.translateChatColors()}" + ChatColor.GRAY + "] " + ChatColor.RED + "[disabled]")

}

sender.sendMessage()
}
sender.sendMessage("----------┌1/1┐----------")

val footerBuilder = java.lang.StringBuilder()
footerBuilder.append(org.bukkit.ChatColor.GRAY)
footerBuilder.append(org.bukkit.ChatColor.STRIKETHROUGH)
footerBuilder.append(" ")
footerBuilder.append(org.bukkit.ChatColor.RESET)
footerBuilder.append(org.bukkit.ChatColor.WHITE)
footerBuilder.append(org.bukkit.ChatColor.BOLD)
footerBuilder.append("1/1")
footerBuilder.append(org.bukkit.ChatColor.RESET)
footerBuilder.append(org.bukkit.ChatColor.GRAY)
footerBuilder.append(org.bukkit.ChatColor.STRIKETHROUGH)
footerBuilder.append(" ")
sender.sendMessage(footerBuilder.toString())
}

private fun joinGame(player: Player, name: String, team: Team? = null) {
Expand Down Expand Up @@ -491,7 +520,7 @@ class MCTennisCommandExecutor @Inject constructor(
private suspend fun reloadArena(sender: CommandSender, arena: TennisArena?) {
try {
arenaRepository.clearCache()
} catch (e: TennisArenaException) {
} catch (e: TennisGameException) {
sender.sendMessage(fallBackPrefix + ChatColor.RED.toString() + "Failed to reload arenas.")
sender.sendMessage(fallBackPrefix + e.message)
return
Expand All @@ -500,13 +529,13 @@ class MCTennisCommandExecutor @Inject constructor(
if (arena == null) {
plugin.reloadConfig()
val language = configurationService.findValue<String>("language")
plugin.reloadTranslation(language, MCTennisLanguage::class.java, "en_us")
plugin.reloadTranslation(language, MCTennisLanguage::class.java, "en_us", "es_es")
plugin.logger.log(Level.INFO, "Loaded language file $language.properties.")

try {
arenaRepository.clearCache()
gameService.reloadAll()
} catch (e: TennisArenaException) {
} catch (e: TennisGameException) {
sender.sendMessage(fallBackPrefix + ChatColor.RED.toString() + "Failed to reload arena ${e.arena.name}.")
sender.sendMessage(fallBackPrefix + e.message)
return
Expand All @@ -519,7 +548,7 @@ class MCTennisCommandExecutor @Inject constructor(
try {
arenaRepository.clearCache()
gameService.reload(arena)
} catch (e: TennisArenaException) {
} catch (e: TennisGameException) {
sender.sendMessage(fallBackPrefix + ChatColor.RED.toString() + "Failed to reload arena ${e.arena.name}.")
sender.sendMessage(fallBackPrefix + e.message)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.github.shynixn.mctennis.impl.exception

import com.github.shynixn.mctennis.entity.TennisArena

class TennisArenaException(val arena: TennisArena, message: String) : RuntimeException(message) {
class TennisGameException(val arena: TennisArena, message: String) : RuntimeException(message) {

}

This file was deleted.

Loading

0 comments on commit 8a76def

Please sign in to comment.