Merge pull request #4 from nickreesdev/master
Added a notification for when a player joins letting them know if they have unclaimed rewards.
This commit is contained in:
commit
461f13597f
@ -1,6 +1,9 @@
|
||||
package zone.themcgamer.core.deliveryMan;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import zone.themcgamer.core.account.Account;
|
||||
import zone.themcgamer.core.account.AccountManager;
|
||||
@ -53,6 +56,23 @@ public class DeliveryManManager extends MiniAccount<DeliveryManClient> {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private void onJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
||||
if (optionalAccount.isEmpty())
|
||||
return;
|
||||
Optional<DeliveryManClient> optionalClient = lookup(player.getUniqueId());
|
||||
if (optionalClient.isEmpty())
|
||||
return;
|
||||
for (DeliveryManReward reward : DeliveryManReward.values()) {
|
||||
if ((canClaim(player, reward) && optionalAccount.get().hasRank(reward.getRequiredRank()))) {
|
||||
player.sendMessage(Style.main(DELIVERY_MAN_NAME, "You have unclaimed rewards! Visit §b" + DELIVERY_MAN_NAME + " §7to claim them!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Claims a {@link Player}'s {@link DeliveryManReward}
|
||||
*
|
||||
|
Reference in New Issue
Block a user