From 9af202331bcc847f0fd73919203096061ba92a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 26 Nov 2013 03:05:16 +0100 Subject: [PATCH] small method rename and checking for ownership before starting a computer --- li/cil/oc/api/network/Context.java | 2 +- li/cil/oc/common/block/Case.scala | 2 +- li/cil/oc/common/block/Computer.scala | 2 +- li/cil/oc/common/container/Case.scala | 2 +- li/cil/oc/common/container/Robot.scala | 2 +- li/cil/oc/server/component/Computer.scala | 4 ++-- reference.conf | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/li/cil/oc/api/network/Context.java b/li/cil/oc/api/network/Context.java index 47ae76abb..dc9b9d2a0 100644 --- a/li/cil/oc/api/network/Context.java +++ b/li/cil/oc/api/network/Context.java @@ -40,7 +40,7 @@ public interface Context { * @param player the name of the player to check for. * @return whether the player with the specified name may use the computer. */ - boolean isUser(String player); + boolean canInteract(String player); /** * Whether the computer is currently in a running state, i.e. it is neither diff --git a/li/cil/oc/common/block/Case.scala b/li/cil/oc/common/block/Case.scala index d41044a43..cf5c4a62c 100644 --- a/li/cil/oc/common/block/Case.scala +++ b/li/cil/oc/common/block/Case.scala @@ -77,7 +77,7 @@ class Case(val parent: SimpleDelegator) extends Computer with SimpleDelegate { override def onBlockRemovedBy(world: World, x: Int, y: Int, z: Int, player: EntityPlayer) = world.getBlockTileEntity(x, y, z) match { case c: tileentity.Case if !world.isRemote => - c.computer.isUser(player.getCommandSenderName) + c.computer.canInteract(player.getCommandSenderName) case _ => super.onBlockRemovedBy(world, x, y, z, player) } } \ No newline at end of file diff --git a/li/cil/oc/common/block/Computer.scala b/li/cil/oc/common/block/Computer.scala index 3a9bf4aab..6fec27049 100644 --- a/li/cil/oc/common/block/Computer.scala +++ b/li/cil/oc/common/block/Computer.scala @@ -28,7 +28,7 @@ abstract class Computer extends Delegate { if (!player.isSneaking) { if (!world.isRemote) { world.getBlockTileEntity(x, y, z) match { - case t: tileentity.Computer if !t.computer.isPaused => t.computer.start() + case t: tileentity.Computer if !t.computer.isPaused && t.computer.canInteract(player.getCommandSenderName) => t.computer.start() case _ => } } diff --git a/li/cil/oc/common/container/Case.scala b/li/cil/oc/common/container/Case.scala index c8826ee1f..b2ac2284d 100644 --- a/li/cil/oc/common/container/Case.scala +++ b/li/cil/oc/common/container/Case.scala @@ -23,5 +23,5 @@ class Case(playerInventory: InventoryPlayer, `case`: tileentity.Case) extends Pl addPlayerInventorySlots(8, 84) override def canInteractWith(player: EntityPlayer) = - super.canInteractWith(player) && `case`.computer.isUser(player.getCommandSenderName) + super.canInteractWith(player) && `case`.computer.canInteract(player.getCommandSenderName) } \ No newline at end of file diff --git a/li/cil/oc/common/container/Robot.scala b/li/cil/oc/common/container/Robot.scala index 2ef3972f1..f36c9348e 100644 --- a/li/cil/oc/common/container/Robot.scala +++ b/li/cil/oc/common/container/Robot.scala @@ -20,5 +20,5 @@ class Robot(playerInventory: InventoryPlayer, robot: tileentity.Robot) extends P addPlayerInventorySlots(8, 160) override def canInteractWith(player: EntityPlayer) = - super.canInteractWith(player) && robot.computer.isUser(player.getCommandSenderName) + super.canInteractWith(player) && robot.computer.canInteract(player.getCommandSenderName) } \ No newline at end of file diff --git a/li/cil/oc/server/component/Computer.scala b/li/cil/oc/server/component/Computer.scala index bcace30fa..740a750dc 100644 --- a/li/cil/oc/server/component/Computer.scala +++ b/li/cil/oc/server/component/Computer.scala @@ -87,7 +87,7 @@ class Computer(val owner: tileentity.Computer) extends ManagedComponent with Con def address = node.address - def isUser(player: String) = !Settings.get.canComputersBeOwned || + def canInteract(player: String) = !Settings.get.canComputersBeOwned || users.isEmpty || users.contains(player) || MinecraftServer.getServer.isSinglePlayer || MinecraftServer.getServer.getConfigurationManager.isPlayerOpped(player) @@ -329,7 +329,7 @@ class Computer(val owner: tileentity.Computer) extends ManagedComponent with Con case Array(name: String, args@_*) if message.name == "computer.signal" => signal(name, Seq(message.source.address) ++ args: _*) case Array(player: EntityPlayer, name: String, args@_*) if message.name == "computer.checked_signal" => - if (isUser(player.getCommandSenderName)) + if (canInteract(player.getCommandSenderName)) signal(name, Seq(message.source.address) ++ args: _*) case _ => } diff --git a/reference.conf b/reference.conf index ad0e349d6..be83aaaeb 100644 --- a/reference.conf +++ b/reference.conf @@ -314,7 +314,7 @@ opencomputers { gpuCopy: 0.0050 # The amount of energy it takes a robot to perform a 90 degree turn. - robotTurn: 4.0 + robotTurn: 5.0 # The amount of energy it takes a robot to move a single block. robotMove: 40.0