Skip to content

Commit

Permalink
Merge branch 'FABRIC-1.14.4' into FABRIC-1.15.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	changelog.md
#	gradle.properties
#	src/main/kotlin/com/mairwunnx/randomteleport/commands/BadLocationCommand.kt
#	src/main/kotlin/com/mairwunnx/randomteleport/commands/RandomTeleportCommand.kt
  • Loading branch information
MairwunNx committed Jun 21, 2020
2 parents 3358822 + a9fc5c8 commit dede9ab
Show file tree
Hide file tree
Showing 17 changed files with 169 additions and 369 deletions.
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: mairwunnx # Replace with a single Ko-fi username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: 'https://money.yandex.ru/to/410015993365458' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://money.yandex.ru/to/410015993365458', 'https://paypal.me/mairwunnx'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
32 changes: 0 additions & 32 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

11 changes: 0 additions & 11 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

47 changes: 13 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
plugins {
id 'fabric-loom'
id "org.jetbrains.kotlin.jvm"
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.61'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.71'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

minecraft {
}
minecraft {}

configurations {
embed
Expand All @@ -31,56 +27,39 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
implementation(group: "com.mojang", name: "brigadier", version: brigadier_version)
implementation(
group: "org.jetbrains.kotlinx",
name: "kotlinx-serialization-runtime",
version: kotlinx_serialization_version
)
embed(
group: "org.jetbrains.kotlinx",
name: "kotlinx-serialization-runtime",
version: kotlinx_serialization_version
)
implementation "com.mojang:brigadier:$brigadier_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlinx_serialization_version"
embed "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlinx_serialization_version"
}

processResources {
inputs.property "version", project.version

from configurations.embed.collect {
if (it.name == "kotlinx-serialization-runtime-0.14.0.jar") {
if (it.name == "kotlinx-serialization-runtime-0.20.0.jar") {
it.isDirectory() ? it : zipTree(it)
}
}

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
include "fabric.mod.json"; expand "version": project.version
}
from(sourceSets.main.resources.srcDirs) { exclude "fabric.mod.json" }
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(JavaCompile) { options.encoding = "UTF-8" }

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}

jar {
from "LICENSE"
}
jar { from "LICENSE" }

compileKotlin.kotlinOptions.jvmTarget = "1.8"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

//noinspection GroovyAssignabilityCheck
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += "-Xuse-experimental=kotlin.Experimental"
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
}
}
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.0+FABRIC-MC-1.15.2] - 2020-06-20

### Added
- Initial 2 major release.

## [1.15.2-1.0.0] - 2020-02-08

### Added
Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx3G
# Fabric Properties
# Check these on https://modmuss50.me/fabric.html
minecraft_version=1.15.2
yarn_mappings=1.15.2+build.12
loader_version=0.7.8+build.184
yarn_mappings=1.15.2+build.17
loader_version=0.8.8+build.202
#Fabric api
fabric_version=0.4.29+build.290-1.15
loom_version=0.2.6-SNAPSHOT
fabric_version=0.13.1+build.316-1.15
loom_version=0.4-SNAPSHOT
# Mod Properties
mod_version=1.15.2-1.0.0
mod_version=2.0.0+FABRIC-MC-1.15.2
maven_group=com.mairwunnx
archives_base_name=Random Teleport-Fabric
archives_base_name=Random Teleport
# Kotlin
kotlin_version=1.3.60
fabric_kotlin_version=1.3.60+build.1
kotlinx_serialization_version=0.14.0
kotlin_version=1.3.71
fabric_kotlin_version=1.3.71+build.1
kotlinx_serialization_version=0.20.0
# Minecraft
brigadier_version=1.0.17
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

