Skip to content

Commit

Permalink
update some things for #48
Browse files Browse the repository at this point in the history
  • Loading branch information
NONPLAYT committed Jun 23, 2023
1 parent 1c6a5ee commit 5b15af4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 28 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ jobs:
version-type: alpha
name: NDailyRewards v${{ env.version_name }}
version: ${{ env.version_name }}
game-version-filter: releases | min-major | min-minor
changelog: ${{ github.event.head_commit.message }}
loaders: |
bukkit
spigot
paper
purpur
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group = gq.bxteam

mcVersion = 1.20-R0.1-SNAPSHOT
version = 2.0.1
mcVersion = 1.20.1-R0.1-SNAPSHOT
version = 2.1

org.gradle.parallel = true
org.gradle.vfs.watch = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public boolean canRegister() {
return true;
}

public String onRequest(OfflinePlayer player, String identifier) {
public String onRequest(OfflinePlayer player, @NotNull String identifier) {
if (identifier.equalsIgnoreCase("next_reward_time")) {
String unix = String.valueOf(new DUser(Objects.requireNonNull(player.getPlayer())).getTimeToGetReward());
String format = this.getString("date_format", "dd/MM/yyyy hh:mma");
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/gq/bxteam/ndailyrewards/manager/RewardGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.List;

import gq.bxteam.ndailyrewards.utils.ArchUtils;
import org.bukkit.ChatColor;
import gq.bxteam.ndailyrewards.utils.logs.LogUtil;
import gq.bxteam.ndailyrewards.utils.logs.LogType;
import gq.bxteam.ndailyrewards.cfg.Config;
Expand All @@ -34,6 +33,8 @@
import org.bukkit.inventory.ItemStack;
import gq.bxteam.ndailyrewards.gui.GUI;

import org.jetbrains.annotations.NotNull;

public class RewardGUI extends GUI {
private final int[] day_slots;
private final ItemStack day_ready;
Expand Down Expand Up @@ -93,8 +94,7 @@ private Inventory build(final Player p) {
if (user.hasActiveReward()) {
if (!user.pastLoginDurationThreshold()) {
icon = new ItemStack(this.day_warmup);
}
else {
} else {
icon = new ItemStack(this.day_ready);
}
} else {
Expand Down Expand Up @@ -133,14 +133,13 @@ private void replaceLore(final ItemStack icon, final int day2, final DUser user,
for (final String s2 : rewa.getLore()) {
lore.add(NDailyRewards.replaceHEXColorCode(s2.replace("%day%", String.valueOf(day2))));
}
}
else {
} else {
String pref = NDailyRewards.replaceHEXColorCode(s);
long timeWarmupFactored = (Config.opt_wm > 0 && !user.pastLoginDurationThreshold()) ? user.warmupDurationUntil() : time;
lore.add(pref.replace("%expire%", ArchUtils.getTimeLeft(user.getTimeToGetReward()))
.replace("%reward-warmup-remaining%", ArchUtils.getTimeLeft(user.warmupDurationUntil()))
.replace("%time%", ArchUtils.getTimeLeft(time))
.replace("%time-warmupfactored%", ArchUtils.getTimeLeft(timeWarmupFactored))
.replace("%time-warmup-factored%", ArchUtils.getTimeLeft(timeWarmupFactored))
.replace("%day%", String.valueOf(day2)));
}
}
Expand All @@ -150,9 +149,9 @@ private void replaceLore(final ItemStack icon, final int day2, final DUser user,
}

@EventHandler
public void onOpen(final InventoryOpenEvent e) {
public void onOpen(final @NotNull InventoryOpenEvent e) {
if (e.getInventory().getHolder() instanceof RewardGUI) {
this.opens.add((Player)e.getPlayer());
this.opens.add((Player) e.getPlayer());
}
}

Expand Down
16 changes: 5 additions & 11 deletions src/main/java/gq/bxteam/ndailyrewards/manager/objects/DUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,25 @@ public boolean pastLoginDurationThreshold() {
long currentTime = System.currentTimeMillis();

// Calculate the login time plus the duration threshold
long thresholdTime = login + (Config.opt_wm * 1000); // Convert seconds to milliseconds
long thresholdTime = login + (Config.opt_wm * 1000L); // Convert seconds to milliseconds

// Check if the current time is past the threshold time
boolean isPastThreshold = currentTime > thresholdTime;

return isPastThreshold;
return currentTime > thresholdTime;
}

public long remainingLoginDuration() {
// Get the current system time
long currentTime = System.currentTimeMillis();

// Calculate the login time plus the duration threshold
long thresholdTime = login + (Config.opt_wm * 1000); // Convert seconds to milliseconds
long thresholdTime = login + (Config.opt_wm * 1000L); // Convert seconds to milliseconds

// Check if the current time is past the threshold time
long difference = thresholdTime - currentTime;

return difference;
return thresholdTime - currentTime;
}

public long warmupDurationUntil() {
// Calculate the login time plus the duration threshold
long thresholdTime = login + (Config.opt_wm * 1000); // Convert seconds to milliseconds

return thresholdTime;
return login + (Config.opt_wm * 1000L);
}
}
6 changes: 2 additions & 4 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ options:
enabled: true
only-when-have: true
days-row: 7
# Time in seconds
rewards-cool-down: 86400
gui-refresh-delay: 5
unlock-after-midnight: false
# Time in seconds
reward-login-delay: 0
enable-metrics: true
rewards:
Expand Down Expand Up @@ -167,7 +165,7 @@ gui:
lore:
- '%reward-lore%'
- ''
- '&c» &7Wait until &e%reward-warmup-remaining% &7 to unlock!'
- '&c» &7Wait until &e%reward-warmup-remaining% &7to unlock!'
next:
material: 'GOLD_BLOCK:0:1'
name: '&e[Day #%day%] &7Awaiting...'
Expand All @@ -187,6 +185,6 @@ gui:
- '&aThe more days in a row you'
- '&ajoin the better the reward!'
- ''
- '&cYou must wait: &7%time-warmupfactored%'
- '&cYou must wait: &7%time-warmup-factored%'
- '&cbefore claiming your next bonus'
slots: 0,1,2,3,4,5,6,7,8,9,17,18,19,20,21,22,23,24,25,26

0 comments on commit 5b15af4

Please sign in to comment.