add 1.7.10

This commit is contained in:
NikkyAI 2018-02-17 23:51:58 +01:00
parent cfc677868a
commit 67d0aab64e
11 changed files with 375 additions and 3 deletions

89
1.7.10/build.gradle Normal file
View File

@ -0,0 +1,89 @@
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
mavenCentral()
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT"
}
}
apply plugin: 'forge'
version = project.mc_version + "-" + project.mod_version
archivesBaseName = project.mod_name
sourceCompatibility = targetCompatibility = '1.8'
configurations {
shade
compile.extendsFrom shade
}
dependencies {
shade project(":core")
}
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: com/google/gson matterlink/repack/com/google/gson"
srgExtra "PK: org/apache/commons matterlink/repack/org/apache/commons"
srgExtra "PK: org/apache/http matterlink/repack/org/apache/http"
srgExtra "PK: org/intelij matterlink/repack/org/intelij"
}
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.mod_version, 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.forgelin_version, 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')
}
}
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'
}
}
jar {
configurations.shade.each { dep ->
from (project.zipTree(dep)) {
exclude "META-INF", "META-INF/**"
}
}
}

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,93 @@
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.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.MinecraftServer
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
//FORGE-DEPENDENT
object EventHandler {
//MC-VERSION & FORGE DEPENDENT
@SubscribeEvent
fun progressEvent(e: AchievementEvent) {
ProgressHandler.handleProgress(
name = e.entityPlayer.displayName,
message = "has earned the achievement",
display = e.achievement.statName.unformattedText
)
}
//FORGE-DEPENDENT
@SubscribeEvent
fun chatEvent(e: ServerChatEvent) {
ChatProcessor.sendToBridge(
user = e.username,
msg = e.message,
event = ""
)
}
//FORGE-DEPENDENT
@SubscribeEvent
fun commandEvent(e: CommandEvent) {
val sender = when {
e.sender is EntityPlayer -> e.sender.commandSenderName
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
}
ChatProcessor.sendToBridge(user = sender, msg = args, event = type)
}
//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
)
}
}
//FORGE-DEPENDENT
@SubscribeEvent
fun joinEvent(e: PlayerEvent.PlayerLoggedInEvent) {
JoinLeaveHandler.handleJoin(e.player.displayName)
}
//FORGE-DEPENDENT
@SubscribeEvent
fun leaveEvent(e: PlayerEvent.PlayerLoggedOutEvent) {
JoinLeaveHandler.handleLeave(e.player.displayName)
}
//FORGE-DEPENDENT
@SubscribeEvent
fun serverTickEvent(e: TickEvent.ServerTickEvent) {
ServerChatHandler.writeIncomingToChat(MinecraftServer.getServer().tickCounter)
}
}

View File

@ -0,0 +1,72 @@
package matterlink
import cpw.mods.fml.common.Mod
import cpw.mods.fml.common.event.*
import matterlink.command.CommandMatterlink
import matterlink.command.IMinecraftCommandSender
import matterlink.command.MatterlinkCommandSender
import matterlink.config.cfg
import net.minecraft.server.MinecraftServer
import net.minecraft.util.ChatComponentText
import net.minecraftforge.common.MinecraftForge
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.Logger
lateinit var logger: Logger
@Mod(
modid = MODID,
name = NAME, version = MODVERSION,
useMetadata = true,
acceptableRemoteVersions = "*"
)
class MatterLink : IMatterLink() {
init {
instance = this
}
@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) {
MinecraftForge.EVENT_BUS.register(EventHandler)
logger = event.modLog
logger.info("Building bridge!")
cfg = MatterLinkConfig(event.suggestedConfigurationFile)
}
@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
this.registerBridgeCommands()
}
@Mod.EventHandler
fun serverStarting(event: FMLServerStartingEvent) {
logger.debug("Registering server commands")
event.registerServerCommand(CommandMatterlink())
serverStartTime = System.currentTimeMillis()
connect()
}
@Mod.EventHandler
fun serverStopping(event: FMLServerStoppingEvent) {
disconnect()
}
//FORGE-DEPENDENT
override fun wrappedSendToPlayers(msg: String) {
MinecraftServer.getServer().addChatMessage(ChatComponentText(msg));
}
//FORGE-DEPENDENT
override fun wrappedPlayerList(): Array<String> {
return MinecraftServer.getServer().allUsernames
}
override fun log(level: String, formatString: String, vararg data: Any) =
logger.log(Level.toLevel(level, Level.INFO),formatString, *data)
override var commandSender: IMinecraftCommandSender = MatterlinkCommandSender
override val mcVersion: String = MCVERSION
override val modVersion: String = MODVERSION
}

