1
0
mirror of https://github.com/nkomarn/harbor.git synced 2024-11-21 17:35:40 +01:00

Restore CI workflow

This commit is contained in:
Mykyta Komarnytskyy 2020-11-13 13:57:46 -08:00
parent ce28be83ad
commit 7ad3625614
3 changed files with 32 additions and 11 deletions

21
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn package --file pom.xml
- name: Upload Artifact
uses: actions/upload-artifact@v2-preview
with:
name: Harbor
path: target/Harbor-*.jar

View File

@ -26,7 +26,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version> <version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -2,8 +2,6 @@ package xyz.nkomarn.harbor.util;
import com.earth2me.essentials.Essentials; import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.Object2LongMap;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -15,6 +13,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import xyz.nkomarn.harbor.Harbor; import xyz.nkomarn.harbor.Harbor;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -22,13 +22,13 @@ import java.util.concurrent.TimeUnit;
public class PlayerManager implements Listener { public class PlayerManager implements Listener {
private final Harbor harbor; private final Harbor harbor;
private final Object2LongMap<UUID> cooldowns; private final Map<UUID, Long> cooldowns;
private final Object2LongMap<UUID> playerActivity; private final Map<UUID, Long> playerActivity;
public PlayerManager(@NotNull Harbor harbor) { public PlayerManager(@NotNull Harbor harbor) {
this.harbor = harbor; this.harbor = harbor;
this.cooldowns = new Object2LongOpenHashMap<>(); this.cooldowns = new HashMap<>();
this.playerActivity = new Object2LongOpenHashMap<>(); this.playerActivity = new HashMap<>();
} }
/** /**
@ -38,7 +38,7 @@ public class PlayerManager implements Listener {
* @return The player's last cooldown time. * @return The player's last cooldown time.
*/ */
public long getCooldown(@NotNull Player player) { public long getCooldown(@NotNull Player player) {
return cooldowns.getOrDefault(player.getUniqueId(), 0); return cooldowns.getOrDefault(player.getUniqueId(), 0L);
} }
/** /**
@ -82,7 +82,7 @@ public class PlayerManager implements Listener {
return false; return false;
} }
long minutes = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - playerActivity.getLong(player.getUniqueId())); long minutes = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - playerActivity.get(player.getUniqueId()));
return minutes >= harbor.getConfiguration().getInteger("afk-detection.timeout"); return minutes >= harbor.getConfiguration().getInteger("afk-detection.timeout");
} }
@ -105,8 +105,8 @@ public class PlayerManager implements Listener {
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent event) { public void onQuit(PlayerQuitEvent event) {
UUID uuid = event.getPlayer().getUniqueId(); UUID uuid = event.getPlayer().getUniqueId();
cooldowns.removeLong(uuid); cooldowns.remove(uuid);
playerActivity.removeLong(uuid); playerActivity.remove(uuid);
} }
private final class AfkListeners implements Listener { private final class AfkListeners implements Listener {