mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8
Conflicts: src/main/scala/li/cil/oc/Localization.scala src/main/scala/li/cil/oc/OpenComputers.scala src/main/scala/li/cil/oc/client/Proxy.scala src/main/scala/li/cil/oc/server/CommandHandler.scala
This commit is contained in:
commit
84d2eb63dc
@ -155,6 +155,7 @@ oc:gui.Analyzer.AddressCopied=Address copied to clipboard.
|
|||||||
oc:gui.Analyzer.ChargerSpeed=§6Charge speed§f: %s
|
oc:gui.Analyzer.ChargerSpeed=§6Charge speed§f: %s
|
||||||
oc:gui.Analyzer.ComponentName=§6Component name§f: %s
|
oc:gui.Analyzer.ComponentName=§6Component name§f: %s
|
||||||
oc:gui.Analyzer.Components=§6Number of connected components§f: %s
|
oc:gui.Analyzer.Components=§6Number of connected components§f: %s
|
||||||
|
oc:gui.Analyzer.CopyToClipboard=Click to copy to clipboard.
|
||||||
oc:gui.Analyzer.LastError=§6Last error§f: %s
|
oc:gui.Analyzer.LastError=§6Last error§f: %s
|
||||||
oc:gui.Analyzer.RobotName=§6Name§f: %s
|
oc:gui.Analyzer.RobotName=§6Name§f: %s
|
||||||
oc:gui.Analyzer.RobotOwner=§6Owner§f: %s
|
oc:gui.Analyzer.RobotOwner=§6Owner§f: %s
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package li.cil.oc
|
package li.cil.oc
|
||||||
|
|
||||||
|
import li.cil.oc.client.CommandHandler.SetClipboardCommand
|
||||||
|
import net.minecraft.event.ClickEvent
|
||||||
|
import net.minecraft.event.HoverEvent
|
||||||
import net.minecraft.util.ChatComponentText
|
import net.minecraft.util.ChatComponentText
|
||||||
import net.minecraft.util.ChatComponentTranslation
|
import net.minecraft.util.ChatComponentTranslation
|
||||||
import net.minecraft.util.StatCollector
|
import net.minecraft.util.StatCollector
|
||||||
@ -23,7 +26,12 @@ object Localization {
|
|||||||
def localizeImmediately(key: String) = StatCollector.translateToLocal(resolveKey(key)).split(nl).map(_.trim).mkString("\n")
|
def localizeImmediately(key: String) = StatCollector.translateToLocal(resolveKey(key)).split(nl).map(_.trim).mkString("\n")
|
||||||
|
|
||||||
object Analyzer {
|
object Analyzer {
|
||||||
def Address(value: String) = localizeLater("gui.Analyzer.Address", value)
|
def Address(value: String) = {
|
||||||
|
val result = localizeLater("gui.Analyzer.Address", value)
|
||||||
|
result.getChatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, s"/${SetClipboardCommand.name} $value"))
|
||||||
|
result.getChatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, localizeLater("gui.Analyzer.CopyToClipboard")))
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
def AddressCopied = localizeLater("gui.Analyzer.AddressCopied")
|
def AddressCopied = localizeLater("gui.Analyzer.AddressCopied")
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package li.cil.oc
|
|||||||
|
|
||||||
import li.cil.oc.common.IMC
|
import li.cil.oc.common.IMC
|
||||||
import li.cil.oc.common.Proxy
|
import li.cil.oc.common.Proxy
|
||||||
import li.cil.oc.server.CommandHandler
|
import li.cil.oc.server.command.CommandHandler
|
||||||
import net.minecraftforge.fml.common.Mod
|
import net.minecraftforge.fml.common.Mod
|
||||||
import net.minecraftforge.fml.common.Mod.EventHandler
|
import net.minecraftforge.fml.common.Mod.EventHandler
|
||||||
import net.minecraftforge.fml.common.SidedProxy
|
import net.minecraftforge.fml.common.SidedProxy
|
||||||
|
31
src/main/scala/li/cil/oc/client/CommandHandler.scala
Normal file
31
src/main/scala/li/cil/oc/client/CommandHandler.scala
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package li.cil.oc.client
|
||||||
|
|
||||||
|
import li.cil.oc.common.command.SimpleCommand
|
||||||
|
import net.minecraft.client.gui.GuiScreen
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
import net.minecraftforge.client.ClientCommandHandler
|
||||||
|
|
||||||
|
object CommandHandler {
|
||||||
|
def register(): Unit = {
|
||||||
|
ClientCommandHandler.instance.registerCommand(SetClipboardCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
object SetClipboardCommand extends SimpleCommand("oc_setclipboard") {
|
||||||
|
override def getCommandUsage(source: ICommandSender): String = name + " <value>"
|
||||||
|
|
||||||
|
override def execute(source: ICommandSender, command: Array[String]): Unit = {
|
||||||
|
if (source.getEntityWorld.isRemote && command != null && command.length > 0) {
|
||||||
|
GuiScreen.setClipboardString(command(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OP levels for reference:
|
||||||
|
// 1 - Ops can bypass spawn protection.
|
||||||
|
// 2 - Ops can use /clear, /difficulty, /effect, /gamemode, /gamerule, /give, /summon, /setblock and /tp, and can edit command blocks.
|
||||||
|
// 3 - Ops can use /ban, /deop, /kick, and /op.
|
||||||
|
// 4 - Ops can use /stop.
|
||||||
|
|
||||||
|
override def getRequiredPermissionLevel = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,6 +34,8 @@ private[oc] class Proxy extends CommonProxy {
|
|||||||
|
|
||||||
api.API.manual = client.Manual
|
api.API.manual = client.Manual
|
||||||
|
|
||||||
|
CommandHandler.register()
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(Textures)
|
MinecraftForge.EVENT_BUS.register(Textures)
|
||||||
|
|
||||||
ModelInitialization.preInit()
|
ModelInitialization.preInit()
|
||||||
|
22
src/main/scala/li/cil/oc/common/command/SimpleCommand.scala
Normal file
22
src/main/scala/li/cil/oc/common/command/SimpleCommand.scala
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package li.cil.oc.common.command
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandBase
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
import net.minecraft.util.BlockPos
|
||||||
|
|
||||||
|
import scala.collection.convert.WrapAsJava._
|
||||||
|
import scala.collection.mutable
|
||||||
|
|
||||||
|
abstract class SimpleCommand(val name: String) extends CommandBase {
|
||||||
|
protected var aliases = mutable.ListBuffer.empty[String]
|
||||||
|
|
||||||
|
override def getName = name
|
||||||
|
|
||||||
|
override def getAliases = aliases
|
||||||
|
|
||||||
|
override def canCommandSenderUse(source: ICommandSender) = true
|
||||||
|
|
||||||
|
override def isUsernameIndex(command: Array[String], i: Int) = false
|
||||||
|
|
||||||
|
override def addTabCompletionOptions(source: ICommandSender, command: Array[String], pos: BlockPos) = List.empty[AnyRef]
|
||||||
|
}
|
@ -3,6 +3,7 @@ package li.cil.oc.common.template
|
|||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
import com.google.common.base.Strings
|
import com.google.common.base.Strings
|
||||||
|
import li.cil.oc.OpenComputers
|
||||||
import li.cil.oc.api
|
import li.cil.oc.api
|
||||||
import li.cil.oc.api.driver.EnvironmentHost
|
import li.cil.oc.api.driver.EnvironmentHost
|
||||||
import li.cil.oc.common.IMC
|
import li.cil.oc.common.IMC
|
||||||
@ -74,7 +75,11 @@ object AssemblerTemplates {
|
|||||||
def validate(inventory: IInventory, slot: Int, stack: ItemStack) = validator match {
|
def validate(inventory: IInventory, slot: Int, stack: ItemStack) = validator match {
|
||||||
case Some(method) => IMC.tryInvokeStatic(method, inventory, slot.underlying(), tier.underlying(), stack)(false)
|
case Some(method) => IMC.tryInvokeStatic(method, inventory, slot.underlying(), tier.underlying(), stack)(false)
|
||||||
case _ => Option(hostClass.fold(api.Driver.driverFor(stack))(api.Driver.driverFor(stack, _))) match {
|
case _ => Option(hostClass.fold(api.Driver.driverFor(stack))(api.Driver.driverFor(stack, _))) match {
|
||||||
case Some(driver) => driver.slot(stack) == kind && driver.tier(stack) <= tier
|
case Some(driver) => try driver.slot(stack) == kind && driver.tier(stack) <= tier catch {
|
||||||
|
case t: AbstractMethodError =>
|
||||||
|
OpenComputers.log.warn(s"Error trying to query driver '${driver.getClass.getName}' for slot and/or tier information. Probably their fault. Yell at them before coming to OpenComputers for support. :P")
|
||||||
|
false
|
||||||
|
}
|
||||||
case _ => false
|
case _ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
package li.cil.oc.server
|
|
||||||
|
|
||||||
import li.cil.oc.Settings
|
|
||||||
import net.minecraft.command.CommandBase
|
|
||||||
import net.minecraft.command.ICommandSender
|
|
||||||
import net.minecraft.command.WrongUsageException
|
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
|
||||||
import net.minecraft.util.BlockPos
|
|
||||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent
|
|
||||||
|
|
||||||
import scala.collection.convert.wrapAsJava._
|
|
||||||
import scala.collection.mutable
|
|
||||||
|
|
||||||
object CommandHandler {
|
|
||||||
def register(e: FMLServerStartingEvent) {
|
|
||||||
e.registerServerCommand(WirelessRenderingCommand)
|
|
||||||
e.registerServerCommand(NonDisassemblyAgreementCommand)
|
|
||||||
}
|
|
||||||
|
|
||||||
// OP levels for reference:
|
|
||||||
// 1 - Ops can bypass spawn protection.
|
|
||||||
// 2 - Ops can use /clear, /difficulty, /effect, /gamemode, /gamerule, /give, /summon, /setblock and /tp, and can edit command blocks.
|
|
||||||
// 3 - Ops can use /ban, /deop, /kick, and /op.
|
|
||||||
// 4 - Ops can use /stop.
|
|
||||||
|
|
||||||
object WirelessRenderingCommand extends SimpleCommand("oc_renderWirelessNetwork") {
|
|
||||||
aliases += "oc_wlan"
|
|
||||||
|
|
||||||
override def getCommandUsage(source: ICommandSender) = name + " <boolean>"
|
|
||||||
|
|
||||||
override def execute(sender: ICommandSender, command: Array[String]) {
|
|
||||||
Settings.rTreeDebugRenderer =
|
|
||||||
if (command != null && command.length > 0)
|
|
||||||
CommandBase.parseBoolean(command(0))
|
|
||||||
else
|
|
||||||
!Settings.rTreeDebugRenderer
|
|
||||||
}
|
|
||||||
|
|
||||||
override def getRequiredPermissionLevel = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
object NonDisassemblyAgreementCommand extends SimpleCommand("oc_preventDisassembling") {
|
|
||||||
aliases += "oc_nodis"
|
|
||||||
aliases += "oc_prevdis"
|
|
||||||
|
|
||||||
override def getCommandUsage(source: ICommandSender) = name + " <boolean>"
|
|
||||||
|
|
||||||
override def execute(sender: ICommandSender, command: Array[String]) {
|
|
||||||
sender match {
|
|
||||||
case player: EntityPlayer =>
|
|
||||||
val stack = player.getHeldItem
|
|
||||||
if (stack != null) {
|
|
||||||
if (!stack.hasTagCompound) {
|
|
||||||
stack.setTagCompound(new NBTTagCompound())
|
|
||||||
}
|
|
||||||
val nbt = stack.getTagCompound
|
|
||||||
val preventDisassembly =
|
|
||||||
if (command != null && command.length > 0)
|
|
||||||
CommandBase.parseBoolean(command(0))
|
|
||||||
else
|
|
||||||
!nbt.getBoolean(Settings.namespace + "undisassemblable")
|
|
||||||
if (preventDisassembly)
|
|
||||||
nbt.setBoolean(Settings.namespace + "undisassemblable", true)
|
|
||||||
else
|
|
||||||
nbt.removeTag(Settings.namespace + "undisassemblable")
|
|
||||||
if (nbt.hasNoTags) stack.setTagCompound(null)
|
|
||||||
}
|
|
||||||
case _ => throw new WrongUsageException("Can only be used by players.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override def getRequiredPermissionLevel = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class SimpleCommand(val name: String) extends CommandBase {
|
|
||||||
protected var aliases = mutable.ListBuffer.empty[String]
|
|
||||||
|
|
||||||
override def getName = name
|
|
||||||
|
|
||||||
override def getAliases = aliases
|
|
||||||
|
|
||||||
override def canCommandSenderUse(sender: ICommandSender) = true
|
|
||||||
|
|
||||||
override def addTabCompletionOptions(sender: ICommandSender, args: Array[String], pos: BlockPos) = List.empty[AnyRef]
|
|
||||||
|
|
||||||
override def isUsernameIndex(command: Array[String], i: Int) = false
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
10
src/main/scala/li/cil/oc/server/command/CommandHandler.scala
Normal file
10
src/main/scala/li/cil/oc/server/command/CommandHandler.scala
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package li.cil.oc.server.command
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.common.event.FMLServerStartingEvent
|
||||||
|
|
||||||
|
object CommandHandler {
|
||||||
|
def register(e: FMLServerStartingEvent) {
|
||||||
|
e.registerServerCommand(WirelessRenderingCommand)
|
||||||
|
e.registerServerCommand(NonDisassemblyAgreementCommand)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package li.cil.oc.server.command
|
||||||
|
|
||||||
|
import li.cil.oc.Settings
|
||||||
|
import li.cil.oc.common.command.SimpleCommand
|
||||||
|
import net.minecraft.command.CommandBase
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
import net.minecraft.command.WrongUsageException
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
|
||||||
|
object NonDisassemblyAgreementCommand extends SimpleCommand("oc_preventDisassembling") {
|
||||||
|
aliases += "oc_nodis"
|
||||||
|
aliases += "oc_prevdis"
|
||||||
|
|
||||||
|
override def getCommandUsage(source: ICommandSender) = name + " <boolean>"
|
||||||
|
|
||||||
|
override def execute(source: ICommandSender, command: Array[String]) {
|
||||||
|
source match {
|
||||||
|
case player: EntityPlayer =>
|
||||||
|
val stack = player.getHeldItem
|
||||||
|
if (stack != null) {
|
||||||
|
if (!stack.hasTagCompound) {
|
||||||
|
stack.setTagCompound(new NBTTagCompound())
|
||||||
|
}
|
||||||
|
val nbt = stack.getTagCompound
|
||||||
|
val preventDisassembly =
|
||||||
|
if (command != null && command.length > 0)
|
||||||
|
CommandBase.parseBoolean(command(0))
|
||||||
|
else
|
||||||
|
!nbt.getBoolean(Settings.namespace + "undisassemblable")
|
||||||
|
if (preventDisassembly)
|
||||||
|
nbt.setBoolean(Settings.namespace + "undisassemblable", true)
|
||||||
|
else
|
||||||
|
nbt.removeTag(Settings.namespace + "undisassemblable")
|
||||||
|
if (nbt.hasNoTags) stack.setTagCompound(null)
|
||||||
|
}
|
||||||
|
case _ => throw new WrongUsageException("Can only be used by players.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OP levels for reference:
|
||||||
|
// 1 - Ops can bypass spawn protection.
|
||||||
|
// 2 - Ops can use /clear, /difficulty, /effect, /gamemode, /gamerule, /give, /summon, /setblock and /tp, and can edit command blocks.
|
||||||
|
// 3 - Ops can use /ban, /deop, /kick, and /op.
|
||||||
|
// 4 - Ops can use /stop.
|
||||||
|
|
||||||
|
override def getRequiredPermissionLevel = 2
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package li.cil.oc.server.command
|
||||||
|
|
||||||
|
import li.cil.oc.Settings
|
||||||
|
import li.cil.oc.common.command.SimpleCommand
|
||||||
|
import net.minecraft.command.CommandBase
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
|
||||||
|
object WirelessRenderingCommand extends SimpleCommand("oc_renderWirelessNetwork") {
|
||||||
|
aliases += "oc_wlan"
|
||||||
|
|
||||||
|
override def getCommandUsage(source: ICommandSender) = name + " <boolean>"
|
||||||
|
|
||||||
|
override def execute(source: ICommandSender, command: Array[String]) {
|
||||||
|
Settings.rTreeDebugRenderer =
|
||||||
|
if (command != null && command.length > 0)
|
||||||
|
CommandBase.parseBoolean(command(0))
|
||||||
|
else
|
||||||
|
!Settings.rTreeDebugRenderer
|
||||||
|
}
|
||||||
|
|
||||||
|
// OP levels for reference:
|
||||||
|
// 1 - Ops can bypass spawn protection.
|
||||||
|
// 2 - Ops can use /clear, /difficulty, /effect, /gamemode, /gamerule, /give, /summon, /setblock and /tp, and can edit command blocks.
|
||||||
|
// 3 - Ops can use /ban, /deop, /kick, and /op.
|
||||||
|
// 4 - Ops can use /stop.
|
||||||
|
|
||||||
|
override def getRequiredPermissionLevel = 2
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user