Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Ref #34 - Add setting to disable the nagging message about on-the-fly…
Browse files Browse the repository at this point in the history
… groups

Some users don't want any worlds to ever share anything, so it makes sense that they shouldn't have to configure every single world.

Signed-off-by: Evan Maddock <maddock.evan@vivaldi.net>
  • Loading branch information
EbonJaeger committed May 19, 2018
1 parent c4fcde7 commit 42f7e9d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/main/kotlin/me/ebonjaeger/perworldinventory/GroupManager.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.ebonjaeger.perworldinventory

import me.ebonjaeger.perworldinventory.configuration.PluginSettings
import me.ebonjaeger.perworldinventory.configuration.Settings
import me.ebonjaeger.perworldinventory.initialization.PluginFolder
import me.ebonjaeger.perworldinventory.service.BukkitService
import org.bukkit.GameMode
Expand All @@ -9,7 +11,8 @@ import java.io.IOException
import javax.inject.Inject

class GroupManager @Inject constructor(@PluginFolder pluginFolder: File,
private val bukkitService: BukkitService)
private val bukkitService: BukkitService,
private val settings: Settings)
{

private val WORLDS_CONFIG_FILE = File(pluginFolder, "worlds.yml")
Expand Down Expand Up @@ -61,8 +64,11 @@ class GroupManager @Inject constructor(@PluginFolder pluginFolder: File,
group = Group(world, worlds, GameMode.SURVIVAL)

addGroup(world, worlds, GameMode.SURVIVAL, false)
ConsoleLogger.warning("Creating a new group on the fly for '$world'." +
" Please double check your `worlds.yml` file configuration!")
if (!settings.getProperty(PluginSettings.DISABLE_NAG))
{
ConsoleLogger.warning("Creating a new group on the fly for '$world'." +
" Please double check your `worlds.yml` file configuration!")
}

return group
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ object PluginSettings : SettingsHolder
@JvmField
@Comment("Set the maximum number of player profiles that can be cached at any given time")
val CACHE_MAX_LIMIT = newProperty("cache-maximum-limit", 1000)

@JvmField
@Comment("Disables the nagging message when a world is created on the fly",
"Intended for users who know what their doing, and don't need to have worlds configured")
val DISABLE_NAG = newProperty("disable-nag-message", false)
}
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ separate-gamemode-inventories: true
# If true, any worlds that are not in the worlds.yml configuration file will share the same inventory
share-if-unconfigured: false

# Disables the nagging message when a world is created on the fly
# Intended for users who know what their doing, and don't need to have worlds configured
disable-nag-message: false

metrics:
# Choose whether or not to enable metrics sending.
# See https://bstats.org/getting-started for details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package me.ebonjaeger.perworldinventory
import com.natpryce.hamkrest.absent
import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import io.mockk.classMockk
import io.mockk.every
import me.ebonjaeger.perworldinventory.TestHelper.mockGroup
import me.ebonjaeger.perworldinventory.configuration.PluginSettings
import me.ebonjaeger.perworldinventory.configuration.Settings
import me.ebonjaeger.perworldinventory.service.BukkitService
import org.bukkit.GameMode
import org.junit.Assert.assertNotNull
Expand All @@ -23,7 +27,9 @@ class GroupManagerTest {

private val bukkitService = Mockito.mock(BukkitService::class.java)

private val groupManager = GroupManager(File(""), bukkitService)
private val settings = classMockk(Settings::class)

private val groupManager = GroupManager(File(""), bukkitService, settings)

@Test
fun shouldReturnAbsentValueForNonExistentGroup() {
Expand Down Expand Up @@ -110,6 +116,7 @@ class GroupManagerTest {
fun getGroupFromWorldWhereNotExists()
{
// given
every { settings.getProperty(PluginSettings.DISABLE_NAG) } returns false
groupManager.groups.clear()
val name = "test"
val worlds = mutableSetOf(name, "${name}_nether", "${name}_the_end")
Expand All @@ -129,6 +136,7 @@ class GroupManagerTest {
fun getGroupAfterCreatedFromGroupFromWorldMethod()
{
// given
every { settings.getProperty(PluginSettings.DISABLE_NAG) } returns false
groupManager.groups.clear()
val name = "test"
val expected = groupManager.getGroupFromWorld(name)
Expand Down

0 comments on commit 42f7e9d

Please sign in to comment.