Compare commits

..

4 Commits

Author SHA1 Message Date
Len d0c324594e Update to 26.1.X 2026-05-15 06:27:45 -05:00
Len afd95fd084 Add RelogCheckCommand 2026-04-06 14:41:34 +02:00
Len 6ac80610bf Update for Minecraft Version 1.21.9 2026-04-06 14:41:24 +02:00
Len 054f39407d Check if mypet is enabled 2025-07-07 16:18:48 +02:00
9 changed files with 101 additions and 34 deletions

2
.gitignore vendored
View File

@ -39,5 +39,3 @@ hs_err_pid*
.gradle .gradle
build/ build/
!gradle/wrapper/gradle-wrapper.jar !gradle/wrapper/gradle-wrapper.jar
*.bat

View File

@ -2,7 +2,6 @@ import java.io.ByteArrayOutputStream
plugins { plugins {
id("java") id("java")
id("com.github.johnrengelman.shadow") version "7.1.0"
} }
group = "com.alttd" group = "com.alttd"
@ -12,7 +11,7 @@ apply<JavaLibraryPlugin>()
java { java {
toolchain { toolchain {
languageVersion.set(JavaLanguageVersion.of(21)) languageVersion.set(JavaLanguageVersion.of(25))
} }
} }
@ -39,21 +38,22 @@ tasks {
} }
dependencies { dependencies {
compileOnly("com.alttd.cosmos:cosmos-api:1.21.10-R0.1-SNAPSHOT") { compileOnly("com.alttd.cosmos:cosmos-api:26.1.2.build.11-release") {
isChanging = true isChanging = true
} }
compileOnly("de.keyle:mypet-api:4.0.0-SNAPSHOT") compileOnly("de.keyle:mypet:3.11-SNAPSHOT")
compileOnly("com.alttd:VillagerShopUI:1.1-SNAPSHOT") { compileOnly("com.alttd:VillagerShopUI:1.1-SNAPSHOT") {
isChanging = true isChanging = true
} }
} }
fun gitCommit(): String { fun gitCommit(): String {
val os = ByteArrayOutputStream() // val os = ByteArrayOutputStream()
project.exec { // project.exec {
isIgnoreExitValue = true // isIgnoreExitValue = true
commandLine = "git rev-parse --short HEAD".split(" ") // commandLine = "git rev-parse --short HEAD".split(" ")
standardOutput = os // standardOutput = os
} // }
return String(os.toByteArray()).trim() // return String(os.toByteArray()).trim()
return "FIXME"
} }

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -1,23 +1,18 @@
rootProject.name = "AFKDetector" import org.gradle.kotlin.dsl.maven
val nexusUser = providers.gradleProperty("alttdSnapshotUsername").orNull ?: System.getenv("NEXUS_USERNAME") rootProject.name = "AFKDetector"
val nexusPass = providers.gradleProperty("alttdSnapshotPassword").orNull ?: System.getenv("NEXUS_PASSWORD")
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
mavenLocal()
mavenCentral() mavenCentral()
maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
maven("https://repo.alttd.com/repository/alttd-snapshot/")
maven { maven {
url = uri("https://repo.alttd.com/repository/alttd-snapshot/") name = "AlttdNexus"
credentials { url = uri(
username = nexusUser "https://repo.alttd.com/repository/alttd/"
password = nexusPass )
} credentials(PasswordCredentials::class)
}
maven("https://repo.papermc.io/repository/maven-public/")
maven {
name = "userderezzedRepoSnapshots"
url = uri("https://repo.userderezzed.dev/snapshots")
} }
} }
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

View File

