Cleanup initalising commands, use much nicer GetTypes() instead of hardcoding every single command (Thanks Xeonaion). Remove /heartbeat and also remove /interval as its license explictly prevents us from modifying its source code.

This commit is contained in:
UnknownShadow200 2016-03-11 21:55:11 +11:00
parent 786d197b12
commit b919ed98a6
8 changed files with 15 additions and 489 deletions

View File

@ -1,327 +0,0 @@
/*
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
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.Collections.Generic;
using MCGalaxy.Commands;
namespace MCGalaxy
{
public abstract partial class Command
{
public static void InitAll()
{
all.AddOtherPerms = true;
all.Add(new Cmd8Ball());
all.Add(new CmdAbort());
all.Add(new CmdAbout());
// all.Add(new CmdAddGlobalBlock());
all.Add(new CmdAdminChat());
all.Add(new CmdAllowGuns());
all.Add(new CmdAfk());
all.Add(new CmdAka());
all.Add(new CmdAlive());
all.Add(new CmdAgree());
all.Add(new CmdAscend());
all.Add(new CmdAward());
all.Add(new CmdAwards());
all.Add(new CmdAwardMod());
all.Add(new CmdBack());
all.Add(new CmdBan());
all.Add(new CmdBanEdit());
all.Add(new CmdBaninfo());
all.Add(new CmdBanip());
all.Add(new CmdBanlist());
all.Add(new CmdBind());
all.Add(new CmdBlocks());
all.Add(new CmdBlockSet());
all.Add(new CmdBlockSpeed());
all.Add(new CmdBotAdd());
all.Add(new CmdBotAI());
all.Add(new CmdBotRemove());
all.Add(new CmdBots());
all.Add(new CmdBotSet());
all.Add(new CmdBotSummon());
all.Add(new CmdBrush());
all.Add(new CmdC4());
all.Add(new CmdCenter());
all.Add(new CmdChain());
all.Add(new CmdChangeLog());
all.Add(new CmdChatRoom());
all.Add(new CmdClearBlockChanges());
all.Add(new CmdClick());
all.Add(new CmdClones());
all.Add(new CmdCmdBind());
all.Add(new CmdCmdCreate());
all.Add(new CmdCmdLoad());
all.Add(new CmdCmdSet());
all.Add(new CmdCmdUnload());
all.Add(new CmdCompile());
all.Add(new CmdCompLoad());
all.Add(new CmdColor());
all.Add(new CmdCopy());
all.Add(new CmdCopyLVL());
all.Add(new CmdCountdown());
all.Add(new CmdCrashServer());
all.Add(new CmdCTF());
all.Add(new CmdCuboid());
all.Add(new CmdCustomColors());
all.Add(new CmdDelete());
all.Add(new CmdDeleteLvl());
all.Add(new CmdDelTempRank());
all.Add(new CmdDemote());
all.Add(new CmdDevs());
all.Add(new CmdDisagree());
all.Add(new CmdDescend());
all.Add(new CmdDisInfect());
all.Add(new CmdDraw());
all.Add(new CmdDrill());
all.Add(new CmdEconomy());
all.Add(new CmdEmote());
all.Add(new CmdEndRound());
all.Add(new CmdEnvironment());
all.Add(new CmdExplode());
all.Add(new CmdFakePay());
all.Add(new CmdFakeRank());
all.Add(new CmdFaq());
all.Add(new CmdFill());
all.Add(new CmdFixGrass());
all.Add(new CmdFlipHead());
all.Add(new CmdFlipHeads());
all.Add(new CmdFly());
all.Add(new CmdFollow());
all.Add(new CmdFreeze());
all.Add(new CmdGarbage());
all.Add(new CmdGcaccept());
all.Add(new CmdGcmods());
all.Add(new CmdGcrules());
//all.Add(new CmdGcbanlistupdate());
all.Add(new CmdGive());
all.Add(new CmdGlobal());
all.Add(new CmdGlobalBlock());
all.Add(new CmdGlobalCLS());
all.Add(new CmdGoto());
all.Add(new CmdGun());
all.Add(new CmdHackRank());
all.Add(new CmdHacks());
all.Add(new CmdHasirc());
//all.Add(new CmdHeartbeat()); // DEBUG COMMAND DO NOT USE
all.Add(new CmdHelp());
all.Add(new CmdHide());
all.Add(new CmdHigh5());
all.Add(new CmdHighlight());
all.Add(new CmdHollow());
all.Add(new CmdHost());
all.Add(new CmdHug());
all.Add(new CmdIgnore());
all.Add(new CmdImpersonate());
all.Add(new CmdImport());
all.Add(new CmdImageprint());
all.Add(new CmdInbox());
all.Add(new CmdInfect());
all.Add(new CmdInfected());
all.Add(new CmdInfo());
all.Add(new CmdInvincible());
all.Add(new CmdIrcControllers());
all.Add(new CmdJail());
all.Add(new CmdJoker());
all.Add(new CmdKick());
all.Add(new CmdKickban());
all.Add(new CmdKill());
all.Add(new CmdKillPhysics());
all.Add(new CmdLastCmd());
all.Add(new CmdLavaSurvival());
all.Add(new CmdLevels());
all.Add(new CmdLimit());
all.Add(new CmdLine());
all.Add(new CmdLoad());
all.Add(new CmdLocation());
all.Add(new CmdLockdown());
all.Add(new CmdLoginMessage());
all.Add(new CmdLogoutMessage());
all.Add(new CmdLowlag());
all.Add(new CmdLevelBlock());
all.Add(new CmdMain());
all.Add(new CmdMap());
all.Add(new CmdMapInfo());
all.Add(new CmdMark());
all.Add(new CmdMaze());
all.Add(new CmdMe());
all.Add(new CmdMeasure());
all.Add(new CmdMessageBlock());
all.Add(new CmdMissile());
all.Add(new CmdMode());
all.Add(new CmdModel());
all.Add(new CmdMods());
all.Add(new CmdModerate());
all.Add(new CmdMoney());
all.Add(new CmdMove());
all.Add(new CmdMoveAll());
all.Add(new CmdMuseum());
all.Add(new CmdMute());
all.Add(new CmdNewLvl());
all.Add(new CmdNews());
all.Add(new CmdNick());
all.Add(new CmdOHide());
all.Add(new CmdOpChat());
all.Add(new CmdOpRules());
all.Add(new CmdOpStats());
all.Add(new CmdOutline());
all.Add(new CmdOverseer());
all.Add(new CmdOZone());
all.Add(new CmdP2P());
all.Add(new CmdPaint());
all.Add(new CmdPass());
all.Add(new CmdPaste());
all.Add(new CmdPatrol());
all.Add(new CmdPause());
all.Add(new CmdPay());
all.Add(new CmdPClients());
all.Add(new CmdPCount());
all.Add(new CmdPCreate());
all.Add(new CmdPerbuildMax());
all.Add(new CmdPermissionBuild());
all.Add(new CmdPermissionVisit());
all.Add(new CmdPervisitMax());
all.Add(new CmdPhysics());
all.Add(new CmdPlace());
all.Add(new CmdPlayerCLS());
all.Add(new CmdPlayerEditDB());
all.Add(new CmdPlayers());
all.Add(new CmdPLoad());
all.Add(new CmdPortal());
all.Add(new CmdPossess());
all.Add(new CmdPromote());
all.Add(new CmdPUnload());
all.Add(new CmdPyramid());
all.Add(new CmdQueue());
all.Add(new CmdQuit());
all.Add(new CmdRagequit());
all.Add(new CmdRainbow());
all.Add(new CmdRankInfo());
all.Add(new CmdRankMsg());
all.Add(new CmdReachDistance());
all.Add(new CmdRedo());
all.Add(new CmdReload());
all.Add(new CmdReferee());
all.Add(new CmdRenameLvl());
all.Add(new CmdRepeat());
all.Add(new CmdReplace());
all.Add(new CmdReplaceAll());
all.Add(new CmdReplaceBrush());
all.Add(new CmdReplaceNot());
all.Add(new CmdReplaceNotBrush());
all.Add(new CmdReport());
all.Add(new CmdResetBot());
all.Add(new CmdResetPass());
all.Add(new CmdRestart());
all.Add(new CmdRestartPhysics());
all.Add(new CmdRestore());
all.Add(new CmdRestoreSelection());
all.Add(new CmdReveal());
all.Add(new CmdReview());
all.Add(new CmdRide());
all.Add(new CmdRoll());
all.Add(new CmdRules());
all.Add(new CmdSave());
all.Add(new CmdSay());
all.Add(new CmdSearch());
all.Add(new CmdSeen());
all.Add(new CmdSend());
all.Add(new CmdSendCmd());
all.Add(new CmdServerReport());
all.Add(new CmdServer());
all.Add(new CmdSetPass());
all.Add(new CmdSetRank());
all.Add(new CmdSetspawn());
all.Add(new CmdShutdown());
all.Add(new CmdSlap());
all.Add(new CmdSpawn());
all.Add(new CmdSpheroid());
all.Add(new CmdSpin());
all.Add(new CmdSPlace());
all.Add(new CmdStaff());
all.Add(new CmdStatic());
all.Add(new CmdSummon());
all.Add(new CmdTake());
all.Add(new CmdTColor());
all.Add(new CmdTempBan());
all.Add(new CmdTempRank());
all.Add(new CmdTempRankInfo());
all.Add(new CmdTempRankList());
all.Add(new CmdText());
all.Add(new CmdTexture());
all.Add(new CmdTime());
all.Add(new CmdTimer());
all.Add(new CmdTitle());
all.Add(new CmdTnt());
all.Add(new CmdTntWars());
all.Add(new CmdTop());
all.Add(new CmdTopFive());
all.Add(new CmdTopTen());
all.Add(new CmdTorus());
all.Add(new CmdTp());
all.Add(new CmdTpA());
all.Add(new CmdTpAccept());
all.Add(new CmdTpDeny());
all.Add(new CmdTpZone());
all.Add(new CmdTree());
all.Add(new CmdTrust());
all.Add(new CmdUBan());
all.Add(new CmdUnban());
all.Add(new CmdUnbanip());
all.Add(new CmdUndo());
all.Add(new CmdUnflood());
all.Add(new CmdUnload());
all.Add(new CmdUnloaded());
all.Add(new CmdUnlock());
all.Add(new CmdUpdate());
all.Add(new CmdView());
all.Add(new CmdViewRanks());
all.Add(new CmdVIP());
all.Add(new CmdVoice());
all.Add(new CmdVote());
all.Add(new CmdVoteKick());
all.Add(new CmdVoteResults());
all.Add(new CmdWarn());
all.Add(new CmdWarp());
all.Add(new CmdWaypoint());
all.Add(new CmdWhisper());
all.Add(new CmdWhitelist());
all.Add(new CmdWhoip());
all.Add(new CmdWhois());
all.Add(new CmdWhoNick());
all.Add(new CmdWhowas());
all.Add(new CmdWrite());
all.Add(new CmdWriteText());
all.Add(new CmdXban());
all.Add(new CmdXColor());
all.Add(new CmdXhide());
all.Add(new CmdXJail());
all.Add(new CmdXModel());
all.Add(new CmdXmute());
all.Add(new CmdXNick());
all.Add(new CmdXspawn());
all.Add(new CmdXTColor());
all.Add(new CmdXTitle());
all.Add(new CmdXundo());
all.Add(new CmdZombieGame());
all.Add(new CmdZone());
core.commands = new List<Command>(all.commands);
Scripting.Autoload();
}
}
}

View File

@ -17,7 +17,9 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using MCGalaxy.Commands; using MCGalaxy.Commands;
namespace MCGalaxy namespace MCGalaxy
{ {
public abstract partial class Command public abstract partial class Command
@ -39,6 +41,18 @@ namespace MCGalaxy
public static CommandList all = new CommandList(); public static CommandList all = new CommandList();
public static CommandList core = new CommandList(); public static CommandList core = new CommandList();
public static void InitAll() {
all.AddOtherPerms = true;
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
for (int i = 0; i < types.Length; i++) {
Type type = types[i];
if (!type.IsSubclassOf(typeof(Command)) || type.IsAbstract) continue;
all.Add((Command)Activator.CreateInstance(type));
}
core.commands = new List<Command>(all.commands);
Scripting.Autoload();
}
protected static void RevertAndClearState(Player p, ushort x, ushort y, ushort z) { protected static void RevertAndClearState(Player p, ushort x, ushort y, ushort z) {
p.ClearBlockchange(); p.ClearBlockchange();
p.RevertBlock(x, y, z); p.RevertBlock(x, y, z);

View File

@ -108,7 +108,6 @@ namespace MCGalaxy.Commands {
new CommandKeywords((new CmdGun()), "shoot boom terrorism missile"); new CommandKeywords((new CmdGun()), "shoot boom terrorism missile");
new CommandKeywords((new CmdHackRank()), "fake rank color set mod"); new CommandKeywords((new CmdHackRank()), "fake rank color set mod");
new CommandKeywords((new CmdHacks()), "hack fake"); new CommandKeywords((new CmdHacks()), "hack fake");
new CommandKeywords((new CmdHeartbeat()), "heart server list");
new CommandKeywords((new CmdHelp()), "info commands cmd list"); new CommandKeywords((new CmdHelp()), "info commands cmd list");
new CommandKeywords((new CmdHide()), "hidden show invisible"); new CommandKeywords((new CmdHide()), "hidden show invisible");
new CommandKeywords((new CmdHigh5()), "high 5 fun"); new CommandKeywords((new CmdHigh5()), "high 5 fun");

View File

@ -1,49 +0,0 @@
/*
Copyright 2010 MCLawl Team - Written by Valek (Modified for use with MCGalaxy)
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;
namespace MCGalaxy.Commands
{
public sealed class CmdHeartbeat : Command
{
public override string name { get { return "heartbeat"; } }
public override string shortcut { get { return "beat"; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Nobody; } }
public CmdHeartbeat() { }
public override void Use(Player p, string message)
{
try
{
Heart.Pump(new ClassiCubeBeat());
}
catch (Exception e)
{
Server.s.Log("Error with MCGalaxy pump.");
Server.ErrorLog(e);
}
Player.SendMessage(p, "Heartbeat pump sent.");
}
public override void Help(Player p)
{
Player.SendMessage(p, "/heartbeat - Forces a pump for the ClassiCube heartbeat. DEBUG PURPOSES ONLY.");
}
}
}

View File

@ -1,104 +0,0 @@
/*
Copyright 2011 MCDerp Team Based in Canada
MCDerp has been Licensed with the below license:
http://www.binpress.com/license/view/l/62e7c4034ccb45cd39d8dcbe9ed87bd8
Or, you can read the below summary;
Can be used on 1 site, unlimited servers
Personal use only (cannot be resold or distributed)
Non-commercial use only
Cannot modify source-code for any purpose (cannot create derivative works)
Software trademarks are included in the license
Software patents are included in the license
*/
using System;
using System.Timers;
namespace MCGalaxy.Commands
{
public class CmdInterval : Command
{
public override string name { get { return "interval"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
Command nowCmd;
Timer checker;
public override void Use(Player p, string message)
{
if (checker==null){
checker = new Timer(60000);
checker.Elapsed += new ElapsedEventHandler(checker_Elapsed);
checker.Start();
}
String[] incoming = message.Split(' ');
if(incoming.Length == 2)
{
nowCmd = Command.all.Find(incoming[0]);
if (nowCmd != null)
{
//command exists
nowCmd.isIntervalized = true;
nowCmd.intervalInMinutes = int.Parse(incoming[1]);
nowCmd.intervalUsingPlayer = p;
try
{
nowCmd.Use(nowCmd.intervalUsingPlayer, "");
}
catch (Exception e)
{
Player.SendMessage(p, "An error occoured. please report this to the devs, cause this cmd seems to be not Interval-Compatible atm");
nowCmd.isIntervalized = false;
return;
}
nowCmd.nextExecution = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, DateTime.Today.Hour, DateTime.Today.Minute + nowCmd.intervalInMinutes, 0);
}else{
Player.SendMessage(p, "This command doesn't exist.");
}
}else if(incoming.Length == 1){
nowCmd = Command.all.Find(incoming[0]);
if (nowCmd != null)
{
//command exists
if (nowCmd.isIntervalized)
{
nowCmd.isIntervalized = false;
Player.SendMessage(p, "Command will not be executed anymore in its Interval");
}
}
else
{
Player.SendMessage(p, "This command doesn't exist.");
}
}else{
this.Help(p); return;
}
nowCmd = null;
}
private void checker_Elapsed(object sender, ElapsedEventArgs e)
{
foreach (Command cmd in Command.all.commands)
{
try
{
if (cmd.nextExecution.CompareTo(DateTime.Today) > 0 && cmd.isIntervalized)
{
cmd.Use(cmd.intervalUsingPlayer, "");
cmd.nextExecution = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, DateTime.Today.Hour, DateTime.Today.Minute + nowCmd.intervalInMinutes, 0);
}
}catch(Exception ex){
}
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/Interval <Command> <Interval in minutes> - Executes a command every given minutes. The command will be executed if you send this command.");
}
}
}

View File

@ -37,7 +37,7 @@ namespace MCGalaxy {
while (true) { while (true) {
zombieRound = false; zombieRound = false;
amountOfRounds = amountOfRounds + 1; amountOfRounds++;
if (gameStatus == 0) { return; } if (gameStatus == 0) { return; }
else if (gameStatus == 1) { DoRound(); if (ChangeLevels) ChangeLevel();} else if (gameStatus == 1) { DoRound(); if (ChangeLevels) ChangeLevel();}

View File

@ -156,7 +156,6 @@
<Compile Include="Commands\Chat\CmdRankMsg.cs" /> <Compile Include="Commands\Chat\CmdRankMsg.cs" />
<Compile Include="Commands\Chat\CmdWhisper.cs" /> <Compile Include="Commands\Chat\CmdWhisper.cs" />
<Compile Include="Commands\CmdOverseer.cs" /> <Compile Include="Commands\CmdOverseer.cs" />
<Compile Include="Commands\Command.All.cs" />
<Compile Include="Commands\Command.cs" /> <Compile Include="Commands\Command.cs" />
<Compile Include="Commands\CommandKeywords.cs" /> <Compile Include="Commands\CommandKeywords.cs" />
<Compile Include="Commands\CommandList.cs" /> <Compile Include="Commands\CommandList.cs" />
@ -322,9 +321,7 @@
<Compile Include="Commands\Other\CmdGarbage.cs" /> <Compile Include="Commands\Other\CmdGarbage.cs" />
<Compile Include="Commands\Other\CmdGun.cs" /> <Compile Include="Commands\Other\CmdGun.cs" />
<Compile Include="Commands\Other\CmdHackRank.cs" /> <Compile Include="Commands\Other\CmdHackRank.cs" />
<Compile Include="Commands\Other\CmdHeartbeat.cs" />
<Compile Include="Commands\Other\CmdImpersonate.cs" /> <Compile Include="Commands\Other\CmdImpersonate.cs" />
<Compile Include="Commands\Other\CmdInterval.cs" />
<Compile Include="Commands\Other\CmdInvincible.cs" /> <Compile Include="Commands\Other\CmdInvincible.cs" />
<Compile Include="Commands\Other\CmdKill.cs" /> <Compile Include="Commands\Other\CmdKill.cs" />
<Compile Include="Commands\Other\CmdLoginMessage.cs" /> <Compile Include="Commands\Other\CmdLoginMessage.cs" />

View File

@ -749,10 +749,6 @@ namespace MCGalaxy {
w.WriteLine("# spam-counter-reset-time\t\t= 2"); w.WriteLine("# spam-counter-reset-time\t\t= 2");
w.WriteLine("# bufferblocks\t\t\t= Should buffer blocks by default for maps?"); w.WriteLine("# bufferblocks\t\t\t= Should buffer blocks by default for maps?");
w.WriteLine(); w.WriteLine();
w.WriteLine("# MCGalaxy-protection-level\t\t= Choose between: Dev/Mod/Off (default is Off). When set to Mod, MCGalaxy Moderators AND Developers are protected. When set to Dev, MCGalaxy Developers only are protected. When set to Off, MCGalaxy staff are not protected.");
w.WriteLine();
w.WriteLine("# menu-style\t\t\t\t= Choose between the default MCGalaxy help menu(0) or the redesigned layout(1). ");
w.WriteLine();
w.WriteLine("# Server options"); w.WriteLine("# Server options");
w.WriteLine("server-name = " + Server.name); w.WriteLine("server-name = " + Server.name);
w.WriteLine("motd = " + Server.motd); w.WriteLine("motd = " + Server.motd);