revert dropping 1.7.10, adding 1.9.4 instead of 1.10/1.11
This commit is contained in:
parent
7818afc920
commit
79c9ac1572
|
@ -102,5 +102,3 @@ run/
|
||||||
|
|
||||||
\.floo
|
\.floo
|
||||||
\.flooignore
|
\.flooignore
|
||||||
|
|
||||||
test\.sh
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
mc_version = 1.10.2
|
|
||||||
mcp_mappings = stable_29
|
|
||||||
forge_version = 12.18.3.2185
|
|
|
@ -1,108 +0,0 @@
|
||||||
package matterlink
|
|
||||||
|
|
||||||
import matterlink.api.ApiMessage.Companion.USER_ACTION
|
|
||||||
import matterlink.config.cfg
|
|
||||||
import matterlink.handlers.*
|
|
||||||
import net.minecraft.command.server.CommandBroadcast
|
|
||||||
import net.minecraft.command.server.CommandEmote
|
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP
|
|
||||||
import net.minecraft.server.dedicated.DedicatedServer
|
|
||||||
import net.minecraftforge.event.CommandEvent
|
|
||||||
import net.minecraftforge.event.ServerChatEvent
|
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent
|
|
||||||
import net.minecraftforge.event.entity.player.AchievementEvent
|
|
||||||
import net.minecraftforge.fml.common.Mod
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent
|
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent
|
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
|
||||||
@Mod.EventBusSubscriber
|
|
||||||
object EventHandler {
|
|
||||||
|
|
||||||
//MC-VERSION & FORGE DEPENDENT
|
|
||||||
@SubscribeEvent
|
|
||||||
@JvmStatic
|
|
||||||
fun progressEvent(e: AchievementEvent) {
|
|
||||||
val achievement = e.achievement
|
|
||||||
val entityPlayer = e.entityPlayer as? EntityPlayerMP ?: return
|
|
||||||
val statFile = entityPlayer.statFile
|
|
||||||
|
|
||||||
if (!statFile.canUnlockAchievement(achievement) || statFile.hasAchievementUnlocked(achievement)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ProgressHandler.handleProgress(
|
|
||||||
name = e.entityPlayer.displayName.unformattedText,
|
|
||||||
message = "has earned the achievement",
|
|
||||||
display = e.achievement.statName.unformattedText
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
|
||||||
@SubscribeEvent
|
|
||||||
@JvmStatic
|
|
||||||
fun chatEvent(e: ServerChatEvent) {
|
|
||||||
if(e.isCanceled) return
|
|
||||||
e.isCanceled = ChatProcessor.sendToBridge(
|
|
||||||
user = e.player.displayName.unformattedText,
|
|
||||||
msg = e.message,
|
|
||||||
event = "",
|
|
||||||
uuid = e.player.gameProfile.id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
|
||||||
@SubscribeEvent
|
|
||||||
@JvmStatic
|
|
||||||
fun commandEvent(e: CommandEvent) {
|
|
||||||
val sender = when {
|
|
||||||
e.sender is DedicatedServer -> cfg.outgoing.systemUser
|
|
||||||
else -> e.sender.displayName.unformattedText
|
|
||||||
}
|
|
||||||
val args = e.parameters.joinToString(" ")
|
|
||||||
val type = when {
|
|
||||||
e.command is CommandEmote -> USER_ACTION
|
|
||||||
e.command.name == "me" -> USER_ACTION
|
|
||||||
e.command is CommandBroadcast -> ""
|
|
||||||
else -> return
|
|
||||||
}
|
|
||||||
ChatProcessor.sendToBridge(user = sender, msg = args, event = type)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
|
||||||
@SubscribeEvent
|
|
||||||
@JvmStatic
|
|
||||||
fun deathEvent(e: LivingDeathEvent) {
|
|
||||||
if (e.entityLiving is EntityPlayer) {
|
|
||||||
DeathHandler.handleDeath(
|
|
||||||
player = e.entityLiving.displayName.unformattedText,
|
|
||||||
deathMessage = e.entityLiving.combatTracker.deathMessage.unformattedText,
|
|
||||||
damageType = e.source.damageType
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
|
||||||
@SubscribeEvent
|
|
||||||
@JvmStatic
|
|
||||||
fun joinEvent(e: PlayerEvent.PlayerLoggedInEvent) {
|
|
||||||
JoinLeaveHandler.handleJoin(e.player.displayName.unformattedText)
|
|
||||||
}
|
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
|
||||||
@SubscribeEvent
|
|
||||||
@JvmStatic
|
|
||||||
fun leaveEvent(e: PlayerEvent.PlayerLoggedOutEvent) {
|
|
||||||
JoinLeaveHandler.handleLeave(e.player.displayName.unformattedText)
|
|
||||||
}
|
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
|
||||||
@SubscribeEvent
|
|
||||||
@JvmStatic
|
|
||||||
fun serverTickEvent(e: TickEvent.ServerTickEvent) {
|
|
||||||
if (e.phase == TickEvent.Phase.END)
|
|
||||||
TickHandler.handleTick()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,146 +0,0 @@
|
||||||
import net.minecraftforge.gradle.user.TaskSourceCopy
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
maven {
|
|
||||||
url = 'http://files.minecraftforge.net/maven'
|
|
||||||
}
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
url = 'https://oss.sonatype.org/content/groups/public'
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url = 'https://plugins.gradle.org/m2/'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '2.2-SNAPSHOT'
|
|
||||||
classpath group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: shadow_version
|
|
||||||
classpath group: 'gradle.plugin.com.matthewprenger', name: 'CurseGradle', version: cursegradle_version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
|
||||||
apply plugin: 'com.matthewprenger.cursegradle'
|
|
||||||
|
|
||||||
version = project.mc_version + '-' + project.mod_version
|
|
||||||
|
|
||||||
archivesBaseName = project.mod_name
|
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile project(':core')
|
|
||||||
compile group: 'net.shadowfacts', name: 'Forgelin', version: project.forgelin_version
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
classifier = ''
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
include project(":core")
|
|
||||||
include project(":api")
|
|
||||||
include project(":Jankson")
|
|
||||||
include dependency(group: 'com.elytradev.concrete', name: 'concrete-common', version: concrete_version)
|
|
||||||
include dependency(group: 'com.elytradev.concrete', name: 'concrete-rulesengine', version: concrete_version)
|
|
||||||
}
|
|
||||||
|
|
||||||
relocate 'blue.endless', 'matterlink.repack.blue.endless'
|
|
||||||
relocate 'com.elytradev.concrete', 'matterlink.repack.com.elytradev.concrete'
|
|
||||||
|
|
||||||
exclude 'dummyThing'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mad hacks to make source replacements work for Kotlin
|
|
||||||
// source: https://github.com/PaleoCrafter/VanillaImmersion/blob/ee82ecafb76659cf7d7822a722c8f63f43f41d01/build.gradle#L119
|
|
||||||
for (set in sourceSets) {
|
|
||||||
def taskName = "source${set.name.capitalize()}Kotlin"
|
|
||||||
def dir = new File(project.getBuildDir(), "sources/${set.name}/kotlin")
|
|
||||||
task(taskName, type: TaskSourceCopy) {
|
|
||||||
source = set.getKotlin()
|
|
||||||
output = dir
|
|
||||||
}
|
|
||||||
def compileTask = tasks[set.getCompileTaskName('kotlin')]
|
|
||||||
compileTask.source = dir
|
|
||||||
compileTask.dependsOn taskName
|
|
||||||
def dirPath = dir.toPath()
|
|
||||||
compileKotlin.include {
|
|
||||||
return it.file.toPath().startsWith(dirPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceJar.from sourceSets.main.kotlin
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
version = project.mc_version + '-' + project.forge_version
|
|
||||||
runDir = 'run'
|
|
||||||
|
|
||||||
mappings = project.mcp_mappings
|
|
||||||
|
|
||||||
replaceIn 'Constants.kt'
|
|
||||||
replace '@MODVERSION@', project.mod_version
|
|
||||||
replace '@MCVERSION@', project.mc_version
|
|
||||||
replace '@FORGELIN-VERSION@', project.forgelin_version
|
|
||||||
replace '@FORGE-VERSION@', project.forge_version
|
|
||||||
replace '-1//@BUILD_NUMBER@', System.env.BUILD_NUMBER ?: -1
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
// this will ensure that this task is redone when the versions change.
|
|
||||||
inputs.property 'version', project.mod_version
|
|
||||||
inputs.property 'mcversion', project.minecraft.version
|
|
||||||
|
|
||||||
// replace stuff in mcmod.info, nothing else
|
|
||||||
from(project(':core').sourceSets.main.resources.srcDirs) {
|
|
||||||
include 'mcmod.info'
|
|
||||||
|
|
||||||
// replace version and mcversion
|
|
||||||
expand 'version': project.mod_version, 'mcversion': project.minecraft.version
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy everything else except the mcmod.info
|
|
||||||
from(project(':core').sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude 'mcmod.info'
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceJar {
|
|
||||||
classifier = 'sources'
|
|
||||||
// copy all the minecraftforge specific classes
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
|
|
||||||
// copy everything else except the mcmod.info
|
|
||||||
from(project(':core').sourceSets.main.allSource) {
|
|
||||||
exclude 'mcmod.info'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
reobf {
|
|
||||||
shadowJar { mappingType = 'SEARGE' }
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar.finalizedBy reobfShadowJar
|
|
||||||
|
|
||||||
curseforge {
|
|
||||||
if (project.hasProperty('CURSEFORGE_API_TOKEN') && project.hasProperty('release')) {
|
|
||||||
apiKey = CURSEFORGE_API_TOKEN
|
|
||||||
}
|
|
||||||
project {
|
|
||||||
id = project.curse_id
|
|
||||||
releaseType = project.curse_release_type
|
|
||||||
if (project.hasProperty('changelog_file')) {
|
|
||||||
println("changelog = $changelog_file")
|
|
||||||
changelogType = 'markdown'
|
|
||||||
changelog = file(changelog_file)
|
|
||||||
}
|
|
||||||
relations {
|
|
||||||
requiredLibrary 'shadowfacts-forgelin'
|
|
||||||
}
|
|
||||||
mainArtifact(shadowJar) {
|
|
||||||
displayName = "MatterLink $version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
mc_version = 1.11.2
|
|
||||||
mcp_mappings = stable_32
|
|
||||||
forge_version = 13.20.1.2386
|
|
|
@ -1,8 +0,0 @@
|
||||||
package matterlink
|
|
||||||
|
|
||||||
const val MODID = "matterlink"
|
|
||||||
const val NAME = "MatterLink"
|
|
||||||
const val MODVERSION = "@MODVERSION@"
|
|
||||||
const val MCVERSION = "@MCVERSION@"
|
|
||||||
const val DEPENDENCIES = "required-after:forgelin@[@FORGELIN-VERSION@,);required-after:forge@[@FORGE-VERSION@,);"
|
|
||||||
const val BUILD_NUMBER = -1//@BUILD_NUMBER@
|
|
|
@ -1,42 +0,0 @@
|
||||||
package matterlink.command
|
|
||||||
|
|
||||||
import matterlink.logger
|
|
||||||
import net.minecraft.command.CommandBase
|
|
||||||
import net.minecraft.command.ICommandSender
|
|
||||||
import net.minecraft.command.WrongUsageException
|
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
|
||||||
import net.minecraft.server.MinecraftServer
|
|
||||||
import net.minecraft.util.text.TextComponentString
|
|
||||||
|
|
||||||
|
|
||||||
class AuthCommand : CommandBase() {
|
|
||||||
override fun getName(): String {
|
|
||||||
return CommandCoreAuth.name
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getUsage(sender: ICommandSender): String {
|
|
||||||
return CommandCoreAuth.usage
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAliases(): List<String> {
|
|
||||||
return CommandCoreAuth.aliases
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getRequiredPermissionLevel(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<String>) {
|
|
||||||
if (args.isEmpty()) {
|
|
||||||
throw WrongUsageException("Invalid command! Valid uses: ${this.getUsage(sender)}")
|
|
||||||
}
|
|
||||||
|
|
||||||
val uuid = (sender as? EntityPlayer)?.uniqueID?.toString()
|
|
||||||
val reply = CommandCoreAuth.execute(args, sender.name, uuid)
|
|
||||||
|
|
||||||
if (reply.isNotEmpty() && sender.sendCommandFeedback()) {
|
|
||||||
sender.sendMessage(TextComponentString(reply))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package matterlink.command
|
|
||||||
|
|
||||||
import net.minecraft.command.CommandBase
|
|
||||||
import net.minecraft.command.ICommandSender
|
|
||||||
import net.minecraft.command.WrongUsageException
|
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
|
||||||
import net.minecraft.server.MinecraftServer
|
|
||||||
import net.minecraft.util.text.TextComponentString
|
|
||||||
|
|
||||||
|
|
||||||
class MatterLinkCommand : CommandBase() {
|
|
||||||
override fun getName(): String {
|
|
||||||
return CommandCoreML.name
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getUsage(sender: ICommandSender): String {
|
|
||||||
return CommandCoreML.usage
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAliases(): List<String> {
|
|
||||||
return CommandCoreML.aliases
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<String>) {
|
|
||||||
if (args.isEmpty()) {
|
|
||||||
throw WrongUsageException("Invalid command! Valid uses: ${this.getUsage(sender)}")
|
|
||||||
}
|
|
||||||
|
|
||||||
val uuid = (sender as? EntityPlayer)?.uniqueID?.toString()
|
|
||||||
val reply = CommandCoreML.execute(args, sender.name, uuid)
|
|
||||||
|
|
||||||
if (reply.isNotEmpty() && sender.sendCommandFeedback()) {
|
|
||||||
sender.sendMessage(TextComponentString(reply))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package matterlink.command
|
|
||||||
|
|
||||||
import matterlink.bridge.command.IBridgeCommand
|
|
||||||
import matterlink.bridge.command.IMinecraftCommandSender
|
|
||||||
import net.minecraft.command.CommandResultStats
|
|
||||||
import net.minecraft.command.ICommandSender
|
|
||||||
import net.minecraft.entity.Entity
|
|
||||||
import net.minecraft.server.MinecraftServer
|
|
||||||
import net.minecraft.util.math.BlockPos
|
|
||||||
import net.minecraft.util.math.Vec3d
|
|
||||||
import net.minecraft.util.text.ITextComponent
|
|
||||||
import net.minecraft.util.text.TextComponentString
|
|
||||||
import net.minecraft.world.World
|
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
|
||||||
import javax.annotation.Nonnull
|
|
||||||
|
|
||||||
class MatterLinkCommandSender(
|
|
||||||
user: String,
|
|
||||||
env: IBridgeCommand.CommandEnvironment,
|
|
||||||
op: Boolean) : IMinecraftCommandSender(user, env, op), ICommandSender {
|
|
||||||
|
|
||||||
override fun execute(cmdString: String): Boolean {
|
|
||||||
return 0 < FMLCommonHandler.instance().minecraftServerInstance.commandManager.executeCommand(
|
|
||||||
this,
|
|
||||||
cmdString
|
|
||||||
).apply {
|
|
||||||
sendReply(cmdString)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDisplayName(): ITextComponent {
|
|
||||||
return TextComponentString(displayName)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getName() = accountName
|
|
||||||
|
|
||||||
override fun getEntityWorld(): World {
|
|
||||||
return FMLCommonHandler.instance().minecraftServerInstance.getWorld(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun canUseCommand(permLevel: Int, commandName: String): Boolean {
|
|
||||||
//we now do permissions checking on our end
|
|
||||||
return canExecute(commandName)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getServer(): MinecraftServer? {
|
|
||||||
return FMLCommonHandler.instance().minecraftServerInstance
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun sendMessage(@Nonnull component: ITextComponent?) {
|
|
||||||
appendReply(component!!.unformattedComponentText)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun sendCommandFeedback(): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
//WtfMojangWhy
|
|
||||||
override fun getPosition(): BlockPos = BlockPos.ORIGIN
|
|
||||||
|
|
||||||
override fun setCommandStat(type: CommandResultStats.Type?, amount: Int) {}
|
|
||||||
|
|
||||||
override fun getPositionVector(): Vec3d = Vec3d.ZERO
|
|
||||||
|
|
||||||
override fun getCommandSenderEntity(): Entity? = null
|
|
||||||
}
|
|
|
@ -14,41 +14,35 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '2.3-SNAPSHOT'
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '2.3-SNAPSHOT'
|
||||||
classpath group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: shadow_version
|
classpath group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: shadowVersion
|
||||||
classpath group: 'gradle.plugin.com.matthewprenger', name: 'CurseGradle', version: cursegradle_version
|
classpath group: 'gradle.plugin.com.matthewprenger', name: 'CurseGradle', version: cursegradleVersion
|
||||||
|
classpath group: 'com.vanniktech', name: 'gradle-dependency-graph-generator-plugin', version: '0.5.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
apply plugin: 'com.matthewprenger.cursegradle'
|
apply plugin: 'com.matthewprenger.cursegradle'
|
||||||
|
apply plugin: "com.vanniktech.dependency.graph.generator"
|
||||||
|
|
||||||
version = project.mc_version + '-' + project.mod_version
|
version = project.mc_version + '-' + project.modVersion
|
||||||
|
|
||||||
archivesBaseName = project.mod_name
|
archivesBaseName = project.modName
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
sourceCompatibility = targetCompatibility = '1.8'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':core')
|
compile project(':core')
|
||||||
compile group: 'net.shadowfacts', name: 'Forgelin', version: project.forgelin_version
|
shadow (project(path: ':core', configuration: 'shadow')) { transitive = false }
|
||||||
|
|
||||||
|
compile group: 'net.shadowfacts', name: 'Forgelin', version: project.forgelinVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
classifier = ''
|
classifier = ''
|
||||||
|
|
||||||
dependencies {
|
|
||||||
include project(":core")
|
|
||||||
include project(":api")
|
|
||||||
include project(":Jankson")
|
|
||||||
include dependency(group: 'com.elytradev.concrete', name: 'concrete-common', version: concrete_version)
|
|
||||||
include dependency(group: 'com.elytradev.concrete', name: 'concrete-rulesengine', version: concrete_version)
|
|
||||||
}
|
|
||||||
|
|
||||||
relocate 'blue.endless', 'matterlink.repack.blue.endless'
|
|
||||||
relocate 'com.elytradev.concrete', 'matterlink.repack.com.elytradev.concrete'
|
|
||||||
|
|
||||||
exclude 'dummyThing'
|
exclude 'dummyThing'
|
||||||
|
configurations = [project.configurations.shadow]
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
|
@ -58,16 +52,16 @@ minecraft {
|
||||||
mappings = project.mcp_mappings
|
mappings = project.mcp_mappings
|
||||||
|
|
||||||
replaceIn 'Constants.kt'
|
replaceIn 'Constants.kt'
|
||||||
replace '@MODVERSION@', project.mod_version
|
replace '@MODVERSION@', project.modVersion
|
||||||
replace '@MCVERSION@', project.mc_version
|
replace '@MCVERSION@', project.mc_version
|
||||||
replace '@FORGELIN-VERSION@', project.forgelin_version
|
replace '@FORGELIN-VERSION@', project.forgelinVersion
|
||||||
replace '@FORGE-VERSION@', project.forge_version
|
replace '@FORGE-VERSION@', project.forge_version
|
||||||
replace '-1//@BUILD_NUMBER@', System.env.BUILD_NUMBER ?: -1
|
replace '-1//@BUILD_NUMBER@', System.env.BUILD_NUMBER ?: -1
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
// this will ensure that this task is redone when the versions change.
|
// this will ensure that this task is redone when the versions change.
|
||||||
inputs.property "version", project.mod_version
|
inputs.property "version", project.modVersion
|
||||||
inputs.property "mcversion", project.minecraft.version
|
inputs.property "mcversion", project.minecraft.version
|
||||||
|
|
||||||
// replace stuff in mcmod.info, nothing else
|
// replace stuff in mcmod.info, nothing else
|
||||||
|
@ -75,7 +69,7 @@ processResources {
|
||||||
include 'mcmod.info'
|
include 'mcmod.info'
|
||||||
|
|
||||||
// replace version and mcversion
|
// replace version and mcversion
|
||||||
expand 'version': project.mod_version, 'mcversion': project.minecraft.version
|
expand 'version': project.modVersion, 'mcversion': project.minecraft.version
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy everything else except the mcmod.info
|
// copy everything else except the mcmod.info
|
||||||
|
@ -99,7 +93,6 @@ sourceJar {
|
||||||
reobf {
|
reobf {
|
||||||
shadowJar { mappingType = 'SEARGE' }
|
shadowJar { mappingType = 'SEARGE' }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.shadowJar.finalizedBy reobfShadowJar
|
tasks.shadowJar.finalizedBy reobfShadowJar
|
||||||
|
|
||||||
curseforge {
|
curseforge {
|
||||||
|
@ -107,8 +100,8 @@ curseforge {
|
||||||
apiKey = CURSEFORGE_API_TOKEN
|
apiKey = CURSEFORGE_API_TOKEN
|
||||||
}
|
}
|
||||||
project {
|
project {
|
||||||
id = project.curse_id
|
id = project.curseId
|
||||||
releaseType = project.curse_release_type
|
releaseType = project.curseReleaseType
|
||||||
if (project.hasProperty('changelog_file')) {
|
if (project.hasProperty('changelog_file')) {
|
||||||
println("changelog = $changelog_file")
|
println("changelog = $changelog_file")
|
||||||
changelogType = 'markdown'
|
changelogType = 'markdown'
|
||||||
|
|
|
@ -42,7 +42,16 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun preInit(event: FMLPreInitializationEvent) {
|
fun preInit(event: FMLPreInitializationEvent) {
|
||||||
logger = event.modLog as org.apache.logging.log4j.core.Logger
|
logger = with(event.modLog) {
|
||||||
|
object : Logger {
|
||||||
|
override fun info(message: String) = this@with.info(message)
|
||||||
|
override fun debug(message: String) = this@with.debug(message)
|
||||||
|
override fun error(message: String) = this@with.error(message)
|
||||||
|
override fun warn(message: String) = this@with.warn(message)
|
||||||
|
override fun trace(message: String) = this@with.trace(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("Building bridge!")
|
logger.info("Building bridge!")
|
||||||
|
|
||||||
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
||||||
|
@ -56,8 +65,8 @@ object MatterLink : IMatterLink() {
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun serverStarting(event: FMLServerStartingEvent) {
|
fun serverStarting(event: FMLServerStartingEvent) {
|
||||||
logger.debug("Registering server commands")
|
logger.debug("Registering server commands")
|
||||||
event.registerServerCommand(MatterLinkCommand())
|
event.registerServerCommand(MatterLinkCommand)
|
||||||
event.registerServerCommand(AuthCommand())
|
event.registerServerCommand(AuthCommand)
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +124,8 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
override fun collectPlayers(area: Area): Set<UUID> {
|
override fun collectPlayers(area: Area): Set<UUID> {
|
||||||
val players = FMLCommonHandler.instance().minecraftServerInstance.playerList.players.filter {
|
val players = FMLCommonHandler.instance().minecraftServerInstance.playerList.players.filter {
|
||||||
( area.allDimensions || area.dimensions.contains(it.dimension) )
|
(area.allDimensions || area.dimensions.contains(it.dimension))
|
||||||
&& area.testInBounds(it.posX.toInt(), it.posY.toInt(), it.posZ.toInt())
|
&& area.testInBounds(it.posX.toInt(), it.posY.toInt(), it.posZ.toInt())
|
||||||
}
|
}
|
||||||
return players.map { it.uniqueID }.toSet()
|
return players.map { it.uniqueID }.toSet()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package matterlink.command
|
package matterlink.command
|
||||||
|
|
||||||
import matterlink.logger
|
|
||||||
import net.minecraft.command.CommandBase
|
import net.minecraft.command.CommandBase
|
||||||
import net.minecraft.command.ICommandSender
|
import net.minecraft.command.ICommandSender
|
||||||
import net.minecraft.command.WrongUsageException
|
import net.minecraft.command.WrongUsageException
|
||||||
|
@ -9,7 +8,7 @@ import net.minecraft.server.MinecraftServer
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
|
|
||||||
|
|
||||||
class AuthCommand : CommandBase() {
|
object AuthCommand : CommandBase() {
|
||||||
override fun getName(): String {
|
override fun getName(): String {
|
||||||
return CommandCoreAuth.name
|
return CommandCoreAuth.name
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package matterlink.command
|
package matterlink.command
|
||||||
|
|
||||||
import matterlink.logger
|
|
||||||
import net.minecraft.command.CommandBase
|
import net.minecraft.command.CommandBase
|
||||||
import net.minecraft.command.ICommandSender
|
import net.minecraft.command.ICommandSender
|
||||||
import net.minecraft.command.WrongUsageException
|
import net.minecraft.command.WrongUsageException
|
||||||
|
@ -9,7 +8,7 @@ import net.minecraft.server.MinecraftServer
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
|
|
||||||
|
|
||||||
class MatterLinkCommand : CommandBase() {
|
object MatterLinkCommand : CommandBase() {
|
||||||
override fun getName(): String {
|
override fun getName(): String {
|
||||||
return CommandCoreML.name
|
return CommandCoreML.name
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url = 'http://files.minecraftforge.net/maven'
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url = 'https://plugins.gradle.org/m2/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '1.2-SNAPSHOT'
|
||||||
|
classpath group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: shadowVersion
|
||||||
|
classpath group: 'gradle.plugin.com.matthewprenger', name: 'CurseGradle', version: cursegradleVersion
|
||||||
|
classpath group: 'com.vanniktech', name: 'gradle-dependency-graph-generator-plugin', version: '0.5.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'forge'
|
||||||
|
//apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
|
apply plugin: 'com.matthewprenger.cursegradle'
|
||||||
|
apply plugin: "com.vanniktech.dependency.graph.generator"
|
||||||
|
|
||||||
|
|
||||||
|
version = project.mc_version + '-' + project.modVersion
|
||||||
|
|
||||||
|
archivesBaseName = project.modName
|
||||||
|
|
||||||
|
sourceCompatibility = targetCompatibility = '1.8'
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
shade
|
||||||
|
compile.extendsFrom shade
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade (project(':core')) { transitive = false }
|
||||||
|
shade (project(':Jankson')) { transitive = false }
|
||||||
|
|
||||||
|
shade group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlinVersion
|
||||||
|
|
||||||
|
shade group: 'com.github.kittinunf.fuel', name: 'fuel', version: fuelVersion
|
||||||
|
shade group: 'com.github.kittinunf.result', name: 'result', version: resultVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = project.mc_version + '-' + project.forge_version + '-' + project.mc_version
|
||||||
|
runDir = 'run'
|
||||||
|
|
||||||
|
mappings = project.mcp_mappings
|
||||||
|
|
||||||
|
// srgExtra 'PK: kotlin matterlink/repack/kotlin'
|
||||||
|
// srgExtra 'PK: org/jetbrains/annotations matterlink/repack/org/jetbrains/annotations'
|
||||||
|
// srgExtra 'PK: org/intellij matterlink/repack/org/intellij'
|
||||||
|
// srgExtra 'PK: blue/endless/ matterlink/repack/blue/endless/'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin.doFirst {
|
||||||
|
def target = 'src/main/kotlin/matterlink/gen'
|
||||||
|
copy {
|
||||||
|
from('src/templates/kotlin/matterlink/Constants.kt')
|
||||||
|
into(target)
|
||||||
|
}
|
||||||
|
ant.replaceregexp(match: '@MODVERSION@', replace: project.modVersion, flags: 'g', byline: true) {
|
||||||
|
fileset(dir: target, includes: 'Constants.kt')
|
||||||
|
}
|
||||||
|
ant.replaceregexp(match: '@MCVERSION@', replace: project.mc_version, flags: 'g', byline: true) {
|
||||||
|
fileset(dir: target, includes: 'Constants.kt')
|
||||||
|
}
|
||||||
|
ant.replaceregexp(match: '@FORGELIN-VERSION@', replace: project.forgelinVersion, flags: 'g', byline: true) {
|
||||||
|
fileset(dir: target, includes: 'Constants.kt')
|
||||||
|
}
|
||||||
|
ant.replaceregexp(match: '@FORGE-VERSION@', replace: project.forge_version, flags: 'g', byline: true) {
|
||||||
|
fileset(dir: target, includes: 'Constants.kt')
|
||||||
|
}
|
||||||
|
ant.replaceregexp(match: '@BUILD_NUMBER@', replace: System.env.BUILD_NUMBER ?: -1, flags: 'g', byline: true) {
|
||||||
|
fileset(dir: target, includes: 'Constants.kt')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
// this will ensure that this task is redone when the versions change.
|
||||||
|
inputs.property 'version', project.modVersion
|
||||||
|
inputs.property 'mcversion', project.minecraft.version
|
||||||
|
|
||||||
|
// replace stuff in mcmod.info, nothing else
|
||||||
|
from(project(':core').sourceSets.main.resources.srcDirs) {
|
||||||
|
include 'mcmod.info'
|
||||||
|
|
||||||
|
// replace version and mcversion
|
||||||
|
expand 'version': project.modVersion, 'mcversion': project.minecraft.version
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy everything else except the mcmod.info
|
||||||
|
from(project(':core').sourceSets.main.resources.srcDirs) {
|
||||||
|
exclude 'mcmod.info'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
configurations.shade.each { dep ->
|
||||||
|
from(project.zipTree(dep)) {
|
||||||
|
exclude 'META-INF', 'META-INF/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
curseforge {
|
||||||
|
if (project.hasProperty('CURSEFORGE_API_TOKEN') && project.hasProperty('release')) {
|
||||||
|
apiKey = CURSEFORGE_API_TOKEN
|
||||||
|
}
|
||||||
|
project {
|
||||||
|
id = project.curseId
|
||||||
|
releaseType = project.curseReleaseType
|
||||||
|
if (project.hasProperty('changelog_file')) {
|
||||||
|
println("changelog = $changelog_file")
|
||||||
|
changelogType = 'markdown'
|
||||||
|
changelog = file(changelog_file)
|
||||||
|
}
|
||||||
|
mainArtifact(jar) {
|
||||||
|
displayName = "MatterLink $version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
mc_version = 1.7.10
|
||||||
|
mcp_mappings = stable_12
|
||||||
|
forge_version = 10.13.4.1614
|
|
@ -0,0 +1,142 @@
|
||||||
|
package matterlink
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent
|
||||||
|
import matterlink.api.ApiMessage.Companion.USER_ACTION
|
||||||
|
import matterlink.config.cfg
|
||||||
|
import matterlink.handlers.*
|
||||||
|
import net.minecraft.command.server.CommandBroadcast
|
||||||
|
import net.minecraft.command.server.CommandEmote
|
||||||
|
import net.minecraft.entity.Entity
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP
|
||||||
|
import net.minecraft.server.dedicated.DedicatedServer
|
||||||
|
import net.minecraftforge.event.CommandEvent
|
||||||
|
import net.minecraftforge.event.ServerChatEvent
|
||||||
|
import net.minecraftforge.event.entity.living.LivingDeathEvent
|
||||||
|
import net.minecraftforge.event.entity.player.AchievementEvent
|
||||||
|
|
||||||
|
//FORGE-DEPENDENT
|
||||||
|
object EventHandler {
|
||||||
|
|
||||||
|
//MC-VERSION & FORGE DEPENDENT
|
||||||
|
@SubscribeEvent
|
||||||
|
fun progressEvent(e: AchievementEvent) {
|
||||||
|
val achievement = e.achievement
|
||||||
|
val entityPlayer = e.entityPlayer as? EntityPlayerMP ?: return
|
||||||
|
val statFile = entityPlayer.statFile
|
||||||
|
|
||||||
|
if (!statFile.canUnlockAchievement(achievement) || statFile.hasAchievementUnlocked(achievement)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressHandler.handleProgress(
|
||||||
|
name = e.entityPlayer.displayName,
|
||||||
|
message = "has earned the achievement",
|
||||||
|
display = e.achievement.statName.unformattedText,
|
||||||
|
x = e.entityPlayer.posX.toInt(),
|
||||||
|
y = e.entityPlayer.posY.toInt(),
|
||||||
|
z = e.entityPlayer.posZ.toInt(),
|
||||||
|
dimension = e.entityPlayer.dimension
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
//FORGE-DEPENDENT
|
||||||
|
@SubscribeEvent
|
||||||
|
fun chatEvent(e: ServerChatEvent) {
|
||||||
|
if(e.isCanceled) return
|
||||||
|
e.isCanceled = ChatProcessor.sendToBridge(
|
||||||
|
user = e.player.displayName,
|
||||||
|
msg = e.message,
|
||||||
|
x = e.player.posX.toInt(),
|
||||||
|
y = e.player.posY.toInt(),
|
||||||
|
z = e.player.posZ.toInt(),
|
||||||
|
dimension = e.player.dimension,
|
||||||
|
event = ChatEvent.PLAIN,
|
||||||
|
uuid = e.player.gameProfile.id
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
//FORGE-DEPENDENT
|
||||||
|
@SubscribeEvent
|
||||||
|
fun commandEvent(e: CommandEvent) {
|
||||||
|
val sender = when {
|
||||||
|
e.sender is DedicatedServer -> cfg.outgoing.systemUser
|
||||||
|
else -> e.sender.commandSenderName
|
||||||
|
}
|
||||||
|
val args = e.parameters.joinToString(" ")
|
||||||
|
val type = with(e.command) {
|
||||||
|
when {
|
||||||
|
this is CommandEmote || commandName.equals("me", true) -> ChatEvent.ACTION
|
||||||
|
this is CommandBroadcast || commandName.equals("say", true) -> ChatEvent.BROADCAST
|
||||||
|
else -> return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val s = e.sender
|
||||||
|
val (x, y, z) = when(s) {
|
||||||
|
is Entity -> Triple(s.posX.toInt(), s.posY.toInt(), s.posZ.toInt())
|
||||||
|
else -> with(s.commandSenderPosition) { Triple(posX, posY, posZ) }
|
||||||
|
}
|
||||||
|
ChatProcessor.sendToBridge(
|
||||||
|
user = sender,
|
||||||
|
msg = args,
|
||||||
|
event = type,
|
||||||
|
x = x,
|
||||||
|
y = y,
|
||||||
|
z = z,
|
||||||
|
dimension = when {
|
||||||
|
e.sender is DedicatedServer -> null
|
||||||
|
else -> e.sender.entityWorld.provider.dimensionId
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//FORGE-DEPENDENT
|
||||||
|
@SubscribeEvent
|
||||||
|
fun deathEvent(e: LivingDeathEvent) {
|
||||||
|
if (e.entityLiving is EntityPlayer) {
|
||||||
|
val player = e.entityLiving as EntityPlayer
|
||||||
|
DeathHandler.handleDeath(
|
||||||
|
player = player.displayName,
|
||||||
|
deathMessage = e.entityLiving.combatTracker.func_151521_b().unformattedText,
|
||||||
|
damageType = e.source.damageType,
|
||||||
|
x = e.entityLiving.posX.toInt(),
|
||||||
|
y = e.entityLiving.posY.toInt(),
|
||||||
|
z = e.entityLiving.posZ.toInt(),
|
||||||
|
dimension = e.entityLiving.dimension
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//FORGE-DEPENDENT
|
||||||
|
@SubscribeEvent
|
||||||
|
fun joinEvent(e: PlayerEvent.PlayerLoggedInEvent) {
|
||||||
|
JoinLeaveHandler.handleJoin(
|
||||||
|
player = e.player.displayName,
|
||||||
|
x = e.player.posX.toInt(),
|
||||||
|
y = e.player.posY.toInt(),
|
||||||
|
z = e.player.posZ.toInt(),
|
||||||
|
dimension = e.player.dimension)
|
||||||
|
}
|
||||||
|
|
||||||
|
//FORGE-DEPENDENT
|
||||||
|
@SubscribeEvent
|
||||||
|
fun leaveEvent(e: PlayerEvent.PlayerLoggedOutEvent) {
|
||||||
|
JoinLeaveHandler.handleLeave(
|
||||||
|
player = e.player.displayName,
|
||||||
|
x = e.player.posX.toInt(),
|
||||||
|
y = e.player.posY.toInt(),
|
||||||
|
z = e.player.posZ.toInt(),
|
||||||
|
dimension = e.player.dimension
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
//FORGE-DEPENDENT
|
||||||
|
@SubscribeEvent
|
||||||
|
fun serverTickEvent(e: TickEvent.ServerTickEvent) {
|
||||||
|
if (e.phase == TickEvent.Phase.END)
|
||||||
|
TickHandler.handleTick()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,43 +1,51 @@
|
||||||
package matterlink
|
package matterlink
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile
|
import com.mojang.authlib.GameProfile
|
||||||
import jline.internal.Log.warn
|
import cpw.mods.fml.common.FMLCommonHandler
|
||||||
|
import cpw.mods.fml.common.Mod
|
||||||
|
import cpw.mods.fml.common.event.FMLInitializationEvent
|
||||||
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent
|
||||||
|
import cpw.mods.fml.common.event.FMLServerStartingEvent
|
||||||
|
import cpw.mods.fml.common.event.FMLServerStoppingEvent
|
||||||
import matterlink.bridge.command.IBridgeCommand
|
import matterlink.bridge.command.IBridgeCommand
|
||||||
|
import matterlink.command.AuthCommand
|
||||||
import matterlink.command.MatterLinkCommand
|
import matterlink.command.MatterLinkCommand
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
import matterlink.config.BaseConfig
|
import matterlink.config.BaseConfig
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.entity.ai.EntityMoveHelper
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP
|
import net.minecraft.entity.player.EntityPlayerMP
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.server.MinecraftServer
|
||||||
|
import net.minecraft.util.ChatComponentText
|
||||||
import net.minecraftforge.common.ForgeVersion
|
import net.minecraftforge.common.ForgeVersion
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
import net.minecraftforge.common.MinecraftForge
|
||||||
import net.minecraftforge.fml.common.Mod
|
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
|
|
||||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent
|
|
||||||
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent
|
|
||||||
import org.apache.logging.log4j.Level
|
|
||||||
import org.apache.logging.log4j.Logger
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@Mod(
|
@Mod(
|
||||||
modid = MODID,
|
modid = MODID,
|
||||||
name = NAME, version = MODVERSION,
|
name = NAME, version = MODVERSION,
|
||||||
serverSideOnly = true,
|
|
||||||
useMetadata = true,
|
useMetadata = true,
|
||||||
acceptableRemoteVersions = "*",
|
acceptableRemoteVersions = "*"
|
||||||
modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter",
|
|
||||||
dependencies = DEPENDENCIES
|
|
||||||
)
|
)
|
||||||
object MatterLink : IMatterLink() {
|
class MatterLink : IMatterLink() {
|
||||||
init {
|
init {
|
||||||
instance = this
|
instance = this
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun preInit(event: FMLPreInitializationEvent) {
|
fun preInit(event: FMLPreInitializationEvent) {
|
||||||
logger = event.modLog as org.apache.logging.log4j.core.Logger
|
MinecraftForge.EVENT_BUS.register(EventHandler)
|
||||||
|
FMLCommonHandler.instance().bus().register(EventHandler)
|
||||||
|
|
||||||
|
logger = with(event.modLog) {
|
||||||
|
object : Logger {
|
||||||
|
override fun info(message: String) = this@with.info(message)
|
||||||
|
override fun debug(message: String) = this@with.debug(message)
|
||||||
|
override fun error(message: String) = this@with.error(message)
|
||||||
|
override fun warn(message: String) = this@with.warn(message)
|
||||||
|
override fun trace(message: String) = this@with.trace(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("Building bridge!")
|
logger.info("Building bridge!")
|
||||||
|
|
||||||
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
||||||
|
@ -51,7 +59,8 @@ object MatterLink : IMatterLink() {
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun serverStarting(event: FMLServerStartingEvent) {
|
fun serverStarting(event: FMLServerStartingEvent) {
|
||||||
logger.debug("Registering server commands")
|
logger.debug("Registering server commands")
|
||||||
event.registerServerCommand(MatterLinkCommand())
|
event.registerServerCommand(MatterLinkCommand)
|
||||||
|
event.registerServerCommand(AuthCommand)
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +71,7 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
//FORGE-DEPENDENT
|
//FORGE-DEPENDENT
|
||||||
override fun wrappedSendToPlayers(msg: String) {
|
override fun wrappedSendToPlayers(msg: String) {
|
||||||
FMLCommonHandler.instance().minecraftServerInstance.playerList.sendMessage(TextComponentString(msg))
|
MinecraftServer.getServer().configurationManager.sendChatMsg(ChatComponentText(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun wrappedSendToPlayer(username: String, msg: String) {
|
override fun wrappedSendToPlayer(username: String, msg: String) {
|
||||||
|
@ -74,7 +83,7 @@ object MatterLink : IMatterLink() {
|
||||||
logger.error("${profile.name} is not online")
|
logger.error("${profile.name} is not online")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
player.sendMessage(TextComponentString(msg))
|
player.addChatMessage(ChatComponentText(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun wrappedSendToPlayer(uuid: UUID, msg: String) {
|
override fun wrappedSendToPlayer(uuid: UUID, msg: String) {
|
||||||
|
@ -86,16 +95,18 @@ object MatterLink : IMatterLink() {
|
||||||
logger.error("${profile.name} is not online")
|
logger.error("${profile.name} is not online")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
player.sendMessage(TextComponentString(msg))
|
player.addChatMessage(ChatComponentText(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isOnline(username: String) = FMLCommonHandler.instance().minecraftServerInstance.onlinePlayerNames.contains(username)
|
override fun isOnline(username: String) = (FMLCommonHandler.instance()
|
||||||
|
.minecraftServerInstance.configurationManager.getPlayerByUsername(username) ?: null) != null
|
||||||
private fun playerByProfile(gameProfile: GameProfile): EntityPlayerMP? = FMLCommonHandler.instance().minecraftServerInstance.playerList.getPlayerByUUID(gameProfile.id)
|
|
||||||
|
|
||||||
|
private fun playerByProfile(gameProfile: GameProfile): EntityPlayerMP? {
|
||||||
|
return FMLCommonHandler.instance().minecraftServerInstance.configurationManager.createPlayerForUser(gameProfile)
|
||||||
|
}
|
||||||
|
|
||||||
private fun profileByUUID(uuid: UUID): GameProfile? = try {
|
private fun profileByUUID(uuid: UUID): GameProfile? = try {
|
||||||
FMLCommonHandler.instance().minecraftServerInstance.playerProfileCache.getProfileByUUID(uuid)
|
FMLCommonHandler.instance().minecraftServerInstance.playerProfileCache.func_152652_a(uuid)
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
logger.warn("cannot find profile by uuid $uuid")
|
logger.warn("cannot find profile by uuid $uuid")
|
||||||
null
|
null
|
||||||
|
@ -108,6 +119,16 @@ object MatterLink : IMatterLink() {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun collectPlayers(area: Area): Set<UUID> {
|
||||||
|
val players = MinecraftServer.getServer().configurationManager.playerEntityList
|
||||||
|
.map { it as EntityPlayerMP }
|
||||||
|
.filter {
|
||||||
|
(area.allDimensions || area.dimensions.contains(it.dimension))
|
||||||
|
&& area.testInBounds(it.posX.toInt(), it.posY.toInt(), it.posZ.toInt())
|
||||||
|
}
|
||||||
|
return players.map { it.uniqueID }.toSet()
|
||||||
|
}
|
||||||
|
|
||||||
override fun nameToUUID(username: String): UUID? = profileByName(username)?.id
|
override fun nameToUUID(username: String): UUID? = profileByName(username)?.id
|
||||||
|
|
||||||
override fun uuidToName(uuid: UUID): String? = profileByUUID(uuid)?.name
|
override fun uuidToName(uuid: UUID): String? = profileByUUID(uuid)?.name
|
||||||
|
@ -122,4 +143,4 @@ object MatterLink : IMatterLink() {
|
||||||
override val modVersion: String = MODVERSION
|
override val modVersion: String = MODVERSION
|
||||||
override val buildNumber = BUILD_NUMBER
|
override val buildNumber = BUILD_NUMBER
|
||||||
override val forgeVersion = ForgeVersion.getVersion()
|
override val forgeVersion = ForgeVersion.getVersion()
|
||||||
}
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package matterlink.command
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandBase
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
import net.minecraft.command.WrongUsageException
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.util.ChatComponentText
|
||||||
|
|
||||||
|
|
||||||
|
object AuthCommand : CommandBase() {
|
||||||
|
override fun getCommandName(): String {
|
||||||
|
return CommandCoreAuth.name
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCommandUsage(sender: ICommandSender): String {
|
||||||
|
return CommandCoreAuth.usage
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCommandAliases(): List<String> {
|
||||||
|
return CommandCoreAuth.aliases
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun processCommand(sender: ICommandSender, args: Array<String>) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
throw WrongUsageException("Invalid command! Valid uses: ${this.getCommandUsage(sender)}")
|
||||||
|
}
|
||||||
|
|
||||||
|
val uuid = (sender as? EntityPlayer)?.uniqueID?.toString()
|
||||||
|
val reply = CommandCoreAuth.execute(args, sender.commandSenderName, uuid)
|
||||||
|
|
||||||
|
if (reply.isNotEmpty()) {
|
||||||
|
sender.addChatMessage(ChatComponentText(reply))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package matterlink.command
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandBase
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
import net.minecraft.command.WrongUsageException
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.util.ChatComponentText
|
||||||
|
|
||||||
|
|
||||||
|
object MatterLinkCommand : CommandBase() {
|
||||||
|
override fun getCommandName(): String {
|
||||||
|
return CommandCoreML.name
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCommandUsage(sender: ICommandSender): String {
|
||||||
|
return CommandCoreML.usage
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCommandAliases(): List<String> {
|
||||||
|
return CommandCoreML.aliases
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun processCommand(sender: ICommandSender, args: Array<String>) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
throw WrongUsageException("Invalid command! Valid uses: ${this.getCommandUsage(sender)}")
|
||||||
|
}
|
||||||
|
|
||||||
|
val uuid = (sender as? EntityPlayer)?.uniqueID?.toString()
|
||||||
|
val reply = CommandCoreML.execute(args, sender.commandSenderName, uuid)
|
||||||
|
|
||||||
|
if (reply.isNotEmpty()) {
|
||||||
|
sender.addChatMessage(ChatComponentText(reply))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package matterlink.command
|
||||||
|
|
||||||
|
import matterlink.bridge.command.IBridgeCommand
|
||||||
|
import matterlink.bridge.command.IMinecraftCommandSender
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
import net.minecraft.server.MinecraftServer
|
||||||
|
import net.minecraft.util.ChatComponentText
|
||||||
|
import net.minecraft.util.ChunkCoordinates
|
||||||
|
import net.minecraft.util.IChatComponent
|
||||||
|
import net.minecraft.world.World
|
||||||
|
|
||||||
|
class MatterLinkCommandSender(
|
||||||
|
user: String,
|
||||||
|
env: IBridgeCommand.CommandEnvironment,
|
||||||
|
op: Boolean) : IMinecraftCommandSender(user, env, op), ICommandSender {
|
||||||
|
|
||||||
|
override fun execute(cmdString: String): Boolean {
|
||||||
|
return 0 < MinecraftServer.getServer().commandManager.executeCommand(
|
||||||
|
this,
|
||||||
|
cmdString
|
||||||
|
).apply {
|
||||||
|
sendReply(cmdString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getFormattedCommandSenderName(): IChatComponent {
|
||||||
|
return ChatComponentText(displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCommandSenderName() = accountName
|
||||||
|
|
||||||
|
override fun getEntityWorld(): World {
|
||||||
|
return MinecraftServer.getServer().worldServerForDimension(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun canCommandSenderUseCommand(permLevel: Int, commandName: String): Boolean {
|
||||||
|
//we do permission
|
||||||
|
return canExecute(commandName)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addChatMessage(component: IChatComponent) {
|
||||||
|
appendReply(component.unformattedText)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCommandSenderPosition(): ChunkCoordinates = ChunkCoordinates(0, 0, 0)
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package matterlink
|
||||||
|
|
||||||
|
const val MODID = "matterlink"
|
||||||
|
const val NAME = "MatterLink"
|
||||||