private static bool allowBlockPlaceChunkOwnership(ModLoader.OnTryChangeBlockUserData d) { if (d.requestedBy.ID.steamID.m_SteamID == 0) { return(true); } string ChunkID = Classes.Managers.WorldManager.positionToString(d.position.ToChunk()); if (Classes.Managers.WorldManager.ChunkDataList.ContainsKey(ChunkID)) { Classes.Data.ChunkData cd = Classes.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 (ConfigManager.getConfigBoolean("chunks.enforce") == true) { return(false); } else { return(true); } } } else { //Utilities.WriteLog("Enforce: " + ConfigManager.getConfigBoolean("chunks.enforce")); if (ConfigManager.getConfigBoolean("chunks.enforce") == true) { return(false); } else { 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 = Classes.Managers.WorldManager.positionToString(d.position.ToChunk()); if (Classes.Managers.WorldManager.ChunkDataList.ContainsKey(ChunkID)) { Classes.Data.ChunkData cd = Classes.Managers.WorldManager.ChunkDataList[ChunkID]; if (cd.hasOwner()) { NetworkID id = cd.getOwner(); if (id == d.requestedBy.ID) { return(true); } return(false); } } } 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 { Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You aren't far enough from spawn"); return(false); } } } else { Helpers.Chat.send(Players.GetPlayer(d.requestedBy.ID), "You don't have build permissions"); return(false); } }