Merge remote-tracking branch 'origin/unstable' into unstable

This commit is contained in:
KingRainbow44 2023-05-12 23:25:38 -04:00
commit 5f9d5dd33f
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
4 changed files with 42 additions and 47 deletions

View File

@ -41,15 +41,14 @@ import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.KahnsSort;
import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.Getter;
import lombok.Setter;
import lombok.val;
import javax.annotation.Nullable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.Setter;
import lombok.val;
public final class Scene {
@Getter private final World world;

View File

@ -1,15 +1,13 @@
package emu.grasscutter.plugin;
import static emu.grasscutter.utils.Language.translate;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.server.event.Event;
import emu.grasscutter.server.event.EventHandler;
import emu.grasscutter.server.event.HandlerPriority;
import emu.grasscutter.utils.FileUtils;
import emu.grasscutter.utils.JsonUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
@ -20,8 +18,9 @@ import java.net.URLClassLoader;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import static emu.grasscutter.utils.Language.translate;
import javax.annotation.Nullable;
import lombok.AllArgsConstructor;
import lombok.Getter;
/** Manages the server's plugins and the event system. */
public final class PluginManager {

View File

@ -1,5 +1,7 @@
package emu.grasscutter.server.http.documentation;
import static emu.grasscutter.config.Configuration.HANDBOOK;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerRunMode;
import emu.grasscutter.data.GameData;
@ -11,11 +13,8 @@ import emu.grasscutter.utils.FileUtils;
import emu.grasscutter.utils.objects.HandbookBody;
import io.javalin.Javalin;
import io.javalin.http.Context;
import java.util.Objects;
import static emu.grasscutter.config.Configuration.HANDBOOK;
/** Handles requests for the new GM Handbook. */
public final class HandbookHandler implements Router {
private final byte[] handbook;
@ -103,8 +102,7 @@ public final class HandbookHandler implements Router {
var avatar = new Avatar(avatarData);
avatar.setLevel(request.getLevel());
avatar.setPromoteLevel(Avatar.getMinPromoteLevel(avatar.getLevel()));
Objects.requireNonNull(avatar
.getSkillDepot())
Objects.requireNonNull(avatar.getSkillDepot())
.getSkillsAndEnergySkill()
.forEach(id -> avatar.setSkillLevel(id, request.getTalentLevels()));
avatar.forceConstellationLevel(request.getConstellations());
@ -215,8 +213,7 @@ public final class HandbookHandler implements Router {
var position = scene.getDefaultLocation(player);
var rotation = scene.getDefaultRotation(player);
// Teleport the player.
scene.getWorld().transferPlayerToScene(
player, scene.getId(), position);
scene.getWorld().transferPlayerToScene(player, scene.getId(), position);
player.getRotation().set(rotation);
ctx.json(HandbookBody.Response.builder().status(200).message("Player teleported.").build());

View File

@ -1,5 +1,8 @@
package emu.grasscutter.tools;
import static emu.grasscutter.utils.FileUtils.getResourcePath;
import static emu.grasscutter.utils.Language.getTextMapKey;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.CommandHandler;
@ -17,10 +20,6 @@ import emu.grasscutter.utils.Language;
import emu.grasscutter.utils.Language.TextStrings;
import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.val;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@ -32,9 +31,9 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import static emu.grasscutter.utils.FileUtils.getResourcePath;
import static emu.grasscutter.utils.Language.getTextMapKey;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.val;
public final class Tools {
/**
@ -413,7 +412,10 @@ public final class Tools {
var file = FileUtils.getResourcePath("resources.info");
try (var reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
var resourceInfo = ResourceInfo.builder();
reader.lines().forEach(line -> {
reader
.lines()
.forEach(
line -> {
var split = line.split(":");
if (split.length != 2) return;
@ -425,8 +427,7 @@ public final class Tools {
case "repo" -> resourceInfo.repository(value);
case "ver" -> resourceInfo.version(value);
case "patches" -> resourceInfo.patches(value);
case "scripts" -> resourceInfo.scripts(
ScriptsType.valueOf(value.toUpperCase()));
case "scripts" -> resourceInfo.scripts(ScriptsType.valueOf(value.toUpperCase()));
case "hasserverres" -> resourceInfo.hasServerResources(
Boolean.parseBoolean(value));
case "hasscenescriptdata" -> resourceInfo.hasSceneScriptData(
@ -436,13 +437,12 @@ public final class Tools {
return resourceInfo.build();
} catch (Exception ignored) {
return new ResourceInfo(
null, null, null,
ScriptsType.UNKNOWN, false, false);
return new ResourceInfo(null, null, null, ScriptsType.UNKNOWN, false, false);
}
}
@AllArgsConstructor @Builder
@AllArgsConstructor
@Builder
public static class ResourceInfo {
private final String repository;
private final String version;