Skip to content

Commit

Permalink
Merge pull request #2 from metalshark/async
Browse files Browse the repository at this point in the history
Async
  • Loading branch information
metalshark authored Mar 29, 2020
2 parents 203fbcd + 5a79f3c commit adc0f92
Show file tree
Hide file tree
Showing 12 changed files with 436 additions and 346 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
language: java
jdk:
- openjdk11

env:
global:
- secure: "X+kVpmQ1mPIviUYUtmn9NsSMYr4ysZUoJ5co3oAM6aE/DbIhbuTsS4mN2SmTIHf6+olvJGr8e4NRvrRgzixCs7ZpraflYC1XHjkxx5fP+F1IA8sIOy+zwTQwiez+v6wrrnqP7+9wJmQpF2qV6bYqC0Fzcl8riBNXzAJ2wFsFujUQ8kdh2+vBDHK4n7oW3YLuqISfSLB5uboOYvQ4RRNT/hyfutdan49/HJIcZn1iH3LbsCfnNtvrja6jLFOloa7D+WNPF3/sQSqLgt6/FrNdOBM+6wvot3D/nsYG9mono56iI2PcUjq6AirKfnpnR1XFcVgYMUjDwzaMtepSY0+H4jVbcGJsfISaumDJh/+q/C3MvsiDluxVj9e7xB4vn4ti+iJS8NZpR9cizhtMnY3WnONOc/yLHoujxy0i/XKMqk7pKX3WkPA8jAVGCXnlr6OLROjVILVbuMrKG4DLqFqiQBnfRZDCLWK1Ka3ymjNXWcf3nyvQQHBPfvrZk1CrRxIfQOLlUBM4/34XjKtH+XBj6xeY0KL0XYzvO7d6cYCV1fVX/fJm1OWjUPc+YtkQgT6kdKra9BJQDqEi2zQI9xGNGwsqO4lhpiaH2hH1pq21aCWqpTrnEYpceZ9bU2Ut7Ej2/woAEK2ubD9tGLwETSsVbu7shmrg/pdRLRredzRLsRM="
- secure: "P0x0Fwaeb+BvBw54rGQGWRHES5qdfWl9PYqLIgZSwepSm4C0oe6+Np4eoSbf2i/9ioP1B41tGZO/WFf+iZiFeyq9FkktIlvDYE5pe5gwUi1aJ9kmFemSPr5YXeGrM5yktxtmVgqm4DiOw37Zq6ZRXUvsnwtrk7bL3fwlScdMY+y0U4lCk0kxoiUajfnSv3/R3J5QI6kGR2LVfK694uzOI1nk05k3SAc3xbflzePzicavjY0w9/fCjV917WeVhclwXkPxhhmoQNNpdqfuXUj3HXXXK3P+zcg+Ez7eBQqwke9Rg2jzH1tKCXqQF6OaNOvOm2EV+cNDyhMDdg4QiID1XVJ8GXSusOIQV8T+bMLkx6HmH7OJomIIfKbFi3FcjyKCXwHUI8eBClANt9BGmIWM8OXQvIdHKDD92yz5IdQJzXVP+zLDj32hE4DeCsRnDYGBWzKeujV/LUKUBeeYdeMbefo4S0M31S7VAleQP0qYgIA3CZmWvHCBcRLGPQmehYRN8r46rV3rGL6nTqqFBz8Xod1JUxYRBKImTA8JOTVfv8FLduYZ4fJv6ksG1PMJoBx2FcPTKTYgWfSkDmaBm9FAkpvp+VLD2WnlsmC7M3OXvf15bWhNWSIwJ1kMhfq62GVZG5qqo0GfiaDpFOVdWiiuHJCteraB/qePzk2ECEX9VzI="
- openjdk11
61 changes: 54 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,61 @@ Version 1.4.7 is intended for 1.13+ only. For older MC versions, please use 1.4.

## Usage
```java
@EventHandler
public void onJoin(final PlayerJoinEvent event) {
//Delay the update by a few ticks until the player is actually on the server
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
@Override
public void run() {
import org.bukkit.Bukkit;
import org.bukkit.event.player.PlayerJoinEvent;
import org.inventivetalent.glow.GlowAPI;

public class PlayerJoinListener implements Listener {

@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event) {

//Delay the update by a few ticks until the player is actually on the server
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {

//Set the event's player glowing in DARK_AQUA for all online players
GlowAPI.setGlowing(event.getPlayer(), GlowAPI.Color.DARK_AQUA, Bukkit.getOnlinePlayers());

}, 10);

}

}
```

```java
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.inventivetalent.glow.GlowAPI;

public class MyClass {

public static void myMethod(Entity entity, Player player) {
if (GlowAPI.isGlowing(entity, player)) {
System.out.println("The entity is glowing for the player.");
}
}, 10);
}

}
```

```java
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.inventivetalent.glow.GlowAPI;

public class MyClass {

public static void myMethod(Collection<Entity> entities, Collection<Player> players) {
if (GlowAPI.isGlowing(entity, player)) {
CompleteableFuture<Void> future = GlowAPI.setGlowingAsync(event.getPlayer(), GlowAPI.Color.DARK_AQUA, Bukkit.getOnlinePlayers());

// Do some other work while that executes in the background

future.join(); //Wait for glowing to be set
}
}

}
```
## Maven
Expand All @@ -40,7 +85,9 @@ public void onJoin(final PlayerJoinEvent event) {
<url>https://jitpack.io</url>
</repository>
</repositories>
```

```xml
<dependencies>
<dependency>
<groupId>com.github.metalshark</groupId>
Expand Down
39 changes: 21 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.inventivetalent.glow</groupId>
<artifactId>GlowAPI</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.0.0</version>

<name>${project.artifactId}</name>
<description>This API allows you to change the glow-color of entities and players.</description>
Expand Down Expand Up @@ -54,31 +54,24 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>${project.groupId}.dependencies.org.bstats</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.bstats:*</include>
<include>org.inventivetalent:glowapi**</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>${project.groupId}</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
</plugins>
</build>
Expand All @@ -89,6 +82,7 @@
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit-lite</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>

<!-- Bukkit -->
Expand All @@ -99,6 +93,14 @@
<scope>provided</scope>
</dependency>

<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>

<!-- Nullable/NotNull -->
<dependency>
<groupId>org.jetbrains</groupId>
Expand All @@ -112,6 +114,7 @@
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
14 changes: 0 additions & 14 deletions settings.xml

This file was deleted.

Loading

0 comments on commit adc0f92

Please sign in to comment.