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