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

BukkitClasses - reformat Block's toString to include more helpful info #3946

Merged
merged 1 commit into from
May 6, 2021
Merged

BukkitClasses - reformat Block's toString to include more helpful info #3946

merged 1 commit into from
May 6, 2021

Conversation

ShaneBeee
Copy link
Contributor

Description

This PR aims to reformat a block's toString() method, to include more info.
See #3315 for the discussion.

I know it was up in the air whether or not a world should be included, and its potential to be too verbose, I included it, as users may have block stored in variables, and this just prints a more accurate accounting of the block.

Ex code:

on load:
	set {_b} to block at location(-910, 12, -234, world "world")
	send "Block: %{_b}%" to console

Output:

Block: 'raw andesite' at -909.5, 12.5, -233.5 in world 'world'

Target Minecraft Versions: any
Requirements: none
Related Issues: #3315

@ShaneBeee ShaneBeee added enhancement Feature request, an issue about something that could be improved, or a PR improving something. 2.6 labels May 6, 2021
double z = location.getZ();
String world = location.getWorld().getName();

return String.format("'%s' at %s, %s, %s in world '%s'", type, x, y, z, world);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watch out for the performance of this method, String#format can in fact be quite expensive in some cases, I imagine users won't do it often enough that it'd become an issue though

@FranKusmiruk FranKusmiruk merged commit 252845a into SkriptLang:master May 6, 2021
@ShaneBeee ShaneBeee deleted the feature/block-to-string branch May 6, 2021 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants