Files
ParchmentMC/patches/server/0018-Expanded-Insomnia-API.patch
Lexi Larkin ce4157e318 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@40adc23 Fix incorrect javadoc in JarLibrary (#9513)
PaperMC/Paper@c016e03 Fix unbreakable flint and steel consumed when igniting creepers (#9509)
PaperMC/Paper@b1334b5 Mark Player.sendSignChange as deprecated (#9382)
PaperMC/Paper@2f8d9db Pathfinder hasPath should check if path is done. (#9231)
PaperMC/Paper@46a36d3 Make ExperienceOrb entities call EntitySpawnEvent (#9197)
PaperMC/Paper@24d690f Fix hopper not marking source inv as changed (#9070)
PaperMC/Paper@383f0ed Remove sign ticking (#9478)
PaperMC/Paper@d8b8f61 Configurable Region Compression Format (#8505)
PaperMC/Paper@2c54b39 Don't support hex in book title and author (#9493)
PaperMC/Paper@e19177a Rewrote Amethyst logic to throw both BlockGrowEvent and BlockSpreadEvent (#9217)
PaperMC/Paper@4283054 Add player whitelist events (#9209)
PaperMC/Paper@aa93dcf feat: add minimessage tag resolvers overload to CommandSender#sendMessage (#9505)
PaperMC/Paper@b14979e Remove isRemoved skip on .discard() (#9520)
PaperMC/Paper@1837f6c Prevent entity removals if the entity slices is receiving status updates
PaperMC/Paper@a40e48f Add cause to PlayerOpenSignEvent (#9441)
PaperMC/Paper@7d1cc6d Add Translatable interface to MusicInstrument (#9538)
PaperMC/Paper@6c7e3c5 Clarify viewers set mutability in chat events (#9525)
PaperMC/Paper@f402f89 Bump net.kyori.ansi to 1.0.2 (#9546)
PaperMC/Paper@81619a6 Fix treasure map config default (#9572)
PaperMC/Paper@13c9d3c Bump net.kyori:ansi to 1.0.3 (#9575)
PaperMC/Paper@2c55dd8 Expand use of strict advancement dim check (#9545)
PaperMC/Paper@69a8013 Fix inventorycloseevent javadocs (#9533)
PaperMC/Paper@2fa8efc Updated Upstream (Bukkit/CraftBukkit) (#9485)
PaperMC/Paper@508a295 Only erase allay memory on non-item targets (#9570)
PaperMC/Paper@31358d5 API for updating recipes on clients (#6463)
PaperMC/Paper@8fe8ca6 Add clickable version on version command (#9347)
PaperMC/Paper@d6d2b6f Only capture actual tree growth (#6464)
2023-08-06 21:36:15 -04:00

61 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Blast-MC <cjblanton2@gmail.com>
Date: Sun, 24 Jul 2022 19:37:33 -0400
Subject: [PATCH] Expanded Insomnia API
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index ece3637304863c8441c153e06ea9934cc91ff961..af23e113aea3112b618d3fc9b0c9baf59a693025 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -81,6 +81,7 @@ import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.players.UserWhiteListEntry;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntitySelector;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.Attributes;
@@ -196,6 +197,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit
private long lastSaveTime;
// Paper end
+ private boolean bypassesInsomnia = false; // Parchment - Insomnia api
public CraftPlayer(CraftServer server, ServerPlayer entity) {
super(server, entity);
@@ -2092,6 +2094,33 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return this;
}
+ // Parchment start
+ @Override
+ public boolean isInsomniac() {
+ return EntitySelector.IS_INSOMNIAC.test(this.getHandle());
+ }
+
+ @Override
+ public void setBypassInsomnia(boolean val) {
+ this.bypassesInsomnia = val;
+ }
+
+ @Override
+ public boolean doesBypassInsomnia() {
+ return this.bypassesInsomnia;
+ }
+
+ @Override
+ public void setTimeSinceLastRest(int ticks) {
+ this.getHandle().getStats().setValue(this.getHandle(), net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST), net.minecraft.util.Mth.clamp(ticks, 1, Integer.MAX_VALUE));
+ }
+
+ @Override
+ public int getTimeSinceLastRest() {
+ return net.minecraft.util.Mth.clamp(this.getHandle().getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE);
+ }
+ // Parchment end
+
@Override
public ServerPlayer getHandle() {
return (ServerPlayer) entity;