mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2025-02-27 17:01:47 +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>
|
<version>1.7-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnaude.commandbook</groupId>
|
||||||
|
<artifactId>CommandBook</artifactId>
|
||||||
|
<version>2.5-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cnaude.dynmap</groupId>
|
<groupId>com.cnaude.dynmap</groupId>
|
||||||
<artifactId>DynmapAPI</artifactId>
|
<artifactId>DynmapAPI</artifactId>
|
||||||
|
7
pom.xml
7
pom.xml
@ -275,6 +275,13 @@
|
|||||||
<version>1.7-SNAPSHOT</version>
|
<version>1.7-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- CommandBook -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnaude.commandbook</groupId>
|
||||||
|
<artifactId>CommandBook</artifactId>
|
||||||
|
<version>2.5-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- DynmapAPI -->
|
<!-- DynmapAPI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cnaude.dynmap</groupId>
|
<groupId>com.cnaude.dynmap</groupId>
|
||||||
|
@ -56,7 +56,14 @@ public class CommandQueueWatcher {
|
|||||||
if (ircCommand != null) {
|
if (ircCommand != null) {
|
||||||
try {
|
try {
|
||||||
String cmd = ircCommand.getGameCommand().split(" ")[0];
|
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.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand());
|
||||||
|
|
||||||
plugin.getServer().dispatchCommand(ircCommand.getIRCConsoleCommandSender(), 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.TownyChatListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.VanishNoPacketListener;
|
import com.cnaude.purpleirc.GameListeners.VanishNoPacketListener;
|
||||||
import com.cnaude.purpleirc.Hooks.AdminPrivateChatHook;
|
import com.cnaude.purpleirc.Hooks.AdminPrivateChatHook;
|
||||||
|
import com.cnaude.purpleirc.Hooks.CommandBookHook;
|
||||||
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
||||||
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
||||||
import com.cnaude.purpleirc.Hooks.JobsHook;
|
import com.cnaude.purpleirc.Hooks.JobsHook;
|
||||||
@ -173,6 +174,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
public AdminPrivateChatHook adminPrivateChatHook;
|
public AdminPrivateChatHook adminPrivateChatHook;
|
||||||
public ShortifyHook shortifyHook;
|
public ShortifyHook shortifyHook;
|
||||||
public ReportRTSHook reportRTSHook;
|
public ReportRTSHook reportRTSHook;
|
||||||
|
public CommandBookHook commandBookHook;
|
||||||
public NetPackets netPackets;
|
public NetPackets netPackets;
|
||||||
public CommandHandlers commandHandlers;
|
public CommandHandlers commandHandlers;
|
||||||
public PurpleTabCompleter ircTabCompleter;
|
public PurpleTabCompleter ircTabCompleter;
|
||||||
@ -321,6 +323,12 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
logInfo("AdminPrivateChat not detected.");
|
logInfo("AdminPrivateChat not detected.");
|
||||||
}
|
}
|
||||||
|
if (isPluginEnabled("CommandBook")) {
|
||||||
|
logInfo("Enabling CommandBook support.");
|
||||||
|
commandBookHook = new CommandBookHook(this);
|
||||||
|
} else {
|
||||||
|
logInfo("CommandBook not detected.");
|
||||||
|
}
|
||||||
if (isPluginEnabled("Jobs")) {
|
if (isPluginEnabled("Jobs")) {
|
||||||
String m = getServer().getPluginManager().getPlugin("Jobs").getDescription().getMain();
|
String m = getServer().getPluginManager().getPlugin("Jobs").getDescription().getMain();
|
||||||
String jobsVersion = getServer().getPluginManager().getPlugin("Jobs").getDescription().getVersion();
|
String jobsVersion = getServer().getPluginManager().getPlugin("Jobs").getDescription().getVersion();
|
||||||
|
Loading…
Reference in New Issue
Block a user