-
Notifications
You must be signed in to change notification settings - Fork 1
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
BuildTools
committed
Jul 2, 2020
1 parent
95e3ab1
commit f85bc6f
Showing
4 changed files
with
71 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
main: zadi15.onDeath.Main | ||
name: onDeath | ||
version: 1.10.0 | ||
author: https://github.com/zadi15 | ||
description: This plugin adds Loction readbacks on death | ||
api-version: 1.16 |
Binary file not shown.
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,6 @@ | ||
main: zadi15.onDeath.Main | ||
name: onDeath | ||
version: 1.10.0 | ||
author: https://github.com/zadi15 | ||
description: This plugin adds Loction readbacks on death | ||
api-version: 1.16 |
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,59 @@ | ||
package zadi15.onDeath; | ||
|
||
/* | ||
* Copyright https://github.com/zadi15 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.PlayerDeathEvent; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import net.md_5.bungee.api.ChatColor; | ||
import net.md_5.bungee.api.chat.ComponentBuilder; | ||
import net.md_5.bungee.api.chat.TextComponent; | ||
import net.md_5.bungee.api.chat.ClickEvent; | ||
import net.md_5.bungee.api.chat.HoverEvent; | ||
|
||
|
||
public class Main extends JavaPlugin implements Listener{ | ||
public void onEnable() { | ||
this.getServer().getPluginManager().registerEvents(this, this); | ||
} | ||
|
||
public void onDisable() { | ||
} | ||
|
||
@EventHandler | ||
public void onDeath(PlayerDeathEvent event) throws InterruptedException { | ||
Player player = event.getEntity(); | ||
int playerx = player.getLocation().getBlockX(); | ||
int playery = player.getLocation().getBlockY(); | ||
int playerz = player.getLocation().getBlockZ(); | ||
String cmdtp = "/tp " + (player).getPlayerListName() + " " + String.valueOf(playerx) + " " + | ||
String.valueOf(playery) + " " + String.valueOf(playerz); | ||
String cmd = "" + String.valueOf(playerx) + " " + | ||
String.valueOf(playery) + " " + String.valueOf(playerz); | ||
player.sendMessage(ChatColor.BLUE + "You have died at the co-ordinates: " + ChatColor.GOLD + cmd); | ||
TextComponent message = new TextComponent("Click to go to death point."); | ||
message.setColor(ChatColor.GOLD); | ||
message.setBold(true); | ||
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmdtp)); | ||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, | ||
new ComponentBuilder("Click here to be teleported back!").color(ChatColor.GRAY).italic(true).create())); | ||
player.spigot().sendMessage(message); | ||
} | ||
} |