Added Harold the Delivery Man
This commit is contained in:
parent
4c7f1fb5a5
commit
879316750d
@ -10,8 +10,9 @@ public class SkullTexture {
|
||||
public static final String DIAMOND_BLOCK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWUwNTc5OTZjYmE0NzMyOGRmNzJmYmEzZWEyYjlhYTM1YzhhODIyN2YxY2VjODljMTg4NGRjYWRhYTgyNGQ4NSJ9fX0=";
|
||||
public static final String EMERALD_BLOCK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjcyYzA1ZGQ3NjI4OGY0MzI4YTI0MzkxYmY0NzI1ZmQyMjYwNTkyZGIzY2Y5YjJiYzIwMzJkZDA1OTZjZjQ0MCJ9fX0=";
|
||||
public static final String COAL_BLOCK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdmNTc2NmQyOTI4ZGMwZGYxYjM0MDRjM2JkMDczYzk0NzZkMjZjODA1NzNiMDMzMmU3Y2NlNzNkZjE1NDgyYSJ9fX0=";
|
||||
public static final String GREEN_BACKPACK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjhhMTI3ZjFjZmQ3OTk4NmU3YmQ5NWQ5MmRlNGY0ZjY4MDQwZTRmODk5ZjgxYjFmOGYzY2ExNWI2NGY1MGYzIn19fQ==";
|
||||
public static final String DISCORD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzYyYTFiNDczYmEzYzI1ZTZlYjE0NThkZmM5NTM5MjFmNWQ5MTQ3OGFmOWQ2ZGRhMDdjMDMyZjkyOGMifX19";
|
||||
public static final String GOLD_CUBE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTkxNDE0Nzc0NGNkMjE4YzlhMDc4MjM0ZjcwMzVjNzFlNGEzNDg1OWFmOTJmYzkxYjg4YzIxZThiMzcyMjNjNSJ9fX0=";
|
||||
public static final String DIAMOND_CUBE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2VkNGFjZThmYTUwN2M0NWIxMWI4OTMzNjJlNDViZWJmNDhjYjIyMDMxNTM1MzJlZmY0MjBhN2Y1Y2Y3NzEwYiJ9fX0=";
|
||||
|
||||
// Team Colors (https://minecraft-heads.com/custom-heads/search?searchword=Leather+Helmet)
|
||||
public static final String TEAM_UNDYED = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjBiZjFkNjQzOWM5OGI0MDY2MTdhOWIxZjdjODM0NGVjZGJiODJhYjkyMTNkMzEzZWRiMjgyMTY2OTQ2MmJkZiJ9fX0=";
|
||||
@ -31,4 +32,19 @@ public class SkullTexture {
|
||||
public static final String TEAM_LIGHT_GRAY = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmNkYmJlYzJlN2M2Zjc5OTY2OTkyZThkM2I2OTAwZjk4ZGFhNGQ0ZGE4OTBlMmI4YWZlNjVhYmNkYzhiMjNjNyJ9fX0=";
|
||||
public static final String TEAM_GRAY = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmNkYmJlYzJlN2M2Zjc5OTY2OTkyZThkM2I2OTAwZjk4ZGFhNGQ0ZGE4OTBlMmI4YWZlNjVhYmNkYzhiMjNjNyJ9fX0=";
|
||||
public static final String TEAM_BLACK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjU3YjZlNGE3MmE5M2E3YTdhMjFmYTI4NmYyZWU3MTViNDlhNmJhNzgyNGRjNTMzZWQyNDBiOTYwNzExNDEzZSJ9fX0=";
|
||||
|
||||
// Backpack Colors (https://minecraft-heads.com/custom-heads/search?searchword=Backpack)
|
||||
public static final String BACKPACK_NAVY_BLUE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGRjYzZlYjQwZjNiYWRhNDFlNDMzOTg4OGQ2ZDIwNzQzNzU5OGJkYmQxNzVjMmU3MzExOTFkNWE5YTQyZDNjOCJ9fX0=";
|
||||
public static final String BACKPACK_GREEN = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2E2YWQ4YWQ5MTNkZWYxM2JkNTc0MTY1NWU3N2QxMzRlYjFiNTdmMDI5NzBkYWE2YjMzMDgyNzU0ZDFhZmZjNCJ9fX0=";
|
||||
public static final String BACKPACK_LIGHT_BLUE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODJjMzdiZmExMTg2M2QwMDI1NTFhMDJiNTE5ZDcxNTRkYTgyNjcwNWQyMDk4MjU5MTUyMmRlMmVhMWIyODhjMiJ9fX0=";
|
||||
public static final String BACKPACK_BLACK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTgyNjQxNzg2YTQyMjA4OGY3NWRjZWU3MDIwNWQ1ODA2MDBmNjlkNmFhMmY3N2QyNjc4YjU4ZDg5YjY5NzNhNiJ9fX0=";
|
||||
public static final String BACKPACK_LIME = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjIxMjhmNDhkOTk3MTg2NTYzZmJjNWI0N2E4OGMwZDBhYWM5MmZhMmMyODVjZDFmYWU0MjBjMzRmYThmMjAxMCJ9fX0=";
|
||||
public static final String BACKPACK_ORANGE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjcwYjU2MjJiN2QwNjhmNTc4OGJmMTlhODM5ODM5MzdiMTZjNTk3MmM5MWY1ZWU3YmY1NGJjYzM2MzhmOWEzNiJ9fX0=";
|
||||
public static final String BACKPACK_PINK = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmUwODdjZDk3NWQyNjRjNzJhZGNhOWVmYzZmYzM0NDc2ZWMzOGUxOGRmNTM2YjMwNzYzNTI2N2EzN2ZhZjA3NiJ9fX0=";
|
||||
public static final String BACKPACK_PURPLE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjE4N2M3MzJhYTM5ZDI5MTM0NjUwYjZhNzJjNmY0MWI5OTA4NWEyNmVjNWU1MTNiYTE4YzQwZDVlY2E5ZTY5YyJ9fX0=";
|
||||
public static final String BACKPACK_RED = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmNlMDE2OTlmNzk2Y2JkZTk1Yzg0OWJlZTNjYzM2OTg3ODQ1MmI0MGE0MTE0NDM2NmQ2NmI0YTA4MjZjZmFhMCJ9fX0=";
|
||||
public static final String BACKPACK_WHITE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTJiYjM4NTE2YjI5NTA0MTg2ZTExNTU5Y2Q1MjUwYWUyMThkYjRkZGQyN2FlNDM4NzI2Yzg0N2NlNmIzYzk4In19fQ==";
|
||||
public static final String BACKPACK_YELLOW = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTFiYmJjNWMyNDM4NGVjYjJmNjg0NGRhMjg1Y2NjZjllYjAxMWM3YTY2NzAxNzdjZjc1Y2Q2NTUxM2JjMTI3NCJ9fX0=";
|
||||
public static final String BACKPACK_GRAY = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmFjNzdiNzZmMGM2NGMxNGMwNDkzNmE1NTc5NmM0OWE4MmZmMTc0ODM4ZGI5MzBkNTJiMGNhYWNkZDIxNTkxNyJ9fX0=";
|
||||
public static final String BACKPACK_BLUE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2U1YWJkYjczNzQ1NTNkMDU2NWNiY2IzMjk1YWVkNTE1YTg5N2ViY2U5ZTBiYzYwZjFjMWY4YWU1NGM3NDlkZiJ9fX0=";
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package zone.themcgamer.core.deliveryMan;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
@RequiredArgsConstructor @Setter @Getter
|
||||
public class DeliveryManClient {
|
||||
private final Map<DeliveryManReward, Long> lastClaimedRewards = new HashMap<>();
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package zone.themcgamer.core.deliveryMan;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import zone.themcgamer.core.account.Account;
|
||||
import zone.themcgamer.core.account.AccountManager;
|
||||
import zone.themcgamer.core.account.MiniAccount;
|
||||
import zone.themcgamer.core.common.Style;
|
||||
import zone.themcgamer.core.deliveryMan.command.DeliveryManCommand;
|
||||
import zone.themcgamer.core.module.ModuleInfo;
|
||||
import zone.themcgamer.data.mysql.MySQLController;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
@ModuleInfo(name = "Delivery Man Manager")
|
||||
public class DeliveryManManager extends MiniAccount<DeliveryManClient> {
|
||||
public static final String DELIVERY_MAN_NAME = "Harold";
|
||||
|
||||
private final DeliveryManRepository repository;
|
||||
|
||||
public DeliveryManManager(JavaPlugin plugin, MySQLController mySQLController) {
|
||||
super(plugin);
|
||||
repository = new DeliveryManRepository(mySQLController.getDataSource());
|
||||
registerCommand(new DeliveryManCommand(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeliveryManClient getAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp) {
|
||||
return new DeliveryManClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, UUID uuid, String name, String ip, String encryptedIp) {
|
||||
return "SELECT `rewardId`, `lastClaimed` FROM `deliveryMan` WHERE `accountId` = '" + accountId + "';";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException {
|
||||
Optional<DeliveryManClient> client = lookup(uuid);
|
||||
if (client.isEmpty())
|
||||
return;
|
||||
while (resultSet.next()) {
|
||||
DeliveryManReward reward = DeliveryManReward.match(resultSet.getString("rewardId"));
|
||||
if (reward == null)
|
||||
continue;
|
||||
client.get().getLastClaimedRewards().put(reward, resultSet.getLong("lastClaimed"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Claims a {@link Player}'s {@link DeliveryManReward}
|
||||
*
|
||||
* @param player the player who is claiming the reward
|
||||
* @param reward the reward that's being claimed
|
||||
*/
|
||||
public void claimReward(Player player, DeliveryManReward reward) {
|
||||
Optional<DeliveryManClient> optionalClient = lookup(player.getUniqueId());
|
||||
if (optionalClient.isEmpty())
|
||||
return;
|
||||
if (!canClaim(player, reward))
|
||||
return;
|
||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
||||
if (optionalAccount.isEmpty())
|
||||
return;
|
||||
repository.claim(optionalAccount.get().getId(), reward);
|
||||
optionalClient.get().getLastClaimedRewards().put(reward, System.currentTimeMillis());
|
||||
player.sendMessage(Style.main(DELIVERY_MAN_NAME, "You claimed §b" + reward.getDisplayName() + "§7."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a {@link DeliveryManReward} can be claimed at the time of checking.
|
||||
*
|
||||
* @param player the player that we are checking from
|
||||
* @param reward the reward that we are seeing if it can be claimed
|
||||
* @return if the reward is claimable
|
||||
*/
|
||||
public boolean canClaim(Player player, DeliveryManReward reward) {
|
||||
Optional<DeliveryManClient> optionalClient = lookup(player.getUniqueId());
|
||||
if (optionalClient.isEmpty())
|
||||
return false;
|
||||
if (!optionalClient.get().getLastClaimedRewards().containsKey(reward))
|
||||
return true;
|
||||
else
|
||||
return System.currentTimeMillis() - optionalClient.get().getLastClaimedRewards().get(reward) > reward.getClaimCooldown();
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package zone.themcgamer.core.deliveryMan;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import zone.themcgamer.data.mysql.data.column.Column;
|
||||
import zone.themcgamer.data.mysql.data.column.impl.IntegerColumn;
|
||||
import zone.themcgamer.data.mysql.data.column.impl.LongColumn;
|
||||
import zone.themcgamer.data.mysql.data.column.impl.StringColumn;
|
||||
import zone.themcgamer.data.mysql.repository.MySQLRepository;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
public class DeliveryManRepository extends MySQLRepository {
|
||||
private static final String CLAIM_REWARD = "INSERT INTO `deliveryMan` " +
|
||||
"(`accountId`, `rewardId`, `lastClaimed`) VALUES " +
|
||||
"(?, ?, ?) ON DUPLICATE KEY UPDATE `lastClaimed`=?";
|
||||
|
||||
public DeliveryManRepository(HikariDataSource dataSource) {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a query to insert / update the reward in the database.
|
||||
*
|
||||
* @param accountId the id of the account that is claiming the reward
|
||||
* @param reward the reward that is being claimed
|
||||
*/
|
||||
public void claim(int accountId, DeliveryManReward reward) {
|
||||
long now = System.currentTimeMillis();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
executeInsert(CLAIM_REWARD, new Column[] {
|
||||
new IntegerColumn("accountId", accountId),
|
||||
new StringColumn("rewardId", reward.getId()),
|
||||
new LongColumn("lastClaimed", now),
|
||||
new LongColumn("lastClaimed", now)
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package zone.themcgamer.core.deliveryMan;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import zone.themcgamer.core.common.SkullTexture;
|
||||
import zone.themcgamer.core.deliveryMan.rewardPackage.RewardPackage;
|
||||
import zone.themcgamer.core.deliveryMan.rewardPackage.impl.DailyRewardPackage;
|
||||
import zone.themcgamer.core.deliveryMan.rewardPackage.impl.MonthlyRewardPackage;
|
||||
import zone.themcgamer.core.deliveryMan.rewardPackage.impl.WeeklyRewardPackage;
|
||||
import zone.themcgamer.data.Rank;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
@AllArgsConstructor @Getter
|
||||
public enum DeliveryManReward {
|
||||
DAILY("dailyReward", "Daily Reward", Rank.DEFAULT, TimeUnit.DAYS.toMillis(1L), new DailyRewardPackage()),
|
||||
WEEKLY("weeklyReward", "Weekly Reward", Rank.DEFAULT, TimeUnit.DAYS.toMillis(7L), new WeeklyRewardPackage()),
|
||||
MONTHLY("monthlyReward", "Monthly Reward", Rank.GAMER, TimeUnit.DAYS.toMillis(30L), new MonthlyRewardPackage());
|
||||
|
||||
private final String id, displayName;
|
||||
private final Rank requiredRank;
|
||||
private final long claimCooldown;
|
||||
private final RewardPackage rewardPackage;
|
||||
|
||||
/**
|
||||
* Get the {@link DeliveryManReward} matching the given id
|
||||
*
|
||||
* @param id the id
|
||||
* @return the reward, otherwise null
|
||||
*/
|
||||
public static DeliveryManReward match(String id) {
|
||||
return Arrays.stream(values()).filter(reward -> reward.getId().equalsIgnoreCase(id)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package zone.themcgamer.core.deliveryMan.command;
|
||||
|
||||
import zone.themcgamer.core.command.Command;
|
||||
import zone.themcgamer.core.command.CommandProvider;
|
||||
import zone.themcgamer.core.deliveryMan.DeliveryManManager;
|
||||
import zone.themcgamer.core.deliveryMan.menu.DeliveryManMenu;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
public class DeliveryManCommand {
|
||||
private final DeliveryManManager deliveryManManager;
|
||||
|
||||
public DeliveryManCommand(DeliveryManManager deliveryManManager) {
|
||||
this.deliveryManManager = deliveryManManager;
|
||||
}
|
||||
|
||||
@Command(name = "deliveryman", description = "Open the Delivery Man menu", playersOnly = true)
|
||||
public void onCommand(CommandProvider command) {
|
||||
new DeliveryManMenu(command.getPlayer(), deliveryManManager).open();
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package zone.themcgamer.core.deliveryMan.menu;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import org.bukkit.entity.Player;
|
||||
import zone.themcgamer.common.TimeUtils;
|
||||
import zone.themcgamer.core.account.Account;
|
||||
import zone.themcgamer.core.account.AccountManager;
|
||||
import zone.themcgamer.core.common.ItemBuilder;
|
||||
import zone.themcgamer.core.common.SkullTexture;
|
||||
import zone.themcgamer.core.common.menu.Button;
|
||||
import zone.themcgamer.core.common.menu.MenuType;
|
||||
import zone.themcgamer.core.common.menu.UpdatableMenu;
|
||||
import zone.themcgamer.core.deliveryMan.DeliveryManClient;
|
||||
import zone.themcgamer.core.deliveryMan.DeliveryManManager;
|
||||
import zone.themcgamer.core.deliveryMan.DeliveryManReward;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
public class DeliveryManMenu extends UpdatableMenu {
|
||||
private final DeliveryManManager deliveryManManager;
|
||||
|
||||
public DeliveryManMenu(Player player, DeliveryManManager deliveryManManager) {
|
||||
super(player, DeliveryManManager.DELIVERY_MAN_NAME, 4, MenuType.CHEST, TimeUnit.SECONDS.toMillis(1L));
|
||||
this.deliveryManManager = deliveryManManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onOpen() {
|
||||
// TODO: 2/19/2021 Make these rewards actually work - Nick
|
||||
set(2, 3, new Button(new ItemBuilder(XMaterial.PLAYER_HEAD)
|
||||
.setSkullOwner(SkullTexture.EMERALD_BLOCK)
|
||||
.setName("§b§lVoting Rewards")
|
||||
.addLoreLine("§7Click to view your §b0 §7unclaimed")
|
||||
.addLoreLine("§7voting rewards!")
|
||||
.toItemStack(), event -> player.sendMessage("voting rewards")));
|
||||
set(2, 5, new Button(new ItemBuilder(XMaterial.PLAYER_HEAD)
|
||||
.setSkullOwner(SkullTexture.DISCORD)
|
||||
.setName("§d§lNitro Reward")
|
||||
.addLoreLine("§7Claimable: §cNo")
|
||||
.toItemStack(), event -> player.sendMessage("nitro reward")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
||||
if (optionalAccount.isEmpty())
|
||||
return;
|
||||
Optional<DeliveryManClient> optionalClient = deliveryManManager.lookup(player.getUniqueId());
|
||||
if (optionalClient.isEmpty())
|
||||
return;
|
||||
int slot = 2;
|
||||
for (DeliveryManReward reward : DeliveryManReward.values()) {
|
||||
boolean canClaim = (deliveryManManager.canClaim(player, reward) && optionalAccount.get().hasRank(reward.getRequiredRank()));
|
||||
ItemBuilder itemBuilder = new ItemBuilder(XMaterial.PLAYER_HEAD)
|
||||
.setSkullOwner(reward.getRewardPackage().getIconTexture(player, optionalAccount.get()))
|
||||
.setGlow(canClaim)
|
||||
.setName((canClaim ? "§a" : "§c") + "§l" + reward.getDisplayName())
|
||||
.addLoreLine("§7Claimable: " + (canClaim ? "§aYes" : "§cNo"));
|
||||
if (reward == DeliveryManReward.MONTHLY) {
|
||||
if (optionalAccount.get().hasRank(reward.getRequiredRank())) {
|
||||
itemBuilder.addLoreLine("")
|
||||
.addLoreLine("§7Your Rank: §b" + optionalAccount.get().getPrimaryRankName());
|
||||
} else {
|
||||
itemBuilder.addLoreLine("")
|
||||
.addLoreLine("§cOnly §bdonators §ccan claim a §b" + reward.getDisplayName() + "§c!");
|
||||
}
|
||||
}
|
||||
itemBuilder.addLoreLine("")
|
||||
.addLoreLine("§7Rewards:")
|
||||
.addLoreLine(" §bNone!"); // TODO: 2/19/2021 This is static at the moment due to the fact the reward base isn't done.
|
||||
if (!deliveryManManager.canClaim(player, reward)) {
|
||||
itemBuilder.addLoreLine("")
|
||||
.addLoreLine("§7Next Delivery: §b" + TimeUtils.formatIntoDetailedString((optionalClient.get().getLastClaimedRewards().get(reward)
|
||||
+ reward.getClaimCooldown()) - System.currentTimeMillis(), true));
|
||||
}
|
||||
set(1, slot, new Button(itemBuilder.toItemStack(), event -> {
|
||||
if (!canClaim)
|
||||
return;
|
||||
close();
|
||||
deliveryManManager.claimReward(player, reward);
|
||||
}));
|
||||
slot += 2;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package zone.themcgamer.core.deliveryMan.rewardPackage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import zone.themcgamer.core.account.Account;
|
||||
import zone.themcgamer.core.common.SkullTexture;
|
||||
import zone.themcgamer.core.deliveryMan.menu.DeliveryManMenu;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
public abstract class RewardPackage {
|
||||
/**
|
||||
* Gets the {@link SkullTexture} which is shown in the {@link DeliveryManMenu}.
|
||||
*
|
||||
* @param player the player to get the texture for
|
||||
* @param account the account to get the texture for
|
||||
* @return the texture
|
||||
*/
|
||||
public abstract String getIconTexture(Player player, Account account);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package zone.themcgamer.core.deliveryMan.rewardPackage.impl;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import zone.themcgamer.core.account.Account;
|
||||
import zone.themcgamer.core.common.SkullTexture;
|
||||
import zone.themcgamer.core.deliveryMan.rewardPackage.RewardPackage;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
public class DailyRewardPackage extends RewardPackage {
|
||||
@Override
|
||||
public String getIconTexture(Player player, Account account) {
|
||||
return SkullTexture.GOLD_CUBE;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package zone.themcgamer.core.deliveryMan.rewardPackage.impl;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import zone.themcgamer.core.account.Account;
|
||||
import zone.themcgamer.core.common.SkullTexture;
|
||||
import zone.themcgamer.core.deliveryMan.rewardPackage.RewardPackage;
|
||||
import zone.themcgamer.data.Rank;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
public class MonthlyRewardPackage extends RewardPackage {
|
||||
@Override
|
||||
public String getIconTexture(Player player, Account account) {
|
||||
if (account.hasRank(Rank.ULTIMATE))
|
||||
return SkullTexture.BACKPACK_PURPLE;
|
||||
else if (account.hasRank(Rank.EXPERT))
|
||||
return SkullTexture.BACKPACK_LIGHT_BLUE;
|
||||
else if (account.hasRank(Rank.HERO))
|
||||
return SkullTexture.BACKPACK_YELLOW;
|
||||
else if (account.hasRank(Rank.SKILLED))
|
||||
return SkullTexture.BACKPACK_ORANGE;
|
||||
else if (account.hasRank(Rank.GAMER))
|
||||
return SkullTexture.BACKPACK_GREEN;
|
||||
else
|
||||
return SkullTexture.BACKPACK_GRAY;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package zone.themcgamer.core.deliveryMan.rewardPackage.impl;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import zone.themcgamer.core.account.Account;
|
||||
import zone.themcgamer.core.common.SkullTexture;
|
||||
import zone.themcgamer.core.deliveryMan.rewardPackage.RewardPackage;
|
||||
|
||||
/**
|
||||
* @author Nicholas
|
||||
*/
|
||||
public class WeeklyRewardPackage extends RewardPackage {
|
||||
@Override
|
||||
public String getIconTexture(Player player, Account account) {
|
||||
return SkullTexture.DIAMOND_CUBE;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import zone.themcgamer.core.chat.component.impl.BasicNameComponent;
|
||||
import zone.themcgamer.core.chat.component.impl.BasicRankComponent;
|
||||
import zone.themcgamer.core.common.MathUtils;
|
||||
import zone.themcgamer.core.common.scoreboard.ScoreboardHandler;
|
||||
import zone.themcgamer.core.deliveryMan.DeliveryManManager;
|
||||
import zone.themcgamer.core.game.kit.KitManager;
|
||||
import zone.themcgamer.core.kingdom.KingdomManager;
|
||||
import zone.themcgamer.core.plugin.MGZPlugin;
|
||||
@ -55,6 +56,8 @@ public class Hub extends MGZPlugin {
|
||||
});
|
||||
new KingdomManager(this, traveller);
|
||||
|
||||
AccountManager.addMiniAccount(new DeliveryManManager(this, mySQLController));
|
||||
|
||||
commandManager.registerCommand(new SpawnCommand(this));
|
||||
}
|
||||
}
|
@ -68,6 +68,12 @@ public class MySQLController {
|
||||
new StringColumn("task", 255, false)
|
||||
}, new String[] { "accountId" }),
|
||||
|
||||
new Table("deliveryMan", new Column[] {
|
||||
new IntegerColumn("accountId", false, false),
|
||||
new StringColumn("rewardId", 50, false),
|
||||
new LongColumn("lastClaimed", false)
|
||||
}, new String[] { "accountId", "rewardId" }),
|
||||
|
||||
new Table("kits", new Column[] {
|
||||
new IntegerColumn("accountId", false, false),
|
||||
new StringColumn("game", 50, false),
|
||||
|
Reference in New Issue
Block a user