mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Register commands dynamically.
This commit is contained in:
parent
68f46a9b27
commit
a19a569a04
@ -1,13 +1,18 @@
|
||||
package venture.Aust1n46.chat.initiators.listeners;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
@ -137,6 +142,9 @@ public class CommandListener implements TabExecutor {
|
||||
@Inject
|
||||
private Unmuteall unmuteall;
|
||||
|
||||
private CommandMap commandMap;
|
||||
private Constructor<PluginCommand> pluginCommandConstructor;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] parameters) {
|
||||
commands.get(command.getName()).execute(sender, command.getName(), parameters);
|
||||
@ -150,6 +158,14 @@ public class CommandListener implements TabExecutor {
|
||||
|
||||
@Inject
|
||||
public void postConstruct() {
|
||||
commandMap = plugin.getServer().getCommandMap();
|
||||
try {
|
||||
pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
|
||||
pluginCommandConstructor.setAccessible(true);
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
commands.put("broadcast", broadcast);
|
||||
commands.put("channel", channel);
|
||||
commands.put("join", channel);
|
||||
@ -211,9 +227,13 @@ public class CommandListener implements TabExecutor {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
private void registerCommand(String command, CommandExecutor commandExecutor) {
|
||||
if (plugin.getCommand(command) != null) {
|
||||
plugin.getCommand(command).setExecutor(commandExecutor);
|
||||
private void registerCommand(final String command, final CommandExecutor commandExecutor) {
|
||||
try {
|
||||
final PluginCommand pluginCommand = pluginCommandConstructor.newInstance(command, plugin);
|
||||
pluginCommand.setExecutor(commandExecutor);
|
||||
commandMap.getKnownCommands().put(command, pluginCommand);
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,224 +7,3 @@ softdepend: [Towny, Factions, EssentialsDiscord]
|
||||
author: Aust1n46
|
||||
website: https://bitbucket.org/Aust1n46/venturechat/
|
||||
description: #1 Channels Chat plugin! Spigot + Bungee. Supports PlaceholderAPI + JSON formatting. Moderation GUI!
|
||||
commands:
|
||||
mute:
|
||||
usage: /mute [playername] [channel]
|
||||
aliases: [mp,vmute]
|
||||
description: Mutes player in a channel so they cannot talk.
|
||||
permission-message: You don't have <permission>
|
||||
unmute:
|
||||
usage: /unmute [playername] [channel]
|
||||
aliases: [ump,vunmute]
|
||||
description: Unmutes player in a channel so they can talk again.
|
||||
permission-message: You don't have <permission>
|
||||
msg:
|
||||
usage: /msg [playername] [msg]
|
||||
aliases: [vmsg]
|
||||
description: Send a message to a player
|
||||
permission-message: You don't have <permission>
|
||||
tell:
|
||||
usage: /tell [playername] [msg]
|
||||
aliases: [vtell]
|
||||
description: Send a message to a player
|
||||
permission-message: You don't have <permission>
|
||||
whisper:
|
||||
usage: /whisper [playername] [msg]
|
||||
aliases: [vwhisper,w]
|
||||
description: Send a message to a player
|
||||
permission-message: You don't have <permission>
|
||||
message:
|
||||
usage: /message [playername] [msg]
|
||||
aliases: [vmessage,pm]
|
||||
description: Send a message to a player
|
||||
permission-message: You don't have <permission>
|
||||
ignore:
|
||||
usage: /ignore [playername] or /ignore ? for more information
|
||||
aliases: [vignore]
|
||||
description: This allows you to prevent a player from sending you a tell /ignore list to see who you have ignored
|
||||
permission-message: You don't have <permission>
|
||||
channel:
|
||||
usage: /channel [channelname]
|
||||
aliases: [ch,vchannel]
|
||||
description: Allows players to add the ability to listen to the channel
|
||||
permission-message: You don't have <permission>
|
||||
leave:
|
||||
usage: /leave [channelname]
|
||||
aliases: [lev,vleave]
|
||||
description: Allows players to leave listening to a channel
|
||||
permission-message: You don't have <permission>
|
||||
join:
|
||||
usage: /join [channelname]
|
||||
aliases: [vjoin]
|
||||
description: Allows players to join a channel
|
||||
permission-message: You don't have <permission>
|
||||
chlist:
|
||||
usage: /chlist
|
||||
aliases: [chl,vchlist]
|
||||
description: Allows players to see a listing of available channels
|
||||
permission-message: You don't have <permission>
|
||||
chwho:
|
||||
usage: /chwho [channelname]
|
||||
aliases: [chw,vchwho]
|
||||
description: Allows players to see a listing of who is listening on a channel
|
||||
permission-message: You don't have <permission>
|
||||
setchannel:
|
||||
usage: /setchannel [playername] [channel]
|
||||
aliases: [sc,vsetchannel]
|
||||
description: Sets a players channel
|
||||
permission-message: You don't have <permission>
|
||||
kickchannel:
|
||||
usage: /kickchannel [playername] [channel]
|
||||
aliases: [kc,vkickchannel]
|
||||
description: Kicks a player out of a channel
|
||||
permission-message: You don't have <permission>
|
||||
muteall:
|
||||
usage: /muteall [playername]
|
||||
aliases: [mpa,vmuteall]
|
||||
description: Mute a player in all channels
|
||||
permission-message: You don't have <permission>
|
||||
unmuteall:
|
||||
usage: /unmuteall [playername]
|
||||
aliases: [umpa,vunmuteall]
|
||||
description: Unmute a player in all channels
|
||||
permission-message: You don't have <permission>
|
||||
kickchannelall:
|
||||
usage: /kickchannelall [playername]
|
||||
aliases: [kca,vkickchannelall]
|
||||
description: Kick a player from all channels
|
||||
permission-message: You don't have <permission>
|
||||
setchannelall:
|
||||
usage: /setchannelall [playername]
|
||||
aliases: [sca,vsetchannelall]
|
||||
description: Set a player into all channels
|
||||
permission-message: You don't have <permission>
|
||||
force:
|
||||
usage: /force [playername] [message]
|
||||
aliases: [for,vforce]
|
||||
description: Force a player to chat or execute a command
|
||||
permission-message: You don't have <permission>
|
||||
forceall:
|
||||
usage: /forceall [message]
|
||||
aliases: [fora,vforceall]
|
||||
description: Force all players to chat or execute a command
|
||||
permission-message: You don't have <permission>
|
||||
listen:
|
||||
usage: /listen [channel]
|
||||
aliases: [lis,vlisten]
|
||||
description: Listen to a channel without setting it as the one your chatting in
|
||||
permission-message: You don't have <permission>
|
||||
chatreload:
|
||||
usage: /chatreload
|
||||
aliases: [cr,vchatreload]
|
||||
description: Reload the config file
|
||||
permission-message: You don't have <permission>
|
||||
reply:
|
||||
usage: /reply [msg]
|
||||
aliases: [vreply]
|
||||
description: Reply to a message
|
||||
permission-message: You don't have <permission>
|
||||
r:
|
||||
usage: /r [msg]
|
||||
aliases: []
|
||||
description: Reply to a message
|
||||
permission-message: You don't have <permission>
|
||||
spy:
|
||||
usage: /spy
|
||||
aliases: [vspy]
|
||||
description: Spy on tells
|
||||
permission-message: You don't have <permission>
|
||||
commandspy:
|
||||
usage: /commandspy
|
||||
aliases: [comspy,vcommandspy]
|
||||
description: Spy on commands
|
||||
permission-message: You don't have <permission>
|
||||
chatinfo:
|
||||
usage: /chatinfo
|
||||
aliases: [ci,vchatinfo]
|
||||
description: Check a players chat info
|
||||
permission-message: You don't have <permission>
|
||||
channelinfo:
|
||||
usage: /channelinfo
|
||||
aliases: [chi,vchannelinfo]
|
||||
description: Check a channels info
|
||||
permission-message: You don't have <permission>
|
||||
venturechat:
|
||||
usage: /venturechat
|
||||
aliases: [vc]
|
||||
description: Check plugin information
|
||||
permission-message: You don't have <permission>
|
||||
me:
|
||||
usage: /me
|
||||
aliases: [vme]
|
||||
description: Send an emote
|
||||
permission-message: You don't have <permission>
|
||||
filter:
|
||||
usage: /filter
|
||||
aliases: [fil,vfilter]
|
||||
description: Toggle filter on and off
|
||||
permission-message: You don't have <permission>
|
||||
broadcast:
|
||||
usage: /broadcast [msg]
|
||||
aliases: [bc,vbroadcast]
|
||||
description: Broadcast a message
|
||||
permission-message: You don't have <permission>
|
||||
commandblock:
|
||||
usage: /commandblock [player] [command]
|
||||
aliases: [cb,vcommandblock]
|
||||
description: Toggle a player blocked from entering a command
|
||||
permission-message: You don't have <permission>
|
||||
party:
|
||||
usage: /party help
|
||||
aliases: [p,chatparty,cp,vparty]
|
||||
description: Party commands
|
||||
permission-message: You don't have <permission>
|
||||
config:
|
||||
usage: /config help
|
||||
aliases: [vconfig]
|
||||
description: Edit commands
|
||||
permission-message: You don't have <permission>
|
||||
clearchat:
|
||||
usage: /clearchat
|
||||
aliases: [cc,vclearchat]
|
||||
description: Clear every players chat
|
||||
permission-message: You don't have <permission>
|
||||
notifications:
|
||||
usage: /notifications
|
||||
aliases: [notify,vnotify]
|
||||
description: Toggles your notifications
|
||||
permission-message: You don't have <permission>
|
||||
removemessage:
|
||||
usage: /removemessage [hashcode]
|
||||
aliases: [rm,vremovemessage]
|
||||
description: Remove a message from the chat
|
||||
permission-message: You don't have <permission>
|
||||
edit:
|
||||
usage: /<command>
|
||||
aliases: [vedit]
|
||||
description: Edit your last chat message
|
||||
permission-message: You don't have <permission>
|
||||
rangedspy:
|
||||
usage: /<command>
|
||||
aliases: [rspy,vrangedspy]
|
||||
description: Toggle spying on ranged channels
|
||||
permission-message: You don't have <permission>
|
||||
buttons:
|
||||
usage: /<command>
|
||||
aliases: [vbuttons]
|
||||
description: Toggle viewing json buttons
|
||||
permission-message: You don't have <permission>
|
||||
venturechatgui:
|
||||
usage: /<command>
|
||||
aliases: [vchatgui]
|
||||
description: Opens the chat management gui
|
||||
permission-message: You don't have <permission>
|
||||
messagetoggle:
|
||||
usage: /<command>
|
||||
aliases: [mtoggle,vmessagetoggle]
|
||||
description: Toggle receiving messages
|
||||
permission-message: You don't have <permission>
|
||||
bungeetoggle:
|
||||
usage: /<command>
|
||||
aliases: [btoggle,vbungeetoggle]
|
||||
description: Toggle receiving BungeeCord chat
|
||||
permission-message: You don't have <permission>
|
Loading…
x
Reference in New Issue
Block a user