private static bool allowBlockPlaceChunkOwnership(ModLoader.OnTryChangeBlockUserData d) { if (d.requestedBy.ID.steamID.m_SteamID == 0) { return(true); } string ChunkID = ColonyAPI.Managers.WorldManager.XZPositionToString(d.voxelHit.ToChunk()); if (Managers.WorldManager.ChunkDataList.ContainsKey(ChunkID)) { Data.ChunkData cd = Managers.WorldManager.ChunkDataList[ChunkID]; NetworkID id = cd.getOwner(); if (cd.hasOwner()) { if (id == d.requestedBy.ID) { return(true); } else { return(false); } } else { //Utilities.WriteLog("Enforce: " + ConfigManager.getConfigBoolean("chunks.enforce")); if (ColonyAPI.Managers.ConfigManager.getConfigBoolean("ColonyPlusPlus-Utilities", "chunks.enforce") == true) { return(false); } else { return(true); } } } else { //Utilities.WriteLog("Enforce: " + ConfigManager.getConfigBoolean("chunks.enforce")); if (ColonyAPI.Managers.ConfigManager.getConfigBoolean("ColonyPlusPlus-Utilities", "chunks.enforce") == true) { return(false); } else { return(true); } } }
public static bool unclaimChunk(Vector3Int position, NetworkID playerid, bool force = false) { Vector3Int p = position.ToChunk(); string chunkname = ColonyAPI.Managers.WorldManager.XZPositionToString(p); if (ChunkDataList.ContainsKey(chunkname)) { Data.ChunkData c = ChunkDataList[chunkname]; if (c.getOwner() == playerid || force) { bool result = c.removeOwner(); SaveJSON(); return(result); } return(false); } else { return(false); } }
protected override bool RunCommand(Players.Player ply, string[] args, NetworkID target) { if (PermissionsManager.CheckAndWarnPermission(ply, "chunk.info") && ColonyAPI.Managers.ConfigManager.getConfigBoolean("ColonyPlusPlus-Utilities", "chunks.enabled")) { Vector3Int pos = ColonyAPI.Managers.WorldManager.positionToVector3Int(ply.Position).ToChunk(); string chunkName = ColonyAPI.Managers.WorldManager.XZPositionToString(pos); if (Managers.WorldManager.ChunkDataList.ContainsKey(chunkName)) { Data.ChunkData c = Managers.WorldManager.ChunkDataList[chunkName]; ColonyAPI.Helpers.Chat.sendSilent(ply, String.Format("Chunk data for chunk: {0}", chunkName), ColonyAPI.Helpers.Chat.ChatColour.lime, ColonyAPI.Helpers.Chat.ChatStyle.bold); ColonyAPI.Helpers.Chat.sendSilent(ply, String.Format("Currently owned: {0}", c.hasOwner()), ColonyAPI.Helpers.Chat.ChatColour.lime, ColonyAPI.Helpers.Chat.ChatStyle.bold); if (c.hasOwner()) { ColonyAPI.Helpers.Chat.sendSilent(ply, String.Format("Currently owned by: {0}", Players.GetPlayer(c.getOwner()).Name), ColonyAPI.Helpers.Chat.ChatColour.lime, ColonyAPI.Helpers.Chat.ChatStyle.bold); } string prevOwners = ""; foreach (NetworkID n in c.ownerHistory) { prevOwners += Players.GetPlayer(n).Name + ", "; } ColonyAPI.Helpers.Chat.sendSilent(ply, String.Format("Previous Owners ({0}): {1}", c.ownerHistory.Count, prevOwners), ColonyAPI.Helpers.Chat.ChatColour.lime, ColonyAPI.Helpers.Chat.ChatStyle.bold); } else { ColonyAPI.Helpers.Chat.sendSilent(ply, "No chunk data", ColonyAPI.Helpers.Chat.ChatColour.red, ColonyAPI.Helpers.Chat.ChatStyle.bold); } } else { ColonyAPI.Helpers.Chat.sendSilent(ply, "You cannot check chunk info", ColonyAPI.Helpers.Chat.ChatColour.red, ColonyAPI.Helpers.Chat.ChatStyle.bold); } return(true); }
public static bool AllowPlaceBlock(ModLoader.OnTryChangeBlockUserData d) { if (PermissionsManager.CheckAndWarnPermission(Players.GetPlayer(d.requestedBy.ID), "world.admin")) { return(true); } // Check permissions if (PermissionsManager.CheckAndWarnPermission(Players.GetPlayer(d.requestedBy.ID), "world.build")) { //Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You have build permissions"); // first check if near spawn if (allowBlockFarEnoughFromSpawn(d)) { //Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You are far enough from spawn"); // what about chunk ownership if (allowBlockPlaceChunkOwnership(d)) { if (d.TypeNew == ItemTypes.IndexLookup.GetIndex("water")) { if (PermissionsManager.CheckAndWarnPermission(Players.GetPlayer(d.requestedBy.ID), "world.spawnbuilder")) { return(true); } return(false); } //Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You own the chunk"); return(true); } else { if (d.TypeNew == ItemTypes.IndexLookup.GetIndex("banner")) { string ChunkID = ColonyAPI.Managers.WorldManager.XZPositionToString(d.voxelHit.ToChunk()); if (Managers.WorldManager.ChunkDataList.ContainsKey(ChunkID)) { Data.ChunkData cd = Managers.WorldManager.ChunkDataList[ChunkID]; if (cd.hasOwner()) { NetworkID id = cd.getOwner(); if (id == d.requestedBy.ID) { return(true); } return(false); } } } ColonyAPI.Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You don't own the chunk"); return(false); } } else { //This section is for spawn. if (PermissionsManager.CheckAndWarnPermission(Players.GetPlayer(d.requestedBy.ID), "spawnbuilder")) { //Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You aren't far enough from spawn, but you are admin"); return(true); } else { ColonyAPI.Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You aren't far enough from spawn"); return(false); } } } else { ColonyAPI.Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You don't have build permissions"); return(false); } }