mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 20:53:40 -04:00
Style: Move hardcoded commands out of Player.Handlers.cs
This commit is contained in:
parent
1f2b31bc6d
commit
51a2ffb677
49
CorePlugin/ChatHandler.cs
Normal file
49
CorePlugin/ChatHandler.cs
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright 2015 MCGalaxy team
|
||||
|
||||
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;
|
||||
using MCGalaxy;
|
||||
|
||||
namespace MCGalaxy.Core {
|
||||
|
||||
internal static class ChatHandler {
|
||||
|
||||
internal static void HandleCommand(string cmd, Player p, string message) {
|
||||
//DO NOT REMOVE THE TWO COMMANDS BELOW, /PONY AND /RAINBOWDASHLIKESCOOLTHINGS. -EricKilla
|
||||
if (cmd == "pony") {
|
||||
if (p.ponycount < 2) {
|
||||
Chat.MessageAll("{0} %Sjust so happens to be a proud brony! Everyone give {0} %Sa brohoof!", p.ColoredName);
|
||||
} else {
|
||||
p.SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
|
||||
}
|
||||
|
||||
p.ponycount++;
|
||||
Plugin.CancelPlayerEvent(PlayerEvents.PlayerCommand, p);
|
||||
} else if (cmd == "rainbowdashlikescoolthings") {
|
||||
if (p.rdcount < 2) {
|
||||
Chat.MessageAll("&1T&2H&3I&4S &5S&6E&7R&8V&9E&aR &bJ&cU&dS&eT &fG&0O&1T &22&30 &4P&CE&7R&DC&EE&9N&1T &5C&6O&7O&8L&9E&aR&b!");
|
||||
} else {
|
||||
p.SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
|
||||
}
|
||||
|
||||
p.rdcount++;
|
||||
Plugin.CancelPlayerEvent(PlayerEvents.PlayerCommand, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,6 @@ using System.IO;
|
||||
using MCGalaxy;
|
||||
|
||||
namespace MCGalaxy.Core {
|
||||
|
||||
internal static class ConnectHandler {
|
||||
|
||||
internal static void HandleConnect(Player p) {
|
||||
|
@ -28,10 +28,13 @@ namespace MCGalaxy.Core {
|
||||
public override void Load(bool startup) {
|
||||
OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect,
|
||||
Priority.System_Level, this, false);
|
||||
OnPlayerCommandEvent.Register(ChatHandler.HandleCommand,
|
||||
Priority.System_Level, this, false);
|
||||
}
|
||||
|
||||
public override void Unload(bool shutdown) {
|
||||
OnPlayerConnectEvent.UnRegister(this);
|
||||
OnPlayerCommandEvent.UnRegister(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,6 +412,7 @@
|
||||
<Compile Include="Config\ServerProperties.cs" />
|
||||
<Compile Include="Config\PropertiesFile.cs" />
|
||||
<Compile Include="Config\StringAttributes.cs" />
|
||||
<Compile Include="CorePlugin\ChatHandler.cs" />
|
||||
<Compile Include="CorePlugin\CorePlugin.cs" />
|
||||
<Compile Include="CorePlugin\ConnectHandler.cs" />
|
||||
<Compile Include="Database\BlockDB.cs" />
|
||||
|
@ -188,7 +188,7 @@ namespace MCGalaxy {
|
||||
|
||||
void Player_PlayerChat(Player p, string message) {
|
||||
if (!Server.irc ||!IsConnected()) return;
|
||||
if (String.IsNullOrEmpty(message.Trim(trimChars))) return;
|
||||
if (message.Trim(trimChars) == "") return;
|
||||
|
||||
string name = Server.ircPlayerTitles ? p.FullName : p.group.prefix + p.ColoredName;
|
||||
Say(name + "%S: " + message, p.opchat);
|
||||
|
@ -679,25 +679,6 @@ return;
|
||||
if (Server.verifyadmins && adminpen && !(cmd == "pass" || cmd == "setpass")) {
|
||||
SendMessage("&cYou must verify first with %T/pass [Password]"); return false;
|
||||
}
|
||||
|
||||
//DO NOT REMOVE THE TWO COMMANDS BELOW, /PONY AND /RAINBOWDASHLIKESCOOLTHINGS. -EricKilla
|
||||
if (cmd == "pony") {
|
||||
if (ponycount < 2) {
|
||||
Chat.MessageAll("{0} %Sjust so happens to be a proud brony! Everyone give {0} %Sa brohoof!", ColoredName);
|
||||
ponycount++;
|
||||
} else {
|
||||
SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
|
||||
}
|
||||
return false;
|
||||
} else if (cmd == "rainbowdashlikescoolthings") {
|
||||
if (rdcount < 2) {
|
||||
Chat.MessageAll("&1T&2H&3I&4S &5S&6E&7R&8V&9E&aR &bJ&cU&dS&eT &fG&0O&1T &22&30 &4P&CE&7R&DC&EE&9N&1T &5C&6O&7O&8L&9E&aR&b!");
|
||||
rdcount++;
|
||||
} else {
|
||||
SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user