1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2022-03-14 18:44:48 +01:00
parent 91a184a400
commit 114de62942
2 changed files with 15 additions and 11 deletions

View File

@ -40,6 +40,7 @@
#### Changes
#### Fixes
* Fixed #3445
## Release Candidate 31 (14 Mar 2022)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#31

View File

@ -55,8 +55,7 @@ public class HologramProjector extends SlimefunItem implements HologramOwner {
addItemHandler(onPlace(), onRightClick(), onBreak());
}
@Nonnull
private BlockPlaceHandler onPlace() {
private @Nonnull BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(false) {
@Override
@ -72,8 +71,7 @@ public class HologramProjector extends SlimefunItem implements HologramOwner {
};
}
@Nonnull
private BlockBreakHandler onBreak() {
private @Nonnull BlockBreakHandler onBreak() {
return new SimpleBlockBreakHandler() {
@Override
@ -83,8 +81,7 @@ public class HologramProjector extends SlimefunItem implements HologramOwner {
};
}
@Nonnull
public BlockUseHandler onRightClick() {
public @Nonnull BlockUseHandler onRightClick() {
return e -> {
e.cancel();
@ -97,15 +94,22 @@ public class HologramProjector extends SlimefunItem implements HologramOwner {
};
}
private static void openEditor(@Nonnull Player p, @Nonnull Block projector) {
private void openEditor(@Nonnull Player p, @Nonnull Block projector) {
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.HOLOGRAM_PROJECTOR.inventory-title"));
menu.addItem(0, new CustomItemStack(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&r" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text"))));
menu.addItem(0, new CustomItemStack(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&f" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text"))));
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
pl.closeInventory();
Slimefun.getLocalization().sendMessage(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true);
ChatUtils.awaitInput(pl, message -> {
// Fixes #3445 - Make sure the projector is not broken
if (!BlockStorage.check(projector, getId())) {
// Hologram projector no longer exists.
// TODO: Add a chat message informing the player that their message was ignored.
return;
}
ArmorStand hologram = getArmorStand(projector, true);
hologram.setCustomName(ChatColors.color(message));
BlockStorage.addBlockInfo(projector, "text", hologram.getCustomName());
@ -115,7 +119,7 @@ public class HologramProjector extends SlimefunItem implements HologramOwner {
return false;
});
menu.addItem(1, new CustomItemStack(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
menu.addItem(1, new CustomItemStack(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1"));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
double offset = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F));
ArmorStand hologram = getArmorStand(projector, true);
@ -154,8 +158,7 @@ public class HologramProjector extends SlimefunItem implements HologramOwner {
return hologram;
}
@Nonnull
private static ArmorStand spawnArmorStand(@Nonnull Location l) {
private static @Nonnull ArmorStand spawnArmorStand(@Nonnull Location l) {
ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
armorStand.setVisible(false);
armorStand.setSilent(true);