revert dropping 1.7.10, adding 1.9.4 instead of 1.10/1.11

This commit is contained in:
nikky 2018-08-16 23:52:11 +02:00
parent 7818afc920
commit 79c9ac1572
63 changed files with 744 additions and 1535 deletions

2
.gitignore vendored
View File

@ -102,5 +102,3 @@ run/
\.floo \.floo
\.flooignore \.flooignore
test\.sh

View File

@ -1,3 +0,0 @@
mc_version = 1.10.2
mcp_mappings = stable_29
forge_version = 12.18.3.2185

View File

@ -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()
}
}

View File

@ -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"
}
}
}

View File

@ -1,3 +0,0 @@
mc_version = 1.11.2
mcp_mappings = stable_32
forge_version = 13.20.1.2386

View File

@ -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@

View File

@ -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))
}
}
}

View File

@ -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))
}
}
}

View File

@ -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
}

View File

@ -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'

View File

@ -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,7 +124,7 @@ 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()

View File

@ -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
} }

View File

@ -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
} }

127
1.7.10/build.gradle Normal file
View File

@ -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"
}
}
}

3
1.7.10/gradle.properties Normal file
View File

@ -0,0 +1,3 @@
mc_version = 1.7.10
mcp_mappings = stable_12
forge_version = 10.13.4.1614

View File

@ -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()
}
}

View File

@ -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

View File

@ -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))
}
}
}

View File

@ -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))
}
}
}

View File

@ -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)
}

View File

@ -0,0 +1,7 @@
package matterlink
const val MODID = "matterlink"
const val NAME = "MatterLink"
const val MODVERSION = "@MODVERSION@"
const val MCVERSION = "@MCVERSION@"
const val BUILD_NUMBER = @BUILD_NUMBER@

View File