View File

@ -0,0 +1,25 @@
package matterlink
import matterlink.config.BaseConfig
import net.minecraftforge.common.config.Configuration
import java.io.File
class MatterLinkConfig(val file: File) : BaseConfig() {
init {
logger.info("Reading bridge blueprints... from {}", file)
val config = Configuration(file)
load(
getBoolean = config::getBoolean,
getString = config::getString,
getStringValidated = config::getString,
getStringValidValues = config::getString,
getStringList = config::getStringList,
addCustomCategoryComment = config::addCustomCategoryComment
)
if (config.hasChanged()) config.save()
}
override fun load() = MatterLinkConfig(file)
}

View File

@ -0,0 +1,33 @@
package matterlink.command
import net.minecraft.command.CommandBase
import net.minecraft.command.ICommandSender
import net.minecraft.command.WrongUsageException
import net.minecraft.util.ChatComponentText
class CommandMatterlink : CommandBase() {
override fun processCommand(sender: ICommandSender, args: Array<String>) {
if (args.isEmpty()) {
throw WrongUsageException("Invalid command! Valid uses: ${this.getCommandUsage(sender)}")
}
val reply = CommandCore.execute(args)
if (reply.isNotEmpty()) {
sender.addChatMessage(ChatComponentText(reply))
}
}
override fun getCommandName(): String {
return CommandCore.getName()
}
override fun getCommandUsage(sender: ICommandSender): String {
return CommandCore.getUsage()
}
override fun getCommandAliases(): List<String> {
return CommandCore.getAliases()
}
}

View File

@ -0,0 +1,50 @@
package matterlink.command
import matterlink.bridge.ApiMessage
import matterlink.bridge.MessageHandler
import matterlink.config.cfg
import net.minecraft.command.ICommandSender
import net.minecraft.entity.Entity
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
object MatterlinkCommandSender : IMinecraftCommandSender, ICommandSender {
private var level: Int = 0
override fun execute(cmdString: String, level: Int): Boolean {
return 0 < MinecraftServer.getServer().commandManager.executeCommand(
this,
cmdString
)
}
override fun getFormattedCommandSenderName(): IChatComponent {
return ChatComponentText(commandSenderName)
}
override fun getCommandSenderName(): String {
return "MatterLink"
}
override fun getEntityWorld(): World {
return MinecraftServer.getServer().worldServerForDimension(0)
}
override fun canCommandSenderUseCommand(permLevel: Int, commandName: String?): Boolean {
//TODO: Implement actual permissions checking
return true
}
override fun addChatMessage(component: IChatComponent) {
MessageHandler.transmit(ApiMessage(
username = cfg.relay.systemUser,
text = component.unformattedText
))
}
override fun getCommandSenderPosition(): ChunkCoordinates = ChunkCoordinates(0,0,0)
}

View File

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

View File

@ -13,7 +13,6 @@ abstract class IMatterLink {
abstract val modVersion: String
abstract var commandSender: IMinecraftCommandSender
//var interrupted: Boolean = false
abstract fun wrappedSendToPlayers(msg: String)

View File

@ -1,3 +1,3 @@
mod_name = MatterLink
mod_version = 1.3
mod_version = 1.3.1
forgelin_version = 1.6.0

View File

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