use of com.almuradev.almura.feature.membership.network.ClientboundMembershipGuiOpenPacket in project Almura by AlmuraDev.
the class MembershipHandler method requestClientGui.
public void requestClientGui(Player player) {
final EconomyService service = Sponge.getServiceManager().provide(EconomyService.class).orElse(null);
final LuckPerms permService = Sponge.getServiceManager().provide(LuckPerms.class).orElse(null);
int currentMembershipLevel = -1;
if (player.hasPermission("almura.membership.gui.open")) {
if (service != null && skillsManager != null && permService != null) {
final Account account = service.getOrCreateAccount(player.getUniqueId()).orElse(null);
BigDecimal balance;
if (account != null) {
final Currency currency = service.getDefaultCurrency();
balance = account.getBalance(currency);
String currentGroup = permService.getUserManager().getUser(player.getUniqueId()).getPrimaryGroup();
if (currentGroup.equalsIgnoreCase("default")) {
currentMembershipLevel = -1;
// should be impossible to reach this unless permissions system is screwed up.
} else if (currentGroup.equalsIgnoreCase("survivor")) {
currentMembershipLevel = 0;
} else if (currentGroup.equalsIgnoreCase("citizen")) {
currentMembershipLevel = 1;
} else if (currentGroup.equalsIgnoreCase("explorer")) {
currentMembershipLevel = 2;
} else if (currentGroup.equalsIgnoreCase("pioneer")) {
currentMembershipLevel = 3;
}
this.network.sendTo(player, new ClientboundMembershipGuiOpenPacket(player.hasPermission("almura.membership.admin"), skillsManager.getTotalSkillLevel(player), balance.doubleValue(), currentMembershipLevel));
}
} else {
serverNotificationManager.sendWindowMessage(player, Text.of("Init Error"), Text.of("Economy Service offline!"));
}
} else {
serverNotificationManager.sendPopupNotification(player, Text.of("Insufficient Permissions"), Text.of("Missing [almura.membership.gui.open]"), 5);
}
}
Aggregations