Fix game time locking

This commit is contained in:
KingRainbow44 2023-05-17 20:53:32 -04:00
parent 69fadff479
commit 18bc68774c
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 21 additions and 4 deletions

View File

@ -723,6 +723,17 @@ public class Player implements PlayerHook {
return playerProfile;
}
/**
* Sets a player's property.
*
* @param prop The property.
* @param value The value as a boolean.
* @return True if the property was set.
*/
public boolean setProperty(PlayerProperty prop, boolean value) {
return setPropertyWithSanityCheck(prop, value ? 1 : 0, true);
}
public boolean setProperty(PlayerProperty prop, int value) {
return setPropertyWithSanityCheck(prop, value, true);
}

View File

@ -1,13 +1,12 @@
package emu.grasscutter.game.world;
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.dungeon.DungeonData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.player.Player.SceneLoadState;
import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.game.props.SceneType;
import emu.grasscutter.game.quest.enums.QuestContent;
import emu.grasscutter.game.world.data.TeleportProperties;
@ -23,13 +22,16 @@ import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.Getter;
import lombok.val;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.val;
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
public final class World implements Iterable<Player> {
@Getter private final GameServer server;
@ -532,6 +534,10 @@ public final class World implements Iterable<Player> {
*/
public void lockTime(boolean locked) {
this.timeLocked = locked;
// Notify players of the locking.
this.getPlayers().forEach(player ->
player.setProperty(PlayerProperty.PROP_IS_GAME_TIME_LOCKED, locked));
}
@Override