forked from OvercastNetwork/Tracker
-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
a167443
commit eac731e
Showing
83 changed files
with
3,066 additions
and
2,708 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,109 +1,111 @@ | ||
<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>tc.oc</groupId> | ||
<artifactId>tracker</artifactId> | ||
<version>1.8-SNAPSHOT</version> | ||
<name>Tracker</name> | ||
<description>Bukkit plugin and API for tracking entity damage and deaths.</description> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
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>tc.oc</groupId> | ||
<artifactId>tracker</artifactId> | ||
<version>1.8-SNAPSHOT</version> | ||
<name>Tracker</name> | ||
<description>Bukkit plugin and API for tracking entity damage and deaths.</description> | ||
|
||
<scm> | ||
<connection>scm:git:[email protected]:Avicus/Tracker.git</connection> | ||
<developerConnection>scm:git:[email protected]:Avicus/Tracker.git</developerConnection> | ||
<url>https://github.com/Avicus/Tracker</url> | ||
</scm> | ||
<scm> | ||
<connection>scm:git:[email protected]:Avicus/Tracker.git</connection> | ||
<developerConnection>scm:git:[email protected]:Avicus/Tracker.git</developerConnection> | ||
<url>https://github.com/Avicus/Tracker</url> | ||
</scm> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>avicus-repo</id> | ||
<url>https://repo.avicus.net/content/repositories/releases/</url> | ||
</repository> | ||
<snapshotRepository> | ||
<id>avicus-repo</id> | ||
<url>https://repo.avicus.net/content/repositories/snapshots/</url> | ||
</snapshotRepository> | ||
</distributionManagement> | ||
<distributionManagement> | ||
<repository> | ||
<id>avicus-repo</id> | ||
<url>https://repo.avicus.net/content/repositories/releases/</url> | ||
</repository> | ||
<snapshotRepository> | ||
<id>avicus-repo</id> | ||
<url>https://repo.avicus.net/content/repositories/snapshots/</url> | ||
</snapshotRepository> | ||
</distributionManagement> | ||
|
||
<repositories> | ||
<repository> | ||
<id>overcast</id> | ||
<url>https://repo.oc.tc/content/groups/public</url> | ||
</repository> | ||
<repository> | ||
<id>avicus-public</id> | ||
<url>https://repo.avicus.net/content/groups/public</url> | ||
</repository> | ||
<repository> | ||
<id>avicus-private</id> | ||
<url>https://repo.avicus.net/content/groups/private/</url> | ||
</repository> | ||
</repositories> | ||
<repositories> | ||
<repository> | ||
<id>overcast</id> | ||
<url>https://repo.oc.tc/content/groups/public</url> | ||
</repository> | ||
<repository> | ||
<id>avicus-public</id> | ||
<url>https://repo.avicus.net/content/groups/public</url> | ||
</repository> | ||
<repository> | ||
<id>avicus-private</id> | ||
<url>https://repo.avicus.net/content/groups/private/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>net.avicus</groupId> | ||
<artifactId>magnet-api</artifactId> | ||
<version>1.8.8-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>14.0.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.sourceforge.findbugs</groupId> | ||
<artifactId>jsr305</artifactId> | ||
<version>1.3.7</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>2.1</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>${basedir}/src/main/java/</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<targetPath>.</targetPath> | ||
<filtering>true</filtering> | ||
<directory>${basedir}/src/main/resources/</directory> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>1.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<artifactSet> | ||
<includes> | ||
<include>joda-time:joda-time</include> | ||
</includes> | ||
</artifactSet> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>net.avicus</groupId> | ||
<artifactId>magnet-api</artifactId> | ||
<version>1.8.8-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>14.0.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.sourceforge.findbugs</groupId> | ||
<artifactId>jsr305</artifactId> | ||
<version>1.3.7</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>2.1</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>${basedir}/src/main/java/</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<targetPath>.</targetPath> | ||
<filtering>true</filtering> | ||
<directory>${basedir}/src/main/resources/</directory> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>1.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<artifactSet> | ||
<includes> | ||
<include>joda-time:joda-time</include> | ||
</includes> | ||
</artifactSet> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
</project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
package tc.oc.tracker; | ||
|
||
import com.google.common.base.Preconditions; | ||
import javax.annotation.Nonnull; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.entity.EntityDamageEvent; | ||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; | ||
|
||
import tc.oc.tracker.plugin.DamageAPIHelper; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
/** | ||
* Provides convenient static API calls for other plugins to use. | ||
*/ | ||
public final class DamageAPI { | ||
private DamageAPI() { } | ||
|
||
/** | ||
* Inflicts the given damage on an entity. | ||
* | ||
* This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. | ||
* | ||
* @param entity Entity to inflict damage upon | ||
* @param damage Amount of half-hearts of damage to inflict | ||
* @param info {@link DamageInfo} object that details the type of damage | ||
* @return the final {@link Damage} object (never null) | ||
* | ||
* @throws NullPointerException if entity or info is null | ||
* @throws IllegalArgumentExcpetion if hearts is less than zero | ||
*/ | ||
public static @Nonnull Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { | ||
Preconditions.checkNotNull(entity, "living entity"); | ||
Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); | ||
Preconditions.checkNotNull(info, "damage info"); | ||
|
||
DamageAPIHelper helper = DamageAPIHelper.get(); | ||
|
||
EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage); | ||
helper.setEventDamageInfo(event, info); | ||
|
||
Bukkit.getPluginManager().callEvent(event); | ||
|
||
if(event.isCancelled()) { | ||
return null; | ||
} | ||
|
||
entity.damage(event.getDamage()); | ||
|
||
helper.setEventDamageInfo(event, null); | ||
|
||
return helper.getOurEvent(event).toDamageObject(); | ||
|
||
private DamageAPI() { | ||
} | ||
|
||
/** | ||
* Inflicts the given damage on an entity. | ||
* | ||
* This method will call the appropriate damage method and fire an {@link EntityDamageEvent}. | ||
* | ||
* @param entity Entity to inflict damage upon | ||
* @param damage Amount of half-hearts of damage to inflict | ||
* @param info {@link DamageInfo} object that details the type of damage | ||
* @return the final {@link Damage} object (never null) | ||
* @throws NullPointerException if entity or info is null | ||
* @throws IllegalArgumentExcpetion if hearts is less than zero | ||
*/ | ||
public static | ||
@Nonnull | ||
Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) { | ||
Preconditions.checkNotNull(entity, "living entity"); | ||
Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero"); | ||
Preconditions.checkNotNull(info, "damage info"); | ||
|
||
DamageAPIHelper helper = DamageAPIHelper.get(); | ||
|
||
EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage); | ||
helper.setEventDamageInfo(event, info); | ||
|
||
Bukkit.getPluginManager().callEvent(event); | ||
|
||
if (event.isCancelled()) { | ||
return null; | ||
} | ||
|
||
entity.damage(event.getDamage()); | ||
|
||
helper.setEventDamageInfo(event, null); | ||
|
||
return helper.getOurEvent(event).toDamageObject(); | ||
} | ||
} |
Oops, something went wrong.