-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add placeholderapi, player head textures and some changes to ItemBuil…
…der + config
- Loading branch information
Showing
13 changed files
with
483 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/space/bxteam/ndailyrewards/hooks/HookManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package space.bxteam.ndailyrewards.hooks; | ||
|
||
import space.bxteam.ndailyrewards.NDailyRewards; | ||
import space.bxteam.ndailyrewards.hooks.list.PlaceholderAPIHook; | ||
import space.bxteam.ndailyrewards.utils.LogUtil; | ||
|
||
public class HookManager { | ||
private final NDailyRewards plugin; | ||
|
||
public HookManager(NDailyRewards plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public void registerHooks() { | ||
if (plugin.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) { | ||
new PlaceholderAPIHook().register(); | ||
LogUtil.log("PlaceholderAPI hook registered", LogUtil.LogLevel.INFO); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/space/bxteam/ndailyrewards/hooks/list/PlaceholderAPIHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package space.bxteam.ndailyrewards.hooks.list; | ||
|
||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import org.bukkit.OfflinePlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
import space.bxteam.ndailyrewards.NDailyRewards; | ||
import space.bxteam.ndailyrewards.managers.reward.RewardManager; | ||
|
||
public class PlaceholderAPIHook extends PlaceholderExpansion { | ||
@Override | ||
public @NotNull String getIdentifier() { | ||
return "dailyrewards"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getAuthor() { | ||
return NDailyRewards.getInstance().getPluginMeta().getAuthors().toString(); | ||
} | ||
|
||
@Override | ||
public @NotNull String getVersion() { | ||
return NDailyRewards.getInstance().getPluginMeta().getVersion(); | ||
} | ||
|
||
@Override | ||
public boolean persist() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean canRegister() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String onRequest(OfflinePlayer player, @NotNull String params) { | ||
if (params.equalsIgnoreCase("reward_day")) { | ||
RewardManager rewardManager = NDailyRewards.getInstance().getRewardManager(); | ||
RewardManager.PlayerRewardData playerRewardData = rewardManager.getPlayerRewardData(player.getUniqueId()); | ||
|
||
return String.valueOf(playerRewardData.getCurrentDay() + 1); | ||
} | ||
|
||
if (params.equalsIgnoreCase("remaining_time")) { | ||
RewardManager rewardManager = NDailyRewards.getInstance().getRewardManager(); | ||
RewardManager.PlayerRewardData playerRewardData = rewardManager.getPlayerRewardData(player.getUniqueId()); | ||
|
||
long timeLeft = playerRewardData.getNext() - System.currentTimeMillis() / 1000L; | ||
if (timeLeft < 0) { | ||
return "00:00:00"; | ||
} else { | ||
return formatTime(timeLeft); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private String formatTime(long seconds) { | ||
long hours = seconds / 3600; | ||
long minutes = (seconds % 3600) / 60; | ||
long secs = seconds % 60; | ||
return String.format("%02d:%02d:%02d", hours, minutes, secs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.