-
Notifications
You must be signed in to change notification settings - Fork 1
Have i been gone long enough?
Hempfest edited this page Aug 15, 2021
·
3 revisions
Labyrinth is equipped with its own AFK player utility, containing multiple states for you to edit!
All we do is simply check if the player already has an AFK impl cached, if not lets initialize one!
public AFK getAFK(Player player) {
if (AFK.get(player) != null) {
return AFK.get(player);
}
return AFK.Initializer.use(player)
.next(Plugin)
.next((e, subscription) -> {
Player p = e.getAfk().getPlayer();
switch (e.getStatus()) {
case AWAY:
TimeWatch.Recording recording = e.getAfk().getRecording();
long minutes = recording.getMinutes();
long seconds = recording.getSeconds();
String format = "&cYou will be kicked in &4{0} &cseconds.";
if (minutes == 14) {
if (seconds == 50) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 10)).translate(), 0, 12, 5);
}
if (seconds == 51) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 9)).translate(), 0, 12, 5);
}
if (seconds == 52) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 8)).translate(), 0, 12, 5);
}
if (seconds == 53) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 7)).translate(), 0, 12, 5);
}
if (seconds == 54) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 6)).translate(), 0, 12, 5);
}
if (seconds == 55) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 5)).translate(), 0, 12, 5);
}
if (seconds == 56) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 4)).translate(), 0, 12, 5);
}
if (seconds == 57) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 3)).translate(), 0, 12, 5);
}
if (seconds == 58) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 2)).translate(), 0, 12, 5);
}
if (seconds == 59) {
p.sendTitle(StringUtils.use("&eHey AFK person!").translate(), StringUtils.use(MessageFormat.format(format, 1)).translate(), 0, 12, 5);
}
}
break;
case PENDING:
Bukkit.broadcastMessage(StringUtils.use("&2&l[&fLabyrinth&2&l]" + " &7Player &b" + p.getName() + " &7is now AFK").translate());
p.setDisplayName(StringUtils.use("&7*AFK&r " + p.getDisplayName()).translate());
e.getAfk().set(AFK.Status.AWAY);
break;
case RETURNING:
p.setDisplayName(p.getName());
Bukkit.broadcastMessage(StringUtils.use("&2&l[&fLabyrinth&2&l]" + " &7Player &b" + p.getName() + " &7is no longer AFK").translate());
e.getAfk().reset(AFK.Status.ACTIVE);
break;
case REMOVABLE:
Bukkit.broadcastMessage(StringUtils.use("&2&l[&fLabyrinth&2&l]" + " &c&oPlayer &b" + p.getName() + " &c&owas kicked for being AFK too long.").translate());
p.kickPlayer(StringUtils.use("&2&l[&fLabyrinth&2&l]" + "\n" + "&c&oAFK too long.\n&c&oKicking to ensure safety :)").translate());
e.getAfk().remove();
break;
case CHATTING:
case EXECUTING:
e.getAfk().set(AFK.Status.RETURNING);
break;
case LEAVING:
p.setDisplayName(p.getName());
Bukkit.broadcastMessage(StringUtils.use("&2&l[&fLabyrinth&2&l]" + " &7Player &b" + p.getName() + " &7is no longer AFK").translate());
e.getAfk().remove();
break;
}
})
.finish();
}
Now we just call this on our server join!
@Subscribe
public void onJoin(DefaultEvent.Join e) {
getAFK(e.getPlayer());
}
-
- AFK Player Utility
- Command Builder
- Command Utility
- Complete GUI Builder
- Complete Head Database/Locator
- Cooldown Abstraction
- Custom Gradient Color Interface
- Custom ID Generation
- Directional Enumeration
- Economy Interface Wrapper
- Entity Creation Tools
- File Management
- Item Recipe Builder
- Item Modification Builder
- Legacy Safe NamespacedKey
- Listing Collections
- Material Matcher
- Message Formatter
- String Utility
- Tab Completion Builder
- Task Scheduling
- Template Creation
- TextComponent Builder
- Vault Permission Interface Wrapper