release 1.2.2

This commit is contained in:
NikkyAI 2018-02-11 16:33:19 +01:00
parent 1b82b037d6
commit bb0af143fd
14 changed files with 471 additions and 8 deletions

2
.gitignore vendored
View File

@ -27,3 +27,5 @@ run_server
#mac #mac
.DS_Store .DS_Store
*.hprof

92
1.10.2/build.gradle Normal file
View File

@ -0,0 +1,92 @@
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
mavenCentral()
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT"
}
}
plugins {
id "com.github.johnrengelman.shadow" version "1.2.4"
}
apply plugin: 'net.minecraftforge.gradle.forge'
version = mc_version + "-" + mod_version
archivesBaseName = "MatterLink"
sourceCompatibility = targetCompatibility = '1.8'
dependencies {
compile project(':core')
compile group: "net.shadowfacts", name: "Forgelin", version: "1.6.0"
}
shadowJar {
classifier ''
// configurations = [project.configurations.shadow]
relocate "org.apache.http", "matterlink.repack.org.apache.http"
relocate "org.apache.commons.logging", "matterlink.repack.org.apache.commons.logging"
dependencies {
include(project(":core"))
include(dependency("org.apache.httpcomponents:httpclient:4.3.3"))
include(dependency("org.apache.httpcomponents:httpcore:4.3.2"))
include(dependency('commons-logging:commons-logging:1.1.3'))
}
exclude 'dummyThing'
}
minecraft {
version = mc_version + "-" + forge_version
runDir = "run"
mappings = mcp_mappings
replaceIn 'MatterLink.kt'
replace '@VERSION@', mod_version
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.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.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.reobfShadowJar.mustRunAfter shadowJar

3
1.10.2/gradle.properties Normal file
View File

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

View File

@ -0,0 +1,97 @@
package matterlink
import matterlink.bridge.ServerChatHandler
import matterlink.bridge.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.server.dedicated.DedicatedServer
import net.minecraft.tileentity.TileEntityCommandBlock
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.FMLCommonHandler
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 EventWrapper {
//MC-VERSION & FORGE DEPENDENT
@SubscribeEvent
@JvmStatic
fun progressEvent(e: AchievementEvent) {
val name = e.entityPlayer.name
val text = "has earned the achievement ${e.achievement.statName.unformattedText}"
ProgressHandler.handleProgress(name, text)
}
//FORGE-DEPENDENT
@SubscribeEvent
@JvmStatic
fun chatEvent(e: ServerChatEvent) {
val user = e.username
val msg = e.message
ChatHandler.handleChat(user, msg)
}
//FORGE-DEPENDENT
@SubscribeEvent
@JvmStatic
fun commandEvent(e: CommandEvent) {
val sender =
when {
e.sender is EntityPlayer -> e.sender.name
e.sender is DedicatedServer -> cfg!!.relay.systemUser
e.sender is TileEntityCommandBlock -> "CommandBlock"
else -> return
}
val args = e.parameters.joinToString(" ")
val type = when {
e.command is CommandEmote -> USER_ACTION
e.command is CommandBroadcast -> ""
else -> return
}
CommandHandler.handleCommand(sender, args, type)
}
//FORGE-DEPENDENT
@SubscribeEvent
@JvmStatic
fun deathEvent(e: LivingDeathEvent) {
if (e.entityLiving is EntityPlayer) {
DeathHandler.handleDeath(
e.entityLiving.name,
e.entityLiving.combatTracker.deathMessage.unformattedText
)
}
}
//FORGE-DEPENDENT
@SubscribeEvent
@JvmStatic
fun joinEvent(e: PlayerEvent.PlayerLoggedInEvent) {
JoinLeaveHandler.handleJoin(e.player.name)
}
//FORGE-DEPENDENT
@SubscribeEvent
@JvmStatic
fun leaveEvent(e: PlayerEvent.PlayerLoggedOutEvent) {
JoinLeaveHandler.handleLeave(e.player.name)
}
//FORGE-DEPENDENT
@SubscribeEvent
@JvmStatic
fun serverTickEvent(e: TickEvent.ServerTickEvent) {
ServerChatHandler.writeIncomingToChat(FMLCommonHandler.instance().minecraftServerInstance.tickCounter)
}
}

View File

@ -0,0 +1,78 @@
package matterlink
import jline.internal.Log
import matterlink.bridge.MessageHandler
import matterlink.bridge.command.BridgeCommandRegistry
import matterlink.bridge.command.HelpCommand
import matterlink.bridge.command.PlayerListCommand
import matterlink.command.CommandMatterlink
import net.minecraft.util.text.TextComponentString
import net.minecraftforge.fml.common.FMLCommonHandler
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.*
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.Logger
const val MODID = "matterlink"
const val NAME = "MatterLink"
const val VERSION = "@VERSION@"
lateinit var logger: Logger
@Mod(
modid = MODID,
name = NAME, version = VERSION,
serverSideOnly = true,
useMetadata = true,
acceptableRemoteVersions = "*",
modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter"
)
object MatterLink : IMatterLink() {
init {
instance = this
}
@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) {
logger = event.modLog
logger.info("Building bridge!")
MatterLinkConfig(event.suggestedConfigurationFile)
}
@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
BridgeCommandRegistry.registerAll(PlayerListCommand, HelpCommand)
}
@Mod.EventHandler
fun serverAboutToStart(event: FMLServerAboutToStartEvent) {
// MessageHandler.start(clear = true)
}
@Mod.EventHandler
fun serverStarting(event: FMLServerStartingEvent) {
logger.debug("Registering server commands")
event.registerServerCommand(CommandMatterlink())
connect()
}
@Mod.EventHandler
fun serverStopping(event: FMLServerStoppingEvent) {
disconnect()
}
//FORGE-DEPENDENT
override fun wrappedSendToPlayers(msg: String) {
FMLCommonHandler.instance().minecraftServerInstance.playerList.sendChatMsg(TextComponentString(msg))
}
//FORGE-DEPENDENT
override fun wrappedPlayerList(): Array<String> {
return FMLCommonHandler.instance().minecraftServerInstance.playerList.onlinePlayerNames
}
override fun log(level: String, formatString: String, vararg data: Any) =
logger.log(Level.toLevel(level, Level.INFO),formatString, *data)
}