@ -11,8 +11,8 @@ buildscript {
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '2.2-SNAPSHOT' 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: '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
} }
} }
@ -20,35 +20,26 @@ 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'
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]
} }
import net.minecraftforge.gradle.user.TaskSourceCopy import net.minecraftforge.gradle.user.TaskSourceCopy
// Mad hacks to make source replacements work for Kotlin // Mad hacks to make source replacements work for Kotlin
@ -77,16 +68,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
@ -94,7 +85,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
@ -119,7 +110,6 @@ sourceJar {
reobf { reobf {
shadowJar { mappingType = 'SEARGE' } shadowJar { mappingType = 'SEARGE' }
} }
tasks.shadowJar.finalizedBy reobfShadowJar tasks.shadowJar.finalizedBy reobfShadowJar
curseforge { curseforge {
@ -127,8 +117,9 @@ 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
addGameVersion '1.10'
if (project.hasProperty('changelog_file')) { if (project.hasProperty('changelog_file')) {
println("changelog = $changelog_file") println("changelog = $changelog_file")
changelogType = 'markdown' changelogType = 'markdown'

3
1.9.4/gradle.properties Normal file
View File

@ -0,0 +1,3 @@
mc_version = 1.9.4
mcp_mappings = stable_26
forge_version = 12.17.0.2051

View File

@ -1,6 +1,5 @@
package matterlink package matterlink
import matterlink.api.ApiMessage.Companion.USER_ACTION
import matterlink.config.cfg import matterlink.config.cfg
import matterlink.handlers.* import matterlink.handlers.*
import net.minecraft.command.server.CommandBroadcast import net.minecraft.command.server.CommandBroadcast
@ -12,18 +11,15 @@ import net.minecraftforge.event.CommandEvent
import net.minecraftforge.event.ServerChatEvent import net.minecraftforge.event.ServerChatEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent import net.minecraftforge.event.entity.living.LivingDeathEvent
import net.minecraftforge.event.entity.player.AchievementEvent 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.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.PlayerEvent import net.minecraftforge.fml.common.gameevent.PlayerEvent
import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent
//FORGE-DEPENDENT //FORGE-DEPENDENT
@Mod.EventBusSubscriber
object EventHandler { object EventHandler {
//MC-VERSION & FORGE DEPENDENT //MC-VERSION & FORGE DEPENDENT
@SubscribeEvent @SubscribeEvent
@JvmStatic
fun progressEvent(e: AchievementEvent) { fun progressEvent(e: AchievementEvent) {
val achievement = e.achievement val achievement = e.achievement
val entityPlayer = e.entityPlayer as? EntityPlayerMP ?: return val entityPlayer = e.entityPlayer as? EntityPlayerMP ?: return
@ -32,76 +28,104 @@ object EventHandler {
if (!statFile.canUnlockAchievement(achievement) || statFile.hasAchievementUnlocked(achievement)) { if (!statFile.canUnlockAchievement(achievement) || statFile.hasAchievementUnlocked(achievement)) {
return return
} }
ProgressHandler.handleProgress( ProgressHandler.handleProgress(
name = e.entityPlayer.displayName.unformattedText, name = e.entityPlayer.displayName.unformattedText,
message = "has earned the achievement", message = "has earned the achievement",
display = e.achievement.statName.unformattedText 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 //FORGE-DEPENDENT
@SubscribeEvent @SubscribeEvent
@JvmStatic
fun chatEvent(e: ServerChatEvent) { fun chatEvent(e: ServerChatEvent) {
if(e.isCanceled) return if(e.isCanceled) return
e.isCanceled = ChatProcessor.sendToBridge( e.isCanceled = ChatProcessor.sendToBridge(
user = e.player.displayName.unformattedText, user = e.player.displayName.unformattedText,
msg = e.message, msg = e.message,
event = "", 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 uuid = e.player.gameProfile.id
) )
} }
//FORGE-DEPENDENT //FORGE-DEPENDENT
@SubscribeEvent @SubscribeEvent
@JvmStatic
fun commandEvent(e: CommandEvent) { fun commandEvent(e: CommandEvent) {
val sender = when { val sender = when {
e.sender is DedicatedServer -> cfg.outgoing.systemUser e.sender is DedicatedServer -> cfg.outgoing.systemUser
else -> e.sender.displayName.unformattedText else -> e.sender.displayName.unformattedText
} }
val args = e.parameters.joinToString(" ") val args = e.parameters.joinToString(" ")
val type = when { val type = with(e.command) {
e.command is CommandEmote -> USER_ACTION when {
e.command.name == "me" -> USER_ACTION this is CommandEmote || commandName.equals("me", true) -> ChatEvent.ACTION
e.command is CommandBroadcast -> "" this is CommandBroadcast || commandName.equals("say", true) -> ChatEvent.BROADCAST
else -> return else -> return
} }
ChatProcessor.sendToBridge(user = sender, msg = args, event = type) }
ChatProcessor.sendToBridge(
user = sender,
msg = args,
event = type,
x = e.sender.position.x,
y = e.sender.position.y,
z = e.sender.position.z,
dimension = when {
e.sender is DedicatedServer -> null
else -> e.sender.commandSenderEntity?.dimension ?: e.sender.entityWorld.provider.dimension
}
)
} }
//FORGE-DEPENDENT //FORGE-DEPENDENT
@SubscribeEvent @SubscribeEvent
@JvmStatic
fun deathEvent(e: LivingDeathEvent) { fun deathEvent(e: LivingDeathEvent) {
if (e.entityLiving is EntityPlayer) { if (e.entityLiving is EntityPlayer) {
DeathHandler.handleDeath( DeathHandler.handleDeath(
player = e.entityLiving.displayName.unformattedText, player = e.entityLiving.displayName.unformattedText,
deathMessage = e.entityLiving.combatTracker.deathMessage.unformattedText, deathMessage = e.entityLiving.combatTracker.deathMessage.unformattedText,
damageType = e.source.damageType 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 //FORGE-DEPENDENT
@SubscribeEvent @SubscribeEvent
@JvmStatic
fun joinEvent(e: PlayerEvent.PlayerLoggedInEvent) { fun joinEvent(e: PlayerEvent.PlayerLoggedInEvent) {
JoinLeaveHandler.handleJoin(e.player.displayName.unformattedText) JoinLeaveHandler.handleJoin(
player = e.player.displayName.unformattedText,
x = e.player.posX.toInt(),
y = e.player.posY.toInt(),
z = e.player.posZ.toInt(),
dimension = e.player.dimension
)
} }
//FORGE-DEPENDENT //FORGE-DEPENDENT
@SubscribeEvent @SubscribeEvent
@JvmStatic
fun leaveEvent(e: PlayerEvent.PlayerLoggedOutEvent) { fun leaveEvent(e: PlayerEvent.PlayerLoggedOutEvent) {
JoinLeaveHandler.handleLeave(e.player.displayName.unformattedText) JoinLeaveHandler.handleLeave(
player = e.player.displayName.unformattedText,
x = e.player.posX.toInt(),
y = e.player.posY.toInt(),
z = e.player.posZ.toInt(),
dimension = e.player.dimension
)
} }
//FORGE-DEPENDENT //FORGE-DEPENDENT
@SubscribeEvent @SubscribeEvent
@JvmStatic
fun serverTickEvent(e: TickEvent.ServerTickEvent) { fun serverTickEvent(e: TickEvent.ServerTickEvent) {
if (e.phase == TickEvent.Phase.END) if (e.phase == TickEvent.Phase.END)
TickHandler.handleTick() TickHandler.handleTick()

View File

@ -2,21 +2,22 @@ package matterlink
import com.mojang.authlib.GameProfile import com.mojang.authlib.GameProfile
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.player.EntityPlayerMP import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.server.MinecraftServer
import net.minecraft.util.text.TextComponentString import net.minecraft.util.text.TextComponentString
import net.minecraftforge.common.ForgeVersion import net.minecraftforge.common.ForgeVersion
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.FMLCommonHandler import net.minecraftforge.fml.common.FMLCommonHandler
import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import net.minecraftforge.fml.common.event.FMLServerStartingEvent import net.minecraftforge.fml.common.event.FMLServerStartingEvent
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent 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(
@ -35,7 +36,17 @@ 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 MinecraftForge.EVENT_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()
@ -49,7 +60,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()
} }
@ -72,7 +84,7 @@ object MatterLink : IMatterLink() {
error("${profile.name} is not online") error("${profile.name} is not online")
return return
} }
player.sendMessage(TextComponentString(msg)) player.addChatMessage(TextComponentString(msg))
} }
override fun wrappedSendToPlayer(uuid: UUID, msg: String) { override fun wrappedSendToPlayer(uuid: UUID, msg: String) {
@ -84,10 +96,10 @@ 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(TextComponentString(msg))
} }
override fun isOnline(username: String) = FMLCommonHandler.instance().minecraftServerInstance.onlinePlayerNames.contains(username) override fun isOnline(username: String) = FMLCommonHandler.instance().minecraftServerInstance.playerList.allUsernames.contains(username)
private fun playerByProfile(gameProfile: GameProfile): EntityPlayerMP? = FMLCommonHandler.instance().minecraftServerInstance.playerList.getPlayerByUUID(gameProfile.id) private fun playerByProfile(gameProfile: GameProfile): EntityPlayerMP? = FMLCommonHandler.instance().minecraftServerInstance.playerList.getPlayerByUUID(gameProfile.id)
@ -106,6 +118,17 @@ object MatterLink : IMatterLink() {
null null
} }
override fun collectPlayers(area: Area): Set<UUID> {
val playerList = FMLCommonHandler.instance().minecraftServerInstance.playerList
val players = playerList.allProfiles
.map { playerList.getPlayerByUUID(it.id) }
.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

View File

@ -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,16 +8,16 @@ 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 getCommandName(): String {
return CommandCoreAuth.name return CommandCoreAuth.name
} }
override fun getUsage(sender: ICommandSender): String { override fun getCommandUsage(sender: ICommandSender): String {
return CommandCoreAuth.usage return CommandCoreAuth.usage
} }
override fun getAliases(): List<String> { override fun getCommandAliases(): List<String> {
return CommandCoreAuth.aliases return CommandCoreAuth.aliases
} }
@ -28,14 +27,14 @@ class AuthCommand : CommandBase() {
override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<String>) { override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<String>) {
if (args.isEmpty()) { if (args.isEmpty()) {
throw WrongUsageException("Invalid command! Valid uses: ${this.getUsage(sender)}") throw WrongUsageException("Invalid command! Valid uses: ${this.getCommandUsage(sender)}")
} }
val uuid = (sender as? EntityPlayer)?.uniqueID?.toString() val uuid = (sender as? EntityPlayer)?.uniqueID?.toString()
val reply = CommandCoreAuth.execute(args, sender.name, uuid) val reply = CommandCoreAuth.execute(args, sender.name, uuid)
if (reply.isNotEmpty() && sender.sendCommandFeedback()) { if (reply.isNotEmpty() && sender.sendCommandFeedback()) {
sender.sendMessage(TextComponentString(reply)) sender.addChatMessage(TextComponentString(reply))
} }
} }

View File

@ -8,29 +8,29 @@ 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 getCommandName(): String {
return CommandCoreML.name return CommandCoreML.name
} }
override fun getUsage(sender: ICommandSender): String { override fun getCommandUsage(sender: ICommandSender): String {
return CommandCoreML.usage return CommandCoreML.usage
} }
override fun getAliases(): List<String> { override fun getCommandAliases(): List<String> {
return CommandCoreML.aliases return CommandCoreML.aliases
} }
override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<String>) { override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<String>) {
if (args.isEmpty()) { if (args.isEmpty()) {
throw WrongUsageException("Invalid command! Valid uses: ${this.getUsage(sender)}") throw WrongUsageException("Invalid command! Valid uses: ${this.getCommandUsage(sender)}")
} }
val uuid = (sender as? EntityPlayer)?.uniqueID?.toString() val uuid = (sender as? EntityPlayer)?.uniqueID?.toString()
val reply = CommandCoreML.execute(args, sender.name, uuid) val reply = CommandCoreML.execute(args, sender.name, uuid)
if (reply.isNotEmpty() && sender.sendCommandFeedback()) { if (reply.isNotEmpty() && sender.sendCommandFeedback()) {
sender.sendMessage(TextComponentString(reply)) sender.addChatMessage(TextComponentString(reply))
} }
} }
} }

View File

@ -18,7 +18,6 @@ class MatterLinkCommandSender(
user: String, user: String,
env: IBridgeCommand.CommandEnvironment, env: IBridgeCommand.CommandEnvironment,
op: Boolean) : IMinecraftCommandSender(user, env, op), ICommandSender { op: Boolean) : IMinecraftCommandSender(user, env, op), ICommandSender {
override fun execute(cmdString: String): Boolean { override fun execute(cmdString: String): Boolean {
return 0 < FMLCommonHandler.instance().minecraftServerInstance.commandManager.executeCommand( return 0 < FMLCommonHandler.instance().minecraftServerInstance.commandManager.executeCommand(
this, this,
@ -38,7 +37,7 @@ class MatterLinkCommandSender(
return FMLCommonHandler.instance().minecraftServerInstance.worldServerForDimension(0) return FMLCommonHandler.instance().minecraftServerInstance.worldServerForDimension(0)
} }
override fun canUseCommand(permLevel: Int, commandName: String): Boolean { override fun canCommandSenderUseCommand(permLevel: Int, commandName: String): Boolean {
//we check user on our end //we check user on our end
return canExecute(commandName) return canExecute(commandName)
} }
@ -47,7 +46,7 @@ class MatterLinkCommandSender(
return FMLCommonHandler.instance().minecraftServerInstance return FMLCommonHandler.instance().minecraftServerInstance
} }
override fun sendMessage(@Nonnull component: ITextComponent?) { override fun addChatMessage(@Nonnull component: ITextComponent?) {
appendReply(component!!.unformattedComponentText) appendReply(component!!.unformattedComponentText)
} }

20
Jenkinsfile vendored
View File

@ -6,20 +6,20 @@ pipeline {
sh 'git submodule update --init --recursive' sh 'git submodule update --init --recursive'
} }
} }
stage("1.10.2") { stage("1.7.10") {
steps { steps {
sh './gradlew :1.10.2:setupCiWorkspace' sh './gradlew :1.7.10:setupCiWorkspace'
sh './gradlew :1.10.2:clean' sh './gradlew :1.7.10:clean'
sh './gradlew :1.10.2:build' sh './gradlew :1.7.10:build'
archiveArtifacts artifacts: '1.10.2/build/libs/*jar' archiveArtifacts artifacts: '1.7.10/build/libs/*jar'
} }
} }
stage("1.11.2") { stage("1.9.4") {
steps { steps {
sh './gradlew :1.11.2:setupCiWorkspace' sh './gradlew :1.9.4:setupCiWorkspace'
sh './gradlew :1.11.2:clean' sh './gradlew :1.9.4:clean'
sh './gradlew :1.11.2:build' sh './gradlew :1.9.4:build'
archiveArtifacts artifacts: '1.11.2/build/libs/*jar' archiveArtifacts artifacts: '1.9.4/build/libs/*jar'
} }
} }
stage("1.12.2") { stage("1.12.2") {

View File

@ -28,9 +28,7 @@ Chat with us on IRC: [#matterlink @ irc.esper.net](irc://irc.esper.net/matterlin
[![Download 1.12.2](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.12.2)](https://curse.nikky.moe/api/url/287323?version=1.12.2) [![Download 1.12.2](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.12.2)](https://curse.nikky.moe/api/url/287323?version=1.12.2)
[![Download 1.11.2](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.11.2)](https://curse.nikky.moe/api/url/287323?version=1.11.2) [![Download 1.9.4](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.9.4)](https://curse.nikky.moe/api/url/287323?version=1.9.4)
[![Download 1.10.2](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.10.2)](https://curse.nikky.moe/api/url/287323?version=1.10.2)
## Dependencies ## Dependencies

5
api/.gitignore vendored
View File

@ -1,5 +0,0 @@
\.idea/
\.gradle/
out/
build/
run/

View File

@ -1,22 +0,0 @@
The MIT License (MIT)
Copyright (c) 2018
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1 +0,0 @@
MatterLinkApi

View File

@ -1,49 +0,0 @@
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
group 'moe.nikky'
version '1.0-SNAPSHOT'
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
languageVersion = "1.2"
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '+'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '+'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
idea {
module {
excludeDirs += [file("run")]
}
}

Binary file not shown.

View File

@ -1,5 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip

172
api/gradlew vendored
View File

@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
api/gradlew.bat vendored
View File

@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,2 +0,0 @@
rootProject.name = 'MatterLinkApi'

View File

@ -1,92 +0,0 @@
package matterlink.api
import com.google.gson.GsonBuilder
import com.google.gson.annotations.SerializedName
/**
* Created by nikky on 07/05/18.
*
* @author Nikky
* @version 1.0
*/
class ApiMessage (
username: String? = null,
text: String? = null,
gateway: String? = null,
channel: String? = null,
userid: String? = null,
avatar: String? = null,
account: String? = null,
protocol: String? = null,
event: String? = null,
id: String? = null
) {
@SerializedName("username") private var _username: String? = username
@SerializedName("text") private var _text: String? = text
@SerializedName("gateway") private var _gateway: String? = gateway
@SerializedName("channel") private var _channel: String? = channel
@SerializedName("userid") private var _userid: String? = userid
@SerializedName("avatar") private var _avatar: String? = avatar
@SerializedName("account") private var _account: String? = account
@SerializedName("protocol") private var _protocol: String? = protocol
@SerializedName("event") private var _event: String? = event
@SerializedName("id") private var _id: String? = id
var username: String
get() = _username ?: ""
set(username) { this._username = username }
var text: String
get() = _text ?: ""
set(text) { this._text = text }
var gateway: String
get() = _gateway ?: ""
set(gateway) { this._gateway = gateway }
var channel: String
get() = _channel ?: ""
set(channel) { this._channel = channel }
var userid: String
get() = _userid ?: ""
set(userid) { this._userid = userid }
var avatar: String
get() = _avatar ?: ""
set(avatar) { this._avatar = avatar }
var account: String
get() = _account ?: ""
set(account) { this._account = account }
var protocol: String
get() = _protocol ?: ""
set(protocol) { this._protocol = protocol }
var event: String
get() = _event ?: ""
set(event) { this._event = event }
var id: String
get() = _id ?: ""
set(id) { this._id = id }
fun encode(): String {
return gson.toJson(this)
}
override fun toString(): String = encode()
companion object {
val USER_ACTION = "user_action"
val JOIN_LEAVE = "join_leave"
private val gson = GsonBuilder()
.create()
fun decode(json: String): ApiMessage {
return gson.fromJson(json, ApiMessage::class.java)
}
}
}

View File

@ -1,16 +0,0 @@
package matterlink.api
data class Config (
var url: String = "",
var token: String = "",
var announceConnect: Boolean = true,
var announceDisconnect: Boolean = true,
var reconnectWait: Long = 500,
var systemUser: String = "Server"
)
{
fun sync(connection: StreamConnection) {
connection.token = token
connection.host = url
}
}

View File

@ -1,201 +0,0 @@
package matterlink.api
import org.apache.logging.log4j.Logger
import java.io.BufferedReader
import java.io.DataOutputStream
import java.io.IOException
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.MalformedURLException
import java.net.ProtocolException
import java.net.URL
import java.util.concurrent.ConcurrentLinkedQueue
/**
* Created by nikky on 07/05/18.
*
* @author Nikky
* @version 1.0
*/
open class MessageHandler {
private var enabled = false
private var connectErrors = 0
private var reconnectCooldown = 0
private var sendErrors = 0
var config: Config = Config()
set(value) {
field = value.apply {
sync(streamConnection)
}
}
//TODO: make callbacks: onConnect onDisconnect onError etc
var queue: ConcurrentLinkedQueue<ApiMessage> = ConcurrentLinkedQueue()
private set
private var streamConnection: StreamConnection = StreamConnection(queue)
var logger: Logger
get() = streamConnection.logger
set(l) {
streamConnection.logger = l
}
private var nextCheck: Long = 0
init {
streamConnection.addOnSuccess { success ->
if (success) {
logger.info("connected successfully")
connectErrors = 0
reconnectCooldown = 0
} else {
reconnectCooldown = connectErrors
connectErrors++
logger.error(String.format("connectErrors: %d", connectErrors))
}
}
}
fun stop(message: String? = null) {
if (message != null && config.announceDisconnect) {
sendStatusUpdate(message)
}
enabled = false
streamConnection.close()
}
fun start(message: String?, clear: Boolean) {
config.sync(streamConnection)
if (clear) {
clear()
}
enabled = true
streamConnection.open()
if (message != null && config.announceConnect) {
sendStatusUpdate(message)
}
}
private fun clear() {
try {
val url = URL(config.url + "/api/messages")
val conn = url.openConnection() as HttpURLConnection
if (!config.token.isEmpty()) {
val bearerAuth = "Bearer " + config.token
conn.setRequestProperty("Authorization", bearerAuth)
}
conn.requestMethod = "GET"
BufferedReader(InputStreamReader(conn.inputStream)).forEachLine { line ->
logger.trace("skipping $line")
}
} catch (e: MalformedURLException) {
e.printStackTrace()
} catch (e: ProtocolException) {
e.printStackTrace()
} catch (e: IOException) {
e.printStackTrace()
}
}
open fun sendStatusUpdate(message: String) {
transmit(ApiMessage(text = message))
}
open fun transmit(msg: ApiMessage) {
if (streamConnection.isConnected || streamConnection.isConnecting) {
if (msg.username.isEmpty())
msg.username = config.systemUser
if (msg.gateway.isEmpty()) {
logger.fatal("missing gateway on message: $msg")
return
}
logger.debug("Transmitting: $msg")
transmitMessage(msg)
}
}
private fun transmitMessage(message: ApiMessage) {
try {
val url = URL(config.url + "/api/message")
val conn = url.openConnection() as HttpURLConnection
if (!config.token.isEmpty()) {
val bearerAuth = "Bearer " + config.token
conn.setRequestProperty("Authorization", bearerAuth)
}
val postData = message.encode()
logger.trace(postData)
conn.requestMethod = "POST"
conn.setRequestProperty("Content-Type", "application/json")
conn.setRequestProperty("charset", "utf-8")
conn.setRequestProperty("Content-Length", "" + postData.toByteArray().size)
conn.doOutput = true
conn.doInput = true
DataOutputStream(conn.outputStream).use { wr -> wr.write(postData.toByteArray()) }
// conn.getInputStream().close();
conn.connect()
val code = conn.responseCode
if (code != 200) {
logger.error("Server returned $code")
sendErrors++
if (sendErrors > 5) {
logger.error("Interrupting Connection to matterbridge API due to status code $code")
stop()
}
} else {
sendErrors = 0
}
} catch (e: IOException) {
e.printStackTrace()
logger.error("sending message caused $e")
sendErrors++
if (sendErrors > 5) {
logger.error("Caught too many errors, closing bridge")
stop()
}
}
}
/**
* clll this method every tick / cycle to make sure it is reconnecting
*/
fun checkConnection() {
if (enabled && !streamConnection.isConnected && !streamConnection.isConnecting) {
logger.trace("check connection")
logger.trace("next: $nextCheck")
logger.trace("now: " + System.currentTimeMillis())
if (nextCheck > System.currentTimeMillis()) return
nextCheck = System.currentTimeMillis() + config.reconnectWait
if (connectErrors >= 10) {
logger.error("Caught too many errors, closing bridge")
stop("Interrupting connection to matterbridge API due to accumulated connection errors")
return
}
if (reconnectCooldown <= 0) {
logger.info("Trying to reconnect")
start("Reconnecting to matterbridge API after connection error", false)
} else {
reconnectCooldown--
}
}
}
}

View File

@ -1,150 +0,0 @@
package matterlink.api
import org.apache.logging.log4j.LogManager
import java.io.IOException
import java.io.InputStream
import java.net.ConnectException
import java.net.HttpURLConnection
import java.net.MalformedURLException
import java.net.URL
import java.util.Arrays
import java.util.LinkedList
import java.util.concurrent.ConcurrentLinkedQueue
/**
* Created by nikky on 07/05/18.
*
* @author Nikky
* @version 1.0
*/
class StreamConnection(private val rcvQueue: ConcurrentLinkedQueue<ApiMessage>) : Runnable {
private var thread: Thread = createThread()
private var urlConnection: HttpURLConnection? = null
private val onSuccessCallbacks = LinkedList<(Boolean) -> Unit>()
var logger = LogManager.getLogger("matterlink.api")
var host = ""
var token = ""
var isConnected = false
private set
var isConnecting = false
private set
var isCancelled = false
private set
private fun createThread(): Thread {
val thread = Thread(this)
thread.name = "RcvThread"
return thread
}
fun addOnSuccess(callback: (Boolean) -> Unit) {
onSuccessCallbacks.add(callback)
}
fun removeOnSuccess(callback: (Boolean) -> Unit) {
onSuccessCallbacks.remove(callback)
}
private fun onSuccess(success: Boolean) {
isConnecting = false
isConnected = success
for (callback in onSuccessCallbacks) {
callback(success)
}
}
override fun run() {
try {
val serviceURL = "$host/api/stream"
val myURL: URL
myURL = URL(serviceURL)
urlConnection = myURL.openConnection() as HttpURLConnection
urlConnection!!.requestMethod = "GET"
if (!token.isEmpty()) {
val bearerAuth = "Bearer $token"
urlConnection!!.setRequestProperty("Authorization", bearerAuth)
}
try {
urlConnection!!.inputStream.use { input ->
logger.info("connection opened")
onSuccess(true)
// BufferedInputStream bufferedInput = new BufferedInputStream(input, 8 * 1024);
val buffer = StringBuilder()
while (!isCancelled) {
val buf = ByteArray(1024)
Thread.sleep(10)
while (input.available() <= 0) {
if (isCancelled) break
Thread.sleep(10)
}
val chars = input.read(buf)
logger.trace( String.format("read %d chars", chars))
if (chars > 0) {
val added = String(Arrays.copyOfRange(buf, 0, chars))
logger.debug("DEBUG", "json: $added")
buffer.append(added)
while (buffer.toString().contains("\n")) {
val index = buffer.indexOf("\n")
val line = buffer.substring(0, index)
buffer.delete(0, index + 1)
rcvQueue.add(ApiMessage.decode(line))
}
} else if (chars < 0) {
break
}
}
}
} finally {
onClose()
}
} catch (e: MalformedURLException) {
e.printStackTrace()
} catch (e: ConnectException) {
e.printStackTrace()
onSuccess(false)
} catch (e: IOException) {
e.printStackTrace()
onSuccess(false)
} catch (e: InterruptedException) {
e.printStackTrace()
}
}
private fun onClose() {
logger.info("Bridge connection closed!")
isConnected = false
isConnecting = false
}
fun open() {
if (!thread.isAlive) {
thread = createThread()
isConnecting = true
isCancelled = false
thread.start()
logger.info("Starting Connection")
}
if (thread.isAlive) {
logger.info("Bridge is connecting")
}
}
fun close() {
try {
isCancelled = true
if (urlConnection != null) {
urlConnection!!.disconnect()
}
thread.join()
logger.info("Thread stopped")
} catch (e: InterruptedException) {
e.printStackTrace()
}
}
}

View File

@ -1,80 +0,0 @@
package matterlink.api
import com.google.gson.Gson
import com.google.gson.stream.JsonReader
import java.io.*
import java.util.Scanner
/**
* Created by nikky on 07/05/18.
*
* @author Nikky
* @version 1.0
*/
object Main {
@Throws(IOException::class)
@JvmStatic
fun main(vararg args: String) {
val handler = MessageHandler()
val queue = handler.queue
val config: Config
val gson = Gson()
try {
val reader = JsonReader(FileReader("config.json"))
config = gson.fromJson(reader, Config::class.java)
handler.config = config
} catch (e: FileNotFoundException) {
e.printStackTrace()
FileWriter("config.json").use { writer -> gson.toJson(handler.config, writer) }
}
// handler.logger = { level, msg -> System.out.printf("[%s] %s%n", level, msg) }
handler.start("Connecting..", true)
Thread {
while (true) {
val next = queue.poll()
if (next != null) {
println(next)
}
try {
Thread.sleep(200)
} catch (e: InterruptedException) {
e.printStackTrace()
}
}
}.start()
Thread {
while (true) {
handler.checkConnection()
try {
Thread.sleep(100)
} catch (e: InterruptedException) {
e.printStackTrace()
}
}
}.start()
val sc = Scanner(System.`in`)
while (true) {
val input = sc.nextLine()
when (input) {
"start" -> {
handler.start("start", false)
}
"stop" -> {
handler.stop("stop")
}
else -> {
handler.transmit(ApiMessage(text = input))
}
}
}
}
}

View File

@ -3,7 +3,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath group: "org.jetbrains.kotlin", name: "kotlin-gradle-plugin", version: kotlin_version classpath group: "org.jetbrains.kotlin", name: "kotlin-gradle-plugin", version: kotlinVersion
} }
} }
@ -17,10 +17,10 @@ subprojects {
apply plugin: "idea" apply plugin: "idea"
if (System.env.BUILD_NUMBER) { if (System.env.BUILD_NUMBER) {
mod_version += "-${System.env.BUILD_NUMBER}" modVersion += "-${System.env.BUILD_NUMBER}"
} else if (!project.hasProperty('release')) { } else if (!project.hasProperty('release')) {
// mod_version += "-dev" // modVersion += "-dev"
mod_version += "-dev" modVersion += "-dev"
} }
idea { idea {
@ -35,6 +35,10 @@ subprojects {
} }
repositories { repositories {
jcenter() jcenter()
maven {
name = "bintray"
url = 'http://jcenter.bintray.com'
}
maven { maven {
name = "elytradev" name = "elytradev"
url = 'http://unascribed.com/maven/releases' url = 'http://unascribed.com/maven/releases'

View File

@ -4,30 +4,31 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath group: "org.jetbrains.kotlin", name: "kotlin-gradle-plugin", version: kotlinVersion
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: 'com.vanniktech', name: 'gradle-dependency-graph-generator-plugin', version: '0.5.0'
} }
} }
apply plugin: 'kotlin' apply plugin: 'kotlin'
apply plugin: "com.github.johnrengelman.shadow" apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "com.vanniktech.dependency.graph.generator"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
dependencies { dependencies {
compile project(':api')
compile project(":Jankson") compile project(":Jankson")
shadow (project(':Jankson')) { transitive = false }
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '+' compile group: 'com.google.code.gson', name: 'gson', version: '+'
compile group: 'com.google.guava', name: 'guava', version: '+' compile group: 'com.google.guava', name: 'guava', version: '+'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '+' compile group: 'com.github.kittinunf.fuel', name: 'fuel', version: fuelVersion
shadow (group: 'com.github.kittinunf.fuel', name: 'fuel', version: fuelVersion) { transitive = false }
compile group: 'com.github.kittinunf.result', name: 'result', version: resultVersion
shadow (group: 'com.github.kittinunf.result', name: 'result', version: resultVersion) { transitive = false }
// compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: project.kotlin_version compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlinVersion
compile group: 'com.elytradev.concrete', name:'concrete-common', version: concrete_version
compile group: 'com.elytradev.concrete', name:'concrete-rulesengine', version: concrete_version
} }
compileKotlin { compileKotlin {
@ -39,13 +40,9 @@ compileKotlin {
shadowJar { shadowJar {
classifier = '' classifier = ''
dependencies {
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 'blue.endless', 'matterlink.repack.blue.endless'
relocate 'com.elytradev.concrete', 'matterlink.repack.com.elytradev.concrete' relocate 'com.github', 'matterlink.repack.com.github'
configurations = [project.configurations.shadow]
} }
//tasks.build.dependsOn shadowJar

View File

@ -1,42 +0,0 @@
package matterlink
import matterlink.HttpClientUtil.client
import org.apache.http.HttpResponse
import org.apache.http.client.methods.HttpGet
import org.apache.http.client.methods.HttpRequestBase
import org.apache.http.impl.client.HttpClientBuilder
/**
* Created by nikky on 15/07/18.
* @author Nikky
*/
object HttpClientUtil {
val client = HttpClientBuilder.create().build()
}
fun String.httpGet(): HttpGet =
HttpGet(this)
fun HttpGet.header(pair: Pair<String, String>): HttpGet = this.apply {
addHeader(pair.first, pair.second)
}
fun HttpGet.responseString(): Triple<HttpRequestBase, HttpResponse, Result> {
val response = client.execute(this)
val result = response.entity.content.bufferedReader().use { it.readText() }
return Triple(this, response, Result.Success(result))
}
sealed class Result {
class Success(
val value: String
) : Result()
class Failure(
val error: Throwable
) : Result()
}

View File

@ -7,12 +7,12 @@ import matterlink.bridge.command.IMinecraftCommandSender
import matterlink.config.BaseConfig import matterlink.config.BaseConfig
import matterlink.config.cfg import matterlink.config.cfg
import matterlink.update.UpdateChecker import matterlink.update.UpdateChecker
import org.apache.logging.log4j.Logger
import java.util.* import java.util.*
lateinit var instance: IMatterLink
lateinit var logger: Logger lateinit var logger: Logger
lateinit var instance: IMatterLink
abstract class IMatterLink { abstract class IMatterLink {
abstract val mcVersion: String abstract val mcVersion: String
abstract val modVersion: String abstract val modVersion: String
@ -29,6 +29,10 @@ abstract class IMatterLink {
abstract fun nameToUUID(username: String): UUID? abstract fun nameToUUID(username: String): UUID?
abstract fun uuidToName(uuid: UUID): String? abstract fun uuidToName(uuid: UUID): String?
init {
}
fun start() { fun start() {
// MessageHandlerInst.logger = { level, msg -> // MessageHandlerInst.logger = { level, msg ->
// when (level) { // when (level) {

View File

@ -0,0 +1,9 @@
package matterlink
interface Logger {
fun info(message: String)
fun debug(message: String)
fun error(message: String)
fun warn(message: String)
fun trace(message: String)
}

View File

@ -1,6 +1,6 @@
package matterlink.api package matterlink.api
import org.apache.logging.log4j.Logger import matterlink.Logger
import java.io.BufferedReader import java.io.BufferedReader
import java.io.DataOutputStream import java.io.DataOutputStream
import java.io.IOException import java.io.IOException
@ -118,7 +118,7 @@ open class MessageHandler {
if (msg.username.isEmpty()) if (msg.username.isEmpty())
msg.username = config.systemUser msg.username = config.systemUser
if (msg.gateway.isEmpty()) { if (msg.gateway.isEmpty()) {
logger.fatal("missing gateway on message: $msg") logger.error("missing gateway on message: $msg")
return return
} }
logger.debug("Transmitting: $msg") logger.debug("Transmitting: $msg")

View File

@ -1,6 +1,6 @@
package matterlink.api package matterlink.api
import org.apache.logging.log4j.LogManager import matterlink.Logger
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.net.ConnectException import java.net.ConnectException
@ -22,7 +22,13 @@ class StreamConnection(private val rcvQueue: ConcurrentLinkedQueue<ApiMessage>)
private var urlConnection: HttpURLConnection? = null private var urlConnection: HttpURLConnection? = null
private val onSuccessCallbacks = LinkedList<(Boolean) -> Unit>() private val onSuccessCallbacks = LinkedList<(Boolean) -> Unit>()
var logger = LogManager.getLogger("matterlink.api") var logger = object : Logger {
override fun info(message: String) = println("INFO: $message")
override fun debug(message: String) = println("DEBUG: $message")
override fun error(message: String) = println("ERROR: $message")
override fun warn(message: String) = println("WARN: $message")
override fun trace(message: String) = println("TRACE: $message")
}
var host = "" var host = ""
var token = "" var token = ""
@ -85,7 +91,7 @@ class StreamConnection(private val rcvQueue: ConcurrentLinkedQueue<ApiMessage>)
logger.trace( String.format("read %d chars", chars)) logger.trace( String.format("read %d chars", chars))
if (chars > 0) { if (chars > 0) {
val added = String(Arrays.copyOfRange(buf, 0, chars)) val added = String(Arrays.copyOfRange(buf, 0, chars))
logger.debug("DEBUG", "json: $added") logger.debug("json: $added")
buffer.append(added) buffer.append(added)
while (buffer.toString().contains("\n")) { while (buffer.toString().contains("\n")) {
val index = buffer.indexOf("\n") val index = buffer.indexOf("\n")

View File

@ -19,7 +19,7 @@ data class BaseConfig(val rootDir: File) {
val configFile: File = cfgDirectory.resolve("matterlink.hjson") val configFile: File = cfgDirectory.resolve("matterlink.hjson")
init { init {
logger.info("Reading bridge blueprints... from {}", rootDir) logger.info("Reading bridge blueprints... from $rootDir")
baseCfg = this baseCfg = this
} }

View File

@ -61,7 +61,7 @@ object ServerChatHandler {
ApiMessage.JOIN_LEAVE -> location.incoming.join_leave ?: defaults.join_leave ApiMessage.JOIN_LEAVE -> location.incoming.join_leave ?: defaults.join_leave
ApiMessage.USER_ACTION -> location.incoming.action ?: defaults.action ApiMessage.USER_ACTION -> location.incoming.action ?: defaults.action
else -> { else -> {
logger.fatal("unknwon event type '${nextMessage.event}' on incoming message") logger.error("unknown event type '${nextMessage.event}' on incoming message")
return return
} }
} }

View File

@ -1,11 +1,10 @@
package matterlink.jenkins package matterlink.jenkins
import com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.result.Result
import com.google.gson.Gson import com.google.gson.Gson
import matterlink.* import matterlink.logger
import matterlink.Result
import matterlink.header
import matterlink.httpGet
import matterlink.responseString
/** /**
* Created by nikky on 03/02/18. * Created by nikky on 03/02/18.

View File

@ -1,11 +1,9 @@
package matterlink.jenkins package matterlink.jenkins
import com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.result.Result
import com.google.gson.Gson import com.google.gson.Gson
import matterlink.Result
import matterlink.header
import matterlink.httpGet
import matterlink.responseString
import matterlink.logger import matterlink.logger
/** /**

View File

@ -4,6 +4,8 @@ import com.google.gson.GsonBuilder
import matterlink.api.ApiMessage import matterlink.api.ApiMessage
import matterlink.bridge.MessageHandlerInst import matterlink.bridge.MessageHandlerInst
import matterlink.config.cfg import matterlink.config.cfg
import matterlink.handlers.ChatEvent
import matterlink.handlers.LocationHandler
import matterlink.instance import matterlink.instance
import matterlink.logger import matterlink.logger
import matterlink.jenkins.JenkinsServer import matterlink.jenkins.JenkinsServer
@ -42,10 +44,11 @@ class UpdateChecker : Thread() {
number > instance.buildNumber -> { number > instance.buildNumber -> {
logger.warn("Mod out of date! New build $number available at $url") logger.warn("Mod out of date! New build $number available at $url")
val difference = number - build.number val difference = number - build.number
MessageHandlerInst.transmit( LocationHandler.sendToLocations(
ApiMessage( msg = "MatterLink out of date! You are $difference builds behind! Please download new version from $url",
text = "MatterLink out of date! You are $difference builds behind! Please download new version from $url" x = 0, y =0, z = 0, dimension = null,
) event = ChatEvent.STATUS,
cause = "MatterLink update notice"
) )
} }
number < instance.buildNumber -> logger.error("lastSuccessfulBuild: $number is older than installed build: ${instance.buildNumber}") number < instance.buildNumber -> logger.error("lastSuccessfulBuild: $number is older than installed build: ${instance.buildNumber}")
@ -130,7 +133,7 @@ class UpdateChecker : Thread() {
logger.info("Matterlink out of date! You are $count $version behind") logger.info("Matterlink out of date! You are $count $version behind")
possibleUpdates.forEach { possibleUpdates.forEach {
logger.info("version: {} download: {}", it.fileName, it.downloadURL) logger.info("version: ${it.fileName} download: ${it.downloadURL}")
} }
logger.warn("Mod out of date! New $version available at ${latest.downloadURL}") logger.warn("Mod out of date! New $version available at ${latest.downloadURL}")

View File

@ -1,9 +1,10 @@
mod_name = MatterLink modName = MatterLink
mod_version = 1.6.3 modVersion = 1.6.4
forgelin_version = 1.6.0 forgelinVersion = 1.6.0
concrete_version = 0.3.8-SNAPSHOT kotlinVersion = 1.2.41
kotlin_version = 1.2.41 shadowVersion = 2.0.2
shadow_version = 2.0.2 fuelVersion = 1.13.0
cursegradle_version = 1.0.10 resultVersion = 1.4.0
curse_id = 287323 cursegradleVersion = 1.0.10
curse_release_type = beta curseId = 287323
curseReleaseType = beta

19
scripts/start.sh Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
java -jar forge-installer.jar --installServer
FORGE_FILE=`grep "The server installed successfully, you should now be able to run the file " forge-installer.jar.log | tail -1`
FORGE_FILE=${FORGE_FILE#"The server installed successfully, you should now be able to run the file "}
echo FORGE_FILE
cp -f "$FORGE_FILE" forge.jar
echo "installed forge"
cp ../eula.txt .
mkdir -p config
rm -rf config/matterlink
cp -r ../matterlink_config config/matterlink
java -jar forge.jar

18
scripts/test12.sh Normal file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
RUN="$PWD/run/1.12.2"
rm -rf "$RUN/mods"
mkdir -p "$RUN/mods"
"$PWD/gradlew" :1.12.2:clean :1.12.2:build && cp -f 1.12.2/build/libs/MatterLink-1.12.2-*-dev.jar "$RUN/mods"
cd "$RUN"
curl -o forge-installer.jar "https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.12.2-14.23.4.2705/forge-1.12.2-14.23.4.2705-installer.jar"
curl -L -o "$RUN/mods/Forgelin.jar" "https://minecraft.curseforge.com/projects/shadowfacts-forgelin/files/2573311/download"
$DIR/scripts/start.sh

15
scripts/test7.sh Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
RUN="$PWD/run/1.7.10"
rm -rf "$RUN/mods"
mkdir -p "$RUN/mods"
"$PWD/gradlew" :1.7.10:clean :1.7.10:build && cp -f $DIR/1.7.10/build/libs/MatterLink-1.7.10-*-dev.jar "$RUN/mods"
cd "$RUN"
curl -o forge-installer.jar "https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-installer.jar"
$DIR/scripts/start.sh

18
scripts/test9.sh Normal file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
RUN="$PWD/run/1.9.4"
rm -rf "$RUN/mods"
mkdir -p "$RUN/mods"
"$PWD/gradlew" :1.9.4:clean :1.9.4:build && cp -f 1.9.4/build/libs/MatterLink-1.9.4-*-dev.jar "$RUN/mods"
cd "$RUN"
curl -o forge-installer.jar "https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.9.4-12.17.0.2051/forge-1.9.4-12.17.0.2051-installer.jar"
curl -L -o "$RUN/mods/Forgelin.jar" "https://minecraft.curseforge.com/projects/shadowfacts-forgelin/files/2505090/download" # "https://minecraft.curseforge.com/projects/shadowfacts-forgelin/files/2573311/download"
$DIR/scripts/start.sh

View File

@ -1,4 +1,4 @@
rootProject.name = 'MatterLink' rootProject.name = 'MatterLink'
include 'core', 'api' include 'core'
include 'Jankson' include 'Jankson'
include '1.12.2', '1.11.2', '1.10.2' include '1.12.2', '1.9.4', '1.7.10'