mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-29 00:26:15 -04:00
Add build types (normal/nomodify/modifyonly)
This commit is contained in:
parent
47911b6e29
commit
3646407eef
@ -34,8 +34,9 @@ namespace MCGalaxy.Commands {
|
|||||||
if (message == "") {
|
if (message == "") {
|
||||||
Player.SendMessage(p, "Map authors: " + p.level.Authors);
|
Player.SendMessage(p, "Map authors: " + p.level.Authors);
|
||||||
Player.SendMessage(p, "Pillaring allowed: " + p.level.Pillaring);
|
Player.SendMessage(p, "Pillaring allowed: " + p.level.Pillaring);
|
||||||
|
Player.SendMessage(p, "Build type: " + p.level.BuildType);
|
||||||
}
|
}
|
||||||
p.level.Authors = message.Replace(" ", "%S, ")
|
p.level.Authors = message.Replace(" ", "%S, ");
|
||||||
Player.SendMessage(p, "Sets the authors of the map to: " + message);
|
Player.SendMessage(p, "Sets the authors of the map to: " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,17 +30,17 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (p == null) { MessageInGameOnly(p); return; }
|
if (p == null) { MessageInGameOnly(p); return; }
|
||||||
if (p.assertingSurvive) {
|
if (p.pledgeSurvive) {
|
||||||
Player.SendMessage(p, "You cannot un-assert that you will be infected."); return;
|
Player.SendMessage(p, "You cannot un-pledge that you will be infected."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.assertingSurvive = true;
|
p.pledgeSurvive = true;
|
||||||
Server.zombie.CurrentLevel
|
Server.zombie.CurrentLevel
|
||||||
.ChatLevel(p.FullName + " %Sasserts that they will not succumb to the infection!");
|
.ChatLevel(p.FullName + " %Spledges that they will not succumb to the infection!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.SendMessage(p, "%T/human %H- asserts that you will not be infected.");
|
Player.SendMessage(p, "%T/human %H- pledges that you will not be infected.");
|
||||||
Player.SendMessage(p, "%HIf you survive, you receive an &aextra 5 %3" + Server.moneys);
|
Player.SendMessage(p, "%HIf you survive, you receive an &aextra 5 %3" + Server.moneys);
|
||||||
Player.SendMessage(p, "%HHowever, if you are infected, you will &close 2 %3" + Server.moneys);
|
Player.SendMessage(p, "%HHowever, if you are infected, you will &close 2 %3" + Server.moneys);
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ namespace MCGalaxy.Games
|
|||||||
Player[] online = PlayerInfo.Online.Items;
|
Player[] online = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in online) {
|
foreach (Player pl in online) {
|
||||||
pl.ratedMap = false;
|
pl.ratedMap = false;
|
||||||
pl.assertingSurvive = false;
|
pl.pledgeSurvive = false;
|
||||||
if (pl.level == oldMap)
|
if (pl.level == oldMap)
|
||||||
{
|
{
|
||||||
if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, "");
|
if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, "");
|
||||||
|
@ -193,9 +193,9 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CheckAssertHuman(Player pAlive) {
|
void CheckAssertHuman(Player pAlive) {
|
||||||
if (!pAlive.assertingSurvive) return;
|
if (!pAlive.pledgeSurvive) return;
|
||||||
pAlive.assertingSurvive = false;
|
pAlive.pledgeSurvive = false;
|
||||||
CurrentLevel.ChatLevel(pAlive.FullName + "%Sfailed the challenge of not being infected.");
|
CurrentLevel.ChatLevel(pAlive.FullName + "%Sbroke their pledge of not being infected.");
|
||||||
pAlive.money = Math.Max(pAlive.money - 2, 0);
|
pAlive.money = Math.Max(pAlive.money - 2, 0);
|
||||||
pAlive.OnMoneyChanged();
|
pAlive.OnMoneyChanged();
|
||||||
}
|
}
|
||||||
@ -254,9 +254,9 @@ namespace MCGalaxy.Games {
|
|||||||
ResetPlayer(pl, ref playersString);
|
ResetPlayer(pl, ref playersString);
|
||||||
} else {
|
} else {
|
||||||
foreach (Player pl in alive) {
|
foreach (Player pl in alive) {
|
||||||
if (pl.assertingSurvive) {
|
if (pl.pledgeSurvive) {
|
||||||
pl.SendMessage("You received &a5 %3" + Server.moneys +
|
pl.SendMessage("You received &a5 %3" + Server.moneys +
|
||||||
"%s for successfully asserting that you would survive.");
|
"%s for successfully pledging that you would survive.");
|
||||||
pl.money += 5;
|
pl.money += 5;
|
||||||
pl.OnMoneyChanged();
|
pl.OnMoneyChanged();
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,14 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
||||||
byte action, byte tile, byte b) {
|
byte action, byte tile, byte b) {
|
||||||
|
|
||||||
|
if (CurrentLevel.BuildType == BuildType.NoModify) {
|
||||||
|
p.RevertBlock(x, y, z); return true;
|
||||||
|
} else if (CurrentLevel.BuildType == BuildType.ModifyOnly
|
||||||
|
&& p.level.GetTile(x, y, z) == Block.op_air) {
|
||||||
|
p.RevertBlock(x, y, z); return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (action == 1 && !CurrentLevel.Pillaring && !p.referee) {
|
if (action == 1 && !CurrentLevel.Pillaring && !p.referee) {
|
||||||
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
|
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
|
||||||
p.blocksStacked++;
|
p.blocksStacked++;
|
||||||
@ -113,8 +121,8 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
public override void PlayerJoinedServer(Player p) {
|
public override void PlayerJoinedServer(Player p) {
|
||||||
if (Status == ZombieGameStatus.NotStarted) return;
|
if (Status == ZombieGameStatus.NotStarted) return;
|
||||||
Player.SendMessage(p, "There is a Zombie Survival game currently in-progress! " +
|
Player.SendMessage(p, "A Zombie Survival game is running! " +
|
||||||
"Join it by typing /g " + CurrentLevelName);
|
"Type %T/g " + CurrentLevelName + " %Sto join.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PlayerJoinedLevel(Player p, Level oldLvl) {
|
public override void PlayerJoinedLevel(Player p, Level oldLvl) {
|
||||||
@ -132,6 +140,10 @@ namespace MCGalaxy.Games {
|
|||||||
p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
|
p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
|
||||||
p.SendMessage("This map has &a" + CurrentLevel.Likes +
|
p.SendMessage("This map has &a" + CurrentLevel.Likes +
|
||||||
" likes %Sand &c" + CurrentLevel.Dislikes + " dislikes");
|
" likes %Sand &c" + CurrentLevel.Dislikes + " dislikes");
|
||||||
|
p.SendCpeMessage(CpeMessageType.Status2,
|
||||||
|
"%SPillaring " + (CurrentLevel.Pillaring ? "&aAllowed" : "&cForbidden") +
|
||||||
|
"%S, Type is &a" + CurrentLevel.BuildType);
|
||||||
|
|
||||||
if (CurrentLevel.Authors != "")
|
if (CurrentLevel.Authors != "")
|
||||||
p.SendMessage("It was created by " + CurrentLevel.Authors);
|
p.SendMessage("It was created by " + CurrentLevel.Authors);
|
||||||
p.SendCpeMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys);
|
p.SendCpeMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys);
|
||||||
@ -141,6 +153,7 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
p.SendCpeMessage(CpeMessageType.BottomRight1, "");
|
p.SendCpeMessage(CpeMessageType.BottomRight1, "");
|
||||||
p.SendCpeMessage(CpeMessageType.Status1, "");
|
p.SendCpeMessage(CpeMessageType.Status1, "");
|
||||||
|
p.SendCpeMessage(CpeMessageType.Status2, "");
|
||||||
Alive.Remove(p);
|
Alive.Remove(p);
|
||||||
Infected.Remove(p);
|
Infected.Remove(p);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ namespace MCGalaxy.Games {
|
|||||||
online = PlayerInfo.Online.Items;
|
online = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in online) {
|
foreach (Player pl in online) {
|
||||||
pl.ratedMap = false;
|
pl.ratedMap = false;
|
||||||
pl.assertingSurvive = false;
|
pl.pledgeSurvive = false;
|
||||||
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
|
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
|
||||||
pl.SendMessage("Going to the next map!");
|
pl.SendMessage("Going to the next map!");
|
||||||
Command.all.Find("goto").Use(pl, next);
|
Command.all.Find("goto").Use(pl, next);
|
||||||
@ -204,7 +204,7 @@ namespace MCGalaxy.Games {
|
|||||||
Player[] online = PlayerInfo.Online.Items;
|
Player[] online = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in online) {
|
foreach (Player pl in online) {
|
||||||
pl.ratedMap = false;
|
pl.ratedMap = false;
|
||||||
pl.assertingSurvive = false;
|
pl.pledgeSurvive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ namespace MCGalaxy {
|
|||||||
SendDefineBlock(pl, def);
|
SendDefineBlock(pl, def);
|
||||||
|
|
||||||
if (pl.HasCpeExt(CpeExt.BlockPermissions))
|
if (pl.HasCpeExt(CpeExt.BlockPermissions))
|
||||||
pl.SendSetBlockPermission(def.BlockID, pl.level.Buildable, pl.level.Deletable);
|
pl.SendSetBlockPermission(def.BlockID, pl.level.CanPlace, pl.level.CanDelete);
|
||||||
}
|
}
|
||||||
Save(global, level);
|
Save(global, level);
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ namespace MCGalaxy {
|
|||||||
SendDefineBlock(pl, def);
|
SendDefineBlock(pl, def);
|
||||||
|
|
||||||
if (pl.HasCpeExt(CpeExt.BlockPermissions))
|
if (pl.HasCpeExt(CpeExt.BlockPermissions))
|
||||||
pl.SendSetBlockPermission(def.BlockID, pl.level.Buildable, pl.level.Deletable);
|
pl.SendSetBlockPermission(def.BlockID, pl.level.CanPlace, pl.level.CanDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ using System.IO.Compression;
|
|||||||
|
|
||||||
namespace MCGalaxy.Levels.IO {
|
namespace MCGalaxy.Levels.IO {
|
||||||
|
|
||||||
|
//WARNING! DO NOT CHANGE THE WAY THE LEVEL IS SAVED/LOADED!
|
||||||
|
//You MUST make it able to save and load as a new version other wise you will make old levels incompatible!
|
||||||
public static class LvlFile {
|
public static class LvlFile {
|
||||||
|
|
||||||
public static void Save(Level level, string file) {
|
public static void Save(Level level, string file) {
|
||||||
|
@ -35,18 +35,14 @@ using MCGalaxy.Levels.IO;
|
|||||||
|
|
||||||
namespace MCGalaxy
|
namespace MCGalaxy
|
||||||
{
|
{
|
||||||
public enum LevelPermission //int is default
|
public enum LevelPermission {
|
||||||
{
|
Banned = -20, Guest = 0, Builder = 30,
|
||||||
Banned = -20,
|
AdvBuilder = 50, Operator = 80,
|
||||||
Guest = 0,
|
Admin = 100, Nobody = 120, Null = 150
|
||||||
Builder = 30,
|
|
||||||
AdvBuilder = 50,
|
|
||||||
Operator = 80,
|
|
||||||
Admin = 100,
|
|
||||||
Nobody = 120,
|
|
||||||
Null = 150
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum BuildType { Normal, ModifyOnly, NoModify };
|
||||||
|
|
||||||
public sealed partial class Level : IDisposable
|
public sealed partial class Level : IDisposable
|
||||||
{
|
{
|
||||||
#region Delegates
|
#region Delegates
|
||||||
@ -208,6 +204,9 @@ namespace MCGalaxy
|
|||||||
public int Likes, Dislikes;
|
public int Likes, Dislikes;
|
||||||
public string Authors = "";
|
public string Authors = "";
|
||||||
public bool Pillaring = !Server.zombie.noPillaring;
|
public bool Pillaring = !Server.zombie.noPillaring;
|
||||||
|
public BuildType BuildType = BuildType.Normal;
|
||||||
|
public bool CanPlace { get { return Buildable && BuildType != BuildType.NoModify; } }
|
||||||
|
public bool CanDelete { get { return Deletable && BuildType != BuildType.NoModify; } }
|
||||||
|
|
||||||
public Level(string n, ushort x, ushort y, ushort z, string type, int seed = 0, bool useSeed = false)
|
public Level(string n, ushort x, ushort y, ushort z, string type, int seed = 0, bool useSeed = false)
|
||||||
{
|
{
|
||||||
|
@ -239,18 +239,15 @@ namespace MCGalaxy
|
|||||||
public void SendCurrentBlockPermissions() {
|
public void SendCurrentBlockPermissions() {
|
||||||
byte count = hasCustomBlocks ? Block.CpeCount : Block.OriginalCount;
|
byte count = hasCustomBlocks ? Block.CpeCount : Block.OriginalCount;
|
||||||
for (byte i = 0; i < count; i++) {
|
for (byte i = 0; i < count; i++) {
|
||||||
bool canPlace = Block.canPlace(this, i);
|
bool canPlace = Block.canPlace(this, i) && level.CanPlace;
|
||||||
bool canDelete = canPlace;
|
bool canDelete = Block.canPlace(this, i) && level.CanDelete;
|
||||||
|
|
||||||
if (!level.Buildable) canPlace = false;
|
|
||||||
if (!level.Deletable) canDelete = false;
|
|
||||||
SendSetBlockPermission(i, canPlace, canDelete);
|
SendSetBlockPermission(i, canPlace, canDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasBlockDefs) return;
|
if (!hasBlockDefs) return;
|
||||||
for (int i = count; i < 256; i++) {
|
for (int i = count; i < 256; i++) {
|
||||||
if (level.CustomBlockDefs[i] == null) continue;
|
if (level.CustomBlockDefs[i] == null) continue;
|
||||||
SendSetBlockPermission((byte)i, level.Buildable, level.Deletable);
|
SendSetBlockPermission((byte)i, level.CanPlace, level.CanDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ namespace MCGalaxy {
|
|||||||
public int playersInfected = 0;
|
public int playersInfected = 0;
|
||||||
internal string lastSpawnColor = "";
|
internal string lastSpawnColor = "";
|
||||||
internal bool ratedMap = false;
|
internal bool ratedMap = false;
|
||||||
internal bool assertingSurvive = false;
|
internal bool pledgeSurvive = false;
|
||||||
|
|
||||||
//Tnt Wars
|
//Tnt Wars
|
||||||
public bool PlayingTntWars = false;
|
public bool PlayingTntWars = false;
|
||||||
@ -341,9 +341,8 @@ namespace MCGalaxy {
|
|||||||
byte head = level.GetTile(x, y, z);
|
byte head = level.GetTile(x, y, z);
|
||||||
byte feet = level.GetTile(x, (ushort)(y - 1), z);
|
byte feet = level.GetTile(x, (ushort)(y - 1), z);
|
||||||
|
|
||||||
if (Block.Walkthrough(Block.Convert(head)) && Block.Walkthrough(Block.Convert(feet)))
|
return (Block.Walkthrough(Block.Convert(head)) || head == Block.Zero)
|
||||||
return false;
|
&& (Block.Walkthrough(Block.Convert(feet)) || feet == Block.Zero);
|
||||||
return Block.Convert(head) != Block.Zero && Block.Convert(head) != Block.op_air;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//This is so that plugin devs can declare a player without needing a socket..
|
//This is so that plugin devs can declare a player without needing a socket..
|
||||||
|
Loading…
x
Reference in New Issue
Block a user