@ -4,6 +4,7 @@ import com.alttd.afkdectector.afkplayer.AFKPlayer;
import com.alttd.afkdectector.command.AFKCheckCommand; import com.alttd.afkdectector.command.AFKCheckCommand;
import com.alttd.afkdectector.command.AFKListCommand; import com.alttd.afkdectector.command.AFKListCommand;
import com.alttd.afkdectector.command.ReloadCommand; import com.alttd.afkdectector.command.ReloadCommand;
import com.alttd.afkdectector.command.RelogCheckCommand;
import com.alttd.afkdectector.config.Config; import com.alttd.afkdectector.config.Config;
import com.alttd.afkdectector.config.Messages; import com.alttd.afkdectector.config.Messages;
import com.alttd.afkdectector.config.MessagesConfig; import com.alttd.afkdectector.config.MessagesConfig;
@ -55,9 +56,10 @@ public class AFKDetector extends JavaPlugin implements Listener {
//getCommand("afk").setExecutor(new AFKCommand(this)); //getCommand("afk").setExecutor(new AFKCommand(this));
getCommand("afklist").setExecutor(new AFKListCommand(this)); getCommand("afklist").setExecutor(new AFKListCommand(this));
getCommand("afkcheck").setExecutor(new AFKCheckCommand(this)); getCommand("afkcheck").setExecutor(new AFKCheckCommand(this));
getCommand("relogcheck").setExecutor(new RelogCheckCommand(this));
getCommand("reloadafkdetector").setExecutor(new ReloadCommand(this)); getCommand("reloadafkdetector").setExecutor(new ReloadCommand(this));
new AFKCheckTimer(this).init(); new AFKCheckTimer(this).init();
myPetEnabled = getServer().getPluginManager().getPlugin("MyPet") != null; myPetEnabled = getServer().getPluginManager().isPluginEnabled("MyPet");
} catch (Throwable t) { } catch (Throwable t) {
getLogger().severe("An error has occured while loading AFKDetector"); getLogger().severe("An error has occured while loading AFKDetector");
if (!(t instanceof ExceptionInInitializerError)) { if (!(t instanceof ExceptionInInitializerError)) {

View File

@ -4,9 +4,8 @@ import com.alttd.afkdectector.AFKDetector;
import com.alttd.afkdectector.config.Config; import com.alttd.afkdectector.config.Config;
import com.alttd.afkdectector.config.Messages; import com.alttd.afkdectector.config.Messages;
import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.MyPetApi;
import de.Keyle.MyPet.api.entity.Pet; import de.Keyle.MyPet.api.entity.MyPet;
import de.Keyle.MyPet.api.player.MyPetPlayer; import de.Keyle.MyPet.api.player.MyPetPlayer;
import de.Keyle.MyPet.api.plugin.MyPetPlugin;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
@ -139,10 +138,10 @@ public class AFKPlayer {
if (!AFKDetector.myPetEnabled) return; if (!AFKDetector.myPetEnabled) return;
MyPetPlayer myPetPlayer = MyPetApi.getPlayerManager().getMyPetPlayer(player); MyPetPlayer myPetPlayer = MyPetApi.getPlayerManager().getMyPetPlayer(player);
if (myPetPlayer == null || !myPetPlayer.hasPet() || !myPetPlayer.getPet().getStatus().equals(Pet.PetState.Here)) if (myPetPlayer == null || !myPetPlayer.hasMyPet() || !myPetPlayer.getMyPet().getStatus().equals(MyPet.PetState.Here))
return; return;
Pet myPet = myPetPlayer.getPet(); MyPet myPet = myPetPlayer.getMyPet();
myPet.removePet(); myPet.removePet();
} }
} }

View File

