Compare commits

..
4 Commits
Author SHA1 Message Date
Ben12345rocks d8ce4a9578 Minor config addition 2018-08-11 11:03:45 -04:00
Ben12345rocks 574e8d4a54 Update version number to 5.14.1 2018-08-11 10:59:09 -04:00
Ben12345rocks 19a7a6a733 Change /vote last to show time since vote 2018-08-11 10:43:43 -04:00
Ben12345rocks 1e131e57c3 Minor config change 2018-08-05 12:28:35 -04:00
6 changed files with 134 additions and 15 deletions

No files matched your search

+15 -1
View File
@@ -169,7 +169,11 @@ Format:
Title: '&3&l%player% Last Vote Times:'
# Lines for each vote site
# %time% = time, using timeformat below
Line: '&3%SiteName%: &6%time%'
# %timesince% = time since vote
Line: '&3%SiteName%: &6%timeSince% ago'
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
TimeFormat: '%amount% %TimeType%'
NeverVoted: 'Never voted'
# Format for /vote total
Total:
@@ -246,6 +250,16 @@ Format:
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
TimeFormat: 'EEE, d MMM yyyy HH:mm'
TimeFomrats:
Day: 'Day'
Days: 'Days'
Hour: 'Hour'
Hours: 'Hours'
Minute: 'Minute'
Minutes: 'Minutes'
Second: 'Second'
Seconds: 'Seconds'
# Format for signs
# SiteName may be all, depending on sign
# %position% = position of player, set by sign
+1 -1
View File
@@ -32,7 +32,7 @@ VoteSites:
VoteDelayDaily: false
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
# Setting this to true will execute the reward offline, NOT WHEN THE PLAYER IS OFFLINE
# Setting this to true will execute the reward offline while the player is offline
# This basiclly disables offline voting if set to true, don't misinterpret this option
ForceOffline: false
+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.Ben12345rocks</groupId>
<artifactId>VotingPlugin</artifactId>
<version>5.14</version>
<version>5.14.1</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -590,6 +590,7 @@ public class Commands {
* the vote site
* @return the string
*/
@Deprecated
public String voteCommandLastDate(User user, VoteSite voteSite) {
long time = user.getTime(voteSite);
if (time > 0) {
@@ -602,9 +603,89 @@ public class Commands {
public String voteCommandLastLine(User user, VoteSite voteSite) {
String timeString = voteCommandLastDate(user, voteSite);
String timeSince = voteCommandLastDuration(user, voteSite);
return config.getFormatCommandsVoteLastLine().replace("%Month% %Day%, %Year% %Hour%:%Minute% %ampm%", "%time%")
.replace("%time%", timeString).replace("%SiteName%", voteSite.getDisplayName());
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("time", timeString);
placeholders.put("SiteName", voteSite.getDisplayName());
placeholders.put("timesince", timeSince);
return StringUtils.getInstance().replacePlaceHolder(Config.getInstance().formatCommandsVoteLastLine,
placeholders);
}
public String voteCommandLastDuration(User user, VoteSite voteSite) {
long time = user.getTime(voteSite);
if (time > 0) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
Duration dur = Duration.between(lastVote, now);
long diffSecond = dur.getSeconds();
int diffDays = (int) (diffSecond / 60 / 60 / 24);
int diffHours = (int) (diffSecond / 60 / 60 - diffDays * 24);
int diffMinutes = (int) (diffSecond / 60 - diffHours * 60 - diffDays * 24 * 60);
int diffSeconds = (int) (diffSecond - diffMinutes * 60 - diffHours * 60 * 60 - diffDays * 24 * 60 * 60);
String info = "";
if (diffDays == 1) {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsDay), "amount", "" + diffDays);
info += " ";
} else if (diffDays > 1) {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsDays), "amount", "" + diffDays);
info += " ";
}
if (diffHours == 1) {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsHour), "amount", "" + diffHours);
info += " ";
} else if (diffHours > 1) {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsHours), "amount", "" + diffHours);
info += " ";
}
if (diffMinutes == 1) {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsMinute), "amount", "" + diffMinutes);
info += " ";
} else if (diffMinutes > 1) {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsMinutes), "amount", "" + diffMinutes);
info += " ";
}
if (diffSeconds == 1) {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsSecond), "amount", "" + diffSeconds);
} else {
info += StringUtils.getInstance()
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
Config.getInstance().formatTimeFormatsSeconds), "amount", "" + diffSeconds);
}
return info;
}
return Config.getInstance().formatCommandsVoteLastNeverVoted;
}
/**
@@ -54,6 +54,39 @@ public class Config extends YMLFile {
@ConfigDataBoolean(path = "Commands.VoteRewardFromVoteURL", defaultValue = false)
public boolean commandsVoteRewardFromVoteURL;
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
public String formatCommandsVoteLastTimeFormat;
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
public String formatCommandsVoteLastLine;
@ConfigDataString(path = "Format.Commands.Vote.Last.NeverVoted", defaultValue = "Never voted")
public String formatCommandsVoteLastNeverVoted;
@ConfigDataString(path = "Format.TimeFormats.Days", defaultValue = "Days")
public String formatTimeFormatsDays;
@ConfigDataString(path = "Format.TimeFormats.Day", defaultValue = "Day")
public String formatTimeFormatsDay;
@ConfigDataString(path = "Format.TimeFormats.Hours", defaultValue = "Hours")
public String formatTimeFormatsHours;
@ConfigDataString(path = "Format.TimeFormats.Hour", defaultValue = "Hour")
public String formatTimeFormatsHour;
@ConfigDataString(path = "Format.TimeFormats.Minutes", defaultValue = "Minutes")
public String formatTimeFormatsMinutes;
@ConfigDataString(path = "Format.TimeFormats.Minute", defaultValue = "Minute")
public String formatTimeFormatsMinute;
@ConfigDataString(path = "Format.TimeFormats.Seconds", defaultValue = "Seconds")
public String formatTimeFormatsSeconds;
@ConfigDataString(path = "Format.TimeFormats.Second", defaultValue = "Second")
public String formatTimeFormatsSecond;
/**
* Allow un joined.
*
@@ -376,15 +409,6 @@ public class Config extends YMLFile {
}
/**
* Gets the commands vote last line.
*
* @return the commands vote last line
*/
public String getFormatCommandsVoteLastLine() {
return getData().getString("Format.Commands.Vote.Last.Line", "&3%SiteName%: &6%time%");
}
/**
* Gets the commands vote last title.
*
@@ -241,7 +241,7 @@ public class PlaceHolders {
}
VoteSite voteSite = plugin.getVoteSite(siteName);
return Commands.getInstance().voteCommandLastDate(user, voteSite);
return Commands.getInstance().voteCommandLastDuration(user, voteSite);
}
public String playerNextVote(User user, String siteName) {