Skip to content

Commit

Permalink
Use TaskManager as opposed to Timer's.
Browse files Browse the repository at this point in the history
New .gitignore
  • Loading branch information
jamierocks committed Dec 29, 2014
1 parent e7e4f2b commit 72c52c8
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 28 deletions.
146 changes: 136 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,136 @@
# Ignore Everything
/*
/*/

# Except These
!/src/
!/.gitignore
!/LICENSE
!/README.md
!/pom.xml
#Eclipse

*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.classpath
.project

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

# sbteclipse plugin
.target

# TeXlipse plugin
.texlipse

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

# NetBeans
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

# Maven Extras
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# Mac
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Linux
*~

# KDE directory preferences
.directory

# TortoiseGit Project-level settings
/.tgitconfig

# vim
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;

import net.canarymod.Canary;
import net.canarymod.api.OfflinePlayer;
Expand All @@ -24,6 +23,7 @@
import net.canarymod.database.exceptions.DatabaseWriteException;
import net.canarymod.plugin.Plugin;

import net.visualillusionsent.utils.TaskManager;
import org.mcstats.Metrics;

import unomodding.canary.playtimelimiter.data.PlayTimeBlacklistAccess;
Expand All @@ -41,8 +41,6 @@ public final class PlayTimeLimiter extends Plugin {
private Map<String, Boolean> seenWarningMessages = new HashMap<String, Boolean>();
private Map<String, Boolean> blacklist = new HashMap<String, Boolean>();

private Timer savePlayTimeTimer = null;
private Timer checkPlayTimeTimer = null;
private boolean started = false;
private final Gson GSON = new Gson();

Expand Down Expand Up @@ -105,16 +103,10 @@ public boolean enable() {
e.printStackTrace();
}

if (savePlayTimeTimer == null) {
this.savePlayTimeTimer = new Timer();
this.savePlayTimeTimer.scheduleAtFixedRate(new PlayTimeSaverTask(this), 30000,
getConfig().getInt("secondsBetweenPlayTimeSaving") * 1000);
}
if (checkPlayTimeTimer == null) {
this.checkPlayTimeTimer = new Timer();
this.checkPlayTimeTimer.scheduleAtFixedRate(new PlayTimeCheckerTask(this), 30000,
getConfig().getInt("secondsBetweenPlayTimeChecks") * 1000);
}
TaskManager.scheduleContinuedTaskInSeconds(new PlayTimeSaverTask(this), 30000,
getConfig().getInt("secondsBetweenPlayTimeSaving"));
TaskManager.scheduleContinuedTaskInSeconds(new PlayTimeCheckerTask(this), 30000,
getConfig().getInt("secondsBetweenPlayTimeChecks"));

// Load any players that may be on at plugin enable
for (Player player : Canary.getServer().getPlayerList()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
import unomodding.canary.playtimelimiter.utils.FileUtils;
import unomodding.canary.playtimelimiter.utils.Timestamper;

public class PlayTimeCheckerTask extends TimerTask {
public class PlayTimeCheckerTask implements Runnable {
private final PlayTimeLimiter plugin;

public PlayTimeCheckerTask(PlayTimeLimiter instance) {
this.plugin = instance;
}

@Override
public void run() {
for (Player player : Canary.getServer().getPlayerList()) {
if (plugin.hasPlayTime(player)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 by ATLauncher and Contributors
* Copyright 2013-2014 by UnoModding, ATLauncher and Contributors
*
* This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/.
Expand All @@ -10,14 +10,13 @@

import unomodding.canary.playtimelimiter.PlayTimeLimiter;

public class PlayTimeSaverTask extends TimerTask {
public class PlayTimeSaverTask implements Runnable {
private final PlayTimeLimiter plugin;

public PlayTimeSaverTask(PlayTimeLimiter instance) {
this.plugin = instance;
}

@Override
public void run() {
this.plugin.savePlayTime(); // Save playtime every 10 minutes
}
Expand Down

0 comments on commit 72c52c8

Please sign in to comment.