Skip to content

Commit c4095d7

Browse files
committed
Changes synced with 1.14.4 branch.
Signed-off-by: Pavel Erokhin (MairwunNx) <[email protected]>
1 parent d8659ff commit c4095d7

File tree

11 files changed

+196
-80
lines changed

11 files changed

+196
-80
lines changed

build.gradle

+48-20
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ buildscript {
2222
}
2323
}
2424

25+
plugins {
26+
id "maven"
27+
}
28+
2529
apply(plugin: "net.minecraftforge.gradle")
2630
apply(plugin: "kotlin")
2731
apply(plugin: "kotlinx-serialization")
2832

33+
String packagesToken = new String(package_public_token.decodeBase64())
34+
2935
version = module_version
3036
group = "com.mairwunnx.$module_id"
3137
archivesBaseName = module_name
@@ -68,39 +74,61 @@ minecraft {
6874
repositories {
6975
jcenter()
7076
mavenCentral()
71-
maven { url("https://minecraft.curseforge.com/api/maven/") }
7277
maven { url("https://libraries.minecraft.net") }
73-
maven { url("https://jitpack.io") }
78+
maven { url "https://jitpack.io" }
79+
maven {
80+
name = "GitHubPackages"
81+
url = uri "https://maven.pkg.github.com/projectessentials/projectessentials-core"
82+
credentials {
83+
username = "[email protected]"
84+
password = packagesToken
85+
}
86+
}
87+
maven {
88+
name = "GitHubPackages"
89+
url = uri "https://maven.pkg.github.com/projectessentials/projectessentials-permissions"
90+
credentials {
91+
username = "[email protected]"
92+
password = packagesToken
93+
}
94+
}
95+
maven {
96+
name = "GitHubPackages"
97+
url = uri "https://maven.pkg.github.com/ProjectEssentials/ProjectEssentials-Cooldown"
98+
credentials {
99+
username = "[email protected]"
100+
password = packagesToken
101+
}
102+
}
103+
maven {
104+
name = "GitHubPackages"
105+
url = uri "https://maven.pkg.github.com/ProjectEssentials/ProjectEssentials-Home"
106+
credentials {
107+
username = "[email protected]"
108+
password = packagesToken
109+
}
110+
}
74111
}
75112

76113
dependencies {
77114
minecraft(group: "net.minecraftforge", name: "forge", version: forge_version)
78-
compile(group: "com.mojang", name: "brigadier", version: brigadier_version)
79-
compile(
115+
116+
implementation 'com.mairwunnx.project_essentials_core:ProjectEssentials-Core:1.15.2-1.1.0'
117+
implementation 'com.mairwunnx.project_essentials_permissions:ProjectEssentials-Permissions:1.15.2-1.0.1'
118+
implementation 'com.mairwunnx.project_essentials_cooldown:ProjectEssentials-Cooldown:1.15.2-1.0.1'
119+
implementation 'com.mairwunnx.project_essentials_home:ProjectEssentials-Home:1.15.2-1.1.0'
120+
121+
implementation(group: "com.mojang", name: "brigadier", version: brigadier_version)
122+
implementation(
80123
group: "org.jetbrains.kotlinx",
81124
name: "kotlinx-serialization-runtime",
82125
version: kotlinx_serialization_version
83126
)
84-
compile(
127+
implementation(
85128
group: "org.jetbrains.kotlin",
86129
name: "kotlin-stdlib-$kotlin_jdk_version_target",
87130
version: kotlin_version
88131
)
89-
compile(
90-
group: "com.github.projectessentials",
91-
name: "ProjectEssentials-Permissions",
92-
version: ess_perm_version
93-
)
94-
compile(
95-
group: "com.github.projectessentials",
96-
name: "ProjectEssentials-Core",
97-
version: ess_core_version
98-
)
99-
compile(
100-
group: "com.github.projectessentials",
101-
name: "ProjectEssentials-Cooldown",
102-
version: ess_cooldown_version
103-
)
104132
}
105133

106134
jar {

changelog.md

+23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.15.2-1.1.0] - 2020-03-18
10+
11+
## Added
12+
- Project Essentials dependencies added to `build.gradle`.
13+
- Respawning at first home \ bed point \ world spawn added.
14+
- Back command compatibility added for respawning.
15+
- Back command compatibility added for spawn command.
16+
- `Messaging.kt` with `sendMessage` method added.
17+
- Compatibility with new localization API.
18+
19+
### Changed
20+
- Kotlin version updated to `1.3.70`.
21+
- KotlinX Serialization updated to `0.20.0`.
22+
- Forge API version updated to `28.2.0`.
23+
- `SetSpawnCommand.kt`: `sendMsg` replaced with `sendMessage`.
24+
- `SetSpawnCommand.kt`: deprecated api replaced on new.
25+
- `SpawnCommand.kt`: `sendMsg` replaced with `sendMessage`.
26+
- `SpawnCommand.kt`: deprecated api replaced on new.
27+
28+
### Removed
29+
- Essentials dependencies removed from `gradle.properties`.
30+
- `curseforge` maven repository removed from repositories in `build.gradle`.
31+
932
## [1.15.2-1.0.0] - 2020-02-08
1033

1134
### Added

gradle.properties

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ forge_mappings_channel_version=20190719-1.14.3
1111
brigadier_version=1.0.17
1212
kotlin_jdk_version_target=jdk8
1313
project_jvm_version_target=1.8
14-
kotlin_version=1.3.61
15-
kotlinx_serialization_version=0.14.0
16-
ess_core_version=v1.15.2-1.+
17-
ess_perm_version=v1.15.2-1.+
18-
ess_cooldown_version=v1.15.2-1.+
19-
module_version=1.15.2-1.0.0
14+
kotlin_version=1.3.70
15+
kotlinx_serialization_version=0.20.0
16+
module_version=1.15.2-1.1.0
2017
module_name=Project Essentials Spawn
2118
module_id=project_essentials_spawn
2219
module_vendor=MairwunNx (Pavel Erokhin)
20+
package_public_token=ZDhjMjgyNjlhM2E0ZTQ0MmM2Mjk5ZWI4YmMyZjI0YzNjOTNkMDVkZA==

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Explore
66

7-
#### [Download mod](https://github.com/ProjectEssentials/ProjectEssentials-Spawn/releases/download/v1.15.2-1.0.0/Project.Essentials.Spawn-1.15.2-1.0.0.jar) · [How to install](https://mairwunnx.gitbook.io/project-essentials/project-essentials-spawn#how-to-install) · [Commands](https://mairwunnx.gitbook.io/project-essentials/project-essentials-spawn#commands-and-permissions) · [Configuration](https://mairwunnx.gitbook.io/project-essentials/project-essentials-spawn#configuration) · [Troubleshooting](https://github.com/ProjectEssentials/ProjectEssentials-Spawn/issues/new/choose) · [CurseForge](https://www.curseforge.com/minecraft/mc-mods/ProjectEssentials-Spawn) · [Change log](changelog.md)
7+
#### [Download mod](https://github.com/ProjectEssentials/ProjectEssentials-Spawn/releases/download/v1.15.2-1.1.0/Project.Essentials.Spawn-1.15.2-1.1.0.jar) · [How to install](https://mairwunnx.gitbook.io/project-essentials/project-essentials-spawn#how-to-install) · [Commands](https://mairwunnx.gitbook.io/project-essentials/project-essentials-spawn#commands-and-permissions) · [Configuration](https://mairwunnx.gitbook.io/project-essentials/project-essentials-spawn#configuration) · [Troubleshooting](https://github.com/ProjectEssentials/ProjectEssentials-Spawn/issues/new/choose) · [CurseForge](https://www.curseforge.com/minecraft/mc-mods/ProjectEssentials-Spawn) · [Change log](changelog.md)
88

99
### Compatibility
1010

src/main/kotlin/com/mairwunnx/projectessentials/spawn/EntryPoint.kt

+64-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.mairwunnx.projectessentials.spawn
22

33
import com.mairwunnx.projectessentials.core.EssBase
4+
import com.mairwunnx.projectessentials.core.backlocation.BackLocationProvider
5+
import com.mairwunnx.projectessentials.core.configuration.localization.LocalizationConfigurationUtils
6+
import com.mairwunnx.projectessentials.core.localization.processLocalizations
7+
import com.mairwunnx.projectessentials.home.HomeAPI
48
import com.mairwunnx.projectessentials.permissions.permissions.PermissionsAPI
59
import com.mairwunnx.projectessentials.spawn.commands.SetSpawnCommand
610
import com.mairwunnx.projectessentials.spawn.commands.SpawnCommand
@@ -25,23 +29,37 @@ class EntryPoint : EssBase() {
2529

2630
init {
2731
modInstance = this
28-
modVersion = "1.15.2-1.0.0"
32+
modVersion = "1.15.2-1.1.0"
2933
logBaseInfo()
3034
validateForgeVersion()
3135
MinecraftForge.EVENT_BUS.register(this)
3236
SpawnModelBase.loadData()
37+
loadLocalization()
38+
}
39+
40+
private fun loadLocalization() {
41+
if (LocalizationConfigurationUtils.getConfig().enabled) {
42+
processLocalizations(
43+
EntryPoint::class.java, listOf(
44+
"/assets/projectessentialsspawn/lang/de_de.json",
45+
"/assets/projectessentialsspawn/lang/ru_ru.json",
46+
"/assets/projectessentialsspawn/lang/en_us.json"
47+
)
48+
)
49+
}
3350
}
3451

3552
@SubscribeEvent(priority = EventPriority.HIGH)
3653
fun onServerStarting(event: FMLServerStartingEvent) {
37-
registerCommands(event.server.commandManager.dispatcher)
54+
registerCommands(event.commandDispatcher)
3855
processFirstSession(event)
3956
SpawnModelBase.assignSpawn(event.server)
4057
}
4158

4259
private fun processFirstSession(event: FMLServerStartingEvent) {
4360
logger.info("Processing first session for loaded world")
4461
var equals = true
62+
// todo: previous todo apply for this
4563
val world = event.server.getWorld(DimensionType.OVERWORLD)
4664

4765
if (SpawnModelBase.spawnModel.xPos.toInt() != world.spawnPoint.x) {
@@ -77,12 +95,53 @@ class EntryPoint : EssBase() {
7795

7896
@SubscribeEvent(priority = EventPriority.HIGHEST)
7997
fun onPlayerRespawn(event: PlayerEvent.PlayerRespawnEvent) {
80-
if (!event.player.bedPosition.isPresent) {
81-
SpawnCommand.moveToSpawn(event.player as ServerPlayerEntity)
98+
val player = event.player as ServerPlayerEntity
99+
BackLocationProvider.commit(player)
100+
101+
fun teleportToSpawnOrBed() {
102+
if (player.bedPosition.isPresent) {
103+
val bedPos = player.bedPosition.get()
104+
val targetWorld = player.server.getWorld(DimensionType.OVERWORLD)
105+
player.teleport(
106+
targetWorld,
107+
bedPos.x.toDouble() + 0.5,
108+
bedPos.y.toDouble() + 0.5,
109+
bedPos.z.toDouble() + 0.5,
110+
player.rotationYaw, player.rotationPitch
111+
)
112+
} else {
113+
SpawnCommand.moveToSpawn(player)
114+
}
82115
}
116+
117+
if (homeInstalled) {
118+
val homes = HomeAPI.takeAll(player)
119+
120+
if (homes.isNotEmpty()) {
121+
val home =
122+
homes.first() // todo configure it with core module (new api with common project settings)
123+
val targetWorld = player.server.getWorld(
124+
DimensionType.getById(home.worldId) ?: DimensionType.OVERWORLD
125+
)
126+
player.teleport(
127+
targetWorld,
128+
home.xPos.toDouble() + 0.5,
129+
home.yPos.toDouble() + 0.5,
130+
home.zPos.toDouble() + 0.5,
131+
home.yaw, home.pitch
132+
)
133+
} else teleportToSpawnOrBed()
134+
} else teleportToSpawnOrBed()
83135
}
84136

85137
private fun loadAdditionalModules() {
138+
try {
139+
Class.forName("com.mairwunnx.projectessentials.home.HomeAPI")
140+
homeInstalled = true
141+
} catch (_: ClassNotFoundException) {
142+
// ignored
143+
}
144+
86145
try {
87146
Class.forName(cooldownAPIClassPath)
88147
cooldownsInstalled = true
@@ -102,6 +161,7 @@ class EntryPoint : EssBase() {
102161
lateinit var modInstance: EntryPoint
103162
var cooldownsInstalled: Boolean = false
104163
var permissionsInstalled: Boolean = false
164+
var homeInstalled: Boolean = false
105165

106166
fun hasPermission(player: ServerPlayerEntity, node: String, opLevel: Int = 4): Boolean =
107167
if (permissionsInstalled) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.mairwunnx.projectessentials.spawn
2+
3+
import com.mairwunnx.projectessentials.core.configuration.localization.LocalizationConfigurationUtils
4+
import com.mairwunnx.projectessentials.core.extensions.sendMsg
5+
import com.mairwunnx.projectessentials.core.localization.sendMsgV2
6+
import net.minecraft.command.CommandSource
7+
8+
internal fun sendMessage(
9+
source: CommandSource,
10+
message: String,
11+
vararg args: String
12+
) {
13+
if (LocalizationConfigurationUtils.getConfig().enabled) {
14+
sendMsgV2(
15+
source.asPlayer(),
16+
"project_essentials_spawn.spawn.$message", *args
17+
)
18+
} else {
19+
sendMsg(
20+
"spawn", source, "spawn.$message", *args
21+
)
22+
}
23+
}

src/main/kotlin/com/mairwunnx/projectessentials/spawn/commands/SetSpawnCommand.kt

+8-12
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package com.mairwunnx.projectessentials.spawn.commands
22

33
import com.mairwunnx.projectessentials.cooldown.essentials.CommandsAliases
44
import com.mairwunnx.projectessentials.core.extensions.isPlayerSender
5-
import com.mairwunnx.projectessentials.core.extensions.sendMsg
6-
import com.mairwunnx.projectessentials.core.helpers.ONLY_PLAYER_CAN
7-
import com.mairwunnx.projectessentials.core.helpers.PERMISSION_LEVEL
5+
import com.mairwunnx.projectessentials.core.helpers.throwOnlyPlayerCan
6+
import com.mairwunnx.projectessentials.core.helpers.throwPermissionLevel
87
import com.mairwunnx.projectessentials.spawn.EntryPoint
98
import com.mairwunnx.projectessentials.spawn.EntryPoint.Companion.hasPermission
109
import com.mairwunnx.projectessentials.spawn.models.SpawnModelBase
10+
import com.mairwunnx.projectessentials.spawn.sendMessage
1111
import com.mojang.brigadier.CommandDispatcher
1212
import com.mojang.brigadier.builder.LiteralArgumentBuilder.literal
1313
import com.mojang.brigadier.context.CommandContext
@@ -47,10 +47,10 @@ object SetSpawnCommand {
4747
SpawnModelBase.spawnModel.yaw = player.rotationYaw
4848
SpawnModelBase.spawnModel.pitch = player.rotationPitch
4949
SpawnModelBase.spawnModel.worldId = player.serverWorld.worldType.id
50-
player.world.spawnPoint = BlockPos(
50+
player.serverWorld.spawnPoint = BlockPos(
5151
player.positionVector.x, player.positionVector.y, player.positionVector.z
5252
)
53-
sendMsg("spawn", c.source, "spawn.set.success")
53+
sendMessage(c.source, "set.success")
5454
logger.info("New spawn point installed by ${player.name.string} with data: ")
5555
logger.info(" - xpos: ${player.positionVector.x}")
5656
logger.info(" - ypos: ${player.positionVector.y}")
@@ -59,15 +59,11 @@ object SetSpawnCommand {
5959
logger.info(" - pitch: ${player.rotationPitch}")
6060
logger.info("Executed command \"${c.input}\" from ${player.name.string}")
6161
} else {
62-
sendMsg("spawn", c.source, "spawn.set.restricted")
63-
logger.info(
64-
PERMISSION_LEVEL
65-
.replace("%0", player.name.string)
66-
.replace("%1", "setspawn")
67-
)
62+
sendMessage(c.source, "set.restricted")
63+
throwPermissionLevel(player.name.string, "setspawn")
6864
}
6965
} else {
70-
logger.info(ONLY_PLAYER_CAN.replace("%0", "setspawn"))
66+
throwOnlyPlayerCan("setspawn")
7167
}
7268
return 0
7369
}

0 commit comments

Comments
 (0)