Release PetTeleport-OG

This commit is contained in:
NotAlexNoyle committed 2026-04-07 09:24:56 -04:00
1 parent 567c5983ad
commit f6330340d5
8 files changed
+148 -28

No files matched your search

+2 -1
View File
@@ -28,7 +28,8 @@ out/
# Gradle files
.gradle/
build
build/
bin/
# Eclipse files
.classpath
+32 -10
View File
@@ -1,18 +1,25 @@
<h1 align="center">🐾 pet-teleport</h1>
<h1 align="center">🐾 PetTeleport-OG</h1>
<div align="center">
<img src="https://i.imgur.com/Bwili3Z.png">
</div>
<div align="center">
<code><img title="License" href="LICENSE" src="https://img.shields.io/github/license/NotAShelf/pet-teleport?style=flat-square"></code>
<code><img title="Issues" href="https://github.com/NotAShelf/pet-teleport/issues" src="https://img.shields.io/github/issues/NotAShelf/pet-teleport?style=flat-square"></code>
<code><img title="Maven Release CI" href="https://github.com/NotAShelf/pet-teleport/actions/workflows/preview.yml" src="https://github.com/NotAShelf/pet-teleport/actions/workflows/preview.yml/badge.svg"></code>
<code><img title="License" href="LICENSE" src="https://img.shields.io/github/license/true-og/PetTeleport-OG?style=flat-square"></code>
<code><img title="Issues" href="https://github.com/true-og/PetTeleport-OG/issues" src="https://img.shields.io/github/issues/true-og/PetTeleport-OG?style=flat-square"></code>
</div>
Ever teleported somewhere in Minecraft only for your pets to not follow you? I have! The problem is that the server instantly unloads unoccupied chunks, often with
your pet in stow! This plugin ensures that all standing pets teleport to you if they ever end up in an unloaded chunk. Handy!
`PetTeleport-OG` is the [TrueOG Network](https://trueog.net) maintained fork of [NotAShelf/pet-teleport](https://github.com/NotAShelf/pet-teleport), which is itself a fork of [Chailotl/pet-teleport](https://github.com/Chailotl/pet-teleport).
## Differences from Upstream
- Built for Purpur 1.19.4.
- Builds with TrueOG Network live config file.
- Adds WorldGuard integration via the `pet-teleport` region flag.
## Usage
<div align="center">
@@ -38,11 +45,11 @@ None!
logPetTeleports: true
worldList:
- lobby
- hub
- some_other_world
- world
- world_nether
- world_the_end
isBlacklist: true
isBlacklist: false
```
| Option | Description | Type |
@@ -51,7 +58,22 @@ isBlacklist: true
| worldList | A list of worlds that pets may or may not teleport to | `list` |
| isBlacklist | Whether the `worldList` option will act as a blacklist. <br>If false, pets may only teleport to the world in the list | `bool` |
The shipped defaults are a whitelist of the three vanilla worlds (`world`, `world_nether`, `world_the_end`), rather than the
sample blacklist (`lobby`, `hub`, `some_other_world`) used by upstream.
### WorldGuard Integration
If [WorldGuard](https://enginehub.org/worldguard) is installed, PetTeleport-OG registers a `pet-teleport` state flag
you can set per region to gate pet teleports into that region:
```
/region flag <region> pet-teleport allow
/region flag <region> pet-teleport deny
```
The flag defaults to `allow`, so regions without it explicitly set behave exactly as they did before. When set to
`deny`, pets will not be teleported to a player standing inside the region.
## License
This is a fork of [Chailotl's pet-teleport plugin](https://github.com/Chailotl/pet-teleport) with minor tweaks and updates. Following the
original license, this repository is also licensed with the [GPL-3.0 license](LICENSE).
Following the original license, this repository is also licensed under the [GPL-3.0 license](LICENSE).
+5 -1
View File
@@ -29,6 +29,7 @@ repositories {
mavenCentral() // Import the Maven Central Maven Repository.
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
maven { url = uri("https://repo.purpurmc.org/snapshots") } // Import the PurpurMC Maven Repository.
maven { url = uri("https://maven.enginehub.org/repo/") } // Import the EngineHub Maven Repository (WorldGuard).
maven { url = uri("file://${System.getProperty("user.home")}/.m2/repository") }
System.getProperty("SELF_MAVEN_LOCAL_REPO")?.let { // TrueOG Bootstrap mavenLocal().
val dir = file(it)
@@ -43,7 +44,10 @@ repositories {
}
/* ---------------------- Java project deps ---------------------------- */
dependencies { compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") }
dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.8")
}
tasks.named<ProcessResources>("processResources") {
val props = mapOf("version" to version, "apiVersion" to apiVersion)
@@ -6,6 +6,19 @@ import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
private UnloadListener unloadListener;
private boolean worldGuardPresent;
@Override
public void onLoad() {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
WorldGuardHandler.registerFlag(getLogger());
worldGuardPresent = true;
}
}
@Override
public void onEnable() {
@@ -13,15 +26,21 @@ public class Main extends JavaPlugin {
saveDefaultConfig();
unloadListener = new UnloadListener(this);
getServer().getPluginManager().registerEvents(unloadListener, this);
getLogger().info("PetTeleport has been enabled.");
getLogger().info("PetTeleport-OG has been enabled.");
}
public boolean isWorldGuardPresent() {
return worldGuardPresent;
}
@Override
public void onDisable() {
getLogger().info("PetTeleport has been disabled.");
getLogger().info("PetTeleport-OG has been disabled.");
}
}
}
@@ -1,17 +1,16 @@
package net.avallion.petTeleport;
import java.util.List;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sittable;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import java.util.List;
public class UnloadListener implements Listener {
private final Main plugin;
@@ -41,7 +40,6 @@ public class UnloadListener implements Listener {
final boolean logPetTeleports = plugin.getConfig().getBoolean("logPetTeleports");
final List<String> worldBlacklist = plugin.getConfig().getStringList("worldBlacklist");
final boolean isBlacklist = plugin.getConfig().getBoolean("isBlacklist");
for (Entity ent : entities) {
if (ent instanceof Sittable && ent instanceof Tameable) {
@@ -60,6 +58,13 @@ public class UnloadListener implements Listener {
}
final Player ply = (Player) tame.getOwner();
if (plugin.isWorldGuardPresent() && !WorldGuardHandler.isTeleportAllowed(ply.getLocation())) {
continue;
}
ent.teleport(ply);
ent.setPortalCooldown(300);
@@ -80,4 +85,4 @@ public class UnloadListener implements Listener {
}
}
}
@@ -0,0 +1,69 @@
package net.avallion.petTeleport;
import java.util.logging.Logger;
import org.bukkit.Location;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
public final class WorldGuardHandler {
public static final String FLAG_NAME = "pet-teleport";
private static StateFlag petTeleportFlag;
private WorldGuardHandler() {
}
public static void registerFlag(Logger logger) {
final FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
try {
final StateFlag flag = new StateFlag(FLAG_NAME, true);
registry.register(flag);
petTeleportFlag = flag;
logger.info("Registered WorldGuard flag: " + FLAG_NAME);
} catch (FlagConflictException e) {
final Flag<?> existing = registry.get(FLAG_NAME);
if (existing instanceof StateFlag) {
petTeleportFlag = (StateFlag) existing;
logger.info("Reusing existing WorldGuard flag: " + FLAG_NAME);
} else {
logger.warning("WorldGuard flag '" + FLAG_NAME
+ "' exists but is not a StateFlag; pet teleports will not be region-gated.");
}
}
}
public static boolean isTeleportAllowed(Location location) {
if (petTeleportFlag == null) {
return true;
}
final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
final RegionQuery query = container.createQuery();
return query.testState(BukkitAdapter.adapt(location), null, petTeleportFlag);
}
}
+4 -4
View File
@@ -4,10 +4,10 @@ logPetTeleports: true
# a list of worlds that pets may or may not teleport to
# see isBlacklist option below
worldList:
- lobby
- hub
- some_other_world
- world
- world_nether
- world_the_end
# whether the list of worlds will act as a blacklist - the worlds in the list are disallowed
# or a whitelist, only the worlds in the list are allowed
isBlacklist: true
isBlacklist: false
+3 -3
View File
@@ -1,7 +1,7 @@
name: PetTeleport
name: PetTeleport-OG
version: ${version}
api-version: ${apiVersion}
description: Pets teleport with you!
authors: [Raus, NotAShelf]
prefix: PetTeleport
authors: [Raus, NotAShelf, NotAlexNoyle]
main: net.avallion.petTeleport.Main
softdepend: [WorldGuard]