Skip to content

Commit f4f70b4

Browse files
committed
init
0 parents  commit f4f70b4

File tree

6 files changed

+382
-0
lines changed

6 files changed

+382
-0
lines changed

.gitignore

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
### Plugin template
2+
# User-specific stuff
3+
.idea/
4+
5+
*.iml
6+
*.ipr
7+
*.iws
8+
9+
# IntelliJ
10+
out/
11+
12+
# Compiled class file
13+
*.class
14+
15+
# Log file
16+
*.log
17+
18+
# BlueJ files
19+
*.ctxt
20+
21+
# Package Files #
22+
*.jar
23+
*.war
24+
*.nar
25+
*.ear
26+
*.zip
27+
*.tar.gz
28+
*.rar
29+
30+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
31+
hs_err_pid*
32+
33+
*~
34+
35+
# temporary files which can be created if a process still has a handle open of a deleted file
36+
.fuse_hidden*
37+
38+
# KDE directory preferences
39+
.directory
40+
41+
# Linux trash folder which might appear on any partition or disk
42+
.Trash-*
43+
44+
# .nfs files are created when an open file is removed but is still being accessed
45+
.nfs*
46+
47+
# General
48+
.DS_Store
49+
.AppleDouble
50+
.LSOverride
51+
52+
# Icon must end with two \r
53+
Icon
54+
55+
# Thumbnails
56+
._*
57+
58+
# Files that might appear in the root of a volume
59+
.DocumentRevisions-V100
60+
.fseventsd
61+
.Spotlight-V100
62+
.TemporaryItems
63+
.Trashes
64+
.VolumeIcon.icns
65+
.com.apple.timemachine.donotpresent
66+
67+
# Directories potentially created on remote AFP share
68+
.AppleDB
69+
.AppleDesktop
70+
Network Trash Folder
71+
Temporary Items
72+
.apdisk
73+
74+
# Windows thumbnail cache files
75+
Thumbs.db
76+
Thumbs.db:encryptable
77+
ehthumbs.db
78+
ehthumbs_vista.db
79+
80+
# Dump file
81+
*.stackdump
82+
83+
# Folder config file
84+
[Dd]esktop.ini
85+
86+
# Recycle Bin used on file shares
87+
$RECYCLE.BIN/
88+
89+
# Windows Installer files
90+
*.cab
91+
*.msi
92+
*.msix
93+
*.msm
94+
*.msp
95+
96+
# Windows shortcuts
97+
*.lnk
98+
99+
target/
100+
101+
pom.xml.tag
102+
pom.xml.releaseBackup
103+
pom.xml.versionsBackup
104+
pom.xml.next
105+
106+
release.properties
107+
dependency-reduced-pom.xml
108+
buildNumber.properties
109+
.mvn/timing.properties
110+
.mvn/wrapper/maven-wrapper.jar
111+
.flattened-pom.xml
112+
113+
# Common working directory
114+
run/

