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

3-axis support for scale sub-command #86

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@ public List<String> tabcompletion(@NotNull CommandSender player, @Nullable Holog

@Override
public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) {
final var scale = Floats.tryParse(args[3]);
final var scaleX = Floats.tryParse(args[3]);
final var scaleY = args.length >= 6 ? Floats.tryParse(args[4]) : scaleX;
final var scaleZ = args.length >= 6 ? Floats.tryParse(args[5]) : scaleX;

if (scale == null) {
if (scaleX == null || scaleY == null || scaleZ == null) {
MessageHelper.error(player, "Could not parse scale");
return false;
}

if (Float.compare(scale, hologram.getData().getDisplayData().getScale().x()) == 0 &&
Float.compare(scale, hologram.getData().getDisplayData().getScale().y()) == 0 &&
Float.compare(scale, hologram.getData().getDisplayData().getScale().z()) == 0) {
if (Float.compare(scaleX, hologram.getData().getDisplayData().getScale().x()) == 0 &&
Float.compare(scaleY, hologram.getData().getDisplayData().getScale().y()) == 0 &&
Float.compare(scaleZ, hologram.getData().getDisplayData().getScale().z()) == 0) {
MessageHelper.warning(player, "This hologram is already at this scale");
return false;
}

final var copied = hologram.getData().copy();
copied.getDisplayData().setScale(new Vector3f(scale, scale, scale));
copied.getDisplayData().setScale(new Vector3f(scaleX, scaleY, scaleZ));

if (!HologramCMD.callModificationEvent(hologram, player, copied, HologramUpdateEvent.HologramModification.SCALE)) {
return false;
Expand All @@ -60,7 +62,7 @@ public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @
FancyHolograms.get().getHologramStorage().save(hologram);
}

MessageHelper.success(player, "Changed scale to " + scale);
MessageHelper.success(player, "Changed scale to " + scaleX + ", " + scaleY + ", " + scaleZ);
return true;
}
}