Skip to content

Commit

Permalink
Merge pull request #229 from FishyFinn/dev
Browse files Browse the repository at this point in the history
Added permission meta tags to teleport_warmup
  • Loading branch information
sakurawald authored Dec 24, 2024
2 parents 01fd344 + f0bc44f commit 0303973
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/chapters/module/teleport_warmup/teleport_warmup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
}
\end{Configuration}

\LevelTwo{Meta}
\begin{description}
\item [fuji.teleport_warmup.warmup] The per player teleport warmup time in seconds.
\end{description}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.sakurawald.module.mixin.teleport_warmup;

import io.github.sakurawald.core.auxiliary.minecraft.EntityHelper;
import io.github.sakurawald.core.auxiliary.minecraft.PermissionHelper;
import io.github.sakurawald.core.auxiliary.minecraft.RegistryHelper;
import io.github.sakurawald.core.auxiliary.minecraft.TextHelper;
import io.github.sakurawald.core.manager.Managers;
Expand All @@ -15,6 +16,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Optional;
import java.util.Set;

@Mixin(value = ServerPlayerEntity.class, priority = 1000 - 500)
Expand All @@ -32,14 +34,18 @@ public void interceptTeleportAndAddTicket(ServerWorld serverWorld, double x, dou
// If we try to spawn a fake-player in the end or nether, the fake-player will initially spawn in overworld
// and teleport to the target world. This will cause the teleport warmup to be triggered.
if (!EntityHelper.isRealPlayer(player)) return;

TeleportTicket ticket = TeleportWarmupInitializer.getTeleportTicket(player);

Optional<Integer> permission_warmup_time = PermissionHelper.getMeta(player.getUuid(), "fuji.teleport_warmup.warmup", Integer::valueOf);
//set warmup seconds to LP permission seconds or default config seconds
int warmup_seconds = permission_warmup_time.orElse(TeleportWarmupInitializer.config.model().warmup_second);

if (ticket == null) {
ticket = TeleportTicket.make(
player
, SpatialPose.of(player)
, new SpatialPose(serverWorld, x, y, z, yaw, pitch)
, TeleportWarmupInitializer.config.model().warmup_second * 1000
, warmup_seconds * 1000
, TeleportWarmupInitializer.config.model().interruptible
);
Managers.getBossBarManager().addTicket(ticket);
Expand Down

0 comments on commit 0303973

Please sign in to comment.