From 699e07a0f751771da988ff973ce9914ef7d4ae45 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Fri, 4 Jan 2019 14:11:33 -0800 Subject: [PATCH] plugin: Add support for expectedPlaceIds in the protocol --- plugin/src/ApiContext.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/plugin/src/ApiContext.lua b/plugin/src/ApiContext.lua index d7a5b6d6..aba7f53d 100644 --- a/plugin/src/ApiContext.lua +++ b/plugin/src/ApiContext.lua @@ -66,6 +66,36 @@ function ApiContext:connect() return Promise.reject(message) end + if body.expectedPlaceIds ~= nil then + local foundId = false + + for _, id in ipairs(body.expectedPlaceIds) do + if id == game.PlaceId then + foundId = true + break + end + end + + if not foundId then + local idList = {} + for _, id in ipairs(body.expectedPlaceIds) do + table.insert(idList, "- " .. tostring(id)) + end + + local message = ( + "Found a Rojo server, but its project is set to only be used with a specific list of places." .. + "\nYour place ID is %s, but needs to be one of these:" .. + "\n%s" .. + "\n\nTo change this list, edit 'servePlaceIds' in roblox-project.json" + ):format( + tostring(game.PlaceId), + table.concat(idList, "\n") + ) + + return Promise.reject(message) + end + end + self.serverId = body.serverId self.connected = true self.partitionRoutes = body.partitions