Replace Timers with Bukkit schedulers
This commit is contained in:
parent
d97c1adaf0
commit
e135df1c62
@ -1,8 +1,6 @@
|
|||||||
package net.spoothie.chairs;
|
package net.spoothie.chairs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -55,21 +53,18 @@ public class EventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class sendSitTask extends TimerTask {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
plugin.sendSit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Timer timer = new Timer();
|
delayedSitTask();
|
||||||
long delay = 1 * 2000;
|
}
|
||||||
timer.schedule(new sendSitTask(), delay);
|
|
||||||
//plugin.sendSit();
|
private void delayedSitTask() {
|
||||||
|
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
plugin.sendSit();
|
||||||
|
}
|
||||||
|
}, 20 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -113,6 +108,7 @@ public class EventListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (event.getPlayer().getItemInHand().getType().isBlock()
|
if (event.getPlayer().getItemInHand().getType().isBlock()
|
||||||
|
&& (event.getPlayer().getItemInHand().getTypeId() != 0)
|
||||||
&& plugin.ignoreIfBlockInHand) {
|
&& plugin.ignoreIfBlockInHand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -287,9 +283,7 @@ public class EventListener implements Listener {
|
|||||||
plugin.sit.put(player.getName(), block.getLocation());
|
plugin.sit.put(player.getName(), block.getLocation());
|
||||||
event.setUseInteractedBlock(Result.DENY);
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
|
|
||||||
Timer timer = new Timer();
|
delayedSitTask();
|
||||||
long delay = 1 * 2000;
|
|
||||||
timer.schedule(new sendSitTask(), delay);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: Chairs
|
name: Chairs
|
||||||
version: 2.0.1
|
version: 2.0.2
|
||||||
description: Let players sit on blocks.
|
description: Let players sit on blocks.
|
||||||
authors:
|
authors:
|
||||||
- spoothie
|
- spoothie
|
||||||
|
Loading…
Reference in New Issue
Block a user