Skip to content

Commit 125d730

Browse files
Merge pull request Artillex-Studios#9 from FreshSMP/master
Use entity scheduler for hide/show player
2 parents 0924eb6 + bf8ca7d commit 125d730

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ group = rootProject.group
22
version = rootProject.version
33

44
dependencies {
5-
implementation("com.artillexstudios.axapi:axapi:1.4.732:all")
5+
implementation("com.artillexstudios.axapi:axapi:1.4.747:all")
66
}
77

88
tasks {

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ subprojects {
3232
}
3333

3434
dependencies {
35-
implementation("com.artillexstudios.axapi:axapi:1.4.732:all")
35+
implementation("com.artillexstudios.axapi:axapi:1.4.747:all")
3636
compileOnly("com.github.ben-manes.caffeine:caffeine:3.2.1")
3737
compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT")
3838
compileOnly("dev.jorel:commandapi-bukkit-shade:10.1.2")

common/src/main/java/com/artillexstudios/axvanish/config/Groups.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private boolean refreshConfig() {
4444

4545
this.config.load();
4646
Map<String, Group> groups = new HashMap<>();
47-
Map<String, Map<String, Object>> section = (Map<String, Map<String, Object>>) this.config.getMap("groups");
47+
Map<String, Map<String, Object>> section = this.config.getMap("groups");
4848
if (section == null) {
4949
return false;
5050
}

common/src/main/java/com/artillexstudios/axvanish/users/User.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import org.bukkit.entity.Player;
2020

2121
public final class User implements com.artillexstudios.axvanish.api.users.User {
22-
private static final Cooldown<User> cancelCooldown = new Cooldown<>();
22+
23+
private static final Cooldown<User> cancelCooldown = Cooldown.create();
24+
2325
private final OfflinePlayer offlinePlayer;
2426
private Group group;
2527
private Player onlinePlayer;

common/src/main/java/com/artillexstudios/axvanish/utils/VanishStateManager.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,38 @@ public void updateViewers(boolean current) {
6363
continue;
6464
}
6565

66+
Runnable retired = () -> this.count(playerCounter, counter);
67+
6668
// We want to be sure that only people who can see the player
6769
// can see the player. This is not a mistake
6870
if (Config.debug) {
6971
LogUtils.debug("Can {} see {}: {}", onlinePlayer.getName(), player.getName(), online.canSee(this.user));
7072
}
7173
if (online.canSee(this.user)) {
72-
Scheduler.get().runAt(onlinePlayer.getLocation(), task -> {
74+
Scheduler.get().run(onlinePlayer, task -> {
7375
onlinePlayer.showPlayer(this.plugin, player);
7476
this.count(playerCounter, counter);
75-
});
77+
}, retired);
7678
} else {
77-
Scheduler.get().runAt(onlinePlayer.getLocation(), task -> {
79+
Scheduler.get().run(onlinePlayer, task -> {
7880
onlinePlayer.hidePlayer(this.plugin, player);
7981
this.count(playerCounter, counter);
80-
});
82+
}, retired);
8183
}
8284

8385
if (Config.debug) {
8486
LogUtils.debug("Can {} see {}: {}", player.getName(), onlinePlayer.getName(), this.user.canSee(online));
8587
}
8688
if (this.user.canSee(online)) {
87-
Scheduler.get().runAt(onlinePlayer.getLocation(), task -> {
89+
Scheduler.get().run(onlinePlayer, task -> {
8890
player.showPlayer(this.plugin, onlinePlayer);
8991
this.count(playerCounter, counter);
90-
});
92+
}, retired);
9193
} else {
92-
Scheduler.get().runAt(onlinePlayer.getLocation(), task -> {
94+
Scheduler.get().run(onlinePlayer, task -> {
9395
player.hideEntity(this.plugin, onlinePlayer);
9496
this.count(playerCounter, counter);
95-
});
97+
}, retired);
9698
}
9799
}
98100
}

0 commit comments

Comments
 (0)