mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 18:30:27 -04:00
Added robot.uuidFormat setting to control UUIDs assigned to robots' fake players. See comment in config for usage. Disclaimer: relatively untested.
This commit is contained in:
parent
2947ded770
commit
8cccc17ace
@ -304,6 +304,16 @@ opencomputers {
|
|||||||
# block from another mod, the name will default to 'OpenComputers'.
|
# block from another mod, the name will default to 'OpenComputers'.
|
||||||
nameFormat: "$player$.robot"
|
nameFormat: "$player$.robot"
|
||||||
|
|
||||||
|
# Controls the UUID robots are given. You can either specify a fixed UUID
|
||||||
|
# here or use the two provided variables:
|
||||||
|
# - $random$, which will assign each robot a random UUID.
|
||||||
|
# - $player$, which assigns to each placed robot the UUID of the player
|
||||||
|
# that placed it (note: if robots are placed by fake players, i.e.
|
||||||
|
# other mods' blocks, they will get that mods' fake player's profile!)
|
||||||
|
# Note that if no player UUID is available this will be the same as
|
||||||
|
# $random$.
|
||||||
|
uuidFormat: "$player$"
|
||||||
|
|
||||||
# This controls how fast robots gain experience, and how that experience
|
# This controls how fast robots gain experience, and how that experience
|
||||||
# alters the stats.
|
# alters the stats.
|
||||||
xp {
|
xp {
|
||||||
|
@ -96,6 +96,7 @@ class Settings(val config: Config) {
|
|||||||
val useAndPlaceRange = config.getDouble("robot.useAndPlaceRange")
|
val useAndPlaceRange = config.getDouble("robot.useAndPlaceRange")
|
||||||
val itemDamageRate = config.getDouble("robot.itemDamageRate") max 0 min 1
|
val itemDamageRate = config.getDouble("robot.itemDamageRate") max 0 min 1
|
||||||
val nameFormat = config.getString("robot.nameFormat")
|
val nameFormat = config.getString("robot.nameFormat")
|
||||||
|
val uuidFormat = config.getString("robot.uuidFormat")
|
||||||
|
|
||||||
// robot.xp
|
// robot.xp
|
||||||
val baseXpToLevel = config.getDouble("robot.xp.baseValue") max 0
|
val baseXpToLevel = config.getDouble("robot.xp.baseValue") max 0
|
||||||
|
@ -185,7 +185,7 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
|
|||||||
}) match {
|
}) match {
|
||||||
case Some((robot, owner, uuid)) =>
|
case Some((robot, owner, uuid)) =>
|
||||||
robot.owner = owner
|
robot.owner = owner
|
||||||
robot.ownerUuid = uuid
|
robot.ownerUuid = Option(robot.determineUUID(uuid))
|
||||||
robot.info.load(stack)
|
robot.info.load(stack)
|
||||||
robot.bot.node.changeBuffer(robot.info.robotEnergy - robot.bot.node.localBuffer)
|
robot.bot.node.changeBuffer(robot.info.robotEnergy - robot.bot.node.localBuffer)
|
||||||
robot.updateInventorySize()
|
robot.updateInventorySize()
|
||||||
|
@ -124,6 +124,18 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
|
|||||||
|
|
||||||
private lazy val player_ = new robot.Player(this)
|
private lazy val player_ = new robot.Player(this)
|
||||||
|
|
||||||
|
def determineUUID(playerUUID: Option[UUID] = None) = {
|
||||||
|
val format = Settings.get.uuidFormat
|
||||||
|
val randomUUID = UUID.randomUUID()
|
||||||
|
try UUID.fromString(format.
|
||||||
|
replaceAllLiterally("$random$", randomUUID.toString).
|
||||||
|
replaceAllLiterally("$player$", playerUUID.map(_.toString).getOrElse(randomUUID.toString))) catch {
|
||||||
|
case t: Throwable =>
|
||||||
|
OpenComputers.log.warn("Failed determining robot UUID, check your config's `uuidFormat` entry!", t)
|
||||||
|
randomUUID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
def name = info.name
|
def name = info.name
|
||||||
|
@ -49,7 +49,7 @@ import scala.reflect._
|
|||||||
|
|
||||||
object Player {
|
object Player {
|
||||||
def profileFor(robot: tileentity.Robot) = {
|
def profileFor(robot: tileentity.Robot) = {
|
||||||
val uuid = robot.ownerUuid.getOrElse(UUID.randomUUID())
|
val uuid = robot.ownerUuid.getOrElse(robot.determineUUID())
|
||||||
val randomId = (robot.world.rand.nextInt(0xFFFFFF) + 1).toString
|
val randomId = (robot.world.rand.nextInt(0xFFFFFF) + 1).toString
|
||||||
val name = Settings.get.nameFormat.
|
val name = Settings.get.nameFormat.
|
||||||
replace("$player$", robot.owner).
|
replace("$player$", robot.owner).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user