View File

@ -0,0 +1,128 @@
package matterlink
import matterlink.config.IMatterLinkConfig
import matterlink.config.cfg
import net.minecraftforge.common.config.Configuration
import java.io.File
import java.util.regex.Pattern
class MatterLinkConfig(file: File) : IMatterLinkConfig() {
init {
logger.info("Reading bridge blueprints... from {}", file)
val config = Configuration(file)
config.addCustomCategoryComment(CATEGORY_RELAY_OPTIONS, "Relay options")
relay = RelayOptions(
systemUser = config.getString(
"systemUser",
CATEGORY_RELAY_OPTIONS,
relay.systemUser,
"Name of the server user (used by death and advancement messages and the /say command)"
),
deathEvents = config.getBoolean(
"deathEvents",
CATEGORY_RELAY_OPTIONS,
relay.deathEvents,
"Relay player death messages"
),
advancements = config.getBoolean(
"advancements",
CATEGORY_RELAY_OPTIONS,
relay.advancements,
"Relay player advancements"
),
joinLeave = config.getBoolean(
"joinLeave",
CATEGORY_RELAY_OPTIONS,
relay.joinLeave,
"Relay when a player joins or leaves the game"
)
)
config.addCustomCategoryComment(CATEGORY_COMMAND, "User commands")
command = CommandOptions(
enable = config.getBoolean(
"enable",
CATEGORY_COMMAND,
command.enable,
"Enable MC bridge commands"
),
prefix = config.getString(
"prefix",
CATEGORY_COMMAND,
command.prefix,
"Prefix for MC bridge commands. Accepts a single character (not alphanumeric or /)",
Pattern.compile("^[^0-9A-Za-z/]$")
)
)
config.addCustomCategoryComment(CATEGORY_FORMATTING_INCOMING, "Gateway -> Server" +
"Formatting options: " +
"Available variables: {username}, {text}, {gateway}, {channel}, {protocol}, {username:antiping}")
formatting = FormattingOptions(
chat = config.getString(
"chat",
CATEGORY_FORMATTING_INCOMING,
formatting.chat,
"Generic chat event, just talking"
),
joinLeave = config.getString(
"joinLeave",
CATEGORY_FORMATTING_INCOMING,
formatting.joinLeave,
"Join and leave events from other gateways"
),
action = config.getString(
"action",
CATEGORY_FORMATTING_INCOMING,
formatting.action,
"User actions (/me) sent by users from other gateways"
)
)
config.addCustomCategoryComment(CATEGORY_FORMATTING_JOIN_LEAVE, "Server -> Gateway" +
"Formatting options: " +
"Available variables: {username}, {username:antiping}")
formattingJoinLeave = FormattingJoinLeave(
joinServer = config.getString(
"joinServer",
CATEGORY_FORMATTING_JOIN_LEAVE,
formattingJoinLeave.joinServer,
"user join message sent to other gateways, available variables: {username}, {username:antiping}"
),
leaveServer = config.getString(
"leaveServer",
CATEGORY_FORMATTING_JOIN_LEAVE,
formattingJoinLeave.leaveServer,
"user leave message sent to other gateways, available variables: {username}, {username:antiping}"
)
)
config.addCustomCategoryComment(CATEGORY_CONNECTION, "Connection settings")
connect = ConnectOptions(
url = config.getString(
"connectURL",
CATEGORY_CONNECTION,
connect.url,
"The URL or IP address of the bridge server"
),
authToken = config.getString(
"authToken",
CATEGORY_CONNECTION,
connect.authToken,
"Auth token used to connect to the bridge server"
),
gateway = config.getString(
"gateway",
CATEGORY_CONNECTION,
connect.gateway,
"MatterBridge gateway"
)
)
if (config.hasChanged()) config.save()
cfg = this
}
}

