mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8
Conflicts: src/main/scala/li/cil/oc/server/component/DebugCard.scala
This commit is contained in:
commit
0b0ce644c7
@ -1,9 +1,18 @@
|
|||||||
|
local version = "OpenLoader 0.2EE"
|
||||||
|
|
||||||
local eeprom = [[
|
local eeprom = [[
|
||||||
_G._OSVERSION = "OpenLoader 0.1EE"
|
_G._OSVERSION = "]] .. version .. [["
|
||||||
local component = component or require('component')
|
local component = component or require('component')
|
||||||
local computer = computer or require('computer')
|
local computer = computer or require('computer')
|
||||||
local unicode = unicode or require('unicode')
|
local unicode = unicode or require('unicode')
|
||||||
|
|
||||||
|
local eeprom = component.list("eeprom")()
|
||||||
|
computer.getBootAddress = function()
|
||||||
|
return component.invoke(eeprom, "getData")
|
||||||
|
end
|
||||||
|
computer.setBootAddress = function(address)
|
||||||
|
return component.invoke(eeprom, "setData", address)
|
||||||
|
end
|
||||||
|
|
||||||
local gpu = component.list("gpu")()
|
local gpu = component.list("gpu")()
|
||||||
local w, h
|
local w, h
|
||||||
@ -147,7 +156,7 @@ say ("Do you really want to flash openloader to EEPROM("..tostring(#eeprom).." b
|
|||||||
if options.q or options.quiet or io.read():lower() == "y" then
|
if options.q or options.quiet or io.read():lower() == "y" then
|
||||||
say("Flashing... Do not reboot now!")
|
say("Flashing... Do not reboot now!")
|
||||||
component.eeprom.set(eeprom)
|
component.eeprom.set(eeprom)
|
||||||
component.eeprom.setLabel((type(options.label) == "string" and options.label) or "OpenLoader")
|
component.eeprom.setLabel((type(options.label) == "string" and options.label) or version)
|
||||||
if options.r or options.reboot then
|
if options.r or options.reboot then
|
||||||
computer.shutdown(true)
|
computer.shutdown(true)
|
||||||
else
|
else
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
_G._OSVERSION = "OpenLoader 0.1"
|
_G._OSVERSION = "OpenLoader 0.2"
|
||||||
local component = component or require('component')
|
local component = component or require('component')
|
||||||
local computer = computer or require('computer')
|
local computer = computer or require('computer')
|
||||||
local unicode = unicode or require('unicode')
|
local unicode = unicode or require('unicode')
|
||||||
|
|
||||||
|
local eeprom = component.list("eeprom")()
|
||||||
|
computer.getBootAddress = function()
|
||||||
|
return component.invoke(eeprom, "getData")
|
||||||
|
end
|
||||||
|
computer.setBootAddress = function(address)
|
||||||
|
return component.invoke(eeprom, "setData", address)
|
||||||
|
end
|
||||||
|
|
||||||
local gpu = component.list("gpu")()
|
local gpu = component.list("gpu")()
|
||||||
local w, h
|
local w, h
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
local event = require "event"
|
||||||
|
local component = require "component"
|
||||||
|
local keyboard = require "keyboard"
|
||||||
|
|
||||||
|
local interactive = io.output() == io.stdout
|
||||||
|
local color, isPal, evt
|
||||||
|
if interactive then
|
||||||
|
color, isPal = component.gpu.getForeground()
|
||||||
|
end
|
||||||
|
io.write("Press 'q' to exit\n")
|
||||||
|
pcall(function()
|
||||||
|
repeat
|
||||||
|
evt = table.pack(event.pull())
|
||||||
|
if interactive then component.gpu.setForeground(0xCC2200) end
|
||||||
|
io.write("[" .. os.date("%T") .. "] ")
|
||||||
|
if interactive then component.gpu.setForeground(0x44CC00) end
|
||||||
|
io.write(tostring(evt[1]) .. string.rep(" ", math.max(10 - #tostring(evt[1]), 0) + 1))
|
||||||
|
if interactive then component.gpu.setForeground(0xB0B00F) end
|
||||||
|
io.write(tostring(evt[2]) .. string.rep(" ", 37 - #tostring(evt[2])))
|
||||||
|
if interactive then component.gpu.setForeground(0xFFFFFF) end
|
||||||
|
if evt.n > 2 then
|
||||||
|
for i = 3, evt.n do
|
||||||
|
io.write(" " .. tostring(evt[i]))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
io.write("\n")
|
||||||
|
until evt[1] == "key_down" and evt[4] == keyboard.keys.q
|
||||||
|
end)
|
||||||
|
if interactive then
|
||||||
|
component.gpu.setForeground(color, isPal)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
NAME
|
||||||
|
dmesg - display messages(events)
|
||||||
|
|
||||||
|
SYNOPIS
|
||||||
|
dmesg
|
||||||
|
|
@ -78,7 +78,7 @@ class RobotProxy extends RedstoneAware with traits.StateAware {
|
|||||||
val components = info.containers ++ info.components
|
val components = info.containers ++ info.components
|
||||||
if (components.length > 0) {
|
if (components.length > 0) {
|
||||||
tooltip.addAll(Tooltip.get("Server.Components"))
|
tooltip.addAll(Tooltip.get("Server.Components"))
|
||||||
for (component <- components) {
|
for (component <- components if component != null) {
|
||||||
tooltip.add("- " + component.getDisplayName)
|
tooltip.add("- " + component.getDisplayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,8 @@ class Raid extends traits.Environment with traits.Inventory with traits.Rotatabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
def tryCreateRaid(id: String) {
|
def tryCreateRaid(id: String) {
|
||||||
if (items.count(_.isDefined) == items.length) {
|
if (items.count(_.isDefined) == items.length && filesystem.fold(true)(fs => fs.node == null || fs.node.address != id)) {
|
||||||
|
filesystem.foreach(fs => if (fs.node != null) fs.node.remove())
|
||||||
val fs = api.FileSystem.asManagedEnvironment(
|
val fs = api.FileSystem.asManagedEnvironment(
|
||||||
api.FileSystem.fromSaveDirectory(id, wipeDisksAndComputeSpace, Settings.get.bufferChanges),
|
api.FileSystem.fromSaveDirectory(id, wipeDisksAndComputeSpace, Settings.get.bufferChanges),
|
||||||
label, this, Settings.resourceDomain + ":hdd_access").
|
label, this, Settings.resourceDomain + ":hdd_access").
|
||||||
|
@ -737,8 +737,8 @@ class Robot extends traits.Computer with traits.PowerInformation with traits.Rot
|
|||||||
player().inventory.addItemStackToInventory(stack)
|
player().inventory.addItemStackToInventory(stack)
|
||||||
spawnStackInWorld(stack, Option(facing))
|
spawnStackInWorld(stack, Option(facing))
|
||||||
}
|
}
|
||||||
} // else: save is screwed and we potentially lose items. Life is hard.
|
|
||||||
setSelectedSlot(oldSelected)
|
setSelectedSlot(oldSelected)
|
||||||
|
} // else: save is screwed and we potentially lose items. Life is hard.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -21,7 +21,6 @@ import li.cil.oc.util.ExtendedWorld._
|
|||||||
import li.cil.oc.util.InventoryUtils
|
import li.cil.oc.util.InventoryUtils
|
||||||
import net.minecraft.block.Block
|
import net.minecraft.block.Block
|
||||||
import net.minecraft.command.CommandResultStats.Type
|
import net.minecraft.command.CommandResultStats.Type
|
||||||
import net.minecraft.command.ICommandSender
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP
|
import net.minecraft.entity.player.EntityPlayerMP
|
||||||
import net.minecraft.item.Item
|
import net.minecraft.item.Item
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
@ -36,11 +35,13 @@ import net.minecraft.world.World
|
|||||||
import net.minecraft.world.WorldServer
|
import net.minecraft.world.WorldServer
|
||||||
import net.minecraft.world.WorldSettings.GameType
|
import net.minecraft.world.WorldSettings.GameType
|
||||||
import net.minecraftforge.common.DimensionManager
|
import net.minecraftforge.common.DimensionManager
|
||||||
|
import net.minecraftforge.common.util.FakePlayer
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory
|
import net.minecraftforge.common.util.FakePlayerFactory
|
||||||
import net.minecraftforge.fluids.FluidRegistry
|
import net.minecraftforge.fluids.FluidRegistry
|
||||||
import net.minecraftforge.fluids.FluidStack
|
import net.minecraftforge.fluids.FluidStack
|
||||||
import net.minecraftforge.fluids.IFluidHandler
|
import net.minecraftforge.fluids.IFluidHandler
|
||||||
|
|
||||||
|
import scala.collection.convert.WrapAsScala._
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
||||||
class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment {
|
class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment {
|
||||||
@ -58,6 +59,17 @@ class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment {
|
|||||||
// Player this card is bound to (if any) to use for permissions.
|
// Player this card is bound to (if any) to use for permissions.
|
||||||
var player: Option[String] = None
|
var player: Option[String] = None
|
||||||
|
|
||||||
|
private lazy val CommandSender = {
|
||||||
|
def defaultFakePlayer = FakePlayerFactory.get(host.world.asInstanceOf[WorldServer], Settings.get.fakePlayerProfile)
|
||||||
|
new CommandSender(host, player match {
|
||||||
|
case Some(name) => Option(MinecraftServer.getServer.getConfigurationManager.getPlayerByUsername(name)) match {
|
||||||
|
case Some(playerEntity) => playerEntity
|
||||||
|
case _ => defaultFakePlayer
|
||||||
|
}
|
||||||
|
case _ => defaultFakePlayer
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
import li.cil.oc.server.component.DebugCard.checkEnabled
|
import li.cil.oc.server.component.DebugCard.checkEnabled
|
||||||
@ -101,10 +113,18 @@ class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment {
|
|||||||
@Callback(doc = """function(command:string):number -- Runs an arbitrary command using a fake player.""")
|
@Callback(doc = """function(command:string):number -- Runs an arbitrary command using a fake player.""")
|
||||||
def runCommand(context: Context, args: Arguments): Array[AnyRef] = {
|
def runCommand(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
checkEnabled()
|
checkEnabled()
|
||||||
val command = args.checkString(0)
|
val commands =
|
||||||
val sender = new CommandSender(host, player)
|
if (args.isTable(0)) collectionAsScalaIterable(args.checkTable(0).values())
|
||||||
val value = MinecraftServer.getServer.getCommandManager.executeCommand(sender, command)
|
else Iterable(args.checkString(0))
|
||||||
result(value, sender.messages.orNull)
|
|
||||||
|
CommandSender.synchronized {
|
||||||
|
CommandSender.prepare()
|
||||||
|
var value = 0
|
||||||
|
for (command <- commands) {
|
||||||
|
value = MinecraftServer.getServer.getCommandManager.executeCommand(CommandSender, command.toString)
|
||||||
|
}
|
||||||
|
result(value, CommandSender.messages.orNull)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):boolean -- Connect the debug card to the block at the specified coordinates.""")
|
@Callback(doc = """function(x:number, y:number, z:number):boolean -- Connect the debug card to the block at the specified coordinates.""")
|
||||||
@ -498,37 +518,34 @@ object DebugCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommandSender(val host: EnvironmentHost, val playerName: Option[String]) extends ICommandSender {
|
class CommandSender(val host: EnvironmentHost, val underlying: EntityPlayerMP) extends FakePlayer(underlying.getEntityWorld.asInstanceOf[WorldServer], underlying.getGameProfile) {
|
||||||
val fakePlayer = {
|
|
||||||
def defaultFakePlayer = FakePlayerFactory.get(host.world.asInstanceOf[WorldServer], Settings.get.fakePlayerProfile)
|
|
||||||
playerName match {
|
|
||||||
case Some(name) => Option(MinecraftServer.getServer.getConfigurationManager.getPlayerByUsername(name)) match {
|
|
||||||
case Some(player) => player
|
|
||||||
case _ => defaultFakePlayer
|
|
||||||
}
|
|
||||||
case _ => defaultFakePlayer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var messages: Option[String] = None
|
var messages: Option[String] = None
|
||||||
|
|
||||||
override def getName = fakePlayer.getName
|
def prepare(): Unit = {
|
||||||
|
val blockPos = BlockPosition(host)
|
||||||
|
posX = blockPos.x
|
||||||
|
posY = blockPos.y
|
||||||
|
posZ = blockPos.z
|
||||||
|
messages = None
|
||||||
|
}
|
||||||
|
|
||||||
|
override def getName = underlying.getName
|
||||||
|
|
||||||
override def getEntityWorld = host.world
|
override def getEntityWorld = host.world
|
||||||
|
|
||||||
override def addChatMessage(message: IChatComponent) {
|
override def addChatMessage(message: IChatComponent) {
|
||||||
messages = Option(messages.getOrElse("") + message.getUnformattedText)
|
messages = Option(messages.fold("")(_ + "\n") + message.getUnformattedText)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getDisplayName = fakePlayer.getDisplayName
|
override def getDisplayName = underlying.getDisplayName
|
||||||
|
|
||||||
override def setCommandStat(`type`: Type, amount: Int) = fakePlayer.setCommandStat(`type`, amount)
|
override def setCommandStat(`type`: Type, amount: Int) = underlying.setCommandStat(`type`, amount)
|
||||||
|
|
||||||
override def getPosition = fakePlayer.getPosition
|
override def getPosition = underlying.getPosition
|
||||||
|
|
||||||
override def canUseCommand(level: Int, commandName: String) = {
|
override def canUseCommand(level: Int, commandName: String) = {
|
||||||
val profile = fakePlayer.getGameProfile
|
val profile = underlying.getGameProfile
|
||||||
val server = fakePlayer.mcServer
|
val server = underlying.mcServer
|
||||||
val config = server.getConfigurationManager
|
val config = server.getConfigurationManager
|
||||||
server.isSinglePlayer || (config.canSendCommands(profile) && (config.getOppedPlayers.getEntry(profile) match {
|
server.isSinglePlayer || (config.canSendCommands(profile) && (config.getOppedPlayers.getEntry(profile) match {
|
||||||
case entry: UserListOpsEntry => entry.getPermissionLevel >= level
|
case entry: UserListOpsEntry => entry.getPermissionLevel >= level
|
||||||
@ -536,11 +553,11 @@ object DebugCard {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getCommandSenderEntity = fakePlayer
|
override def getCommandSenderEntity = underlying
|
||||||
|
|
||||||
override def getPositionVector = fakePlayer.getPositionVector
|
override def getPositionVector = underlying.getPositionVector
|
||||||
|
|
||||||
override def sendCommandFeedback() = fakePlayer.sendCommandFeedback()
|
override def sendCommandFeedback() = underlying.sendCommandFeedback()
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestValue extends AbstractValue {
|
class TestValue extends AbstractValue {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user