-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/fr/zelytra/daedalus/commands/checkpoint/Checkpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/fr/zelytra/daedalus/events/waiting/environment/JumpCheckPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, Location> 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")); | ||
} | ||
|
||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters