Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
extendedclip committed Mar 7, 2018
0 parents commit 2859f6c
Show file tree
Hide file tree
Showing 8 changed files with 1,004 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PAPI-Expansion-Essentials</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.extendedclip.papi.expansion.essentials</groupId>
<artifactId>essentials-expansion</artifactId>
<version>1.1.0</version>
<name>PAPI-Expansion-Essentials</name>
<description>PlaceholderAPI expansion for Essentials placeholders</description>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>clips-public-repo</id>
<url>http://repo.extendedclip.com/content/repositories/public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.8.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.earth2me</groupId>
<artifactId>essentials</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<finalName>${name}</finalName>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
<encoding>UTF-8</encoding>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
/*
*
* Essentials-Expansion
* Copyright (C) 2018 Ryan McCarthy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package com.extendedclip.papi.expansion.essentials;

import java.util.Date;

import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.TimeUtil;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.Kit;
import com.earth2me.essentials.User;

public class EssentialsExpansion extends PlaceholderExpansion {

private Essentials essentials;

private final String VERSION = getClass().getPackage().getImplementationVersion();

@Override
public boolean canRegister() {
return Bukkit.getPluginManager().getPlugin("Essentials") != null;
}

@Override
public boolean register() {
essentials = (Essentials) Bukkit.getPluginManager().getPlugin(getPlugin());
if (essentials != null) {
return super.register();
}
return false;
}

@Override
public String getAuthor() {
return "clip";
}

@Override
public String getIdentifier() {
return "essentials";
}

@Override
public String getPlugin() {
return "Essentials";
}

@Override
public String getVersion() {
return VERSION;
}

@Override
public String onPlaceholderRequest(Player p, String identifier) {



if (p == null) {
return "";
}

if (identifier.startsWith("kit_last_use_")) {
String kit = identifier.split("kit_last_use_")[1];

Kit k = null;

try {
k = new Kit(kit, essentials);
} catch (Exception e) {
return "invalid kit";
}

long time = essentials.getUser(p).getKitTimestamp(k.getName());

if (time == 1 || time <= 0) {
return "1";
}
return PlaceholderAPIPlugin.getDateFormat().format(new Date(time));
}

if (identifier.startsWith("kit_is_available_")) {
String kit = identifier.split("kit_is_available_")[1];

Kit k = null;

User u = essentials.getUser(p);

try {
k = new Kit(kit, essentials);
} catch (Exception e) {
return PlaceholderAPIPlugin.booleanFalse();
}

long time = -1 ;

try {
time = k.getNextUse(u);
} catch (Exception e) {
return PlaceholderAPIPlugin.booleanFalse();
}

return time == 0 ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
}

if (identifier.startsWith("kit_time_until_available_")) {
String kit = identifier.split("kit_time_until_available_")[1];

Kit k = null;

User u = essentials.getUser(p);

try {
k = new Kit(kit, essentials);
} catch (Exception e) {
return PlaceholderAPIPlugin.booleanFalse();
}

long time = -1;

try {
time = k.getNextUse(u);
} catch (Exception e) {
return "-1";
}
int seconds = (int)(time - System.currentTimeMillis())/1000;

if (seconds <= 0) {
return "0";
}
return TimeUtil.getTime(seconds);
}

if (identifier.startsWith("has_kit_")) {
String kit = identifier.split("has_kit_")[1];
return p.hasPermission("essentials.kits." + kit) ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
}

switch (identifier) {
case "is_teleport_enabled":
return essentials.getUser(p).isTeleportEnabled() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
case "vanished":
return essentials.getUser(p).isVanished() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
case "afk":
return essentials.getUser(p).isAfk() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
case "fly":
return essentials.getUser(p).isFlyClickJump() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
case "nickname":
return essentials.getUser(p).getNickname() != null ? essentials.getUser(p).getNickname() : p.getName();
case "godmode":
return essentials.getUser(p).isGodModeEnabled() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
case "jailed":
return String.valueOf(essentials.getUser(p).isJailed());
case "pm_recipient":
User u = essentials.getUser(p);
if (u.getReplyRecipient() != null) {
return u.getReplyRecipient().getName();
} else {
return "";
}
}

return null;
}




}
Binary file added target/PAPI-Expansion-Essentials.jar
Binary file not shown.
1 change: 1 addition & 0 deletions target/classes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/com/
5 changes: 5 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Generated by Maven
#Wed Mar 07 11:43:05 EST 2018
version=1.1.0
groupId=com.extendedclip.papi.expansion.essentials
artifactId=essentials-expansion

0 comments on commit 2859f6c

Please sign in to comment.