Skip to content

For Plugins That Doesn't Support CommandPrompter

Ethan Bacurio edited this page Jan 17, 2022 · 1 revision

Since CommandPrompter relies on the event PlayerCommandPreprocessEvent, it cannot intercept commands that were dispatched using Bukkit.dispatchCommand(). And many Menu plugins (other than DeluxeMenu and ChestCommands) use this Bukkit.dispatchCommand() to execute a command when an item is clicked on the menus.

However, in Project Secundum, I've added an option to hack the CommandMap and add an event that I could listen to whenever Bukkit.dispatchCommand() is called. This feature uses the Unsafe package in Java to allow me to inject my modified CommandMap into CraftServer.java and CraftPluginManager.java. Because of its "hacky" nature, this option is disabled by default, and I recommend convincing the menu plugin developer to add support for CommandPrompter first.

How To Enable Modified CommandMap

Simply set the following option in config.yml to true.

# Enable unsafe features for
# CommandPrompter. Enabling this
# allows CommandPrompter to
# modify the command map and
# catch dispatched commands
Enable-Unsafe: false

After setting the option to true, you must restart the server, for the hack to work.

If some commands doesn't seem to work. Increase the value of the following option below

# If Enable-Unsafe is set to
# true, this delay (in ticks)
# will be used before modifying
# the command map to allow all
# plugins to register all of
# their commands First
# 
# If you experience issues,
# increase the value of this delay.
# Note that 20 ticks is 1 second.
Modification-Delay: 1