-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
138 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...rc/main/kotlin/com/willfp/libreforge/integrations/custombiomes/CustomBiomesIntegration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.willfp.libreforge.integrations.custombiomes | ||
|
||
import com.willfp.libreforge.integrations.LoadableIntegration | ||
import org.bukkit.Location | ||
|
||
interface CustomBiomesIntegration: LoadableIntegration { | ||
/** | ||
* Get a biome at given location. (Supports vanilla biomes as well) | ||
* | ||
* @param location The location to get the biome at. | ||
* @return The found biome, null otherwise | ||
*/ | ||
fun getBiome(location: Location?): NamedBiome? | ||
} |
22 changes: 22 additions & 0 deletions
22
core/src/main/kotlin/com/willfp/libreforge/integrations/custombiomes/CustomBiomesManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.willfp.libreforge.integrations.custombiomes | ||
|
||
import com.willfp.eco.core.integrations.IntegrationRegistry | ||
import com.willfp.libreforge.plugin | ||
import org.bukkit.Location | ||
import org.bukkit.event.Listener | ||
|
||
val customBiomesIntegrations = IntegrationRegistry<CustomBiomesIntegration>() | ||
|
||
val Location.namedBiome: NamedBiome? | ||
get() { | ||
val world = this.world ?: return null | ||
val vanilla = world.getBiome(this) | ||
|
||
return if (vanilla.name.lowercase() == "biome") { | ||
customBiomesIntegrations | ||
.firstOrNull { it.getBiome(this) != null } | ||
?.getBiome(this) | ||
} else { | ||
VanillaNamedBiome(vanilla) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
core/src/main/kotlin/com/willfp/libreforge/integrations/custombiomes/NamedBiome.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.willfp.libreforge.integrations.custombiomes | ||
|
||
import org.bukkit.block.Biome | ||
|
||
interface NamedBiome { | ||
val name: String | ||
} | ||
|
||
class VanillaNamedBiome( | ||
biome: Biome | ||
) : NamedBiome { | ||
override val name = biome.name | ||
} |
38 changes: 38 additions & 0 deletions
38
...src/main/kotlin/com/willfp/libreforge/integrations/custombiomes/impl/CustomBiomesTerra.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.willfp.libreforge.integrations.custombiomes.impl | ||
|
||
import com.dfsek.terra.api.world.biome.Biome | ||
import com.dfsek.terra.bukkit.world.BukkitAdapter | ||
import com.willfp.eco.core.EcoPlugin | ||
import com.willfp.libreforge.integrations.custombiomes.CustomBiomesIntegration | ||
import com.willfp.libreforge.integrations.custombiomes.NamedBiome | ||
import com.willfp.libreforge.integrations.custombiomes.customBiomesIntegrations | ||
import org.bukkit.Location | ||
|
||
object CustomBiomesTerra : CustomBiomesIntegration { | ||
override fun getPluginName(): String { | ||
return "Terra" | ||
} | ||
|
||
override fun getBiome(location: Location?): NamedBiome? { | ||
if (location == null || location.world == null) { | ||
return null | ||
} | ||
|
||
val terraLocation = BukkitAdapter.adapt(location) ?: return null | ||
val terraWorld = BukkitAdapter.adapt(location.world!!) ?: return null | ||
val biomeProvider = terraWorld.biomeProvider ?: return null | ||
val biome = biomeProvider.getBiome(terraLocation, terraWorld.seed) ?: return null | ||
|
||
return TerraNamedBiome(biome) | ||
} | ||
|
||
override fun load(plugin: EcoPlugin) { | ||
customBiomesIntegrations.register(this) | ||
} | ||
|
||
private class TerraNamedBiome( | ||
biome: Biome | ||
) : NamedBiome { | ||
override val name: String = biome.id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToDrop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.willfp.libreforge.mutators.impl | ||
|
||
import com.willfp.eco.core.config.interfaces.Config | ||
import com.willfp.libreforge.NoCompileData | ||
import com.willfp.libreforge.mutators.Mutator | ||
import com.willfp.libreforge.mutators.parameterTransformers | ||
import com.willfp.libreforge.triggers.TriggerData | ||
import com.willfp.libreforge.triggers.TriggerParameter | ||
import com.willfp.libreforge.triggers.event.EditableDropEvent | ||
|
||
object MutatorLocationToDrop : Mutator<NoCompileData>("location_to_drop") { | ||
override val parameterTransformers = parameterTransformers { | ||
TriggerParameter.EVENT becomes TriggerParameter.LOCATION | ||
} | ||
|
||
override fun mutate(data: TriggerData, config: Config, compileData: NoCompileData): TriggerData { | ||
val event = data.event as? EditableDropEvent ?: return data | ||
|
||
return data.copy( | ||
location = event.dropLocation | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ softdepend: | |
- WorldGuard | ||
- Citizens | ||
- TAB | ||
- Terra | ||
|
||
commands: | ||
lrcdb: | ||
|