mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 00:12:29 +00:00
Format code [skip actions]
This commit is contained in:
parent
8c0045a8d7
commit
ff124095bb
@ -41,15 +41,14 @@ import emu.grasscutter.server.packet.send.*;
|
|||||||
import emu.grasscutter.utils.KahnsSort;
|
import emu.grasscutter.utils.KahnsSort;
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
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.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.val;
|
||||||
|
|
||||||
public final class Scene {
|
public final class Scene {
|
||||||
@Getter private final World world;
|
@Getter private final World world;
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package emu.grasscutter.plugin;
|
package emu.grasscutter.plugin;
|
||||||
|
|
||||||
|
import static emu.grasscutter.utils.Language.translate;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.server.event.Event;
|
import emu.grasscutter.server.event.Event;
|
||||||
import emu.grasscutter.server.event.EventHandler;
|
import emu.grasscutter.server.event.EventHandler;
|
||||||
import emu.grasscutter.server.event.HandlerPriority;
|
import emu.grasscutter.server.event.HandlerPriority;
|
||||||
import emu.grasscutter.utils.FileUtils;
|
import emu.grasscutter.utils.FileUtils;
|
||||||
import emu.grasscutter.utils.JsonUtils;
|
import emu.grasscutter.utils.JsonUtils;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -20,8 +18,9 @@ import java.net.URLClassLoader;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import static emu.grasscutter.utils.Language.translate;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/** Manages the server's plugins and the event system. */
|
/** Manages the server's plugins and the event system. */
|
||||||
public final class PluginManager {
|
public final class PluginManager {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package emu.grasscutter.server.http.documentation;
|
package emu.grasscutter.server.http.documentation;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.HANDBOOK;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.Grasscutter.ServerRunMode;
|
import emu.grasscutter.Grasscutter.ServerRunMode;
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
@ -11,11 +13,8 @@ import emu.grasscutter.utils.FileUtils;
|
|||||||
import emu.grasscutter.utils.objects.HandbookBody;
|
import emu.grasscutter.utils.objects.HandbookBody;
|
||||||
import io.javalin.Javalin;
|
import io.javalin.Javalin;
|
||||||
import io.javalin.http.Context;
|
import io.javalin.http.Context;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static emu.grasscutter.config.Configuration.HANDBOOK;
|
|
||||||
|
|
||||||
/** Handles requests for the new GM Handbook. */
|
/** Handles requests for the new GM Handbook. */
|
||||||
public final class HandbookHandler implements Router {
|
public final class HandbookHandler implements Router {
|
||||||
private final byte[] handbook;
|
private final byte[] handbook;
|
||||||
@ -103,8 +102,7 @@ public final class HandbookHandler implements Router {
|
|||||||
var avatar = new Avatar(avatarData);
|
var avatar = new Avatar(avatarData);
|
||||||
avatar.setLevel(request.getLevel());
|
avatar.setLevel(request.getLevel());
|
||||||
avatar.setPromoteLevel(Avatar.getMinPromoteLevel(avatar.getLevel()));
|
avatar.setPromoteLevel(Avatar.getMinPromoteLevel(avatar.getLevel()));
|
||||||
Objects.requireNonNull(avatar
|
Objects.requireNonNull(avatar.getSkillDepot())
|
||||||
.getSkillDepot())
|
|
||||||
.getSkillsAndEnergySkill()
|
.getSkillsAndEnergySkill()
|
||||||
.forEach(id -> avatar.setSkillLevel(id, request.getTalentLevels()));
|
.forEach(id -> avatar.setSkillLevel(id, request.getTalentLevels()));
|
||||||
avatar.forceConstellationLevel(request.getConstellations());
|
avatar.forceConstellationLevel(request.getConstellations());
|
||||||
@ -215,8 +213,7 @@ public final class HandbookHandler implements Router {
|
|||||||
var position = scene.getDefaultLocation(player);
|
var position = scene.getDefaultLocation(player);
|
||||||
var rotation = scene.getDefaultRotation(player);
|
var rotation = scene.getDefaultRotation(player);
|
||||||
// Teleport the player.
|
// Teleport the player.
|
||||||
scene.getWorld().transferPlayerToScene(
|
scene.getWorld().transferPlayerToScene(player, scene.getId(), position);
|
||||||
player, scene.getId(), position);
|
|
||||||
player.getRotation().set(rotation);
|
player.getRotation().set(rotation);
|
||||||
|
|
||||||
ctx.json(HandbookBody.Response.builder().status(200).message("Player teleported.").build());
|
ctx.json(HandbookBody.Response.builder().status(200).message("Player teleported.").build());
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package emu.grasscutter.tools;
|
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.GameConstants;
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.command.CommandHandler;
|
import emu.grasscutter.command.CommandHandler;
|
||||||
@ -17,10 +20,6 @@ import emu.grasscutter.utils.Language;
|
|||||||
import emu.grasscutter.utils.Language.TextStrings;
|
import emu.grasscutter.utils.Language.TextStrings;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.val;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -32,9 +31,9 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.LongStream;
|
import java.util.stream.LongStream;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import static emu.grasscutter.utils.FileUtils.getResourcePath;
|
import lombok.Builder;
|
||||||
import static emu.grasscutter.utils.Language.getTextMapKey;
|
import lombok.val;
|
||||||
|
|
||||||
public final class Tools {
|
public final class Tools {
|
||||||
/**
|
/**
|
||||||
@ -413,36 +412,37 @@ public final class Tools {
|
|||||||
var file = FileUtils.getResourcePath("resources.info");
|
var file = FileUtils.getResourcePath("resources.info");
|
||||||
try (var reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
|
try (var reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
|
||||||
var resourceInfo = ResourceInfo.builder();
|
var resourceInfo = ResourceInfo.builder();
|
||||||
reader.lines().forEach(line -> {
|
reader
|
||||||
var split = line.split(":");
|
.lines()
|
||||||
if (split.length != 2) return;
|
.forEach(
|
||||||
|
line -> {
|
||||||
|
var split = line.split(":");
|
||||||
|
if (split.length != 2) return;
|
||||||
|
|
||||||
var key = split[0].trim();
|
var key = split[0].trim();
|
||||||
var value = split[1].trim();
|
var value = split[1].trim();
|
||||||
|
|
||||||
// Apply the value to the correct field.
|
// Apply the value to the correct field.
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "repo" -> resourceInfo.repository(value);
|
case "repo" -> resourceInfo.repository(value);
|
||||||
case "ver" -> resourceInfo.version(value);
|
case "ver" -> resourceInfo.version(value);
|
||||||
case "patches" -> resourceInfo.patches(value);
|
case "patches" -> resourceInfo.patches(value);
|
||||||
case "scripts" -> resourceInfo.scripts(
|
case "scripts" -> resourceInfo.scripts(ScriptsType.valueOf(value.toUpperCase()));
|
||||||
ScriptsType.valueOf(value.toUpperCase()));
|
case "hasserverres" -> resourceInfo.hasServerResources(
|
||||||
case "hasserverres" -> resourceInfo.hasServerResources(
|
Boolean.parseBoolean(value));
|
||||||
Boolean.parseBoolean(value));
|
case "hasscenescriptdata" -> resourceInfo.hasSceneScriptData(
|
||||||
case "hasscenescriptdata" -> resourceInfo.hasSceneScriptData(
|
Boolean.parseBoolean(value));
|
||||||
Boolean.parseBoolean(value));
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return resourceInfo.build();
|
return resourceInfo.build();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
return new ResourceInfo(
|
return new ResourceInfo(null, null, null, ScriptsType.UNKNOWN, false, false);
|
||||||
null, null, null,
|
|
||||||
ScriptsType.UNKNOWN, false, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor @Builder
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
public static class ResourceInfo {
|
public static class ResourceInfo {
|
||||||
private final String repository;
|
private final String repository;
|
||||||
private final String version;
|
private final String version;
|
||||||
|
Loading…
Reference in New Issue
Block a user