mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-11 21:06:55 +00:00
folia scheduling part MXIV
This commit is contained in:
@@ -32,12 +32,14 @@ public class PlayerManager {
|
|||||||
Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, (task) -> Bukkit.getWorlds().forEach((world -> {
|
Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, (task) -> Bukkit.getWorlds().forEach((world -> {
|
||||||
for (Chunk chunk : world.getLoadedChunks()) {
|
for (Chunk chunk : world.getLoadedChunks()) {
|
||||||
if (!chunk.isEntitiesLoaded()) continue;
|
if (!chunk.isEntitiesLoaded()) continue;
|
||||||
for (Entity entity : chunk.getEntities()) {
|
Bukkit.getRegionScheduler().run(plugin, chunk.getWorld(), chunk.getX(), chunk.getZ(), (task1) -> {
|
||||||
if (!(entity instanceof Tameable tameable)) continue;
|
for (Entity entity : chunk.getEntities()) {
|
||||||
UUID ownerId = tameable.getOwnerUniqueId();
|
if (!(entity instanceof Tameable tameable)) continue;
|
||||||
if (ownerId == null) continue;
|
UUID ownerId = tameable.getOwnerUniqueId();
|
||||||
getPlayerData(ownerId);
|
if (ownerId == null) continue;
|
||||||
}
|
getPlayerData(ownerId);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})), 5, 20 * 15);
|
})), 5, 20 * 15);
|
||||||
|
|
||||||
@@ -248,6 +250,7 @@ public class PlayerManager {
|
|||||||
public CompletableFuture<Boolean> togglePlayerPvpState(UUID uuid) {
|
public CompletableFuture<Boolean> togglePlayerPvpState(UUID uuid) {
|
||||||
return getPlayerData(uuid).thenApply(playerData -> {
|
return getPlayerData(uuid).thenApply(playerData -> {
|
||||||
playerData.setPvpEnabled(!playerData.isPvpEnabled());
|
playerData.setPvpEnabled(!playerData.isPvpEnabled());
|
||||||
|
plugin.getSqLite().updatePlayerInfo(uuid, new PlayerData(uuid, playerData.isPvpEnabled()));
|
||||||
return playerData.isPvpEnabled();
|
return playerData.isPvpEnabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user