Skip to content

Commit

Permalink
clean up meta from that pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 2, 2023
1 parent ba6a77b commit 6e0772b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Expand Up @@ -137,7 +137,6 @@ public InventoryView openAnvil(Player player, Location loc) {
return player.openAnvil(loc, true);
}

@SuppressWarnings("UnstableApiUsage")
@Override
public void teleport(Entity entity, Location loc, PlayerTeleportEvent.TeleportCause cause, List<TeleportCommand.EntityState> entityTeleportFlags, List<TeleportCommand.Relative> relativeTeleportFlags) {
if (!NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) {
Expand Down
Expand Up @@ -26,17 +26,17 @@ public class TeleportCommand extends AbstractCommand {

public TeleportCommand() {
setName("teleport");
setSyntax("teleport (<entity>|...) [<location>] (cause:<cause>) (entity_options:<option>|...) (relative_options:<option>|...) (relative)");
setRequiredArguments(1, 5);
setSyntax("teleport (<entity>|...) [<location>] (cause:<cause>) (entity_options:<option>|...) (relative) (relative_axes:<axis>|...)");
setRequiredArguments(1, 6);
isProcedural = false;
autoCompile();
}

// <--[command]
// @Name Teleport
// @Syntax teleport (<entity>|...) [<location>] (cause:<cause>) (entity_options:<option>|...) (relative_options:<option>|...) (relative)
// @Syntax teleport (<entity>|...) [<location>] (cause:<cause>) (entity_options:<option>|...) (relative) (relative_axes:<axis>|...)
// @Required 1
// @Maximum 5
// @Maximum 6
// @Short Teleports the entity(s) to a new location.
// @Synonyms tp
// @Group entity
Expand All @@ -48,11 +48,14 @@ public TeleportCommand() {
//
// Instead of a valid entity, an unspawned NPC or an offline player may also be used.
//
// Optionally, specify additional teleport options using the 'entity_options:'/'relative_options:' arguments (Paper only).
// This allows things like relative teleports (smoother over short distances), retaining an open inventory when teleporting, etc. - see the links below for more information.
// See <@link url https://jd.papermc.io/paper/1.19/io/papermc/paper/entity/TeleportFlag.EntityState.html>/<@link url https://jd.papermc.io/paper/1.19/io/papermc/paper/entity/TeleportFlag.Relative.html> for all possible options.
// Alternatively, specify 'relative' to automatically use all the options in <@link url https://jd.papermc.io/paper/1.19/io/papermc/paper/entity/TeleportFlag.Relative.html>, for a fully relative teleport.
// Note that the API this is based on is marked as experimental, so while unlikely, breaking changes are possible.
// Optionally specify "relative" to use relative teleportation (Paper only). This is primarily useful only for players, but available for all entities.
// Relative teleports are smoother for the client when teleporting over short distances.
// Optionally, you may use "relative_axes:" to specify a set of axes to move relative on (and other axes will be treated as absolute), as any of "X", "Y", "Z", "YAW", "PITCH".
//
// Optionally, specify additional teleport options using the 'entity_options:' arguments (Paper only).
// This allows things like retaining an open inventory when teleporting - see the links below for more information.
// See <@link url https://jd.papermc.io/paper/1.19/io/papermc/paper/entity/TeleportFlag.EntityState.html> for all possible options.
// Note that the API this is based on is marked as experimental in Paper, and so may change in the future.
//
// @Tags
// <EntityTag.location>
Expand Down Expand Up @@ -90,7 +93,7 @@ public TeleportCommand() {
public void addCustomTabCompletions(TabCompletionsBuilder tab) {
tab.addNotesOfType(LocationTag.class);
tab.addWithPrefix("entity_options:", EntityState.values());
tab.addWithPrefix("relative_options:", Relative.values());
tab.addWithPrefix("relative_axes:", Relative.values());
}

public enum EntityState { RETAIN_PASSENGERS, RETAIN_VEHICLE, RETAIN_OPEN_INVENTORY }
Expand All @@ -101,7 +104,7 @@ public static void autoExecute(ScriptEntry scriptEntry,
@ArgLinear @ArgName("location") @ArgDefaultNull ObjectTag locationRaw,
@ArgPrefixed @ArgName("cause") @ArgDefaultText("plugin") PlayerTeleportEvent.TeleportCause cause,
@ArgName("entity_options") @ArgPrefixed @ArgDefaultNull @ArgSubType(EntityState.class) List<EntityState> entityOptions,
@ArgName("relative_options") @ArgPrefixed @ArgDefaultNull @ArgSubType(Relative.class) List<Relative> relativeOptions,
@ArgName("relative_axes") @ArgPrefixed @ArgDefaultNull @ArgSubType(Relative.class) List<Relative> relativeAxes,
@ArgName("relative") boolean relative) {
if (locationRaw == null) { // Compensate for legacy "- teleport <loc>" default fill
locationRaw = entityList;
Expand All @@ -113,8 +116,8 @@ else if (entityList.identify().startsWith("l@")) { // Compensate for legacy enti
entityList = swap;
Deprecations.outOfOrderArgs.warn(scriptEntry);
}
if (relative) {
relativeOptions = Arrays.asList(Relative.values());
if (relative && relativeAxes == null) {
relativeAxes = Arrays.asList(Relative.values());
}
LocationTag location = locationRaw.asType(LocationTag.class, scriptEntry.context);
ListTag entities = entityList.asType(ListTag.class, scriptEntry.context);
Expand Down Expand Up @@ -146,8 +149,8 @@ else if (entityList.identify().startsWith("l@")) { // Compensate for legacy enti
NMSHandler.entityHelper.look(entity.getBukkitEntity(), location.getYaw(), location.getPitch());
return;
}
if (entityOptions != null || relativeOptions != null) {
PaperAPITools.instance.teleport(entity.getBukkitEntity(), location, cause, entityOptions, relativeOptions);
if (entityOptions != null || relativeAxes != null) {
PaperAPITools.instance.teleport(entity.getBukkitEntity(), location, cause, entityOptions, relativeAxes);
continue;
}
entity.teleport(location, cause);
Expand Down

0 comments on commit 6e0772b

Please sign in to comment.