Fix ignore-if-block-in-hand issue with empty hand counting as a air block
Replace Timers with Bukkit schedulers Some refactoring optimizations
This commit is contained in:
parent
e135df1c62
commit
8954be85a1
@ -208,22 +208,42 @@ public class Chairs extends JavaPlugin {
|
|||||||
pm.addPermission(new Permission("chairs.self","Allow player to self disable or enable sitting.",pd));
|
pm.addPermission(new Permission("chairs.self","Allow player to self disable or enable sitting.",pd));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send sit packet to all online players
|
private PacketContainer getSitPacket(Player p) {
|
||||||
public void sendSit(Player p) {
|
|
||||||
PacketContainer fakeSit = protocolManager.createPacket(40);
|
PacketContainer fakeSit = protocolManager.createPacket(40);
|
||||||
fakeSit.getSpecificModifier(int.class).write(0, p.getEntityId());
|
fakeSit.getSpecificModifier(int.class).write(0, p.getEntityId());
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
watcher.setObject(0, (byte)4);
|
watcher.setObject(0, (byte)4);
|
||||||
fakeSit.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
|
fakeSit.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
|
||||||
|
return fakeSit;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PacketContainer getStandPacket(Player p) {
|
||||||
|
PacketContainer fakeSit = protocolManager.createPacket(40);
|
||||||
|
fakeSit.getSpecificModifier(int.class).write(0, p.getEntityId());
|
||||||
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
|
watcher.setObject(0, (byte)0);
|
||||||
|
fakeSit.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
|
||||||
|
return fakeSit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send sit packet to all online players that are on same world and can see player
|
||||||
|
public void sendSit(Player p) {
|
||||||
|
sendPacketToPlayers(getSitPacket(p),p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendPacketToPlayers(PacketContainer pc, Player p) {
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (onlinePlayer.canSee(p)) {
|
||||||
|
if (onlinePlayer.getWorld().equals(p.getWorld())) {
|
||||||
try {
|
try {
|
||||||
protocolManager.sendServerPacket(onlinePlayer, fakeSit);
|
protocolManager.sendServerPacket(onlinePlayer, pc);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// Nothing here
|
// Nothing here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void sendSit() {
|
public void sendSit() {
|
||||||
for (String s : sit.keySet()) {
|
for (String s : sit.keySet()) {
|
||||||
@ -242,21 +262,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
sit.remove(p.getName());
|
sit.remove(p.getName());
|
||||||
}
|
}
|
||||||
|
sendPacketToPlayers(getStandPacket(p),p);
|
||||||
PacketContainer fakeSit = protocolManager.createPacket(40);
|
|
||||||
fakeSit.getSpecificModifier(int.class).write(0, p.getEntityId());
|
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
|
||||||
watcher.setObject(0, (byte)0);
|
|
||||||
fakeSit.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
|
|
||||||
|
|
||||||
|
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
|
||||||
try {
|
|
||||||
protocolManager.sendServerPacket(onlinePlayer, fakeSit);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// Nothing here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logInfo(String _message) {
|
public void logInfo(String _message) {
|
||||||
|
Loading…
Reference in New Issue
Block a user