[![image](https://github.com/MairwunNx/RandomTeleport/raw/master/assets/Telegram.png)](https://t.me/minecraftforge)

[![image](https://github.com/MairwunNx/RandomTeleport/raw/master/assets/Support.png)](https://ko-fi.com/mairwunnx)
[![image](https://github.com/MairwunNx/RandomTeleport/raw/master/assets/Support.png)](https://paypal.me/mairwunnx)
4 changes: 1 addition & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
pluginManagement {
repositories {
jcenter()
gradlePluginPortal()
jcenter().apply { gradlePluginPortal() }
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
}

plugins {
id("fabric-loom") version extra.properties["loom_version"].toString()
kotlin("jvm") version extra.properties["kotlin_version"].toString()
Expand Down
21 changes: 8 additions & 13 deletions src/main/kotlin/com/mairwunnx/randomteleport/EntryPoint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,19 @@ object EntryPoint : ModInitializer {
private val logger = LogManager.getLogger()

init {
logger.info("Random Teleport mod initializing")
ConfigurationManager.load()
logger.info("Random Teleport mod initializing").also { ConfigurationManager.load() }
}

override fun onInitialize() {
override fun onInitialize() =
ServerStartCallback.EVENT.register(ServerStartCallback {
logger.info("Commands registering starting for Random Teleport")
RandomTeleportCommand.register(it.commandManager.dispatcher)
BadLocationCommand.register(it.commandManager.dispatcher)
})
}).also {
ServerStopCallback.EVENT.register(ServerStopCallback { ConfigurationManager.save() })
}

ServerStopCallback.EVENT.register(ServerStopCallback {
ConfigurationManager.save()
})
}

internal fun hasPermission(
player: ServerPlayerEntity,
opLevel: Int
): Boolean = player.server.opPermissionLevel >= opLevel
fun hasPermission(
player: ServerPlayerEntity, opLevel: Int
) = player.server.opPermissionLevel >= opLevel
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mairwunnx.randomteleport.commands

import com.mairwunnx.randomteleport.EntryPoint
import com.mairwunnx.randomteleport.EntryPoint.hasPermission
import com.mairwunnx.randomteleport.configuration.TeleportStrategy.*
import com.mairwunnx.randomteleport.managers.ConfigurationManager
import com.mairwunnx.randomteleport.managers.ConfigurationManager.get
import com.mairwunnx.randomteleport.managers.TeleportRollbackManager
import com.mojang.brigadier.CommandDispatcher
import com.mojang.brigadier.context.CommandContext
Expand All @@ -16,9 +16,7 @@ object BadLocationCommand {
private val logger = LogManager.getLogger()

fun register(dispatcher: CommandDispatcher<ServerCommandSource>) {
dispatcher.register(
CommandManager.literal("bad-location").executes(::execute)
)
dispatcher.register(CommandManager.literal("bad-location").executes(::execute))
}

private fun execute(context: CommandContext<ServerCommandSource>): Int {
Expand All @@ -27,17 +25,13 @@ object BadLocationCommand {
val playerName = context.source.player.name.string

if (isPlayer) {
if (!EntryPoint.hasPermission(player, 1)) {
if (!hasPermission(player, get().opLevelForRollBack)) {
context.source.sendFeedback(
TranslatableText(
"random_teleport.teleport.rollback_restricted"
), false
)
return 0
TranslatableText("random_teleport.teleport.rollback_restricted"), false
).let { return 0 }
}

val position = TeleportRollbackManager.requestPosition(playerName)

if (position == null) {
context.source.sendFeedback(
TranslatableText(
Expand All @@ -46,38 +40,31 @@ object BadLocationCommand {
)
} else {
context.source.sendFeedback(
TranslatableText(
"random_teleport.teleport.teleporting_back"
), false
TranslatableText("random_teleport.teleport.teleporting_back"), false
)

when (ConfigurationManager.get().teleportStrategy) {
USUALLY_TELEPORT, KEEP_LOADED, ATTEMPT_TELEPORT, SET_AND_UPDATE -> {
player.teleport(
position.x + getCenterPosBlock(),
position.y + getCenterPosBlock(),
position.z + getCenterPosBlock()
)
}
SET_POSITION -> {
player.setPos(
position.x + getCenterPosBlock(),
position.y + getCenterPosBlock(),
position.z + getCenterPosBlock()
)
}
}

TeleportRollbackManager.removeEntry(playerName)
when (get().teleportStrategy) {
USUALLY_TELEPORT, KEEP_LOADED, ATTEMPT_TELEPORT -> player.teleport(
position.x + getCenterPosBlock(),
position.y + getCenterPosBlock(),
position.z + getCenterPosBlock()
)
SET_AND_UPDATE -> player.updatePositionAndAngles(
position.x + getCenterPosBlock(),
position.y + getCenterPosBlock(),
position.z + getCenterPosBlock(),
player.yaw, player.pitch
)
SET_POSITION -> player.updatePosition(
position.x + getCenterPosBlock(),
position.y + getCenterPosBlock(),
position.z + getCenterPosBlock()
)
}.also { TeleportRollbackManager.removeEntry(playerName) }
}

return 0
} else {
logger.info("Unable to use this command. Only player can execute this command.")
return 0
}
} else logger.info("Only player can execute this command.").let { return 0 }
}

private fun getCenterPosBlock(): Double =
if (ConfigurationManager.get().teleportOnCenterBlock) 0.5 else 0.0
private fun getCenterPosBlock() = if (get().teleportOnCenterBlock) 0.5 else 0.0
}
Loading

0 comments on commit dede9ab

Please sign in to comment.