Added a delayed block changes sending method.
This commit is contained in:
parent
ecd219fb2d
commit
f939e27464
@ -33,6 +33,6 @@ public class PlayerRespawnListener implements Listener
|
|||||||
System.out.println("player: " + event.getPlayer());
|
System.out.println("player: " + event.getPlayer());
|
||||||
System.out.println("position: " + event.getPlayer().getLocation());
|
System.out.println("position: " + event.getPlayer().getLocation());
|
||||||
|
|
||||||
GateBlockChangeSender.updateGateBlocks(event.getPlayer(), event.getRespawnLocation());
|
GateBlockChangeSender.updateGateBlocks(event.getPlayer(), event.getRespawnLocation(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,6 @@ public class PlayerTeleportListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GateBlockChangeSender.updateGateBlocks(event.getPlayer(), event.getTo());
|
GateBlockChangeSender.updateGateBlocks(event.getPlayer(), event.getTo(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package de.craftinc.gates.util;
|
|||||||
|
|
||||||
import de.craftinc.gates.Plugin;
|
import de.craftinc.gates.Plugin;
|
||||||
import de.craftinc.gates.Gate;
|
import de.craftinc.gates.Gate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,17 +30,15 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class GateBlockChangeSender
|
public class GateBlockChangeSender
|
||||||
{
|
{
|
||||||
public static void updateGateBlocks(final Player player)
|
/**
|
||||||
{
|
* Sends gate blocks to player at a given location. Will send the updates either immediately or
|
||||||
if (player == null) {
|
* immediately and after a short delay.
|
||||||
throw new IllegalArgumentException("'player' must not be 'null'!");
|
* @param player A player to send block changes to. Must not be null!
|
||||||
}
|
* @param location The location to look for gates nearby. Must not be null!
|
||||||
|
* @param sendDelayed Set to 'true' if the block changes shall be send a second time after a one
|
||||||
updateGateBlocks(player, player.getLocation());
|
* second delay.
|
||||||
}
|
*/
|
||||||
|
public static void updateGateBlocks(final Player player, final Location location, boolean sendDelayed)
|
||||||
|
|
||||||
public static void updateGateBlocks(final Player player, final Location location)
|
|
||||||
{
|
{
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
throw new IllegalArgumentException("'player' must not be 'null'!");
|
throw new IllegalArgumentException("'player' must not be 'null'!");
|
||||||
@ -68,10 +67,45 @@ public class GateBlockChangeSender
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sendDelayed) {
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
updateGateBlocks(player, location, false);
|
||||||
|
}
|
||||||
|
}, 20L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method calls: updateGateBlocks(player, location, false);
|
||||||
|
*/
|
||||||
|
public static void updateGateBlocks(final Player player, final Location location)
|
||||||
|
{
|
||||||
|
updateGateBlocks(player, location, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method calls: updateGateBlocks(player, player.getLocation(), false);
|
||||||
|
*/
|
||||||
|
public static void updateGateBlocks(final Player player)
|
||||||
|
{
|
||||||
|
if (player == null) {
|
||||||
|
throw new IllegalArgumentException("'player' must not be 'null'!");
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGateBlocks(player, player.getLocation(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends block changes to players near a given gate.
|
||||||
|
* @param gate Must not be 'null'!
|
||||||
|
*/
|
||||||
public static void updateGateBlocks(final Gate gate)
|
public static void updateGateBlocks(final Gate gate)
|
||||||
{
|
{
|
||||||
if (gate == null) {
|
if (gate == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user