Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Bundle-Free/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Bundle-Premium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem-Proxy</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Proxy/WarpSystem-Proxy-Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem-Proxy</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem-Proxy</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Spigot-Free/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ private boolean allNull(Object... o) {

@Override
public boolean tp(Player gate, PlayerData player, @Nullable Double x, @Nullable Double y, @Nullable Double z, @Nullable Float yaw, @Nullable Float pitch, @Nullable String server, @Nullable String world) {
return tp(gate, player, x, y, z, yaw, pitch, server, world, true);
}

@Override
public boolean tp(Player gate, PlayerData player, @Nullable Double x, @Nullable Double y, @Nullable Double z, @Nullable Float yaw, @Nullable Float pitch, @Nullable String server, @Nullable String world, boolean notifyPlayer) {
if (checkStatusTp(gate, player)) return true;
Player p = Bukkit.getPlayer(player.getName());
if(p == null) return false;
Expand Down Expand Up @@ -147,13 +152,19 @@ public boolean tp(Player gate, PlayerData player, @Nullable Double x, @Nullable
TeleportOptions options = new TeleportOptions(new Destination(new LocationAdapter(l)), destination.toString(), Origin.TeleportCommand);
options.setSkip(true);
options.setMessage(Lang.getPrefix() + (gate == p ? Lang.get("Teleported_To") : Lang.get("Teleported_To_By").replace("%gate%", gate.getName())));
options.setNotifyPlayer(notifyPlayer);

WarpSystem.getInstance().getTeleportManager().teleport(p, options);
return true;
}

@Override
public void tp(Player gate, PlayerData player, PlayerData target) {
tp(gate, player, target, true);
}

@Override
public void tp(Player gate, PlayerData player, PlayerData target, boolean notifyPlayer) {
if (checkStatusTp(gate, player)) return;
if (checkStatusTp(gate, target)) return;

Expand All @@ -175,6 +186,7 @@ public void tp(Player gate, PlayerData player, PlayerData target) {
TeleportOptions options = new TeleportOptions(new Destination(new LocationAdapter(targetP.getLocation())), targetP.getName(), Origin.TeleportCommand);
options.setSkip(true);
options.setMessage(Lang.getPrefix() + (gate == playerP ? Lang.get("Teleported_To") : Lang.get("Teleported_To_By").replace("%gate%", gate.getName())));
options.setNotifyPlayer(notifyPlayer);

WarpSystem.getInstance().getTeleportManager().teleport(playerP, options);
}
Expand Down
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Spigot-Premium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ private boolean allNull(Object... o) {

@Override
public boolean tp(Player gate, PlayerData player, @Nullable Double x, @Nullable Double y, @Nullable Double z, @Nullable Float yaw, @Nullable Float pitch, @Nullable String server, @Nullable String world) {
return tp(gate, player, x, y, z, yaw, pitch, server, world, true);
}

@Override
public boolean tp(Player gate, PlayerData player, @Nullable Double x, @Nullable Double y, @Nullable Double z, @Nullable Float yaw, @Nullable Float pitch, @Nullable String server, @Nullable String world, boolean notifyPlayer) {
if (checkStatusTp(gate, player)) return true;
Player p = Bukkit.getPlayer(player.getName());

Expand Down Expand Up @@ -207,13 +212,19 @@ public boolean tp(Player gate, PlayerData player, @Nullable Double x, @Nullable
TeleportOptions options = new TeleportOptions(new Destination(new LocationAdapter(l)), destination.toString(), Origin.TeleportCommand);
options.setSkip(true);
options.setMessage(Lang.getPrefix() + (gate == p ? Lang.get("Teleported_To") : Lang.get("Teleported_To_By").replace("%gate%", gate.getName())));
options.setNotifyPlayer(notifyPlayer);

WarpSystem.getInstance().getTeleportManager().teleport(p, options);
return true;
}

@Override
public void tp(Player gate, PlayerData player, PlayerData target) {
tp(gate, player, target, true);
}

@Override
public void tp(Player gate, PlayerData player, PlayerData target, boolean notifyPlayer) {
if (checkStatusTp(gate, player)) return;
if (checkStatusTp(gate, target)) return;

Expand All @@ -238,6 +249,7 @@ public void tp(Player gate, PlayerData player, PlayerData target) {
TeleportOptions options = new TeleportOptions(new Destination(new LocationAdapter(targetP.getLocation())), targetP.getName(), Origin.TeleportCommand);
options.setSkip(true);
options.setMessage(Lang.getPrefix() + (gate == playerP ? Lang.get("Teleported_To") : Lang.get("Teleported_To_By").replace("%gate%", gate.getName())));
options.setNotifyPlayer(notifyPlayer);

WarpSystem.getInstance().getTeleportManager().teleport(playerP, options);
}
Expand Down
2 changes: 1 addition & 1 deletion WarpSystem/WarpSystem-Spigot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>WarpSystem</artifactId>
<groupId>de.codingair</groupId>
<version>5.1.14_Hotfix-8</version>
<version>5.1.16-silent-tp-command</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Permissions {

private static final String PERMISSION_USE_TELEPORT_COMMAND = "warpsystem.use.teleportCommand";
public static final String PERMISSION_USE_TELEPORT_COMMAND_TP = PERMISSION_USE_TELEPORT_COMMAND + ".tp";
public static final String PERMISSION_USE_TELEPORT_COMMAND_TP_SILENT = PERMISSION_USE_TELEPORT_COMMAND_TP + ".silent";
public static final String PERMISSION_USE_TELEPORT_COMMAND_TPHERE = PERMISSION_USE_TELEPORT_COMMAND + ".tphere";
public static final String PERMISSION_USE_TELEPORT_COMMAND_TPTO = PERMISSION_USE_TELEPORT_COMMAND + ".tpto";
public static final String PERMISSION_USE_TELEPORT_COMMAND_TP_TOGGLE = PERMISSION_USE_TELEPORT_COMMAND + ".tptoggle";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class TeleportOptions implements Options {
private boolean waitForTeleport; //Waiting for walking teleports
private boolean confirmPayment = true;
private boolean silent;
private boolean notifyPlayer = true;

private String payMessage;
private String paymentDeniedMessage;
Expand Down Expand Up @@ -225,6 +226,14 @@ public void setSilent(boolean silent) {
this.silent = silent;
}

public boolean isNotifyPlayer() {
return notifyPlayer;
}

public void setNotifyPlayer(boolean notifyPlayer) {
this.notifyPlayer = notifyPlayer;
}

public SoundData getTeleportSound() {
if (teleportSound == null) teleportSound = AnimationManager.getInstance().getActive().getTeleportSound();
if (this.teleportSound == null) this.teleportSound = SoundPage.createStandard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,61 +48,68 @@ public void start() {
String finalMessage = message;

if (options.getOriginalDestination().usesBukkitTeleportation()) {
Bukkit.getPluginManager().registerEvents(listener = new Listener() {
@EventHandler (priority = EventPriority.MONITOR)
public void onTeleport(PlayerTeleportEvent e) {
if (player.equals(e.getPlayer())) {
afterEffectPosition.setValue(e.getTo());

if (e.isCancelled()) {
String[] text = new String[2];
String msg = Lang.get("Teleporting_Info");

if (d == TeleportDelay.Display.TITLE) {
int i = msg.indexOf("\n");
if (i != -1) {
text[0] = msg.substring(0, i);
text[1] = msg.substring(i + 2);
} else text[0] = msg;
}

if (d == TeleportDelay.Display.ACTION_BAR) MessageAPI.sendActionBar(player, Lang.get("Teleport_Cancelled"));
else if (d == TeleportDelay.Display.TITLE) MessageAPI.sendTitle(player, text[0], text[1], 2, 10, 2);
HandlerList.unregisterAll(this);

cancel(Result.CANCELLED);
} else if (Version.atMost(8))
Bukkit.getPluginManager().callEvent(new PlayerTeleportAcceptEvent(e.getPlayer())); //1.8 doesn't provide a packet based PlayerTeleportAcceptEvent
else {
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getPluginManager().callEvent(new PlayerTeleportAcceptEvent(player));
org.bukkit.plugin.Plugin plugin = WarpSystem.getInstance();
if (plugin != null) {
Bukkit.getPluginManager().registerEvents(listener = new Listener() {
@EventHandler (priority = EventPriority.MONITOR)
public void onTeleport(PlayerTeleportEvent e) {
if (player.equals(e.getPlayer())) {
afterEffectPosition.setValue(e.getTo());

if (e.isCancelled()) {
String[] text = new String[2];
String msg = Lang.get("Teleporting_Info");

if (d == TeleportDelay.Display.TITLE) {
int i = msg.indexOf("\n");
if (i != -1) {
text[0] = msg.substring(0, i);
text[1] = msg.substring(i + 2);
} else text[0] = msg;
}
}.runTaskLater(WarpSystem.getInstance(), 5); //safety timeout (PlayerTeleportAcceptEvent doesn't get triggered while spawning)

if (d == TeleportDelay.Display.ACTION_BAR) MessageAPI.sendActionBar(player, Lang.get("Teleport_Cancelled"));
else if (d == TeleportDelay.Display.TITLE) MessageAPI.sendTitle(player, text[0], text[1], 2, 10, 2);
HandlerList.unregisterAll(this);

cancel(Result.CANCELLED);
} else if (Version.atMost(8))
Bukkit.getPluginManager().callEvent(new PlayerTeleportAcceptEvent(e.getPlayer())); //1.8 doesn't provide a packet based PlayerTeleportAcceptEvent
else {
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getPluginManager().callEvent(new PlayerTeleportAcceptEvent(player));
}
}.runTaskLater(plugin, 5); //safety timeout (PlayerTeleportAcceptEvent doesn't get triggered while spawning)
}
}
}
}

@EventHandler
public void onTeleported(PlayerTeleportAcceptEvent e) {
if (player.equals(e.getPlayer())) {
if (player.isOnline()) {
options.getOriginalDestination().sendMessage(player, finalMessage, options.getDisplayName(), options.getCosts(player), options.getOriginalOrigin());
if (options.getTeleportSound() != null) options.getTeleportSound().play(player);
end();
@EventHandler
public void onTeleported(PlayerTeleportAcceptEvent e) {
if (player.equals(e.getPlayer())) {
if (player.isOnline()) {
if (options.isNotifyPlayer()) {
options.getOriginalDestination().sendMessage(player, finalMessage, options.getDisplayName(), options.getCosts(player), options.getOriginalOrigin());
} else {
Bukkit.getLogger().info("[WarpSystem] Silent TP: " + player.getName() + " -> " + (options.getDisplayName() != null ? options.getDisplayName() : "destination"));
}
if (options.getTeleportSound() != null) options.getTeleportSound().play(player);
end();
}
}
}
}

@EventHandler
public void onQuit(PlayerQuitEvent e) {
if (player.equals(e.getPlayer())) {
HandlerList.unregisterAll(this);
cancel(Result.DISCONNECT);
@EventHandler
public void onQuit(PlayerQuitEvent e) {
if (player.equals(e.getPlayer())) {
HandlerList.unregisterAll(this);
cancel(Result.DISCONNECT);
}
}
}
}, WarpSystem.getInstance());
}, plugin);
}
}

options.getOriginalDestination().teleport(player, message, options.getDisplayName(), options.getPermission() == null, options.isSilent(), options.getCosts(player), new Callback<Result>() {
Expand Down
Loading