Skip to content

Commit

Permalink
Use eye location instead of feet location
Browse files Browse the repository at this point in the history
  • Loading branch information
Luncaaa committed Jun 29, 2023
1 parent f89e702 commit 15cb232
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void run(CommandSender sender, String[] args) {

if (display != null) {
Player player = (Player) sender;
display.setLocation(player.getLocation());
display.setLocation(player.getEyeLocation());
sender.sendMessage(MessagesManager.getColoredMessage("&aThe display &e" + args[1] + " &ahas been successfully removed.", true));
} else {
sender.sendMessage(MessagesManager.getColoredMessage("&cThe display &b" + args[1] + " &cdoes not exist!", true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public void createDisplay(Player p, DisplayType type, String name, String value)
// Set properties in the display file.
ConfigurationSection locationSection = displayConfig.createSection("location");
locationSection.set("world", p.getWorld().getName());
locationSection.set("x", p.getLocation().getX());
locationSection.set("y", p.getLocation().getY());
locationSection.set("z", p.getLocation().getZ());
locationSection.set("x", p.getEyeLocation().getX());
locationSection.set("y", p.getEyeLocation().getY());
locationSection.set("z", p.getEyeLocation().getZ());

displayConfig.set("rotationType", org.bukkit.entity.Display.Billboard.CENTER.name());

Expand All @@ -92,7 +92,7 @@ public void createDisplay(Player p, DisplayType type, String name, String value)
BaseDisplay newDisplay = null;
switch (type) {
case BLOCK -> {
BlockDisplay blockDisplay = Objects.requireNonNull(p.getLocation().getWorld()).spawn(p.getLocation(), BlockDisplay.class);
BlockDisplay blockDisplay = Objects.requireNonNull(p.getWorld()).spawn(p.getEyeLocation(), BlockDisplay.class);
try {
newDisplay = new ADBlockDisplay(displayConfigManager, blockDisplay).create(Objects.requireNonNull(Material.getMaterial(value)).createBlockData());
} catch (IllegalArgumentException e) {
Expand All @@ -102,11 +102,11 @@ public void createDisplay(Player p, DisplayType type, String name, String value)
}
}
case TEXT -> {
TextDisplay textDisplay = Objects.requireNonNull(p.getLocation().getWorld()).spawn(p.getLocation(), TextDisplay.class);
TextDisplay textDisplay = Objects.requireNonNull(p.getWorld()).spawn(p.getEyeLocation(), TextDisplay.class);
newDisplay = new ADTextDisplay(displayConfigManager, textDisplay).create(value);
}
case ITEM -> {
ItemDisplay itemDisplay = Objects.requireNonNull(p.getLocation().getWorld()).spawn(p.getLocation(), ItemDisplay.class);
ItemDisplay itemDisplay = Objects.requireNonNull(p.getWorld()).spawn(p.getEyeLocation(), ItemDisplay.class);
newDisplay = new ADItemDisplay(displayConfigManager, itemDisplay).create(Objects.requireNonNull(Material.getMaterial(value)));
}
}
Expand Down

0 comments on commit 15cb232

Please sign in to comment.