Skip to content

Commit

Permalink
Add GPS enabled when the player dies on their last location.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCubee committed Mar 21, 2022
1 parent a5f3910 commit 59d4ebf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/fr/mrcubee/waypoint/WayPointPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fr.mrcubee.waypoint.command.GpsCommand;
import fr.mrcubee.waypoint.command.WaypointCommand;
import fr.mrcubee.waypoint.listeners.AsyncPlayerChatListener;
import fr.mrcubee.waypoint.listeners.PlayerDeathListener;
import fr.mrcubee.waypoint.listeners.PlayerJoinQuitListener;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -38,6 +39,7 @@ public void onEnable() {
this.gps.runTaskTimerAsynchronously(this, 0L, 5L);
pluginManager.registerEvents(new AsyncPlayerChatListener(), this);
pluginManager.registerEvents(new PlayerJoinQuitListener(), this);
pluginManager.registerEvents(new PlayerDeathListener(), this);
getCommand("gps").setExecutor(new GpsCommand());
getCommand("waypoint").setExecutor(new WaypointCommand());
for (Player player : Bukkit.getOnlinePlayers())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.mrcubee.waypoint.listeners;

import fr.mrcubee.langlib.Lang;
import fr.mrcubee.waypoint.GPS;
import fr.mrcubee.waypoint.WayPoint;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;

public class PlayerDeathListener implements Listener {

@EventHandler
public void event(final PlayerRespawnEvent event) {
final String waypointName = Lang.getMessage(event.getPlayer(), "waypoint.death.name", "&cLANG ERROR", true);

GPS.setLocation(event.getPlayer(), new WayPoint(waypointName, event.getPlayer().getLocation()));
}

}
6 changes: 5 additions & 1 deletion src/main/resources/lang/EN_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ gps.command.waypoint.not_exist=&cThe waypoint does not exist.
waypoint.command.already_exist=&cThe waypoint already exists.
waypoint.command.not_exist=&cThe waypoint does not exist.
waypoint.command.created=&aThe &e%s &awaypoint has been created.
waypoint.command.removed=&aWaypoint &e%s &ahas been deleted.
waypoint.command.removed=&aWaypoint &e%s &ahas been deleted.

# Death Waypoint

waypoint.death.name=Last death
6 changes: 5 additions & 1 deletion src/main/resources/lang/FR_fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ gps.command.waypoint.not_exist=&cLe waypoint n'existe pas.
waypoint.command.already_exist=&cLe waypoint existe déjà.
waypoint.command.not_exist=&cLe waypoint n'existe pas.
waypoint.command.created=&aLe waypoint &e%s &aa été créé.
waypoint.command.removed=&aLe waypoint &e%s &aa été supprimé.
waypoint.command.removed=&aLe waypoint &e%s &aa été supprimé.

# Death Waypoint

waypoint.death.name=Dernière mort

0 comments on commit 59d4ebf

Please sign in to comment.