mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 14:54:12 -04:00
Core: Combine /allowguns and /map
This commit is contained in:
parent
28039c1bc7
commit
ba51b97366
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
Written by Jack1312
|
|
||||||
Copyright 2011 MCForge
|
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
|
||||||
not use this file except in compliance with the Licenses. You may
|
|
||||||
obtain a copy of the Licenses at
|
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
||||||
or implied. See the Licenses for the specific language governing
|
|
||||||
permissions and limitations under the Licenses.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
namespace MCGalaxy.Commands {
|
|
||||||
public sealed class CmdAllowGuns : Command {
|
|
||||||
public override string name { get { return "allowguns"; } }
|
|
||||||
public override string shortcut { get { return "ag"; } }
|
|
||||||
public override string type { get { return CommandTypes.Moderation; } }
|
|
||||||
public override bool museumUsable { get { return true; } }
|
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
|
||||||
public CmdAllowGuns() { }
|
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
|
||||||
if (CheckSuper(p, message, "level name")) return;
|
|
||||||
Level lvl = p.level;
|
|
||||||
if (message != "") {
|
|
||||||
lvl = LevelInfo.FindMatches(p, message);
|
|
||||||
if (lvl == null) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lvl.guns) {
|
|
||||||
Chat.MessageAll("&9Gun usage has been disabled on &c{0}&9!", lvl.name);
|
|
||||||
Player[] players = PlayerInfo.Online.Items;
|
|
||||||
foreach (Player pl in players)
|
|
||||||
if (pl.level.name.CaselessEq(lvl.name))
|
|
||||||
pl.aiming = false;
|
|
||||||
} else {
|
|
||||||
Chat.MessageAll("&9Gun usage has been enabled on &c{0}&9!", lvl.name);
|
|
||||||
}
|
|
||||||
lvl.guns = !lvl.guns;
|
|
||||||
Level.SaveSettings(lvl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Help(Player p) {
|
|
||||||
Player.Message(p, "%T/allowguns [level]");
|
|
||||||
Player.Message(p, "%HAllows/disallows guns and missiles on the specified level.");
|
|
||||||
Player.Message(p, "%HIf no [level] is given, uses your current level.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,7 +29,8 @@ namespace MCGalaxy.Commands.World {
|
|||||||
new CommandPerm(LevelPermission.Admin, "+ can set realm owners") }; }
|
new CommandPerm(LevelPermission.Admin, "+ can set realm owners") }; }
|
||||||
}
|
}
|
||||||
public override CommandAlias[] Aliases {
|
public override CommandAlias[] Aliases {
|
||||||
get { return new[] { new CommandAlias("ps", "physicspeed") }; }
|
get { return new[] { new CommandAlias("ps", "physicspeed"),
|
||||||
|
new CommandAlias("allowguns", null, "guns") }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
|
@ -31,20 +31,21 @@ namespace MCGalaxy {
|
|||||||
{ "Overload", (p, l, value) => SetPhysicsOverload(p, l, value, "Physics overload") },
|
{ "Overload", (p, l, value) => SetPhysicsOverload(p, l, value, "Physics overload") },
|
||||||
{ "Fall", (p, l, value) => SetInt(p, l, ref l.fall, value, "Fall distance") },
|
{ "Fall", (p, l, value) => SetInt(p, l, ref l.fall, value, "Fall distance") },
|
||||||
{ "Drown", (p, l, value) => SetInt(p, l, ref l.drown, value, "Drown time (in tenths of a second)") },
|
{ "Drown", (p, l, value) => SetInt(p, l, ref l.drown, value, "Drown time (in tenths of a second)") },
|
||||||
{ "Finite", (p, l, value) => Set(p, l, ref l.finite, "Finite mode") },
|
{ "Finite", (p, l, value) => Toggle(p, l, ref l.finite, "Finite mode") },
|
||||||
{ "AI", (p, l, value) => Set(p, l, ref l.ai, "Animal AI") },
|
{ "AI", (p, l, value) => Toggle(p, l, ref l.ai, "Animal AI") },
|
||||||
{ "Edge", (p, l, value) => Set(p, l, ref l.edgeWater, "Edge water") },
|
{ "Edge", (p, l, value) => Toggle(p, l, ref l.edgeWater, "Edge water") },
|
||||||
{ "Grass", (p, l, value) => Set(p, l, ref l.GrassGrow, "Growing grass") },
|
{ "Grass", (p, l, value) => Toggle(p, l, ref l.GrassGrow, "Growing grass") },
|
||||||
{ "Death", (p, l, value) => Set(p, l, ref l.Death, "Survival death") },
|
{ "Death", (p, l, value) => Toggle(p, l, ref l.Death, "Survival death") },
|
||||||
{ "Killer", (p, l, value) => Set(p, l, ref l.Killer, "Killer blocks") },
|
{ "Killer", (p, l, value) => Toggle(p, l, ref l.Killer, "Killer blocks") },
|
||||||
{ "Unload", (p, l, value) => Set(p, l, ref l.unload, "Auto unload") },
|
{ "Unload", (p, l, value) => Toggle(p, l, ref l.unload, "Auto unload") },
|
||||||
{ "LoadOnGoto", (p, l, value) => Set(p, l, ref l.loadOnGoto, "Load on goto") },
|
{ "LoadOnGoto", (p, l, value) => Toggle(p, l, ref l.loadOnGoto, "Load on goto") },
|
||||||
{ "LeafDecay", (p, l, value) => Set(p, l, ref l.leafDecay, "Leaf decay") },
|
{ "LeafDecay", (p, l, value) => Toggle(p, l, ref l.leafDecay, "Leaf decay") },
|
||||||
{ "RandomFlow", (p, l, value) => Set(p, l, ref l.randomFlow, "Random flow") },
|
{ "RandomFlow", (p, l, value) => Toggle(p, l, ref l.randomFlow, "Random flow") },
|
||||||
{ "GrowTrees", (p, l, value) => Set(p, l, ref l.growTrees, "Tree growing") },
|
{ "GrowTrees", (p, l, value) => Toggle(p, l, ref l.growTrees, "Tree growing") },
|
||||||
{ "Chat", (p, l, value) => Set(p, l, ref l.worldChat, "Roleplay (level only) chat: ", true) },
|
{ "Chat", (p, l, value) => Toggle(p, l, ref l.worldChat, "Roleplay (level only) chat: ", true) },
|
||||||
{ "Buildable", (p, l, value) => SetPerms(p, l, ref l.Buildable, "Buildable") },
|
{ "Guns", ToggleGuns },
|
||||||
{ "Deletable", (p, l, value) => SetPerms(p, l, ref l.Deletable, "Deletable") },
|
{ "Buildable", (p, l, value) => TogglePerms(p, l, ref l.Buildable, "Buildable") },
|
||||||
|
{ "Deletable", (p, l, value) => TogglePerms(p, l, ref l.Deletable, "Deletable") },
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Dictionary<string, string> Help = new Dictionary<string, string>() {
|
public static Dictionary<string, string> Help = new Dictionary<string, string>() {
|
||||||
@ -66,6 +67,7 @@ namespace MCGalaxy {
|
|||||||
{ "RandomFlow", "%HWhether flooding liquids flow less uniformly." },
|
{ "RandomFlow", "%HWhether flooding liquids flow less uniformly." },
|
||||||
{ "GrowTrees", "%HWhether saplings grow into trees after a while." },
|
{ "GrowTrees", "%HWhether saplings grow into trees after a while." },
|
||||||
{ "Chat", "%HWhether chat is only seen from and sent to players in the map." },
|
{ "Chat", "%HWhether chat is only seen from and sent to players in the map." },
|
||||||
|
{ "Guns", "%HWhether guns and missiles can be used" },
|
||||||
{ "Buildable", "%HWhether any blocks can be placed by players." },
|
{ "Buildable", "%HWhether any blocks can be placed by players." },
|
||||||
{ "Deletable", "%HWhether any blocks can be deleted by players." },
|
{ "Deletable", "%HWhether any blocks can be deleted by players." },
|
||||||
};
|
};
|
||||||
@ -81,6 +83,24 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static string GetBool(bool value) { return value ? "&aON" : "&cOFF"; }
|
static string GetBool(bool value) { return value ? "&aON" : "&cOFF"; }
|
||||||
|
|
||||||
|
static void SetMotd(Player p, Level lvl, string value) {
|
||||||
|
lvl.motd = value == "" ? "ignore" : value;
|
||||||
|
lvl.ChatLevel("Map's MOTD was changed to: &b" + lvl.motd);
|
||||||
|
|
||||||
|
Player[] players = PlayerInfo.Online.Items;
|
||||||
|
foreach (Player pl in players) {
|
||||||
|
if (pl.level != lvl || !pl.HasCpeExt(CpeExt.HackControl)) continue;
|
||||||
|
pl.Send(Hacks.MakeHackControl(pl));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetRealmOwner(Player p, Level lvl, string value) {
|
||||||
|
lvl.RealmOwner = value;
|
||||||
|
if (value == "") Player.Message(p, "Removed realm owner for this level.");
|
||||||
|
else Player.Message(p, "Set realm owner/owners of this level to {0}.", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void SetPhysicsSpeed(Player p, Level lvl, string value, string name) {
|
static void SetPhysicsSpeed(Player p, Level lvl, string value, string name) {
|
||||||
SetInt(p, lvl, ref lvl.speedPhysics, value, name, PhysicsSpeedValidator);
|
SetInt(p, lvl, ref lvl.speedPhysics, value, name, PhysicsSpeedValidator);
|
||||||
@ -105,38 +125,6 @@ namespace MCGalaxy {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void SetMotd(Player p, Level lvl, string value) {
|
|
||||||
lvl.motd = value == "" ? "ignore" : value;
|
|
||||||
lvl.ChatLevel("Map's MOTD was changed to: &b" + lvl.motd);
|
|
||||||
|
|
||||||
Player[] players = PlayerInfo.Online.Items;
|
|
||||||
foreach (Player pl in players) {
|
|
||||||
if (pl.level != lvl || !pl.HasCpeExt(CpeExt.HackControl)) continue;
|
|
||||||
pl.Send(Hacks.MakeHackControl(pl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetRealmOwner(Player p, Level lvl, string value) {
|
|
||||||
lvl.RealmOwner = value;
|
|
||||||
if (value == "") Player.Message(p, "Removed realm owner for this level.");
|
|
||||||
else Player.Message(p, "Set realm owner/owners of this level to {0}.", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetPerms(Player p, Level lvl, ref bool target, string name) {
|
|
||||||
Set(p, lvl, ref target, name);
|
|
||||||
lvl.UpdateBlockPermissions();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Set(Player p, Level lvl, ref bool target, string name, bool not = false) {
|
|
||||||
target = !target;
|
|
||||||
bool display = not ? !target : target;
|
|
||||||
lvl.ChatLevel(name + ": " + GetBool(display));
|
|
||||||
|
|
||||||
if (p == null || p.level != lvl)
|
|
||||||
Player.Message(p, name + ": " + GetBool(display));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetInt(Player p, Level lvl, ref int target, string value, string name,
|
static void SetInt(Player p, Level lvl, ref int target, string value, string name,
|
||||||
Func<Player, int, bool> validator = null) {
|
Func<Player, int, bool> validator = null) {
|
||||||
if (value == "") { Player.Message(p, "You must provide an integer."); return; }
|
if (value == "") { Player.Message(p, "You must provide an integer."); return; }
|
||||||
@ -147,5 +135,31 @@ namespace MCGalaxy {
|
|||||||
target = raw;
|
target = raw;
|
||||||
lvl.ChatLevel(name + ": &b" + target);
|
lvl.ChatLevel(name + ": &b" + target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ToggleGuns(Player p, Level lvl, string value) {
|
||||||
|
Toggle(p, lvl, ref lvl.guns, "Guns allowed");
|
||||||
|
if (lvl.guns) return;
|
||||||
|
|
||||||
|
Player[] players = PlayerInfo.Online.Items;
|
||||||
|
foreach (Player pl in players) {
|
||||||
|
if (pl.level.name.CaselessEq(lvl.name))
|
||||||
|
pl.aiming = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TogglePerms(Player p, Level lvl, ref bool target, string name) {
|
||||||
|
Toggle(p, lvl, ref target, name);
|
||||||
|
lvl.UpdateBlockPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Toggle(Player p, Level lvl, ref bool target, string name, bool not = false) {
|
||||||
|
target = !target;
|
||||||
|
bool display = not ? !target : target;
|
||||||
|
lvl.ChatLevel(name + ": " + GetBool(display));
|
||||||
|
|
||||||
|
if (p == null || p.level != lvl)
|
||||||
|
Player.Message(p, name + ": " + GetBool(display));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,6 @@
|
|||||||
<Compile Include="Commands\Information\CmdWhois.cs" />
|
<Compile Include="Commands\Information\CmdWhois.cs" />
|
||||||
<Compile Include="Commands\Information\CmdWhoNick.cs" />
|
<Compile Include="Commands\Information\CmdWhoNick.cs" />
|
||||||
<Compile Include="Commands\Information\WhoInfo.cs" />
|
<Compile Include="Commands\Information\WhoInfo.cs" />
|
||||||
<Compile Include="Commands\Moderation\CmdAllowGuns.cs" />
|
|
||||||
<Compile Include="Commands\Moderation\CmdBan.cs" />
|
<Compile Include="Commands\Moderation\CmdBan.cs" />
|
||||||
<Compile Include="Commands\Moderation\CmdBanEdit.cs" />
|
<Compile Include="Commands\Moderation\CmdBanEdit.cs" />
|
||||||
<Compile Include="Commands\Moderation\CmdBanip.cs" />
|
<Compile Include="Commands\Moderation\CmdBanip.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user