Merge pull request #5 from nickreesdev/master

Delivery Man Changes
This commit is contained in:
Braydon 2021-02-19 23:22:19 -05:00 committed by GitHub
commit 4a77fe053b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

@ -1,5 +1,6 @@
package zone.themcgamer.core.deliveryMan; package zone.themcgamer.core.deliveryMan;
import com.cryptomorin.xseries.XSound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -25,11 +26,14 @@ import java.util.UUID;
public class DeliveryManManager extends MiniAccount<DeliveryManClient> { public class DeliveryManManager extends MiniAccount<DeliveryManClient> {
public static final String DELIVERY_MAN_NAME = "Harold"; public static final String DELIVERY_MAN_NAME = "Harold";
private final boolean displayNotification;
private final DeliveryManRepository repository; private final DeliveryManRepository repository;
public DeliveryManManager(JavaPlugin plugin, MySQLController mySQLController) { public DeliveryManManager(JavaPlugin plugin, MySQLController mySQLController, boolean displayNotification) {
super(plugin); super(plugin);
repository = new DeliveryManRepository(mySQLController.getDataSource()); repository = new DeliveryManRepository(mySQLController.getDataSource());
this.displayNotification = displayNotification;
registerCommand(new DeliveryManCommand(this)); registerCommand(new DeliveryManCommand(this));
} }
@ -58,6 +62,8 @@ public class DeliveryManManager extends MiniAccount<DeliveryManClient> {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
private void onJoin(PlayerJoinEvent event) { private void onJoin(PlayerJoinEvent event) {
if (!displayNotification)
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId()); Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
if (optionalAccount.isEmpty()) if (optionalAccount.isEmpty())
@ -90,6 +96,7 @@ public class DeliveryManManager extends MiniAccount<DeliveryManClient> {
return; return;
repository.claim(optionalAccount.get().getId(), reward); repository.claim(optionalAccount.get().getId(), reward);
optionalClient.get().getLastClaimedRewards().put(reward, System.currentTimeMillis()); optionalClient.get().getLastClaimedRewards().put(reward, System.currentTimeMillis());
player.playSound(player.getEyeLocation(), XSound.ENTITY_PLAYER_LEVELUP.parseSound(), 0.9f, 1f);
player.sendMessage(Style.main(DELIVERY_MAN_NAME, "You claimed §b" + reward.getDisplayName() + "§7.")); player.sendMessage(Style.main(DELIVERY_MAN_NAME, "You claimed §b" + reward.getDisplayName() + "§7."));
} }

@ -39,9 +39,10 @@ public class DeliveryManMenu extends UpdatableMenu {
.toItemStack(), event -> player.sendMessage("voting rewards"))); .toItemStack(), event -> player.sendMessage("voting rewards")));
set(2, 5, new Button(new ItemBuilder(XMaterial.PLAYER_HEAD) set(2, 5, new Button(new ItemBuilder(XMaterial.PLAYER_HEAD)
.setSkullOwner(SkullTexture.DISCORD) .setSkullOwner(SkullTexture.DISCORD)
.setName("§d§lNitro Reward") .setName("§d§lNitro Rewards")
.addLoreLine("§7Claimable: §cNo") .addLoreLine("§7Click to view your §d0 §7unclaimed")
.toItemStack(), event -> player.sendMessage("nitro reward"))); .addLoreLine("§7nitro boosting rewards!")
.toItemStack(), event -> player.sendMessage("nitro rewards")));
} }
@Override @Override

@ -56,7 +56,7 @@ public class Hub extends MGZPlugin {
}); });
new KingdomManager(this, traveller); new KingdomManager(this, traveller);
AccountManager.addMiniAccount(new DeliveryManManager(this, mySQLController)); AccountManager.addMiniAccount(new DeliveryManManager(this, mySQLController, true));
commandManager.registerCommand(new SpawnCommand(this)); commandManager.registerCommand(new SpawnCommand(this));
} }