-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
546 additions
and
44 deletions.
There are no files selected for viewing
Binary file not shown.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
41 changes: 27 additions & 14 deletions
41
src/com/loohp/interactivechatdiscordsrvaddon/Metrics/Metrics.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
42 changes: 42 additions & 0 deletions
42
src/com/loohp/interactivechatdiscordsrvaddon/Utils/Cache.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,42 @@ | ||
package com.loohp.interactivechatdiscordsrvaddon.Utils; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import org.bukkit.Bukkit; | ||
|
||
import com.loohp.interactivechatdiscordsrvaddon.InteractiveChatDiscordSrvAddon; | ||
|
||
public class Cache<T> { | ||
|
||
private static Map<String, Cache<?>> data = new ConcurrentHashMap<>(); | ||
|
||
private long timeCreated; | ||
private T object; | ||
|
||
private Cache(T object) { | ||
this.timeCreated = System.currentTimeMillis(); | ||
this.object = object; | ||
} | ||
|
||
public long getTimeCreated() { | ||
return timeCreated; | ||
} | ||
|
||
public T getObject() { | ||
return object; | ||
} | ||
|
||
public static Cache<?> getCache(String key) { | ||
return data.get(key); | ||
} | ||
|
||
public static <T> void putCache(String key, T object, long ticks) { | ||
Cache<T> cache = new Cache<>(object); | ||
data.put(key, cache); | ||
Bukkit.getScheduler().runTaskLater(InteractiveChatDiscordSrvAddon.plugin, () -> { | ||
data.remove(key, cache); | ||
}, ticks); | ||
} | ||
|
||
} |
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.