Skip to content

Commit 420f0c7

Browse files
committed
add TeleportUtils
1 parent 9c24d19 commit 420f0c7

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Diff for: build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ repositories {
3232
name 'nu-langchecker'
3333
url 'https://raw.githubusercontent.com/Librazy/NyaaUtilsLangChecker/maven-repo'
3434
}
35+
36+
maven {
37+
name 'ess-repo'
38+
url 'http://repo.ess3.net/content/groups/essentials'
39+
}
3540
}
3641

3742
dependencies {
3843
compile 'org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT'
3944
compile 'net.milkbowl.vault:VaultAPI:1.6'
4045
compile 'org.librazy:NyaaUtilsLangChecker:1.0-SNAPSHOT'
46+
compile('net.ess3:Essentials:2.13-SNAPSHOT') {
47+
transitive = false
48+
}
4149
}
4250

4351
compileJava {
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package cat.nyaa.nyaacore.utils;
2+
3+
import com.earth2me.essentials.Essentials;
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.Location;
6+
import org.bukkit.entity.Player;
7+
import org.bukkit.event.player.PlayerTeleportEvent;
8+
9+
import java.util.List;
10+
11+
public class TeleportUtils {
12+
13+
public void Teleport(Player player, Location loc) {
14+
if (!player.isOnline()) {
15+
return;
16+
}
17+
Essentials ess = null;
18+
if (Bukkit.getServer().getPluginManager().getPlugin("Essentials") != null) {
19+
ess = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
20+
}
21+
if (ess != null) {
22+
try {
23+
ess.getUser(player).getTeleport().now(loc, false, PlayerTeleportEvent.TeleportCause.PLUGIN);
24+
return;
25+
} catch (Exception e) {
26+
e.printStackTrace();
27+
}
28+
player.setFallDistance(0);
29+
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
30+
}
31+
}
32+
33+
public void Teleport(List<Player> players, Location loc) {
34+
for (Player p : players) {
35+
Teleport(p, loc);
36+
}
37+
}
38+
}

Diff for: src/main/resources/plugin.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ main: cat.nyaa.nyaacore.NyaaCoreLoader
33
description: "Code infrastructure for all NyaaCat plugins."
44
version: 3.0
55
depend: [Vault]
6+
softdepend: [Essentials]
67
authors: [RecursiveG,Librazy]
78
website: "https://github.com/NyaaCat/NyaaCore"

0 commit comments

Comments
 (0)