mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2025-02-27 08:51:22 +01:00
Detect CommandBook commands and dispatch them correctly.
This commit is contained in:
parent
1360e32cca
commit
55c3538fce
@ -294,6 +294,12 @@
|
||||
<version>1.7-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.cnaude.commandbook</groupId>
|
||||
<artifactId>CommandBook</artifactId>
|
||||
<version>2.5-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.cnaude.dynmap</groupId>
|
||||
<artifactId>DynmapAPI</artifactId>
|
||||
|
7
pom.xml
7
pom.xml
@ -275,6 +275,13 @@
|
||||
<version>1.7-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- CommandBook -->
|
||||
<dependency>
|
||||
<groupId>com.cnaude.commandbook</groupId>
|
||||
<artifactId>CommandBook</artifactId>
|
||||
<version>2.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- DynmapAPI -->
|
||||
<dependency>
|
||||
<groupId>com.cnaude.dynmap</groupId>
|
||||
|
@ -56,7 +56,14 @@ public class CommandQueueWatcher {
|
||||
if (ircCommand != null) {
|
||||
try {
|
||||
String cmd = ircCommand.getGameCommand().split(" ")[0];
|
||||
if (plugin.getServer().getVersion().contains("MC: 1.8") && plugin.getServer().getPluginCommand(cmd) == null) {
|
||||
boolean isCommandBookCommand = false;
|
||||
plugin.logDebug("CMD: " + cmd);
|
||||
if (plugin.commandBookHook != null) {
|
||||
isCommandBookCommand = plugin.commandBookHook.isCommandBookCommand(cmd);
|
||||
plugin.logDebug("Is this is a CommandBook command? " + Boolean.toString(isCommandBookCommand));
|
||||
}
|
||||
if (plugin.getServer().getVersion().contains("MC: 1.8") && plugin.getServer().getPluginCommand(cmd) == null
|
||||
&& !isCommandBookCommand) {
|
||||
plugin.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand());
|
||||
|
||||
plugin.getServer().dispatchCommand(ircCommand.getIRCConsoleCommandSender(), ircCommand.getGameCommand());
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2014 cnaude
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.cnaude.purpleirc.Hooks;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import com.sk89q.commandbook.CommandBook;
|
||||
import com.zachsthings.libcomponents.bukkit.BukkitComponent;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cnaude
|
||||
*/
|
||||
public class CommandBookHook {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final CommandBook commandBook;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public CommandBookHook(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
this.commandBook = (CommandBook) plugin.getServer().getPluginManager().getPlugin("CommandBook");
|
||||
}
|
||||
|
||||
public boolean isCommandBookCommand(String command) {
|
||||
for (BukkitComponent bc: commandBook.getComponentManager().getComponents()) {
|
||||
for (String s : bc.getCommands().keySet()) {
|
||||
if (s.equals(command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -40,6 +40,7 @@ import com.cnaude.purpleirc.GameListeners.TitanChatListener;
|
||||
import com.cnaude.purpleirc.GameListeners.TownyChatListener;
|
||||
import com.cnaude.purpleirc.GameListeners.VanishNoPacketListener;
|
||||
import com.cnaude.purpleirc.Hooks.AdminPrivateChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.CommandBookHook;
|
||||
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
||||
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.JobsHook;
|
||||
@ -173,6 +174,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
public AdminPrivateChatHook adminPrivateChatHook;
|
||||
public ShortifyHook shortifyHook;
|
||||
public ReportRTSHook reportRTSHook;
|
||||
public CommandBookHook commandBookHook;
|
||||
public NetPackets netPackets;
|
||||
public CommandHandlers commandHandlers;
|
||||
public PurpleTabCompleter ircTabCompleter;
|
||||
@ -321,6 +323,12 @@ public class PurpleIRC extends JavaPlugin {
|
||||
} else {
|
||||
logInfo("AdminPrivateChat not detected.");
|
||||
}
|
||||
if (isPluginEnabled("CommandBook")) {
|
||||
logInfo("Enabling CommandBook support.");
|
||||
commandBookHook = new CommandBookHook(this);
|
||||
} else {
|
||||
logInfo("CommandBook not detected.");
|
||||
}
|
||||
if (isPluginEnabled("Jobs")) {
|
||||
String m = getServer().getPluginManager().getPlugin("Jobs").getDescription().getMain();
|
||||
String jobsVersion = getServer().getPluginManager().getPlugin("Jobs").getDescription().getVersion();
|
||||
|
Loading…
Reference in New Issue
Block a user