small method rename and checking for ownership before starting a computer

This commit is contained in:
Florian Nücke 2013-11-26 03:05:16 +01:00
parent 34033966da
commit 9af202331b
7 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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)
}
}

View File

@ -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 _ =>
}
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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 _ =>
}

View File

@ -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