trying to get a little bit of... structure into image names; cleaned up some shell stuff; added pastebin downloader
@ -2,9 +2,9 @@
|
|||||||
oc:block.Adapter.name=Adapter
|
oc:block.Adapter.name=Adapter
|
||||||
oc:block.Cable.name=Kabel
|
oc:block.Cable.name=Kabel
|
||||||
oc:block.Capacitor.name=Kondensator
|
oc:block.Capacitor.name=Kondensator
|
||||||
oc:block.CaseAdvanced.name=Hochwertiges Gehäuse
|
oc:block.Case0.name=Einfaches Gehäuse
|
||||||
oc:block.CaseBasic.name=Einfaches Gehäuse
|
oc:block.Case1.name=Hochwertiges Gehäuse
|
||||||
oc:block.CaseProfessional.name=Professionelles Gehäuse
|
oc:block.Case2.name=Ausgezeichnetes Gehäuse
|
||||||
oc:block.Charger.name=Ladestation
|
oc:block.Charger.name=Ladestation
|
||||||
oc:block.DiskDrive.name=Diskettenlaufwerk
|
oc:block.DiskDrive.name=Diskettenlaufwerk
|
||||||
oc:block.Keyboard.name=Tastatur
|
oc:block.Keyboard.name=Tastatur
|
||||||
@ -13,33 +13,37 @@ oc:block.PowerDistributor.name=Stromverteiler
|
|||||||
oc:block.Robot.name=Roboter
|
oc:block.Robot.name=Roboter
|
||||||
oc:block.RobotAfterimage.name=Roboter
|
oc:block.RobotAfterimage.name=Roboter
|
||||||
oc:block.Router.name=Router
|
oc:block.Router.name=Router
|
||||||
oc:block.ScreenAdvanced.name=Hochwertiger Bildschirm
|
oc:block.Screen0.name=Einfacher Bildschirm
|
||||||
oc:block.ScreenBasic.name=Einfacher Bildschirm
|
oc:block.Screen1.name=Hochwertiger Bildschirm
|
||||||
oc:block.ScreenProfessional.name=Professioneller Bildschirm
|
oc:block.Screen2.name=Ausgezeichneter Bildschirm
|
||||||
|
|
||||||
# Items
|
# Items
|
||||||
|
oc:item.ALU.name=Arithmetisch-logische Einheit (ALU)
|
||||||
oc:item.Analyzer.name=Messgerät
|
oc:item.Analyzer.name=Messgerät
|
||||||
oc:item.ArithmeticLogicUnit.name=Arithmetisch-logische Einheit (ALU)
|
|
||||||
oc:item.ArrowKeys.name=Pfeiltasten
|
oc:item.ArrowKeys.name=Pfeiltasten
|
||||||
oc:item.ButtonGroup.name=Tastengruppe
|
oc:item.ButtonGroup.name=Tastengruppe
|
||||||
oc:item.CircuitBoard.name=Basis Platte
|
oc:item.CardBase.name=Kartenbasis
|
||||||
|
oc:item.CircuitBoard.name=Leiterplatte
|
||||||
oc:item.ControlUnit.name=Steuerwerk (CU)
|
oc:item.ControlUnit.name=Steuerwerk (CU)
|
||||||
oc:item.CPU.name=Hauptprozessor (CPU)
|
oc:item.CPU.name=Hauptprozessor (CPU)
|
||||||
oc:item.Card.name=Karte
|
oc:item.Crafting.name=Crafting Upgrade
|
||||||
oc:item.Crafting.name=Crafting
|
|
||||||
oc:item.CuttingWire.name=Schneidedraht
|
oc:item.CuttingWire.name=Schneidedraht
|
||||||
oc:item.FloppyDisk.name=Diskette
|
oc:item.Disk.name=Platte
|
||||||
oc:item.Generator.name=Generator
|
oc:item.Floppy.name=Diskette
|
||||||
oc:item.GraphicsCardAdvanced.name=Hochwertige Grafikkarte
|
oc:item.Generator.name=Generator Upgrade
|
||||||
oc:item.GraphicsCardBasic.name=Einfache Grafikkarte
|
oc:item.GraphicsCard0.name=Einfache Grafikkarte
|
||||||
oc:item.GraphicsCardProfessional.name=Professionelle Grafikkarte
|
oc:item.GraphicsCard1.name=Hochwertige Grafikkarte
|
||||||
|
oc:item.GraphicsCard2.name=Ausgezeichnete Grafikkarte
|
||||||
oc:item.HardDiskDrive.name=Festplatte
|
oc:item.HardDiskDrive.name=Festplatte
|
||||||
oc:item.IronNugget.name=Eisennugget
|
oc:item.IronNugget.name=Eisennugget
|
||||||
oc:item.Memory.name=Speicher
|
oc:item.Memory.name=Speicher
|
||||||
|
oc:item.Microchip0.name=Einfacher Microchip
|
||||||
|
oc:item.Microchip1.name=Hochwertiger Microchip
|
||||||
|
oc:item.Microchip2.name=Ausgezeichneter Microchip
|
||||||
oc:item.NetworkCard.name=Netzwerkkarte
|
oc:item.NetworkCard.name=Netzwerkkarte
|
||||||
oc:item.NumPad.name=Ziffernblock
|
oc:item.NumPad.name=Ziffernblock
|
||||||
oc:item.PrintedCircuitBoard.name=Leiterplatte (PCB)
|
oc:item.PrintedCircuitBoard.name=Gedruckte Leiterplatte (PCB)
|
||||||
oc:item.RawCircuitBoard.name=Rohe Basis Platte
|
oc:item.RawCircuitBoard.name=Leiterplattenrohling
|
||||||
oc:item.RedstoneCard.name=Redstonekarte
|
oc:item.RedstoneCard.name=Redstonekarte
|
||||||
oc:item.Transistor.name=Transistor
|
oc:item.Transistor.name=Transistor
|
||||||
oc:item.WirelessNetworkCard.name=Drahtlosnetzwerkkarte
|
oc:item.WirelessNetworkCard.name=Drahtlosnetzwerkkarte
|
||||||
@ -52,6 +56,7 @@ oc:gui.Analyzer.RobotName=Name
|
|||||||
oc:gui.Analyzer.RobotOwner=Besitzer
|
oc:gui.Analyzer.RobotOwner=Besitzer
|
||||||
oc:gui.Analyzer.StoredEnergy=Gespeicherte Energie
|
oc:gui.Analyzer.StoredEnergy=Gespeicherte Energie
|
||||||
oc:gui.Analyzer.TotalEnergy=Insgesamt gespeicherte Energie
|
oc:gui.Analyzer.TotalEnergy=Insgesamt gespeicherte Energie
|
||||||
|
oc:gui.Analyzer.Users=Benutzer
|
||||||
oc:gui.Robot.Power=Energie
|
oc:gui.Robot.Power=Energie
|
||||||
oc:gui.Robot.TurnOff=Ausschalten
|
oc:gui.Robot.TurnOff=Ausschalten
|
||||||
oc:gui.Robot.TurnOn=Einschalten
|
oc:gui.Robot.TurnOn=Einschalten
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
oc:block.Adapter.name=Adapter
|
oc:block.Adapter.name=Adapter
|
||||||
oc:block.Cable.name=Cable
|
oc:block.Cable.name=Cable
|
||||||
oc:block.Capacitor.name=Capacitor
|
oc:block.Capacitor.name=Capacitor
|
||||||
oc:block.CaseAdvanced.name=Advanced Case
|
oc:block.Case0.name=Basic Case
|
||||||
oc:block.CaseBasic.name=Basic Case
|
oc:block.Case1.name=Advanced Case
|
||||||
oc:block.CaseProfessional.name=Professional Case
|
oc:block.Case2.name=Superior Case
|
||||||
oc:block.Charger.name=Charger
|
oc:block.Charger.name=Charger
|
||||||
oc:block.DiskDrive.name=Disk Drive
|
oc:block.DiskDrive.name=Disk Drive
|
||||||
oc:block.Keyboard.name=Keyboard
|
oc:block.Keyboard.name=Keyboard
|
||||||
@ -17,29 +17,33 @@ oc:block.PowerDistributor.name=Power Distributor
|
|||||||
oc:block.Robot.name=Robot
|
oc:block.Robot.name=Robot
|
||||||
oc:block.RobotAfterimage.name=Robot
|
oc:block.RobotAfterimage.name=Robot
|
||||||
oc:block.Router.name=Router
|
oc:block.Router.name=Router
|
||||||
oc:block.ScreenAdvanced.name=Advanced Screen
|
oc:block.Screen0.name=Basic Screen
|
||||||
oc:block.ScreenBasic.name=Basic Screen
|
oc:block.Screen1.name=Advanced Screen
|
||||||
oc:block.ScreenProfessional.name=Professional Screen
|
oc:block.Screen2.name=Superior Screen
|
||||||
|
|
||||||
# Items
|
# Items
|
||||||
|
oc:item.ALU.name=Arithmetic Logic Unit (ALU)
|
||||||
oc:item.Analyzer.name=Analyzer
|
oc:item.Analyzer.name=Analyzer
|
||||||
oc:item.ArithmeticLogicUnit.name=Arithmetic Logic Unit (ALU)
|
|
||||||
oc:item.ArrowKeys.name=Arrow Keys
|
oc:item.ArrowKeys.name=Arrow Keys
|
||||||
oc:item.ButtonGroup.name=Button Group
|
oc:item.ButtonGroup.name=Button Group
|
||||||
|
oc:item.CardBase.name=Card Base
|
||||||
oc:item.CircuitBoard.name=Circuit Board
|
oc:item.CircuitBoard.name=Circuit Board
|
||||||
oc:item.ControlUnit.name=Control Unit (CU)
|
oc:item.ControlUnit.name=Control Unit (CU)
|
||||||
oc:item.CPU.name=Central Processing Unit (CPU)
|
oc:item.CPU.name=Central Processing Unit (CPU)
|
||||||
oc:item.Card.name=Card
|
oc:item.Crafting.name=Crafting Upgrade
|
||||||
oc:item.Crafting.name=Crafting
|
|
||||||
oc:item.CuttingWire.name=Cutting Wire
|
oc:item.CuttingWire.name=Cutting Wire
|
||||||
|
oc:item.Disk.name=Disk Platter
|
||||||
oc:item.FloppyDisk.name=Floppy Disk
|
oc:item.FloppyDisk.name=Floppy Disk
|
||||||
oc:item.Generator.name=Generator
|
oc:item.Generator.name=Generator Upgrade
|
||||||
oc:item.GraphicsCardAdvanced.name=Advanced Graphics Card
|
oc:item.GraphicsCard0.name=Basic Graphics Card
|
||||||
oc:item.GraphicsCardBasic.name=Basic Graphics Card
|
oc:item.GraphicsCard1.name=Advanced Graphics Card
|
||||||
oc:item.GraphicsCardProfessional.name=Professional Graphics Card
|
oc:item.GraphicsCard2.name=Superior Graphics Card
|
||||||
oc:item.HardDiskDrive.name=Hard Disk Drive
|
oc:item.HardDiskDrive.name=Hard Disk Drive
|
||||||
oc:item.IronNugget.name=Iron Nugget
|
oc:item.IronNugget.name=Iron Nugget
|
||||||
oc:item.Memory.name=Memory
|
oc:item.Memory.name=Memory
|
||||||
|
oc:item.Microchip0.name=Simple Microchip
|
||||||
|
oc:item.Microchip1.name=Advanced Microchip
|
||||||
|
oc:item.Microchip2.name=Superior Microchip
|
||||||
oc:item.NetworkCard.name=Network Card
|
oc:item.NetworkCard.name=Network Card
|
||||||
oc:item.NumPad.name=Numeric Keypad
|
oc:item.NumPad.name=Numeric Keypad
|
||||||
oc:item.PrintedCircuitBoard.name=Printed Circuit Board (PCB)
|
oc:item.PrintedCircuitBoard.name=Printed Circuit Board (PCB)
|
||||||
|
@ -16,7 +16,7 @@ while term.isAvailable() do
|
|||||||
local expression = load("return " .. command, "=stdin", "t", env)
|
local expression = load("return " .. command, "=stdin", "t", env)
|
||||||
local code = expression or statement
|
local code = expression or statement
|
||||||
if code then
|
if code then
|
||||||
local result = table.pack(shell.execute(code))
|
local result = table.pack(pcall(code))
|
||||||
if not result[1] or result.n > 1 then
|
if not result[1] or result.n > 1 then
|
||||||
print(table.unpack(result, 2, result.n))
|
print(table.unpack(result, 2, result.n))
|
||||||
end
|
end
|
||||||
|
57
assets/opencomputers/lua/rom/bin/pastebin.lua
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
local args, options = shell.parse(...)
|
||||||
|
if #args < 2 then
|
||||||
|
print("Usage: pastebin [-f] <id> <file>")
|
||||||
|
print(" -f: Force overwriting existing files.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local m = component.modem
|
||||||
|
if not m or not m.isWireless() then
|
||||||
|
print("no primary wireless modem found")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not m.isHttpEnabled() then
|
||||||
|
print("http support is not enabled")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local id = args[1]
|
||||||
|
local filename = shell.resolve(args[2])
|
||||||
|
|
||||||
|
if fs.exists(filename) then
|
||||||
|
if not options.f or not os.remove(filename) then
|
||||||
|
print("file already exists")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local url = "http://pastebin.com/raw.php?i=" .. id
|
||||||
|
local result, reason = m.send(url)
|
||||||
|
if not result then
|
||||||
|
print("failed sending request: " .. reason)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local f, reason = io.open(filename, "w")
|
||||||
|
if not f then
|
||||||
|
print("failed opening file for writing: " .. reason)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
repeat
|
||||||
|
local _, responseUrl, result, reason = event.pull("http_response")
|
||||||
|
if responseUrl == url then
|
||||||
|
if not result and reason then
|
||||||
|
print("failed fetching data: " .. reason)
|
||||||
|
f:close()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if result then
|
||||||
|
f:write(result)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
until not result
|
||||||
|
|
||||||
|
f:close()
|
||||||
|
print("saved data to " .. filename)
|
@ -1,4 +1,5 @@
|
|||||||
local event, listeners, timers = {}, {}, {}
|
local event, listeners, timers = {}, {}, {}
|
||||||
|
local lastInterrupt = -math.huge
|
||||||
|
|
||||||
local function matches(signal, name, filter)
|
local function matches(signal, name, filter)
|
||||||
if name and not (type(signal[1]) == "string" and signal[1]:match(name))
|
if name and not (type(signal[1]) == "string" and signal[1]:match(name))
|
||||||
@ -144,6 +145,7 @@ function event.pull(...)
|
|||||||
end
|
end
|
||||||
tick()
|
tick()
|
||||||
if event.shouldInterrupt() then
|
if event.shouldInterrupt() then
|
||||||
|
lastInterrupt = os.uptime()
|
||||||
error("interrupted", 0)
|
error("interrupted", 0)
|
||||||
end
|
end
|
||||||
if not (seconds or hasFilter) or matches(signal, name, filter) then
|
if not (seconds or hasFilter) or matches(signal, name, filter) then
|
||||||
@ -153,7 +155,8 @@ function event.pull(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function event.shouldInterrupt()
|
function event.shouldInterrupt()
|
||||||
return keyboard.isControlDown() and
|
return os.uptime() - lastInterrupt > 1 and
|
||||||
|
keyboard.isControlDown() and
|
||||||
keyboard.isAltDown() and
|
keyboard.isAltDown() and
|
||||||
keyboard.isKeyDown(keyboard.keys.c)
|
keyboard.isKeyDown(keyboard.keys.c)
|
||||||
end
|
end
|
||||||
|
@ -153,6 +153,11 @@ function filesystem.mount(fs, path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function filesystem.path(path)
|
||||||
|
local parts = segments(path)
|
||||||
|
return table.concat(parts, "/", 1, #parts - 1) .. "/"
|
||||||
|
end
|
||||||
|
|
||||||
function filesystem.name(path)
|
function filesystem.name(path)
|
||||||
local parts = segments(path)
|
local parts = segments(path)
|
||||||
return parts[#parts]
|
return parts[#parts]
|
||||||
@ -410,7 +415,7 @@ local function onComponentAdded(_, address, componentType)
|
|||||||
name = filesystem.concat("/mnt", name)
|
name = filesystem.concat("/mnt", name)
|
||||||
filesystem.mount(proxy, name)
|
filesystem.mount(proxy, name)
|
||||||
if isAutorunEnabled then
|
if isAutorunEnabled then
|
||||||
shell.execute(filesystem.concat(name, "autorun"), proxy)
|
os.execute(filesystem.concat(name, "autorun"), proxy)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,15 +18,11 @@ os.execute = function(command)
|
|||||||
for part in tail:gmatch("%S+") do
|
for part in tail:gmatch("%S+") do
|
||||||
table.insert(args, part)
|
table.insert(args, part)
|
||||||
end
|
end
|
||||||
return shell.execute(head, table.unpack(args))
|
return shell.execute(head, _ENV, table.unpack(args))
|
||||||
end
|
end
|
||||||
|
|
||||||
function os.exit()
|
function os.exit()
|
||||||
local result, reason = shell.kill(coroutine.running())
|
error("terminated", 0)
|
||||||
if result then
|
|
||||||
coroutine.yield() -- never returns
|
|
||||||
end
|
|
||||||
error(reason, 2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
os.remove = fs.remove
|
os.remove = fs.remove
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
local shell = {}
|
local shell = {}
|
||||||
local cwd = "/"
|
local cwd = "/"
|
||||||
local path = {"/bin/", "/usr/bin/", "/home/bin/"}
|
local path = {"/bin/", "/usr/bin/", "/home/bin/"}
|
||||||
local aliases = {dir="ls", move="mv", rename="mv", copy="cp", del="rm",
|
local aliases = {dir="ls", list="ls", move="mv", rename="mv", copy="cp",
|
||||||
md="mkdir", cls="clear", more="less", rs="redstone",
|
del="rm", md="mkdir", cls="clear", more="less", rs="redstone",
|
||||||
view="edit -r"}
|
view="edit -r"}
|
||||||
local running = {}
|
local running = {}
|
||||||
|
|
||||||
@ -77,65 +77,6 @@ function shell.setWorkingDirectory(dir)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function shell.execute(program, ...)
|
|
||||||
if type(program) ~= "function" then
|
|
||||||
local where, reason = shell.resolve(program, "lua")
|
|
||||||
if not where then
|
|
||||||
return nil, reason
|
|
||||||
end
|
|
||||||
local code, reason = loadfile(where, "t", setmetatable({}, {__index=_ENV}))
|
|
||||||
if not code then
|
|
||||||
return nil, reason
|
|
||||||
end
|
|
||||||
program = code
|
|
||||||
end
|
|
||||||
local co, args, result = coroutine.create(program), table.pack(true, ...), nil
|
|
||||||
running[co] = true
|
|
||||||
while running[co] and args[1] do
|
|
||||||
result = table.pack(coroutine.resume(co, table.unpack(args, 2, args.n)))
|
|
||||||
if coroutine.status(co) ~= "dead" then
|
|
||||||
-- Emulate CC behavior by making yields a filtered event.wait.
|
|
||||||
if type(result[2]) == "string" then
|
|
||||||
args = table.pack(pcall(event.pull, table.unpack(result, 2, result.n)))
|
|
||||||
else
|
|
||||||
args = {true, n=1}
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
running[co] = nil
|
|
||||||
if not args[1] then
|
|
||||||
return false, "interrupted"
|
|
||||||
end
|
|
||||||
return table.unpack(result, 1, result.n)
|
|
||||||
end
|
|
||||||
|
|
||||||
function shell.kill(co)
|
|
||||||
if running[co] ~= nil then
|
|
||||||
running[co] = nil
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return nil, "not a program thread"
|
|
||||||
end
|
|
||||||
|
|
||||||
function shell.parse(...)
|
|
||||||
local params = table.pack(...)
|
|
||||||
local args = {}
|
|
||||||
local options = {}
|
|
||||||
for i = 1, params.n do
|
|
||||||
local param = params[i]
|
|
||||||
if unicode.sub(param, 1, 1) == "-" then
|
|
||||||
for j = 2, unicode.len(param) do
|
|
||||||
options[unicode.sub(param, j, j)] = true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
table.insert(args, param)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return args, options
|
|
||||||
end
|
|
||||||
|
|
||||||
function shell.getPath()
|
function shell.getPath()
|
||||||
return table.concat(path, ":")
|
return table.concat(path, ":")
|
||||||
end
|
end
|
||||||
@ -170,6 +111,59 @@ function shell.resolve(path, ext)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function shell.execute(program, env, ...)
|
||||||
|
checkArg(1, program, "string")
|
||||||
|
local filename, reason = shell.resolve(program, "lua")
|
||||||
|
if not filename then
|
||||||
|
return nil, reason
|
||||||
|
end
|
||||||
|
local code, reason = loadfile(filename, "t", setmetatable({}, {__index=env}))
|
||||||
|
if not code then
|
||||||
|
return nil, reason
|
||||||
|
end
|
||||||
|
local co, args, result = coroutine.create(code), table.pack(true, ...), nil
|
||||||
|
table.insert(running, filename)
|
||||||
|
-- Emulate CC behavior by making yields a filtered event.pull()
|
||||||
|
repeat
|
||||||
|
result = table.pack(coroutine.resume(co, table.unpack(args, 2, args.n)))
|
||||||
|
if coroutine.status(co) == "dead" then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if type(result[2]) == "string" then
|
||||||
|
args = table.pack(pcall(event.pull, table.unpack(result, 2, result.n)))
|
||||||
|
else
|
||||||
|
args = {true, n=1}
|
||||||
|
end
|
||||||
|
until not args[1]
|
||||||
|
table.remove(running)
|
||||||
|
if not args[1] then
|
||||||
|
return false, args[2]
|
||||||
|
end
|
||||||
|
return table.unpack(result, 1, result.n)
|
||||||
|
end
|
||||||
|
|
||||||
|
function shell.parse(...)
|
||||||
|
local params = table.pack(...)
|
||||||
|
local args = {}
|
||||||
|
local options = {}
|
||||||
|
for i = 1, params.n do
|
||||||
|
local param = params[i]
|
||||||
|
if unicode.sub(param, 1, 1) == "-" then
|
||||||
|
for j = 2, unicode.len(param) do
|
||||||
|
options[unicode.sub(param, j, j)] = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(args, param)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return args, options
|
||||||
|
end
|
||||||
|
|
||||||
|
function shell.running(level)
|
||||||
|
level = level or 1
|
||||||
|
return running[1 + (#running - level)]
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
_G.shell = shell
|
_G.shell = shell
|
||||||
|
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 268 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 313 B |
Before Width: | Height: | Size: 330 B After Width: | Height: | Size: 330 B |
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 520 B |
Before Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 208 B |
BIN
assets/opencomputers/textures/items/disk_floppy.png
Normal file
After Width: | Height: | Size: 508 B |
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 350 B After Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 303 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 398 B |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 313 B |
@ -4,7 +4,7 @@ import cpw.mods.fml.common.registry.GameRegistry
|
|||||||
import li.cil.oc.common.item
|
import li.cil.oc.common.item
|
||||||
import net.minecraft.item.{Item, ItemStack}
|
import net.minecraft.item.{Item, ItemStack}
|
||||||
import net.minecraftforge.oredict.OreDictionary
|
import net.minecraftforge.oredict.OreDictionary
|
||||||
import li.cil.oc.common.item.Disc
|
import li.cil.oc.common.item.Disk
|
||||||
|
|
||||||
object Items {
|
object Items {
|
||||||
var multi: item.Delegator = null
|
var multi: item.Delegator = null
|
||||||
@ -36,11 +36,11 @@ object Items {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
// Crafting
|
// Crafting
|
||||||
var card: item.Card = null
|
var card: item.CardBase = null
|
||||||
var circuitBoardBody: item.CircuitBoard = null
|
var circuitBoardBody: item.CircuitBoard = null
|
||||||
var printedCircuitBoard: item.PrintedCircuitBoard = null
|
var printedCircuitBoard: item.PrintedCircuitBoard = null
|
||||||
var ironCutter: item.CuttingWire = null
|
var ironCutter: item.CuttingWire = null
|
||||||
var chip1, chip2, chip3: item.Chip = null
|
var chip1, chip2, chip3: item.Microchip = null
|
||||||
var numPad: item.NumPad = null
|
var numPad: item.NumPad = null
|
||||||
var arrowKeys: item.ArrowKeys = null
|
var arrowKeys: item.ArrowKeys = null
|
||||||
var buttonGroup: item.ButtonGroup = null
|
var buttonGroup: item.ButtonGroup = null
|
||||||
@ -51,7 +51,7 @@ object Items {
|
|||||||
|
|
||||||
var ironNugget: item.IronNugget = null
|
var ironNugget: item.IronNugget = null
|
||||||
var rawCircuitBoard: item.RawCircuitBoard = null
|
var rawCircuitBoard: item.RawCircuitBoard = null
|
||||||
var disc: item.Disc = null
|
var disc: item.Disk = null
|
||||||
|
|
||||||
|
|
||||||
def init() {
|
def init() {
|
||||||
@ -76,15 +76,15 @@ object Items {
|
|||||||
wlan = new item.WirelessNetworkCard(multi)
|
wlan = new item.WirelessNetworkCard(multi)
|
||||||
crafting = new item.Crafting(multi)
|
crafting = new item.Crafting(multi)
|
||||||
|
|
||||||
card = new item.Card(multi)
|
card = new item.CardBase(multi)
|
||||||
circuitBoardBody = new item.CircuitBoard(multi)
|
circuitBoardBody = new item.CircuitBoard(multi)
|
||||||
printedCircuitBoard = new item.PrintedCircuitBoard(multi)
|
printedCircuitBoard = new item.PrintedCircuitBoard(multi)
|
||||||
ironCutter = new item.CuttingWire(multi)
|
ironCutter = new item.CuttingWire(multi)
|
||||||
|
|
||||||
|
|
||||||
chip1 = new item.Chip(multi, 0)
|
chip1 = new item.Microchip(multi, 0)
|
||||||
chip2 = new item.Chip(multi, 1)
|
chip2 = new item.Microchip(multi, 1)
|
||||||
chip3 = new item.Chip(multi, 2)
|
chip3 = new item.Microchip(multi, 2)
|
||||||
|
|
||||||
numPad = new item.NumPad(multi)
|
numPad = new item.NumPad(multi)
|
||||||
arrowKeys = new item.ArrowKeys(multi)
|
arrowKeys = new item.ArrowKeys(multi)
|
||||||
@ -105,6 +105,6 @@ object Items {
|
|||||||
OreDictionary.registerOre("potionPoison", new ItemStack(Item.potion, 1, 16452))
|
OreDictionary.registerOre("potionPoison", new ItemStack(Item.potion, 1, 16452))
|
||||||
|
|
||||||
rawCircuitBoard = new item.RawCircuitBoard(multi)
|
rawCircuitBoard = new item.RawCircuitBoard(multi)
|
||||||
disc = new item.Disc(multi)
|
disc = new item.Disk(multi)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ import net.minecraft.world.World
|
|||||||
import net.minecraftforge.common.ForgeDirection
|
import net.minecraftforge.common.ForgeDirection
|
||||||
|
|
||||||
abstract class Case(val parent: SimpleDelegator) extends Computer with SimpleDelegate {
|
abstract class Case(val parent: SimpleDelegator) extends Computer with SimpleDelegate {
|
||||||
|
val unlocalizedName = "Case" + tier
|
||||||
|
|
||||||
def tier: Int
|
def tier: Int
|
||||||
|
|
||||||
@ -88,24 +89,18 @@ abstract class Case(val parent: SimpleDelegator) extends Computer with SimpleDel
|
|||||||
object Case {
|
object Case {
|
||||||
|
|
||||||
class Tier1(parent: SimpleDelegator) extends Case(parent) {
|
class Tier1(parent: SimpleDelegator) extends Case(parent) {
|
||||||
val unlocalizedName = "CaseBasic"
|
|
||||||
|
|
||||||
def tier = 0
|
def tier = 0
|
||||||
|
|
||||||
override def color = 0x7F7F7F
|
override def color = 0x7F7F7F
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tier2(parent: SimpleDelegator) extends Case(parent) {
|
class Tier2(parent: SimpleDelegator) extends Case(parent) {
|
||||||
val unlocalizedName = "CaseAdvanced"
|
|
||||||
|
|
||||||
def tier = 1
|
def tier = 1
|
||||||
|
|
||||||
override def color = 0xFFFF66
|
override def color = 0xFFFF66
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tier3(parent: SimpleDelegator) extends Case(parent) {
|
class Tier3(parent: SimpleDelegator) extends Case(parent) {
|
||||||
val unlocalizedName = "CaseProfessional"
|
|
||||||
|
|
||||||
def tier = 2
|
def tier = 2
|
||||||
|
|
||||||
override def color = 0x66FFFF
|
override def color = 0x66FFFF
|
||||||
|
@ -14,6 +14,7 @@ import net.minecraft.world.World
|
|||||||
import net.minecraftforge.common.ForgeDirection
|
import net.minecraftforge.common.ForgeDirection
|
||||||
|
|
||||||
abstract class Screen(val parent: SimpleDelegator) extends SimpleDelegate {
|
abstract class Screen(val parent: SimpleDelegator) extends SimpleDelegate {
|
||||||
|
val unlocalizedName = "Screen" + tier
|
||||||
|
|
||||||
def tier: Int
|
def tier: Int
|
||||||
|
|
||||||
@ -297,24 +298,18 @@ abstract class Screen(val parent: SimpleDelegator) extends SimpleDelegate {
|
|||||||
object Screen {
|
object Screen {
|
||||||
|
|
||||||
class Tier1(parent: SimpleDelegator) extends Screen(parent) {
|
class Tier1(parent: SimpleDelegator) extends Screen(parent) {
|
||||||
val unlocalizedName = "ScreenBasic"
|
|
||||||
|
|
||||||
def tier = 0
|
def tier = 0
|
||||||
|
|
||||||
override def color = 0x7F7F7F
|
override def color = 0x7F7F7F
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tier2(parent: SimpleDelegator) extends Screen(parent) {
|
class Tier2(parent: SimpleDelegator) extends Screen(parent) {
|
||||||
val unlocalizedName = "ScreenAdvanced"
|
|
||||||
|
|
||||||
def tier = 1
|
def tier = 1
|
||||||
|
|
||||||
override def color = 0xFFFF66
|
override def color = 0xFFFF66
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tier3(parent: SimpleDelegator) extends Screen(parent) {
|
class Tier3(parent: SimpleDelegator) extends Screen(parent) {
|
||||||
val unlocalizedName = "ScreenProfessional"
|
|
||||||
|
|
||||||
def tier = 2
|
def tier = 2
|
||||||
|
|
||||||
override def color = 0x66FFFF
|
override def color = 0x66FFFF
|
||||||
|
@ -4,7 +4,7 @@ import li.cil.oc.Settings
|
|||||||
import net.minecraft.client.renderer.texture.IconRegister
|
import net.minecraft.client.renderer.texture.IconRegister
|
||||||
|
|
||||||
class ALU(val parent: Delegator) extends Delegate {
|
class ALU(val parent: Delegator) extends Delegate {
|
||||||
val unlocalizedName = "ArithmeticLogicUnit"
|
val unlocalizedName = "ALU"
|
||||||
|
|
||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
@ -9,6 +9,6 @@ class ArrowKeys(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":arrow_keys")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":keys_arrow")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ class ButtonGroup(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":button_group")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":keys_group")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package li.cil.oc.common.item
|
|||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import net.minecraft.client.renderer.texture.IconRegister
|
import net.minecraft.client.renderer.texture.IconRegister
|
||||||
|
|
||||||
class Card(val parent: Delegator) extends Delegate {
|
class CardBase(val parent: Delegator) extends Delegate {
|
||||||
val unlocalizedName = "Card"
|
val unlocalizedName = "CardBase"
|
||||||
|
|
||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
@ -18,6 +18,6 @@ class Crafting(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) = {
|
override def registerIcons(iconRegister: IconRegister) = {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":crafting")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":upgrade_crafting")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@ package li.cil.oc.common.item
|
|||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import net.minecraft.client.renderer.texture.IconRegister
|
import net.minecraft.client.renderer.texture.IconRegister
|
||||||
|
|
||||||
class Disc(val parent: Delegator) extends Delegate {
|
class Disk(val parent: Delegator) extends Delegate {
|
||||||
val unlocalizedName = "Disc"
|
val unlocalizedName = "Disk"
|
||||||
|
|
||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disc")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,6 +22,6 @@ class FloppyDisk(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk_floppy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ class Generator(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) = {
|
override def registerIcons(iconRegister: IconRegister) = {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":generator")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":upgrade_generator")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack
|
|||||||
|
|
||||||
class GraphicsCard(val parent: Delegator, val tier: Int) extends Delegate {
|
class GraphicsCard(val parent: Delegator, val tier: Int) extends Delegate {
|
||||||
val baseName = "GraphicsCard"
|
val baseName = "GraphicsCard"
|
||||||
val unlocalizedName = baseName + Array("Basic", "Advanced", "Professional").apply(tier)
|
val unlocalizedName = baseName + tier
|
||||||
|
|
||||||
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
|
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
|
||||||
val (w, h) = Settings.screenResolutionsByTier(tier)
|
val (w, h) = Settings.screenResolutionsByTier(tier)
|
||||||
@ -27,6 +27,6 @@ class GraphicsCard(val parent: Delegator, val tier: Int) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":gpu" + tier)
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_graphics" + tier)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -44,6 +44,6 @@ class HardDiskDrive(val parent: Delegator, val tier: Int) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":hdd" + tier)
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk_harddrive" + tier)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,6 @@ class Memory(val parent: Delegator, val tier: Int) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":ram" + tier)
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":memory" + tier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@ package li.cil.oc.common.item
|
|||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import net.minecraft.client.renderer.texture.IconRegister
|
import net.minecraft.client.renderer.texture.IconRegister
|
||||||
|
|
||||||
class Chip(val parent: Delegator, val tier: Int) extends Delegate {
|
class Microchip(val parent: Delegator, val tier: Int) extends Delegate {
|
||||||
val baseName = "Chip"
|
val baseName = "Microchip"
|
||||||
val unlocalizedName = baseName + Array("Basic", "Advanced", "Professional").apply(tier)
|
val unlocalizedName = baseName + tier
|
||||||
|
|
||||||
override def registerIcons(iconRegister: IconRegister) = {
|
override def registerIcons(iconRegister: IconRegister) = {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":chipset" + tier)
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":microchip" + tier)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,6 @@ class NetworkCard(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) = {
|
override def registerIcons(iconRegister: IconRegister) = {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":lancard")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_lan")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ class NumPad(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":numpad")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":keys_numpad")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ class PrintedCircuitBoard(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":pcb")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":circuit_board_printed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ class RawCircuitBoard(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":raw_circuit_board")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":circuit_board_raw")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ class RedstoneCard(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":rscard")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_redstone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ class WirelessNetworkCard(val parent: Delegator) extends Delegate {
|
|||||||
override def registerIcons(iconRegister: IconRegister) = {
|
override def registerIcons(iconRegister: IconRegister) = {
|
||||||
super.registerIcons(iconRegister)
|
super.registerIcons(iconRegister)
|
||||||
|
|
||||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":wlancard")
|
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_wlan")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,13 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
|||||||
|
|
||||||
override def isWireless(context: Context, args: Arguments): Array[AnyRef] = result(true)
|
override def isWireless(context: Context, args: Arguments): Array[AnyRef] = result(true)
|
||||||
|
|
||||||
|
@LuaCallback(value = "isHttpEnabled", direct = true)
|
||||||
|
def isHttpEnabled(context: Context, args: Arguments): Array[AnyRef] = result(Settings.get.httpEnabled)
|
||||||
|
|
||||||
override def send(context: Context, args: Arguments) = {
|
override def send(context: Context, args: Arguments) = {
|
||||||
val address = args.checkString(0)
|
val address = args.checkString(0)
|
||||||
if (Settings.get.httpEnabled && isValidInternetRequest(address)) {
|
if (isHttpRequest(address)) {
|
||||||
|
checkAddress(address)
|
||||||
val post = if (args.isString(1)) Option(args.checkString(1)) else None
|
val post = if (args.isString(1)) Option(args.checkString(1)) else None
|
||||||
WirelessNetworkCard.threadPool.submit(new Runnable {
|
WirelessNetworkCard.threadPool.submit(new Runnable {
|
||||||
def run() = try {
|
def run() = try {
|
||||||
@ -59,7 +63,20 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
|||||||
http.setRequestMethod("GET")
|
http.setRequestMethod("GET")
|
||||||
http.setDoOutput(false)
|
http.setDoOutput(false)
|
||||||
}
|
}
|
||||||
context.signal("http_response", address, scala.io.Source.fromInputStream(http.getInputStream).getLines().mkString("\n"))
|
var part: Option[String] = None
|
||||||
|
for (line <- scala.io.Source.fromInputStream(http.getInputStream).getLines()) {
|
||||||
|
if ((part + line).length <= Settings.get.maxNetworkPacketSize) {
|
||||||
|
part = Some(part.getOrElse("") + line + "\n")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
context.signal("http_response", address, part.get)
|
||||||
|
part = None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.signal("http_response", address, part.orNull)
|
||||||
|
if (part.isDefined) {
|
||||||
|
context.signal("http_response", address)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
http.disconnect()
|
http.disconnect()
|
||||||
@ -68,7 +85,10 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
case e: Throwable => context.signal("http_response", address, Unit, Option(e.getMessage).getOrElse(e.toString))
|
case e: FileNotFoundException =>
|
||||||
|
context.signal("http_response", address, Unit, "not found: " + Option(e.getMessage).getOrElse(e.toString))
|
||||||
|
case e: Throwable =>
|
||||||
|
context.signal("http_response", address, Unit, Option(e.getMessage).getOrElse(e.toString))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
result(true)
|
result(true)
|
||||||
@ -111,20 +131,9 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def isValidInternetRequest(address: String) = {
|
private def isHttpRequest(address: String) = {
|
||||||
try {
|
try {
|
||||||
val url = new URL(address)
|
new URL(address)
|
||||||
val protocol = url.getProtocol
|
|
||||||
if (!protocol.matches("^https?$")) {
|
|
||||||
throw new Exception()
|
|
||||||
}
|
|
||||||
val host = Matcher.quoteReplacement(url.getHost)
|
|
||||||
if (Settings.get.httpHostWhitelist.length > 0 && !Settings.get.httpHostWhitelist.exists(host.matches)) {
|
|
||||||
throw new Exception()
|
|
||||||
}
|
|
||||||
if (Settings.get.httpHostBlacklist.exists(host.matches)) {
|
|
||||||
throw new Exception()
|
|
||||||
}
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
@ -132,6 +141,21 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def checkAddress(address: String) {
|
||||||
|
val url = new URL(address)
|
||||||
|
val protocol = url.getProtocol
|
||||||
|
if (!protocol.matches("^https?$")) {
|
||||||
|
throw new FileNotFoundException("unsupported protocol")
|
||||||
|
}
|
||||||
|
val host = Matcher.quoteReplacement(url.getHost)
|
||||||
|
if (Settings.get.httpHostWhitelist.length > 0 && !Settings.get.httpHostWhitelist.exists(host.matches)) {
|
||||||
|
throw new FileNotFoundException("domain is not whitelisted")
|
||||||
|
}
|
||||||
|
if (Settings.get.httpHostBlacklist.exists(host.matches)) {
|
||||||
|
throw new FileNotFoundException("domain is blacklisted")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def update() {
|
override def update() {
|
||||||
|
@ -428,9 +428,9 @@ opencomputers {
|
|||||||
# All entries are regular expression patterns, but they will only be
|
# All entries are regular expression patterns, but they will only be
|
||||||
# applied to the host name (domain) of a given URL.
|
# applied to the host name (domain) of a given URL.
|
||||||
blacklist: [
|
blacklist: [
|
||||||
"127\\.0\\.0\\.1"
|
"^127\\.0\\.0\\.1$"
|
||||||
"10\\.\\d+\\.\\d+\\.\\d+"
|
"^10\\.\\d+\\.\\d+\\.\\d+$"
|
||||||
"192\\.\\d+\\.\\d+\\.\\d+"
|
"^192\\.\\d+\\.\\d+\\.\\d+$"
|
||||||
]
|
]
|
||||||
|
|
||||||
# This is a list of whitelisted domain names. Requests may only be made to
|
# This is a list of whitelisted domain names. Requests may only be made to
|
||||||
@ -441,8 +441,8 @@ opencomputers {
|
|||||||
# All entries are regular expression patterns, but they will only be
|
# All entries are regular expression patterns, but they will only be
|
||||||
# applied to the host name (domain) of a given URL.
|
# applied to the host name (domain) of a given URL.
|
||||||
whitelist: [
|
whitelist: [
|
||||||
"gist\\.github\\.com"
|
"^gist\\.github\\.com$"
|
||||||
"pastebin\\.com"
|
"^(:?www\\.)?pastebin\\.com$"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|