View File

@ -0,0 +1,53 @@
package matterlink.command
import com.google.common.collect.Lists
import matterlink.MODID
import matterlink.bridge.MessageHandler
import matterlink.bridge.ServerChatHandler
import matterlink.instance
import matterlink.logger
import net.minecraft.command.CommandBase
import net.minecraft.command.ICommandSender
import net.minecraft.server.MinecraftServer
class CommandMatterlink : CommandBase() {
private val aliases: List<String>
init {
aliases = Lists.newArrayList(MODID, "bridge", "BRIDGE")
}
override fun getName(): String {
return "bridge"
}
override fun getUsage(sender: ICommandSender): String {
return "bridge <connect|disconnect>"
}
override fun getAliases(): List<String> {
return aliases
}
override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<String>) /*throws CommandException*/ {
if (args.isEmpty()) {
//throw new WrongUsageException("")
return
}
//TODO: check if sender is OP or test if normal users cannot send this
val cmd = args[0].toLowerCase()
when (cmd) {
"connect" -> {
instance.connect()
}
"disconnect" -> {
instance.disconnect()
}
}
}
}

View File

@ -1,4 +1,3 @@
mc_version = 1.11.2 mc_version = 1.11.2
mcp_mappings = stable_32 mcp_mappings = stable_32
forge_version = 13.20.1.2386 forge_version = 13.20.1.2386
forgegradle_version = 2.3-SNAPSHOT

View File

@ -47,7 +47,7 @@ object MatterLink : IMatterLink() {
@Mod.EventHandler @Mod.EventHandler
fun serverAboutToStart(event: FMLServerAboutToStartEvent) { fun serverAboutToStart(event: FMLServerAboutToStartEvent) {
MessageHandler.start(clear = true) // MessageHandler.start(clear = true)
} }
@Mod.EventHandler @Mod.EventHandler

View File

@ -1,4 +1,3 @@
mc_version = 1.12.2 mc_version = 1.12.2
mcp_mappings = snapshot_20171003 mcp_mappings = snapshot_20171003
forge_version = 14.23.1.2599 forge_version = 14.23.1.2599
forgegradle_version = 2.3-SNAPSHOT

8
Jenkinsfile vendored
View File

@ -1,6 +1,14 @@
pipeline { pipeline {
agent any agent any
stages { stages {
stage("1.10.2") {
steps {
sh './gradlew :1.10.2:setupCiWorkspace'
sh './gradlew :1.10.2:clean'
sh './gradlew :1.10.2:build'
archive '1.10.2/build/libs/*jar'
}
}
stage("1.11.2") { stage("1.11.2") {
steps { steps {
sh './gradlew :1.11.2:setupCiWorkspace' sh './gradlew :1.11.2:setupCiWorkspace'

View File

@ -85,7 +85,7 @@ object MessageHandler {
// MessageHandler.transmit(ApiMessage(text="bridge closing", username="Server")) // MessageHandler.transmit(ApiMessage(text="bridge closing", username="Server"))
try { try {
streamConnection.close() streamConnection.close()
} catch(e: SocketException) { } catch (e: SocketException) {
instance.error("exception: $e") instance.error("exception: $e")
} }
} }
@ -97,8 +97,12 @@ object MessageHandler {
if (!streamConnection.isAlive) { if (!streamConnection.isAlive) {
connecting = true connecting = true
streamConnection.start() streamConnection.start()
// MessageHandler.transmit(ApiMessage(text="bridge connected", username="Server")) // MessageHandler.transmit(ApiMessage(text="bridge connected", username="Server"))
} }
if (streamConnection.isAlive) {
instance.info("Bridge Connection opened")
}
} }

View File

@ -1 +1 @@
mod_version = 1.2.1 mod_version = 1.2.2

View File

@ -1,2 +1,2 @@
rootProject.name = 'MatterLink' rootProject.name = 'MatterLink'
include 'core', '1.12.2', '1.11.2' include 'core', '1.12.2', '1.11.2', '1.10.2'