-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiplier and UpdateRealTimePlayedTask #727
Open
HectorJuarezL
wants to merge
11
commits into
Staartvin:master
Choose a base branch
from
HectorJuarezL:time-fix-for-lag
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
52459a2
Update UpdateTimePlayedTask.java
HectorJuarezL 60d414f
Changes
HectorJuarezL b9e80d7
Added multiplier
HectorJuarezL ae449a0
Update Settings.yml
HectorJuarezL c5f8385
Update UpdateRealTimePlayedTask.java
HectorJuarezL df7b8e6
realtime added
HectorJuarezL e4a17fd
Added multiplier command
HectorJuarezL 55e4731
Update MultiplierCommand.java
HectorJuarezL d241c38
Added multiplier command
HectorJuarezL 41b19fd
Multiplier command added
HectorJuarezL e776b99
Change UpdateTimePlayedTaskd and added multiplier command in settings…
HectorJuarezL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
69 changes: 69 additions & 0 deletions
69
src/me/armar/plugins/autorank/commands/MultiplierCommand.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,69 @@ | ||
package me.armar.plugins.autorank.commands; | ||
|
||
import me.armar.plugins.autorank.Autorank; | ||
import me.armar.plugins.autorank.commands.manager.AutorankCommand; | ||
import me.armar.plugins.autorank.language.Lang; | ||
import me.armar.plugins.autorank.permissions.AutorankPermission; | ||
import me.armar.plugins.autorank.util.AutorankTools; | ||
import me.armar.plugins.autorank.playtimes.PlayTimeManager; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
|
||
/** | ||
* The command delegator for the '/ar set' command. | ||
*/ | ||
public class MultiplierCommand extends AutorankCommand { | ||
|
||
private final Autorank plugin; | ||
|
||
public MultiplierCommand(final Autorank instance) { | ||
plugin = instance; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { | ||
|
||
|
||
if (args.length < 2) { | ||
sender.sendMessage(Lang.INVALID_FORMAT.getConfigValue(this.getUsage())); | ||
return true; | ||
} | ||
|
||
int value = AutorankTools.readTimeInput(args, 1); | ||
|
||
if (value >= 1) { | ||
|
||
if (!this.hasPermission(AutorankPermission.SET_LOCAL_TIME, sender)) { | ||
return true; | ||
} | ||
|
||
if(plugin.getSettingsConfig().multiplierCommandIsEnabled()){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checks if the command is enable |
||
PlayTimeManager.MULTIPLIER=value; | ||
sender.sendMessage(ChatColor.AQUA + "MULTIPLIER = " + PlayTimeManager.MULTIPLIER); | ||
}else{ | ||
sender.sendMessage(ChatColor.AQUA + "Multipler command is disabled in settings config."); | ||
} | ||
|
||
} else { | ||
AutorankTools.sendColoredMessage(sender, Lang.INVALID_FORMAT.getConfigValue(this.getUsage())); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Set multiplier's time to [value]."; | ||
} | ||
|
||
@Override | ||
public String getPermission() { | ||
return AutorankPermission.SET_LOCAL_TIME; | ||
} | ||
|
||
@Override | ||
public String getUsage() { | ||
return "/ar multiplier [value]"; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ public UpdateTimePlayedTask(Autorank instance, UUID uuid) { | |
public void run() { | ||
|
||
Player player = plugin.getServer().getPlayer(uuid); | ||
long lastPlayTimeUpdate=plugin.getTaskManager().getLastPlayTimeUpdate(uuid); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before the value is overwritten, it is saved in this variable |
||
int timeToAdd; | ||
|
||
// Cancel task as player is not online anymore. | ||
if (player == null || !player.isOnline()) { | ||
|
@@ -55,9 +57,18 @@ public void run() { | |
return; | ||
} | ||
|
||
|
||
if(plugin.getSettingsConfig().useMoreAccurateTimings()){ | ||
//This compute the time elapsed between the last update and the current update. | ||
timeToAdd=(int)Math.round((System.currentTimeMillis()-lastPlayTimeUpdate)/60000f*PlayTimeManager.MULTIPLIER); | ||
}else{ | ||
//Multiply by 1 doesn't affect the performance | ||
timeToAdd=PlayTimeManager.INTERVAL_MINUTES*PlayTimeManager.MULTIPLIER; | ||
} | ||
|
||
// Add time to a player's current time for all storage providers. | ||
for (final TimeType type : TimeType.values()) { | ||
plugin.getPlayTimeStorageManager().addPlayerTime(type, uuid, PlayTimeManager.INTERVAL_MINUTES); | ||
plugin.getPlayTimeStorageManager().addPlayerTime(type, uuid, timeToAdd); | ||
} | ||
|
||
// Auto assign path (if possible) | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiplier value can't be less than 1