@ -0,0 +1,65 @@
package com.alttd.afkdectector.command;
import com.alttd.afkdectector.AFKDetector;
import com.alttd.afkdectector.afkplayer.AFKPlayer;
import com.alttd.afkdectector.config.Messages;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.title.Title;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class RelogCheckCommand implements CommandExecutor, TabCompleter {
private final AFKDetector plugin;
public RelogCheckCommand(AFKDetector plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!(args.length > 0)) {
sender.sendMessage(Component.text(command.getUsage(), NamedTextColor.RED));
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
sender.sendMessage(Component.text(command.getUsage(), NamedTextColor.RED));
return true;
}
MiniMessage miniMessage = AFKDetector.miniMessage;
target.showTitle(Title.title(miniMessage.deserialize(Messages.RELOG_CHECK_TITLE.getMessage()),
miniMessage.deserialize(Messages.RELOG_CHECK_SUBTITLE.getMessage())));
if (sender instanceof Player player) {
String cmd = "msg " + args[0] + " " + Messages.RELOG_CHECK_MESSAGE.getMessage();
PlayerCommandPreprocessEvent commandEvent = new PlayerCommandPreprocessEvent(player, "/" + cmd);
Bukkit.getPluginManager().callEvent(commandEvent);
player.performCommand(cmd);
} else {
Bukkit.dispatchCommand(sender, "msg " + args[0] + " " + Messages.RELOG_CHECK_MESSAGE.getMessage());
}
return true;
}
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, String[] strings) {
List<String> completions = new ArrayList<>();
if (strings.length == 1) {
StringUtil.copyPartialMatches(strings[0], plugin.players.values().stream().filter(AFKPlayer::isAFK).map(AFKPlayer::getPlayerName).collect(Collectors.toList()), completions);
}
return null;
}
}

View File

@ -19,6 +19,9 @@ public enum Messages {
AFK_CHECK_TITLE("afkcheck-title", "AFK CHECK"), AFK_CHECK_TITLE("afkcheck-title", "AFK CHECK"),
AFK_CHECK_SUBTITLE("afkcheck-subtitle", "Please respond to the dm from staff!"), AFK_CHECK_SUBTITLE("afkcheck-subtitle", "Please respond to the dm from staff!"),
AFK_CHECK_MESSAGE("afkcheck-message", "Hey, since you're near a farm and not moving. I'm making sure you aren't afk. Please respond to me if you're not AFK."), AFK_CHECK_MESSAGE("afkcheck-message", "Hey, since you're near a farm and not moving. I'm making sure you aren't afk. Please respond to me if you're not AFK."),
RELOG_CHECK_TITLE("relogcheck-title", "AFK CHECK"),
RELOG_CHECK_SUBTITLE("relogcheck-subtitle", "Please respond to the dm from staff!"),
RELOG_CHECK_MESSAGE("relogcheck-message", "Hey, since you're near a farm and not moving. I'm making sure you aren't afk. Please respond to me if you're not AFK."),
AFK_KICK_STAFF_MESSAGE("afkkick-staff-messsge", "<gold><player> got afk kicked after being afk for <afk_time> minutes."), AFK_KICK_STAFF_MESSAGE("afkkick-staff-messsge", "<gold><player> got afk kicked after being afk for <afk_time> minutes."),
SUSPICIOUS_KICK_COUNT("afkkick-suspicious-message", "<gold><player> has had <count> suspicious AFK kicks since last reboot."), SUSPICIOUS_KICK_COUNT("afkkick-suspicious-message", "<gold><player> has had <count> suspicious AFK kicks since last reboot."),
AFK_SOON_BOSS_BAR("afk-soon-boss-bar", "<dark_aqua>Time until AFK.</dark_aqua>"), AFK_SOON_BOSS_BAR("afk-soon-boss-bar", "<dark_aqua>Time until AFK.</dark_aqua>"),

View File

@ -19,6 +19,11 @@ commands:
permission: afkdetector.afkcheck permission: afkdetector.afkcheck
permission-message: You do not have permission! permission-message: You do not have permission!
usage: /afkcheck <target> usage: /afkcheck <target>
relogcheck:
description: Sends and relogcheck message to the target
permission: afkdetector.relogcheck
permission-message: You do not have permission!
usage: /relogcheck <target>
reloadafkdetector: reloadafkdetector:
description: Reloads the plugin config description: Reloads the plugin config
permission: afkdetector.reload permission: afkdetector.reload