diff --git a/src/main/java/fr/zelytra/daedalus/Daedalus.java b/src/main/java/fr/zelytra/daedalus/Daedalus.java index 4cdad11..a92b409 100644 --- a/src/main/java/fr/zelytra/daedalus/Daedalus.java +++ b/src/main/java/fr/zelytra/daedalus/Daedalus.java @@ -2,6 +2,7 @@ import fr.zelytra.daedalus.commands.broadcast.Broadcast; import fr.zelytra.daedalus.commands.broadcast.BroadcastTab; +import fr.zelytra.daedalus.commands.checkpoint.Checkpoint; import fr.zelytra.daedalus.commands.item.ItemsCommands; import fr.zelytra.daedalus.commands.item.ItemsTabs; import fr.zelytra.daedalus.commands.location.ShareLocation; @@ -92,6 +93,7 @@ private void regCommands() { getCommand("wiki").setExecutor(new Wiki()); getCommand("coordinate").setExecutor(new ShareLocation()); getCommand("test").setExecutor(new test()); + getCommand("checkpoint").setExecutor(new Checkpoint()); getCommand("revive").setExecutor(new Revive()); getCommand("revive").setTabCompleter(new ReviveTabs()); diff --git a/src/main/java/fr/zelytra/daedalus/commands/checkpoint/Checkpoint.java b/src/main/java/fr/zelytra/daedalus/commands/checkpoint/Checkpoint.java new file mode 100644 index 0000000..68cd6bb --- /dev/null +++ b/src/main/java/fr/zelytra/daedalus/commands/checkpoint/Checkpoint.java @@ -0,0 +1,27 @@ +package fr.zelytra.daedalus.commands.checkpoint; + +import fr.zelytra.daedalus.Daedalus; +import fr.zelytra.daedalus.events.waiting.environment.JumpCheckPoint; +import fr.zelytra.daedalus.managers.game.settings.GameSettings; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class Checkpoint implements CommandExecutor { + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + Player player = (Player) sender; + + if(!Daedalus.getInstance().getGameManager().isWaiting()) + return false; + + if(JumpCheckPoint.jumpCP.containsKey(player.getName())) + player.teleport(JumpCheckPoint.jumpCP.get(player.getName())); + else + player.sendMessage(GameSettings.LANG.textOf("event.jumpCPNotFound")); + + return true; + } +} diff --git a/src/main/java/fr/zelytra/daedalus/events/EventsManager.java b/src/main/java/fr/zelytra/daedalus/events/EventsManager.java index b653360..6a5bd51 100644 --- a/src/main/java/fr/zelytra/daedalus/events/EventsManager.java +++ b/src/main/java/fr/zelytra/daedalus/events/EventsManager.java @@ -26,6 +26,7 @@ import fr.zelytra.daedalus.events.waiting.entities.EntityDamageListener; import fr.zelytra.daedalus.events.waiting.entities.EntityTargetListener; import fr.zelytra.daedalus.events.waiting.environment.BlockPlaceListener; +import fr.zelytra.daedalus.events.waiting.environment.JumpCheckPoint; import fr.zelytra.daedalus.events.waiting.gui.GameSettingsInterface; import fr.zelytra.daedalus.events.waiting.gui.TeamSelector; import fr.zelytra.daedalus.events.waiting.item.GameStarter; @@ -86,6 +87,7 @@ public static void registerEvents(Daedalus pl) { /* Environment */ pm.registerEvents(new BlockPlaceListener(), pl); + pm.registerEvents(new JumpCheckPoint(), pl); pm.registerEvents(new TreeGrowthListener(), pl); pm.registerEvents(new MilkDrink(), pl); pm.registerEvents(new PortalListener(), pl); diff --git a/src/main/java/fr/zelytra/daedalus/events/running/environnement/gods/listener/HermesHandler.java b/src/main/java/fr/zelytra/daedalus/events/running/environnement/gods/listener/HermesHandler.java index 363b286..edb8c7c 100644 --- a/src/main/java/fr/zelytra/daedalus/events/running/environnement/gods/listener/HermesHandler.java +++ b/src/main/java/fr/zelytra/daedalus/events/running/environnement/gods/listener/HermesHandler.java @@ -64,7 +64,7 @@ public void setFlyOnJump(PlayerToggleFlightEvent e) { if (jumper.getLocation().getY() >= 93) { e.setCancelled(true); - jumper.sendMessage(Message.getPlayerPrefixe() + GameSettings.LANG.textOf("event.jumpToHigh")); + jumper.sendMessage(Message.getPlayerPrefixe() + GameSettings.LANG.textOf("event.jumpTooHigh")); return; } diff --git a/src/main/java/fr/zelytra/daedalus/events/waiting/environment/JumpCheckPoint.java b/src/main/java/fr/zelytra/daedalus/events/waiting/environment/JumpCheckPoint.java new file mode 100644 index 0000000..1016568 --- /dev/null +++ b/src/main/java/fr/zelytra/daedalus/events/waiting/environment/JumpCheckPoint.java @@ -0,0 +1,56 @@ +package fr.zelytra.daedalus.events.waiting.environment; + +import fr.zelytra.daedalus.Daedalus; +import fr.zelytra.daedalus.managers.game.settings.GameSettings; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +import java.util.HashMap; + +public class JumpCheckPoint implements Listener { + public static HashMap jumpCP = new HashMap<>(); + + @EventHandler + public void onPressurePlate(PlayerInteractEvent e) { + if (!Daedalus.getInstance().getGameManager().isWaiting()) + return; + + if (e.getAction() == Action.PHYSICAL) { + Location cp = e.getPlayer().getLocation().getBlock().getLocation(); + cp.setX(cp.getX() + 0.5); + cp.setZ(cp.getZ() + 0.5); + cp.setPitch(e.getPlayer().getLocation().getPitch()); + cp.setYaw(e.getPlayer().getLocation().getYaw()); + + if (jumpCP.containsKey(e.getPlayer().getName()) && jumpCP.get(e.getPlayer().getName()).getY() == cp.getY()) + return; + + if (cp.getBlock().getType() == Material.AIR) { + for (double x = (cp.getX() - 1); x <= cp.getX() + 1; x++) + for (double z = (cp.getZ() - 1); z <= cp.getZ() + 1; z++) { + Location temp = cp.clone(); + temp.setX(x); + temp.setZ(z); + + if (temp.getBlock().getType() == Material.JUNGLE_PRESSURE_PLATE) { + jumpCP.put(e.getPlayer().getName(), temp); + e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_NOTE_BLOCK_XYLOPHONE, 2, 2); + e.getPlayer().sendMessage(GameSettings.LANG.textOf("event.jumpCP")); + return; + } + } + } else { + jumpCP.put(e.getPlayer().getName(), cp); + e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_NOTE_BLOCK_XYLOPHONE, 2, 2); + e.getPlayer().sendMessage(GameSettings.LANG.textOf("event.jumpCP")); + } + + + } + } +} diff --git a/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerInteractListener.java b/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerInteractListener.java index af9a37f..a51afa6 100644 --- a/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerInteractListener.java +++ b/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerInteractListener.java @@ -12,5 +12,6 @@ public void onPlayerInteract(PlayerInteractEvent e) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK && Daedalus.getInstance().getGameManager().isWaiting()) e.setCancelled(true); + } } diff --git a/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerJoinListener.java b/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerJoinListener.java index 146bfc4..8da8a87 100644 --- a/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerJoinListener.java +++ b/src/main/java/fr/zelytra/daedalus/events/waiting/players/PlayerJoinListener.java @@ -33,7 +33,7 @@ private void preparePlayer(Player p, GameStatesEnum state) { Bukkit.broadcastMessage("§8[§a+§8] §f" + p.getName()); Faction playerFaction = Daedalus.getInstance().getGameManager().getFactionManager().getFactionOf(p); - for (CustomMaterial material : CustomMaterial.values()){ + for (CustomMaterial material : CustomMaterial.values()) { NamespacedKey itemKey = new NamespacedKey(Daedalus.getInstance(), material.getName()); p.discoverRecipe(itemKey); } @@ -46,8 +46,8 @@ private void preparePlayer(Player p, GameStatesEnum state) { p.setMaxHealth(20); p.setLevel(0); p.getInventory().clear(); - p.teleport(new Location(Bukkit.getWorld(Daedalus.WORLD_NAME), 669, 162, 675)); - for(PotionEffect potionEffectType : p.getActivePotionEffects()) + p.teleport(new Location(Bukkit.getWorld(Daedalus.WORLD_NAME), 634.5, 160.5, 572.5, -90, 0)); + for (PotionEffect potionEffectType : p.getActivePotionEffects()) p.removePotionEffect(potionEffectType.getType()); if (playerFaction == null) diff --git a/src/main/java/fr/zelytra/daedalus/managers/items/CustomMaterial.java b/src/main/java/fr/zelytra/daedalus/managers/items/CustomMaterial.java index 7a6a148..b2ffadb 100644 --- a/src/main/java/fr/zelytra/daedalus/managers/items/CustomMaterial.java +++ b/src/main/java/fr/zelytra/daedalus/managers/items/CustomMaterial.java @@ -5,7 +5,7 @@ import org.bukkit.inventory.EquipmentSlot; public enum CustomMaterial { - ZEUS_LIGHTNING(GameSettings.LANG.textOf("godItem.ZEUS_LIGHTNIN"), "zeus_lightning", 1, Material.PHANTOM_MEMBRANE, ItemType.MISCELLANEOUS), + ZEUS_LIGHTNING(GameSettings.LANG.textOf("godItem.ZEUS_LIGHTNING"), "zeus_lightning", 1, Material.PHANTOM_MEMBRANE, ItemType.MISCELLANEOUS), HADES_SCEPTER(GameSettings.LANG.textOf("godItem.HADES_SCEPTER"), "hades_scepter", 2, Material.PHANTOM_MEMBRANE, ItemType.MISCELLANEOUS), APHRODITE_HEART(GameSettings.LANG.textOf("godItem.APHRODITE_HEART"), "aphrodite_heart", 3, Material.PHANTOM_MEMBRANE, ItemType.MISCELLANEOUS), DEMETER_SICKLE(GameSettings.LANG.textOf("godItem.DEMETER_SICKLE"), "demeter_sickle", 4, Material.PHANTOM_MEMBRANE, ItemType.MISCELLANEOUS), diff --git a/src/main/resources/lang/en.conf b/src/main/resources/lang/en.conf index 589fb36..01ebd6e 100644 --- a/src/main/resources/lang/en.conf +++ b/src/main/resources/lang/en.conf @@ -95,7 +95,7 @@ maze.generateMatrix="§8Generating maze..." maze.lockingStructure="§8Locking structures area... " maze.generateGrid="§8Generating grid..." event.drinkMilk="§cYou cannot drink milk" -event.jumpToHigh="§6Don't try to jump too high" +event.jumpTooHigh="§6Don't try to jump too high" event.playerShine="§eI feels like i'm walking on sunshine " event.mazeFalling="§6The wall maze begin to fall... Advise : §cRUN." event.minoRelease="§8Minotaure §6has been released in the Maze... May Divinities be with you !" @@ -107,6 +107,8 @@ event.divineTrackerNoStruct="§cNo structure around you" event.divineTrackerTrack="§r§8 block away from §1§l" event.victoryTitle="§6§l win !" event.victorySubTitle="oskour" +event.jumpCP="§6Jump§8>> §6/checkpoint to reach your last checkpoint" +event.jumpCPNotFound="§6Jump§8>> §6You don't yet reach a checkpoint" menu.teamChooser="§6Choose a team" chat.global="[Global] " chat.team="[Team] " diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8fb32de..242f032 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -57,3 +57,8 @@ commands: hadesrevive: description: Hades revive power + checkpoint: + aliases: + - cp + description: Teleport you to the latest checkpoint reached +