Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Block Command Sender #2160

Closed
Whimsyturtle opened this issue Jun 14, 2019 · 2 comments
Closed

Command Block Command Sender #2160

Whimsyturtle opened this issue Jun 14, 2019 · 2 comments
Labels
completed The issue has been fully resolved and the change will be in the next Skript update. enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).

Comments

@Whimsyturtle
Copy link
Member

Description

Currently, when you make a command like

command /example:
    trigger:
         broadcast "%command sender's location%"

and execute the command /example in a command block, the location broadcasted will return with a <none>

My suggestion is to add a test for whether or not command blocks are executing the command, and to return the location of the executing command block should the command sender's location be used

@Blueyescat
Copy link
Contributor

Blueyescat commented Jun 14, 2019

Possible to implement, just a CommandSender -> Block converter.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/command/BlockCommandSender.html

It would be also nice to if event-block would work for command blocks, not sure if it will work with the converter.

Already works for command block minecarts.

@TheBentoBox TheBentoBox added enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements). labels Jun 19, 2019
@Whimsyturtle
Copy link
Member Author

Whimsyturtle commented Sep 4, 2019

@Blueyescat I was trying to implement this via registering a new converter in DefaultConverters.java, with the following code

		// CommandSender - Block
		Converters.registerConverter(CommandSender.class, Block.class, new Converter<CommandSender, Block>() {
			@Override
			@Nullable
			public Block convert(final CommandSender s) {
				System.out.println("Request: CommandSender -> Block");
				if (s instanceof BlockCommandSender) {
					System.out.println("Successful Conv");
					return ((BlockCommandSender) s).getBlock();
				}
				System.out.println("Failed Conv");
				return null;
			}
		});

But after running the above Script, this converter is not called at all... any idea?

Edit:
Debugged the Converter Class and got this...
image

Caused by this being initialized first?
image

@Whimsyturtle Whimsyturtle added the completed The issue has been fully resolved and the change will be in the next Skript update. label Oct 21, 2019
@bensku bensku closed this as completed Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed The issue has been fully resolved and the change will be in the next Skript update. enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).
Projects
None yet
Development

No branches or pull requests

4 participants