From 437eea2499353c797e1cba0d93d56fc577eea4be Mon Sep 17 00:00:00 2001 From: Nick Hensel Date: Sun, 15 Sep 2024 01:43:30 +0200 Subject: [PATCH] prog --- .../club/devcord/gamejam/EventCancelers.java | 22 +++++- .../club/devcord/gamejam/Nigulpyggub.java | 7 +- .../devcord/gamejam/SantasBellRinger.java | 35 +++++++++ .../devcord/gamejam/commands/GameCommand.java | 11 +-- .../devcord/gamejam/commands/TeamCommand.java | 49 +++++++------ .../gamejam/level/eyes/BlockShower.java | 15 ++-- .../gamejam/level/eyes/EndListener.java | 41 +++++++++++ .../devcord/gamejam/level/eyes/EyesLevel.java | 8 ++- .../gamejam/level/eyes/GateOpener.java | 71 +++++++------------ .../gamejam/level/poempel/MoveListener.java | 19 ++++- .../gamejam/level/thejump/TheJumpLevel.java | 2 +- 11 files changed, 200 insertions(+), 80 deletions(-) create mode 100644 src/main/java/club/devcord/gamejam/SantasBellRinger.java create mode 100644 src/main/java/club/devcord/gamejam/level/eyes/EndListener.java diff --git a/src/main/java/club/devcord/gamejam/EventCancelers.java b/src/main/java/club/devcord/gamejam/EventCancelers.java index 218d4cc..1a86653 100644 --- a/src/main/java/club/devcord/gamejam/EventCancelers.java +++ b/src/main/java/club/devcord/gamejam/EventCancelers.java @@ -1,5 +1,6 @@ package club.devcord.gamejam; +import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -11,7 +12,16 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.io.PrintWriter; +import java.io.StringWriter; + public class EventCancelers implements Listener { + private final Nigulpyggub plugin; + + public EventCancelers(Nigulpyggub plugin) { + this.plugin = plugin; + } + @EventHandler public void onFoodChange(FoodLevelChangeEvent event) { event.setCancelled(true); @@ -25,8 +35,18 @@ public void onDamage(EntityDamageEvent event) { @EventHandler public void onEndereye(PlayerInteractEvent event) { - if (event.getMaterial().equals(Material.ENDER_EYE)) { + if (event.getMaterial().equals(Material.ENDER_EYE) && + (event.getClickedBlock() == null || event.getClickedBlock().getType() != Material.END_PORTAL_FRAME)) { + Exception exception = dasAugeBrauchstDuNoch(); + Component component = plugin.exceptionToComponent(exception); + event.getPlayer().sendMessage(component); event.setCancelled(true); } } + + private Exception dasAugeBrauchstDuNoch() { + NullPointerException nullPointerException = new NullPointerException(); + nullPointerException.printStackTrace(new PrintWriter(new StringWriter())); + return nullPointerException; + } } diff --git a/src/main/java/club/devcord/gamejam/Nigulpyggub.java b/src/main/java/club/devcord/gamejam/Nigulpyggub.java index eabb132..2f39318 100644 --- a/src/main/java/club/devcord/gamejam/Nigulpyggub.java +++ b/src/main/java/club/devcord/gamejam/Nigulpyggub.java @@ -7,6 +7,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import java.io.PrintWriter; @@ -20,8 +21,10 @@ public class Nigulpyggub extends JavaPlugin { @Override public void onEnable() { - getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this); - getServer().getPluginManager().registerEvents(new EventCancelers(), this); + PluginManager pluginManager = getServer().getPluginManager(); + pluginManager.registerEvents(new PlayerJoinListener(), this); + pluginManager.registerEvents(new EventCancelers(this), this); + pluginManager.registerEvents(new SantasBellRinger(), this); getServer().getPluginCommand("team").setExecutor(new TeamCommand(this)); getServer().getPluginCommand("game").setExecutor(new GameCommand(this)); // lagger.start(); diff --git a/src/main/java/club/devcord/gamejam/SantasBellRinger.java b/src/main/java/club/devcord/gamejam/SantasBellRinger.java new file mode 100644 index 0000000..d3c2deb --- /dev/null +++ b/src/main/java/club/devcord/gamejam/SantasBellRinger.java @@ -0,0 +1,35 @@ +package club.devcord.gamejam; + +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class SantasBellRinger implements Listener { + + public static final ItemStack THE_BELL; + + static { + THE_BELL = new ItemStack(Material.IRON_SWORD); + ItemMeta itemMeta = THE_BELL.getItemMeta(); + itemMeta.setCustomModelData(17); + itemMeta.displayName(Component.text("Santa's Bell").color(NamedTextColor.DARK_GREEN)); + THE_BELL.setItemMeta(itemMeta); + } + + @EventHandler + public void ringRingSantaRingRing(PlayerInteractEvent event) { + if (event.getPlayer().getInventory().getItemInMainHand().isSimilar(THE_BELL)) { + Sound sound = Sound.sound(Key.key("minecraft:item.santabell"), Sound.Source.MASTER, 1, 1); + Location loc = event.getPlayer().getLocation(); + event.getPlayer().getWorld().playSound(sound, loc.x(), loc.y(), loc.z()); + } + } +} diff --git a/src/main/java/club/devcord/gamejam/commands/GameCommand.java b/src/main/java/club/devcord/gamejam/commands/GameCommand.java index db2e3ac..72fe960 100644 --- a/src/main/java/club/devcord/gamejam/commands/GameCommand.java +++ b/src/main/java/club/devcord/gamejam/commands/GameCommand.java @@ -39,7 +39,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } if (args.length < 1) { - player.sendMessage(MiniMessage.miniMessage().deserialize("You have to use: /game start")); + player.sendMessage(MiniMessage.miniMessage().deserialize("Du musst: /game start/stop/skip nutzen")); return false; } @@ -56,6 +56,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command LevelPipeline levelPipeline = new LevelPipeline(team, plugin); levelPipeline.start(); plugin.teamPipelines().put(team, levelPipeline); + + plugin.getServer().broadcast(MiniMessage.miniMessage().deserialize("Spiel gestartet!")); } } case "stop" -> { @@ -70,10 +72,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command playerLocation.setWorld(world); p.teleport(playerLocation); }); -// plugin.teams().stream().map(Team::world).forEach(w -> plugin.getServer().unloadWorld(w, false)); plugin.teamPipelines().clear(); + + plugin.getServer().broadcast(MiniMessage.miniMessage().deserialize("Spiel gestoppt!")); } - case "level" -> { + case "skip" -> { Optional team = plugin.teamForPlayer(player); LevelPipeline pipeline = plugin.teamPipelines().get(team.orElseThrow()); @@ -82,7 +85,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command pipeline.next(); } } - default -> player.sendMessage(MiniMessage.miniMessage().deserialize(" Unknown command.")); + default -> player.sendMessage(MiniMessage.miniMessage().deserialize("Unbekannter Command.")); } return true; } diff --git a/src/main/java/club/devcord/gamejam/commands/TeamCommand.java b/src/main/java/club/devcord/gamejam/commands/TeamCommand.java index ab18719..5ba0f4e 100644 --- a/src/main/java/club/devcord/gamejam/commands/TeamCommand.java +++ b/src/main/java/club/devcord/gamejam/commands/TeamCommand.java @@ -45,46 +45,46 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command case "delete" -> plugin.teamForName(player.getName()) .ifPresentOrElse(team -> { plugin.teams().remove(team); - player.sendMessage(MiniMessage.miniMessage().deserialize("Your team was deleted!")); - }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize("You're not the creator of a team."))); + player.sendMessage(MiniMessage.miniMessage().deserialize("Dein Team wurde gelöscht!")); + }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize("Du bist in keinem Team!"))); case "create" -> { boolean alreadyInTeam = plugin.teamForPlayer(player).isPresent(); if (alreadyInTeam) { - player.sendMessage(MiniMessage.miniMessage().deserialize("You are already in a team!")); + player.sendMessage(MiniMessage.miniMessage().deserialize("Du bist schon in einem Team!")); return true; } World teamWorld = duplicator.duplicate(player.getName()); Team team = new Team(player, teamWorld); plugin.teamPipelines().put(team, null); - player.sendMessage(MiniMessage.miniMessage().deserialize("Team with name %s created".formatted(player.getName()))); + player.sendMessage(MiniMessage.miniMessage().deserialize("Team %s erstellt.".formatted(player.getName()))); } case "join" -> { if (args.length != 2) { - player.sendMessage(MiniMessage.miniMessage().deserialize("You have to use: /team join ")); + player.sendMessage(MiniMessage.miniMessage().deserialize("Du musst: /team join nutzen!")); return false; } if(plugin.teamForPlayer(player).isPresent()) { - player.sendMessage(MiniMessage.miniMessage().deserialize("You are already in a team!")); + player.sendMessage(MiniMessage.miniMessage().deserialize("Du bist schon in einem Team!")); return false; } plugin.teamForName(args[1]).ifPresentOrElse(team -> { - team.players().forEach(p -> p.sendMessage(MiniMessage.miniMessage().deserialize("%s joined the team".formatted(player.getName())))); + team.players().forEach(p -> p.sendMessage(MiniMessage.miniMessage().deserialize("%s ist dem Team beigetreten.".formatted(player.getName())))); team.addPlayer(player); - player.sendMessage(MiniMessage.miniMessage().deserialize("You joined the team %s".formatted(team.name()))); - }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize("No team found for creator %s".formatted(args[1])))); + player.sendMessage(MiniMessage.miniMessage().deserialize("Du bist dem Team %s beigetreten.".formatted(team.name()))); + }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize("Kein Team mit dem Namen %s gefunden.".formatted(args[1])))); } case "info" -> plugin.teamForPlayer(player) .ifPresentOrElse(team -> { - TextComponent text = Component.text("Your team: %s".formatted(team.name())) + TextComponent text = Component.text("Dein Team: %s".formatted(team.name())) .append(Component.newline()) - .append(Component.text("Members: %s".formatted(team.players().stream().map(Player::getName).collect(Collectors.joining(", "))))); + .append(Component.text("Mitglieder: %s".formatted(team.players().stream().map(Player::getName).collect(Collectors.joining(", "))))); player.sendMessage(text); - }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize("You're not in a team!"))); + }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize("Du bist nicht in einem Team!"))); case "tp" -> { if (!player.isOp()) { player.sendMessage(MiniMessage.miniMessage().deserialize("Du musst mehr Rechte tanken.")); @@ -92,7 +92,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } if (args.length != 2) { - player.sendMessage(MiniMessage.miniMessage().deserialize("You have to use: /team tp ")); + player.sendMessage(MiniMessage.miniMessage().deserialize("Du musst: /team tp nutzen")); } String name = args[1]; @@ -104,8 +104,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command playerLocation.setWorld(world); player.teleport(playerLocation); - player.sendMessage(MiniMessage.miniMessage().deserialize("You were teleport to world %s".formatted(world.getName()))); - }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize(" Team with name %s not found".formatted(name)))); + player.sendMessage(MiniMessage.miniMessage().deserialize("Du wurdest zur Welt %s teleportiert.".formatted(world.getName()))); + }, () -> player.sendMessage(MiniMessage.miniMessage().deserialize(" Team mit name %s nicht gefunden.".formatted(name)))); } case "world" -> { @@ -114,9 +114,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return false; } - player.sendMessage(MiniMessage.miniMessage().deserialize("Current world: %s".formatted(player.getWorld().getName()))); + player.sendMessage(MiniMessage.miniMessage().deserialize("Derzeitige Welt: %s".formatted(player.getWorld().getName()))); } - default -> player.sendMessage(MiniMessage.miniMessage().deserialize("Unknown command")); + default -> player.sendMessage(MiniMessage.miniMessage().deserialize("Unbekannter Befehl.")); } return false; @@ -125,29 +125,36 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command @Override public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (args.length <= 1) { - return completions(sender, List.of("create", "join", "delete", "info"), List.of("tp", "world")); + return completions(sender, label, List.of("create", "join", "delete", "info"), List.of("tp", "world")); } if (args[0].equalsIgnoreCase("tp") && sender.isOp()) { return plugin.getServer().getWorlds().stream() .map(World::getName) + .filter(s -> s.startsWith(args[0])) .toList(); } if (args[0].equalsIgnoreCase("join")) { - return plugin.teams().stream().map(Team::name).toList(); + return plugin.teams().stream() + .map(Team::name) + .filter(s -> s.startsWith(args[0])) + .toList(); } return List.of(); } - private List completions(CommandSender player, List normal, List admin) { + private List completions(CommandSender player, String current, List normal, List admin) { if (!player.isOp()) { return normal; } ArrayList strings = new ArrayList<>(normal); strings.addAll(admin); - return strings; + return strings + .stream() + .filter(s -> s.startsWith(current)) + .toList(); } } diff --git a/src/main/java/club/devcord/gamejam/level/eyes/BlockShower.java b/src/main/java/club/devcord/gamejam/level/eyes/BlockShower.java index 0135c73..dd6ed8f 100644 --- a/src/main/java/club/devcord/gamejam/level/eyes/BlockShower.java +++ b/src/main/java/club/devcord/gamejam/level/eyes/BlockShower.java @@ -11,6 +11,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; import org.bukkit.scheduler.BukkitTask; import java.util.Random; @@ -39,13 +41,18 @@ public void stopItemSwitching() { private void switchItems() { team.players().forEach(player -> { - if(player.getInventory().getItemInMainHand().isSimilar(TheJumpLevel.THE_EYE) && random.nextInt(0, 100) < 40) { + PlayerInventory inventory = player.getInventory(); + if(inventory.getItemInMainHand().isSimilar(TheJumpLevel.THE_EYE) && random.nextInt(0, 100) < 40) { var newSlot = random.nextInt(0, 8); - while(newSlot == player.getInventory().getHeldItemSlot()) { + while(inventory.getItem(newSlot) != null + && inventory.getItem(newSlot).isEmpty()) { newSlot = random.nextInt(0, 8); } - player.getInventory().setItem(player.getInventory().getHeldItemSlot(), ); + var air = new ItemStack(Material.AIR); + inventory.setItem(inventory.getHeldItemSlot(), air); + inventory.setItem(newSlot, TheJumpLevel.THE_EYE); + setVisibility(player); } }); } @@ -88,7 +95,7 @@ public void setVisibility(Player player) { if(itemInHand.isSimilar(TheJumpLevel.THE_EYE)) { showBlocks(player, Material.BONE_BLOCK.createBlockData()); } else { - showBlocks(player, Material.AIR.createBlockData()); + showBlocks(player, Material.BARRIER.createBlockData()); } } diff --git a/src/main/java/club/devcord/gamejam/level/eyes/EndListener.java b/src/main/java/club/devcord/gamejam/level/eyes/EndListener.java new file mode 100644 index 0000000..e5b5fc9 --- /dev/null +++ b/src/main/java/club/devcord/gamejam/level/eyes/EndListener.java @@ -0,0 +1,41 @@ +package club.devcord.gamejam.level.eyes; + +import club.devcord.gamejam.Team; +import club.devcord.gamejam.level.LevelPipeline; +import club.devcord.gamejam.level.thejump.TheJumpLevel; +import net.kyori.adventure.text.minimessage.MiniMessage; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +public class EndListener implements Listener { + + private final Team team; + private final LevelPipeline levelPipeline; + + public EndListener(Team team, LevelPipeline levelPipeline) { + this.team = team; + this.levelPipeline = levelPipeline; + } + + @EventHandler + public void onEnderEyePlace(PlayerInteractEvent event) { + if (!team.players().contains(event.getPlayer())) return; + + if (event.getMaterial() == Material.ENDER_EYE && event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.END_PORTAL_FRAME) { + var thropy = new ItemStack(Material.DIAMOND_HOE); + var meta = thropy.getItemMeta(); + meta.displayName(MiniMessage.miniMessage().deserialize("You are a Bug survivor")); + meta.setCustomModelData(85); + thropy.setItemMeta(meta); + team.players().forEach(player -> { + player.getInventory().addItem(thropy); + player.getInventory().remove(TheJumpLevel.THE_EYE); + }); + + levelPipeline.next(); + } + } +} diff --git a/src/main/java/club/devcord/gamejam/level/eyes/EyesLevel.java b/src/main/java/club/devcord/gamejam/level/eyes/EyesLevel.java index ce1f794..316e0c1 100644 --- a/src/main/java/club/devcord/gamejam/level/eyes/EyesLevel.java +++ b/src/main/java/club/devcord/gamejam/level/eyes/EyesLevel.java @@ -7,17 +7,20 @@ import org.bukkit.Location; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.plugin.PluginManager; public class EyesLevel extends Level { private final BlockShower blockShower; private final GateOpener opener; + private final EndListener endListener; public EyesLevel(Team team, Nigulpyggub plugin, LevelPipeline pipeline) { super(team, plugin, pipeline); - this.opener = new GateOpener(team); + this.opener = new GateOpener(team, plugin); this.blockShower = new BlockShower(team, plugin); + this.endListener = new EndListener(team, pipeline); } @Override @@ -28,6 +31,7 @@ public void start() { PluginManager pluginManager = plugin().getServer().getPluginManager(); pluginManager.registerEvents(blockShower, plugin()); pluginManager.registerEvents(opener, plugin()); + pluginManager.registerEvents(endListener, plugin()); team().players().forEach(blockShower::setVisibility); blockShower.startItemSwitching(); @@ -36,7 +40,9 @@ public void start() { @Override public void stop() { PlayerItemHeldEvent.getHandlerList().unregister(blockShower); + PlayerMoveEvent.getHandlerList().unregister(blockShower); PlayerInteractEvent.getHandlerList().unregister(opener); + PlayerInteractEvent.getHandlerList().unregister(endListener); blockShower.stopItemSwitching(); } diff --git a/src/main/java/club/devcord/gamejam/level/eyes/GateOpener.java b/src/main/java/club/devcord/gamejam/level/eyes/GateOpener.java index e72e845..2c3ed15 100644 --- a/src/main/java/club/devcord/gamejam/level/eyes/GateOpener.java +++ b/src/main/java/club/devcord/gamejam/level/eyes/GateOpener.java @@ -1,5 +1,6 @@ package club.devcord.gamejam.level.eyes; +import club.devcord.gamejam.Nigulpyggub; import club.devcord.gamejam.Team; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; @@ -13,28 +14,30 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.Plugin; +import java.util.List; + public class GateOpener implements Listener { private final Team team; - private final + private final Nigulpyggub plugin; private boolean gateOpen = false; - private boolean first; - private boolean second; - private boolean third; - private boolean forth; + private final List NOTES = List.of(Note.E, Note.C, Note.H, Note.C, Note.E); + + private int counter = 0; - public GateOpener(Team team) { + public GateOpener(Team team, Nigulpyggub plugin) { this.team = team; + this.plugin = plugin; } private enum Note { C, E, H; private static Note forButton(Location location) { - if (isLocation(location, 354, 45, -484)) return E; if (isLocation(location, 354, 45, -486)) return C; + if (isLocation(location, 354, 45, -484)) return E; if (isLocation(location, 354, 45, -482)) return H; return null; } @@ -52,7 +55,6 @@ public void checkButtonPress(PlayerInteractEvent event) { Location location = event.getClickedBlock().getLocation(); Note note = Note.forButton(location); - Bukkit.broadcastMessage(note.toString() + ""); if (note == null) return; int pitch = switch (note) { @@ -61,38 +63,17 @@ public void checkButtonPress(PlayerInteractEvent event) { case H -> 2; }; Sound sound = Sound.sound(Key.key("minecraft:instrument.sax"), Sound.Source.MASTER, 100, pitch); - event.getPlayer().playSound(sound); - - if (forth && note == Note.E) { - openGate(); - return; - } - - if (third && note == Note.C) { - forth = true; - return; - } + team.players().forEach(player -> player.playSound(sound)); - if (second && note == Note.H) { - third = true; - return; + if (NOTES.get(counter) == note) { + counter++; + } else { + counter = 0; } - if (first && note == Note.C) { - second = true; - return; - } - - if (!first && note == Note.E) { - first = true; - return; + if (counter == 5) { + openGate(); } - - - first = false; - second = false; - third = false; - forth = false; } } @@ -103,16 +84,18 @@ private void openGate() { BlockData airData = Material.AIR.createBlockData(); BlockData ironData = Material.IRON_BARS.createBlockData(); + plugin.getServer().getScheduler().runTaskLater(plugin, () -> { + team.players().forEach(player -> player.playSound(Sound.sound(Key.key("minecraft:ride.coaster.bar_close"), Sound.Source.MASTER, 100, 1))); + for (int i = 0; i < 4; i++) { + world.setBlockData(355, 45+i, -483, airData); + world.setBlockData(355, 45+i, -485, airData); - - for (int i = 0; i < 4; i++) { - world.setBlockData(355, 45+i, -483, airData); - world.setBlockData(355, 45+i, -483, airData); - - for (int j = 0; j < 3; j++) { - world.setBlockData(357, 45+i, -482 + j*2, ironData); + for (int j = 0; j < 3; j++) { + world.setBlockData(357, 45+i, -482 - j*2, ironData); + } } - } + }, 20); + } diff --git a/src/main/java/club/devcord/gamejam/level/poempel/MoveListener.java b/src/main/java/club/devcord/gamejam/level/poempel/MoveListener.java index 89762c1..5d1f927 100644 --- a/src/main/java/club/devcord/gamejam/level/poempel/MoveListener.java +++ b/src/main/java/club/devcord/gamejam/level/poempel/MoveListener.java @@ -1,11 +1,14 @@ package club.devcord.gamejam.level.poempel; import club.devcord.gamejam.Nigulpyggub; +import club.devcord.gamejam.SantasBellRinger; import club.devcord.gamejam.Team; import club.devcord.gamejam.level.LevelPipeline; import io.papermc.paper.math.BlockPosition; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Location; import org.bukkit.Material; @@ -16,7 +19,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.*; public class MoveListener implements Listener { @@ -41,7 +47,8 @@ public class MoveListener implements Listener { private final Map> alreadyDone = Map.of( "completed", new HashSet<>(), "void", new HashSet<>(), - "fart", new HashSet<>() + "fart", new HashSet<>(), + "xmas", new HashSet<>() ); private final LevelPipeline pipeline; @@ -62,6 +69,12 @@ void handlePlayerMove(PlayerMoveEvent event) { player.sendMultiBlockChange(emptyChunk); } + if (location.blockX() == 152 && location.blockY() == 41 && location.getBlockZ() == -406 && alreadyDone.get("xmas").add(uuid)) { + player.playSound(Sound.sound(Key.key("minecraft:item.santabell"), Sound.Source.MASTER, 100, 1)); + + player.getInventory().addItem(SantasBellRinger.THE_BELL); + } + if (location.blockX() == 152 && location.blockY() == 40 && location.blockZ() == -402 && alreadyDone.get("fart").add(uuid)) { player.playSound(Sound.sound(Key.key("minecraft:random.fart1"), Sound.Source.MASTER, 100, 1)); } @@ -73,7 +86,9 @@ void handlePlayerMove(PlayerMoveEvent event) { if (location.blockX() == 146 && location.blockZ() == -410) { var newLoc = new Location(player.getWorld(), 150, 42, -410, 180.0F, 15.0F); player.teleport(newLoc); - player.sendMessage(plugin.exceptionToComponent(new OutOfMemoryError("Java is very hungry.."))); + OutOfMemoryError throwable = new OutOfMemoryError("Java is very hungry.."); + throwable.printStackTrace(new PrintWriter(new StringWriter())); + player.sendMessage(plugin.exceptionToComponent(throwable)); player.playSound(Sound.sound(Key.key("minecraft:ambient.toilet"), Sound.Source.MASTER, 100, 1)); } diff --git a/src/main/java/club/devcord/gamejam/level/thejump/TheJumpLevel.java b/src/main/java/club/devcord/gamejam/level/thejump/TheJumpLevel.java index f6cbf69..fba9cbc 100644 --- a/src/main/java/club/devcord/gamejam/level/thejump/TheJumpLevel.java +++ b/src/main/java/club/devcord/gamejam/level/thejump/TheJumpLevel.java @@ -17,7 +17,7 @@ public class TheJumpLevel extends Level { static { THE_EYE = new ItemStack(Material.ENDER_EYE); var meta = THE_EYE.getItemMeta(); - meta.displayName(MiniMessage.miniMessage().deserialize("Sehhilfe")); + meta.displayName(MiniMessage.miniMessage().deserialize("Die schüchterne Sehhilfe")); THE_EYE.setItemMeta(meta); }