pom.xml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>me.hsgamer</groupId>
8+
<artifactId>TimedTopperAPI</artifactId>
9+
<version>1.0.0</version>
10+
11+
<name>TimedTopperAPI</name>
12+
13+
<properties>
14+
<java.version>1.8</java.version>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
</properties>
17+
18+
<repositories>
19+
<repository>
20+
<id>spigotmc-repo</id>
21+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
22+
</repository>
23+
</repositories>
24+
25+
<build>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-compiler-plugin</artifactId>
30+
<version>3.13.0</version>
31+
<configuration>
32+
<source>${java.version}</source>
33+
<target>${java.version}</target>
34+
</configuration>
35+
</plugin>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-source-plugin</artifactId>
39+
<version>3.3.1</version>
40+
<executions>
41+
<execution>
42+
<id>attach-sources</id>
43+
<goals>
44+
<goal>jar-no-fork</goal>
45+
</goals>
46+
</execution>
47+
</executions>
48+
</plugin>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-javadoc-plugin</artifactId>
52+
<version>3.12.0</version>
53+
<executions>
54+
<execution>
55+
<id>attach-javadocs</id>
56+
<goals>
57+
<goal>jar</goal>
58+
</goals>
59+
</execution>
60+
</executions>
61+
<configuration>
62+
<source>${java.version}</source>
63+
<outputDirectory>${project.build.directory}/reports</outputDirectory>
64+
</configuration>
65+
</plugin>
66+
</plugins>
67+
<resources>
68+
<resource>
69+
<directory>src/main/resources</directory>
70+
<filtering>true</filtering>
71+
</resource>
72+
</resources>
73+
</build>
74+
75+
<dependencies>
76+
<dependency>
77+
<groupId>org.spigotmc</groupId>
78+
<artifactId>spigot-api</artifactId>
79+
<version>1.13.2-R0.1-SNAPSHOT</version>
80+
<scope>provided</scope>
81+
</dependency>
82+
</dependencies>
83+
</project>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package me.hsgamer.timedtopper.api;
2+
3+
import me.hsgamer.timedtopper.api.data.TimeRange;
4+
import me.hsgamer.timedtopper.api.data.TimedData;
5+
6+
import java.util.Collection;
7+
import java.util.Map;
8+
import java.util.Optional;
9+
import java.util.UUID;
10+
import java.util.concurrent.atomic.AtomicReference;
11+
12+
/**
13+
* The API of TimedTopper
14+
*/
15+
public interface TimedTopperAPI {
16+
/**
17+
* The reference of the instance of the API
18+
*/
19+
AtomicReference<TimedTopperAPI> INSTANCE = new AtomicReference<>();
20+
21+
/**
22+
* Get the instance of the API
23+
*
24+
* @return the instance of the API
25+
*/
26+
static TimedTopperAPI getInstance() {
27+
TimedTopperAPI api = INSTANCE.get();
28+
if (api == null) {
29+
throw new IllegalStateException("TimedTopper API is not initialized!");
30+
}
31+
return api;
32+
}
33+
34+
/**
35+
* Get the name of the available holders
36+
*
37+
* @return the holder names
38+
*/
39+
Collection<String> getHolders();
40+
41+
/**
42+
* Check if the holder exists
43+
*
44+
* @param holder the holder
45+
* @return true if it does
46+
*/
47+
boolean hasHolder(String holder);
48+
49+
/**
50+
* Get the data of the holder
51+
*
52+
* @param holder the holder
53+
* @return the data
54+
*/
55+
Map<UUID, TimedData> getData(String holder);
56+
57+
/**
58+
* Get the data of a unique id in the holder
59+
*
60+
* @param holder the holder
61+
* @param uuid the unique id
62+
* @return the data, or empty if the id doesn't exist
63+
* @throws NullPointerException if the holder doesn't exist
64+
*/
65+
Optional<TimedData> getData(String holder, UUID uuid);
66+
67+
/**
68+
* Get the time range of the holder
69+
*
70+
* @param holder the holder
71+
* @return the time range
72+
* @throws NullPointerException if the holder doesn't exist
73+
*/
74+
TimeRange getTimeRange(String holder);
75+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package me.hsgamer.timedtopper.api.data;
2+
3+
/**
4+
* The time range of the holder
5+
*/
6+
public interface TimeRange {
7+
/**
8+
* Get the Unix timestamp in milliseconds of the start time
9+
*
10+
* @return the start time
11+
*/
12+
long startTime();
13+
14+
/**
15+
* Get the Unix timestamp in milliseconds of the end time
16+
*
17+
* @return the end time
18+
*/
19+
long endTime();
20+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package me.hsgamer.timedtopper.api.data;
2+
3+
/**
4+
* The data of an entry
5+
*/
6+
public interface TimedData {
7+
/**
8+
* Get the initial value
9+
*
10+
* @return the initial value
11+
*/
12+
double initial();
13+
14+
/**
15+
* Get the current value
16+
*
17+
* @return the current value
18+
*/
19+
double current();
20+
21+
/**
22+
* Get the Unix timestamp in milliseconds of the last update
23+
*
24+
* @return the timestamp
25+
*/
26+
long timestamp();
27+
28+
/**
29+
* Get the difference between the initial value and the current value
30+
*
31+
* @return the difference
32+
*/
33+
double diff();
34+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package me.hsgamer.timedtopper.api.event;
2+
3+
import me.hsgamer.timedtopper.api.data.TimedData;
4+
import org.bukkit.event.Event;
5+
import org.bukkit.event.HandlerList;
6+
7+
import java.util.List;
8+
import java.util.Map;
9+
import java.util.UUID;
10+
11+
/**
12+
* The event when a holder resets its entries
13+
*/
14+
public class HolderResetEvent extends Event {
15+
private static final HandlerList HANDLERS = new HandlerList();
16+
private final String holder;
17+
private final List<Map.Entry<UUID, TimedData>> top;
18+
19+
public HolderResetEvent(String holder, List<Map.Entry<UUID, TimedData>> top) {
20+
this.holder = holder;
21+
this.top = top;
22+
}
23+
24+
public HolderResetEvent(boolean isAsync, String holder, List<Map.Entry<UUID, TimedData>> top) {
25+
super(isAsync);
26+
this.holder = holder;
27+
this.top = top;
28+
}
29+
30+
public static HandlerList getHandlerList() {
31+
return HANDLERS;
32+
}
33+
34+
/**
35+
* Get the name of the holder
36+
*
37+
* @return the name of the holder
38+
*/
39+
public String getHolder() {
40+
return holder;
41+
}
42+
43+
/**
44+
* Get the list of the entries, ordered by the difference of the data
45+
*
46+
* @return the entries
47+
*/
48+
public List<Map.Entry<UUID, TimedData>> getTop() {
49+
return top;
50+
}
51+
52+
@Override
53+
public HandlerList getHandlers() {
54+
return HANDLERS;
55+
}
56+
}

0 commit comments

Comments
 (0)