Skip to content

Commit 2859f6c

Browse files
committed
Initial commit
0 parents  commit 2859f6c

File tree

8 files changed

+1004
-0
lines changed

8 files changed

+1004
-0
lines changed

.classpath

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="output" path="target/classes"/>
36+
</classpath>

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>PAPI-Expansion-Essentials</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.extendedclip.papi.expansion.essentials</groupId>
4+
<artifactId>essentials-expansion</artifactId>
5+
<version>1.1.0</version>
6+
<name>PAPI-Expansion-Essentials</name>
7+
<description>PlaceholderAPI expansion for Essentials placeholders</description>
8+
9+
<repositories>
10+
<repository>
11+
<id>spigot-repo</id>
12+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
13+
</repository>
14+
<repository>
15+
<id>placeholderapi</id>
16+
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
17+
</repository>
18+
<repository>
19+
<id>clips-public-repo</id>
20+
<url>http://repo.extendedclip.com/content/repositories/public/</url>
21+
</repository>
22+
</repositories>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.spigotmc</groupId>
27+
<artifactId>spigot-api</artifactId>
28+
<version>1.12-R0.1-SNAPSHOT</version>
29+
<scope>compile</scope>
30+
</dependency>
31+
<dependency>
32+
<groupId>me.clip</groupId>
33+
<artifactId>placeholderapi</artifactId>
34+
<version>2.8.4</version>
35+
<scope>provided</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>com.earth2me</groupId>
39+
<artifactId>essentials</artifactId>
40+
<version>2.0.1</version>
41+
<scope>provided</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-jar-plugin</artifactId>
50+
<version>2.3.2</version>
51+
<configuration>
52+
<finalName>${name}</finalName>
53+
<archive>
54+
<manifest>
55+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
56+
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
57+
</manifest>
58+
</archive>
59+
</configuration>
60+
</plugin>
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-compiler-plugin</artifactId>
64+
<version>3.2</version>
65+
<configuration>
66+
<target>1.8</target>
67+
<source>1.8</source>
68+
<encoding>UTF-8</encoding>
69+
<useIncrementalCompilation>false</useIncrementalCompilation>
70+
</configuration>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
</project>
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
/*
2+
*
3+
* Essentials-Expansion
4+
* Copyright (C) 2018 Ryan McCarthy
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
*
20+
*/
21+
package com.extendedclip.papi.expansion.essentials;
22+
23+
import java.util.Date;
24+
25+
import me.clip.placeholderapi.PlaceholderAPIPlugin;
26+
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
27+
import me.clip.placeholderapi.util.TimeUtil;
28+
29+
import org.bukkit.Bukkit;
30+
import org.bukkit.entity.Player;
31+
32+
import com.earth2me.essentials.Essentials;
33+
import com.earth2me.essentials.Kit;
34+
import com.earth2me.essentials.User;
35+
36+
public class EssentialsExpansion extends PlaceholderExpansion {
37+
38+
private Essentials essentials;
39+
40+
private final String VERSION = getClass().getPackage().getImplementationVersion();
41+
42+
@Override
43+
public boolean canRegister() {
44+
return Bukkit.getPluginManager().getPlugin("Essentials") != null;
45+
}
46+
47+
@Override
48+
public boolean register() {
49+
essentials = (Essentials) Bukkit.getPluginManager().getPlugin(getPlugin());
50+
if (essentials != null) {
51+
return super.register();
52+
}
53+
return false;
54+
}
55+
56+
@Override
57+
public String getAuthor() {
58+
return "clip";
59+
}
60+
61+
@Override
62+
public String getIdentifier() {
63+
return "essentials";
64+
}
65+
66+
@Override
67+
public String getPlugin() {
68+
return "Essentials";
69+
}
70+
71+
@Override
72+
public String getVersion() {
73+
return VERSION;
74+
}
75+
76+
@Override
77+
public String onPlaceholderRequest(Player p, String identifier) {
78+
79+
80+
81+
if (p == null) {
82+
return "";
83+
}
84+
85+
if (identifier.startsWith("kit_last_use_")) {
86+
String kit = identifier.split("kit_last_use_")[1];
87+
88+
Kit k = null;
89+
90+
try {
91+
k = new Kit(kit, essentials);
92+
} catch (Exception e) {
93+
return "invalid kit";
94+
}
95+
96+
long time = essentials.getUser(p).getKitTimestamp(k.getName());
97+
98+
if (time == 1 || time <= 0) {
99+
return "1";
100+
}
101+
return PlaceholderAPIPlugin.getDateFormat().format(new Date(time));
102+
}
103+
104+
if (identifier.startsWith("kit_is_available_")) {
105+
String kit = identifier.split("kit_is_available_")[1];
106+
107+
Kit k = null;
108+
109+
User u = essentials.getUser(p);
110+
111+
try {
112+
k = new Kit(kit, essentials);
113+
} catch (Exception e) {
114+
return PlaceholderAPIPlugin.booleanFalse();
115+
}
116+
117+
long time = -1 ;
118+
119+
try {
120+
time = k.getNextUse(u);
121+
} catch (Exception e) {
122+
return PlaceholderAPIPlugin.booleanFalse();
123+
}
124+
125+
return time == 0 ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
126+
}
127+
128+
if (identifier.startsWith("kit_time_until_available_")) {
129+
String kit = identifier.split("kit_time_until_available_")[1];
130+
131+
Kit k = null;
132+
133+
User u = essentials.getUser(p);
134+
135+
try {
136+
k = new Kit(kit, essentials);
137+
} catch (Exception e) {
138+
return PlaceholderAPIPlugin.booleanFalse();
139+
}
140+
141+
long time = -1;
142+
143+
try {
144+
time = k.getNextUse(u);
145+
} catch (Exception e) {
146+
return "-1";
147+
}
148+
int seconds = (int)(time - System.currentTimeMillis())/1000;
149+
150+
if (seconds <= 0) {
151+
return "0";
152+
}
153+
return TimeUtil.getTime(seconds);
154+
}
155+
156+
if (identifier.startsWith("has_kit_")) {
157+
String kit = identifier.split("has_kit_")[1];
158+
return p.hasPermission("essentials.kits." + kit) ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
159+
}
160+
161+
switch (identifier) {
162+
case "is_teleport_enabled":
163+
return essentials.getUser(p).isTeleportEnabled() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
164+
case "vanished":
165+
return essentials.getUser(p).isVanished() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
166+
case "afk":
167+
return essentials.getUser(p).isAfk() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
168+
case "fly":
169+
return essentials.getUser(p).isFlyClickJump() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
170+
case "nickname":
171+
return essentials.getUser(p).getNickname() != null ? essentials.getUser(p).getNickname() : p.getName();
172+
case "godmode":
173+
return essentials.getUser(p).isGodModeEnabled() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
174+
case "jailed":
175+
return String.valueOf(essentials.getUser(p).isJailed());
176+
case "pm_recipient":
177+
User u = essentials.getUser(p);
178+
if (u.getReplyRecipient() != null) {
179+
return u.getReplyRecipient().getName();
180+
} else {
181+
return "";
182+
}
183+
}
184+
185+
return null;
186+
}
187+
188+
189+
190+
191+
}
5.65 KB
Binary file not shown.

target/classes/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/com/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#Generated by Maven
2+
#Wed Mar 07 11:43:05 EST 2018
3+
version=1.1.0
4+
groupId=com.extendedclip.papi.expansion.essentials
5+
artifactId=essentials-expansion

0 commit comments

Comments
 (0)