Commit 77076a76 authored by memetrollsXD's avatar memetrollsXD Committed by GitHub
Browse files

Merge branch 'development' into restart-command

parents 2632ae37 86694158
[submodule "Grasscutter-Protos"]
path = Grasscutter-Protos
url = https://github.com/Melledy/Grasscutter-Protos
Subproject commit 0537e9cc4c7856a7c6f88bbbaa908a80c4ee677e
...@@ -17,39 +17,24 @@ ...@@ -17,39 +17,24 @@
"gachaType": 301, "gachaType": 301,
"scheduleId": 903, "scheduleId": 903,
"bannerType": "EVENT", "bannerType": "EVENT",
"prefabPath": "GachaShowPanel_A076", "prefabPath": "GachaShowPanel_A079",
"previewPrefabPath": "UI_Tab_GachaShowPanel_A076", "previewPrefabPath": "UI_Tab_GachaShowPanel_A079",
"titlePath": "UI_GACHA_SHOW_PANEL_A076_TITLE", "titlePath": "UI_GACHA_SHOW_PANEL_A079_TITLE",
"costItem": 223, "costItem": 223,
"beginTime": 0, "beginTime": 0,
"endTime": 1924992000, "endTime": 1924992000,
"sortId": 9998, "sortId": 9998,
"maxItemType": 1, "maxItemType": 1,
"rateUpItems1": [1066], "rateUpItems1": [1002],
"rateUpItems2": [1023, 1043, 1064] "rateUpItems2": [1053, 1020, 1045]
},
{
"gachaType": 400,
"scheduleId": 913,
"bannerType": "EVENT",
"prefabPath": "GachaShowPanel_A077",
"previewPrefabPath": "UI_Tab_GachaShowPanel_A077",
"titlePath": "UI_Tab_GachaShowPanel_A077",
"costItem": 223,
"beginTime": 0,
"endTime": 1924992000,
"sortId": 9998,
"maxItemType": 1,
"rateUpItems1": [1022],
"rateUpItems2": [1023, 1043, 1064]
}, },
{ {
"gachaType": 302, "gachaType": 302,
"scheduleId": 923, "scheduleId": 913,
"bannerType": "WEAPON", "bannerType": "WEAPON",
"prefabPath": "GachaShowPanel_A078", "prefabPath": "GachaShowPanel_A080",
"previewPrefabPath": "UI_Tab_GachaShowPanel_A078", "previewPrefabPath": "UI_Tab_GachaShowPanel_A080",
"titlePath": "UI_GACHA_SHOW_PANEL_A078_TITLE", "titlePath": "UI_GACHA_SHOW_PANEL_A080_TITLE",
"costItem": 223, "costItem": 223,
"beginTime": 0, "beginTime": 0,
"endTime": 1924992000, "endTime": 1924992000,
...@@ -58,7 +43,7 @@ ...@@ -58,7 +43,7 @@
"eventChance": 75, "eventChance": 75,
"softPity": 80, "softPity": 80,
"hardPity": 80, "hardPity": 80,
"rateUpItems1": [11510, 15503], "rateUpItems1": [11509, 12504],
"rateUpItems2": [11402, 12403, 13401, 14402, 15405] "rateUpItems2": [11401, 12402, 13407, 14401, 15401]
} }
] ]
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
# #
## ##
from mitmproxy import ctx, http from mitmproxy import http
class MlgmXyysd_Genshin_Impact_Proxy: class MlgmXyysd_Genshin_Impact_Proxy:
...@@ -53,14 +53,11 @@ class MlgmXyysd_Genshin_Impact_Proxy: ...@@ -53,14 +53,11 @@ class MlgmXyysd_Genshin_Impact_Proxy:
"hk4e-sdk-os-static.hoyoverse.com", "hk4e-sdk-os-static.hoyoverse.com",
"sdk-os-static.hoyoverse.com", "sdk-os-static.hoyoverse.com",
"api-account-os.hoyoverse.com", "api-account-os.hoyoverse.com",
"hk4e-sdk-os.hoyoverse.com" "hk4e-sdk-os.hoyoverse.com",
"overseauspider.yuanshen.com"
] ]
if flow.request.url.startswith("http://overseauspider.yuanshen.com:8888/log"): if flow.request.host in LIST_DOMAINS:
ctx.log.info("Block overseauspider.yuanshen.com")
flow.response = http.HTTPResponse.make(404)
elif flow.request.host in LIST_DOMAINS:
ctx.log.info("Redirect " + flow.request.host)
flow.request.host = REMOTE_HOST flow.request.host = REMOTE_HOST
addons = [ addons = [
......
@echo off
::This will not work if your java is in a different location, plugin as necessary
::this just saves you from changing your PATH
"C:\Program Files\Java\jdk1.8.0_202\bin\java.exe" -jar ./grasscutter.jar
\ No newline at end of file
...@@ -7,9 +7,11 @@ import java.lang.annotation.RetentionPolicy; ...@@ -7,9 +7,11 @@ import java.lang.annotation.RetentionPolicy;
public @interface Command { public @interface Command {
String label() default ""; String label() default "";
String usage() default ""; String usage() default "No usage specified";
String[] aliases() default {""}; String description() default "No description specified";
String[] aliases() default {};
Execution execution() default Execution.ALL; Execution execution() default Execution.ALL;
......
...@@ -68,10 +68,12 @@ public final class CommandMap { ...@@ -68,10 +68,12 @@ public final class CommandMap {
* Returns a list of all registered commands. * Returns a list of all registered commands.
* @return All command handlers as a list. * @return All command handlers as a list.
*/ */
public List<CommandHandler> getHandlers() { public List<CommandHandler> getHandlersAsList() {
return new LinkedList<>(this.commands.values()); return new LinkedList<>(this.commands.values());
} }
public HashMap<String, CommandHandler> getHandlers() { return new LinkedHashMap<>(this.commands); }
/** /**
* Returns a handler by label/alias. * Returns a handler by label/alias.
* @param label The command label. * @param label The command label.
...@@ -111,8 +113,7 @@ public final class CommandMap { ...@@ -111,8 +113,7 @@ public final class CommandMap {
if(player != null) { if(player != null) {
String permissionNode = this.annotations.get(label).permission(); String permissionNode = this.annotations.get(label).permission();
Account account = player.getAccount(); Account account = player.getAccount();
List<String> permissions = account.getPermissions(); if(permissionNode != "" && !account.hasPermission(permissionNode)) {
if(!permissions.contains("*") && !permissions.contains(permissionNode)) {
CommandHandler.sendMessage(player, "You do not have permission to run this command."); return; CommandHandler.sendMessage(player, "You do not have permission to run this command."); return;
} }
} }
......
...@@ -5,14 +5,13 @@ import emu.grasscutter.database.DatabaseHelper; ...@@ -5,14 +5,13 @@ import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.GenshinPlayer;
import java.util.List; import java.util.*;
import java.util.stream.Collectors;
/** /**
* A container for server-related commands. * A container for server-related commands.
*/ */
public final class ServerCommands { public final class ServerCommands {
@Command(label = "reload", usage = "Usage: reload") @Command(label = "reload", usage = "reload", description = "Reload server config", permission = "server.reload")
public static class ReloadCommand implements CommandHandler { public static class ReloadCommand implements CommandHandler {
@Override @Override
...@@ -25,12 +24,87 @@ public final class ServerCommands { ...@@ -25,12 +24,87 @@ public final class ServerCommands {
@Override @Override
public void execute(GenshinPlayer player, List<String> args) { public void execute(GenshinPlayer player, List<String> args) {
CommandHandler.sendMessage(player, "Reloading config.");
this.execute(args); this.execute(args);
CommandHandler.sendMessage(player, "Reload complete.");
}
}
@Command(label = "kick", usage = "kick <player>", description = "Kicks the specified player from the server (WIP)", permission = "server.kick")
public static class KickCommand implements CommandHandler {
@Override
public void execute(List<String> args) {
this.execute(null, args);
}
@Override
public void execute(GenshinPlayer player, List<String> args) {
int target = Integer.parseInt(args.get(0));
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if(targetPlayer == null) {
CommandHandler.sendMessage(player, "Player not found.");
return;
}
if(player != null) {
CommandHandler.sendMessage(null, String.format("Player [%s:%s] has kicked player [%s:%s]", player.getAccount().getPlayerId(), player.getAccount().getUsername(), target, targetPlayer.getAccount().getUsername()));
}
CommandHandler.sendMessage(player, String.format("Kicking player [%s:%s]", target, targetPlayer.getAccount().getUsername()));
targetPlayer.getSession().close();
}
}
@Command(label = "stop", usage = "stop", description = "Stops the server", permission = "server.stop")
public static class StopCommand implements CommandHandler {
@Override
public void execute(List<String> args) {
Grasscutter.getLogger().info("Server shutting down...");
for (GenshinPlayer p : Grasscutter.getGameServer().getPlayers().values()) {
p.dropMessage("Server shutting down...");
}
System.exit(1);
}
}
@Command(label = "broadcast", aliases = {"b"},
usage = "broadcast <message>", description = "Sends a message to all the players", permission = "server.broadcast")
public static class BroadcastCommand implements CommandHandler {
@Override
public void execute(List<String> args) {
if(args.size() < 1) {
CommandHandler.sendMessage(null, "Usage: broadcast <message>"); return;
}
String message = String.join(" ", args.subList(0, args.size()));
for (GenshinPlayer p : Grasscutter.getGameServer().getPlayers().values()) {
p.dropMessage(message);
}
CommandHandler.sendMessage(null, "Message sent.");
}
@Override
public void execute(GenshinPlayer player, List<String> args) {
if(args.size() < 1) {
CommandHandler.sendMessage(player, "Usage: broadcast <message>"); return;
}
String message = String.join(" ", args.subList(0, args.size()));
for (GenshinPlayer p : Grasscutter.getGameServer().getPlayers().values()) {
p.dropMessage(message);
}
CommandHandler.sendMessage(player, "Message sent.");
} }
} }
@Command(label = "sendmessage", aliases = {"sendmsg", "msg"}, @Command(label = "sendmessage", aliases = {"sendmsg", "msg"},
usage = "Usage: sendmessage <player> <message>") usage = "sendmessage <player> <message>", description = "Sends a message to a player")
public static class SendMessageCommand implements CommandHandler { public static class SendMessageCommand implements CommandHandler {
@Override @Override
...@@ -81,8 +155,8 @@ public final class ServerCommands { ...@@ -81,8 +155,8 @@ public final class ServerCommands {
} }
@Command(label = "account", @Command(label = "account",
usage = "Usage: account <create|delete> <username> [uid]", usage = "account <create|delete> <username> [uid]",
execution = Command.Execution.CONSOLE) description = "Modify user accounts", execution = Command.Execution.CONSOLE)
public static class AccountCommand implements CommandHandler { public static class AccountCommand implements CommandHandler {
@Override @Override
...@@ -126,8 +200,8 @@ public final class ServerCommands { ...@@ -126,8 +200,8 @@ public final class ServerCommands {
} }
@Command(label = "permission", @Command(label = "permission",
usage = "Usage: permission <add|remove> <username> <permission>", usage = "permission <add|remove> <username> <permission>",
execution = Command.Execution.CONSOLE) description = "Grants or removes a permission for a user", permission = "*")
public static class PermissionCommand implements CommandHandler { public static class PermissionCommand implements CommandHandler {
@Override @Override
...@@ -166,50 +240,93 @@ public final class ServerCommands { ...@@ -166,50 +240,93 @@ public final class ServerCommands {
} }
@Command(label = "help", @Command(label = "help",
usage = "Usage: help [command]") usage = "help [command]", description = "Sends the help message or shows information about a specified command")
public static class HelpCommand implements CommandHandler { public static class HelpCommand implements CommandHandler {
@Override @Override
public void execute(List<String> args) { public void execute(List<String> args) {
List<CommandHandler> handlers = CommandMap.getInstance().getHandlers(); this.execute(null, args);
List<Command> annotations = handlers.stream() }
.map(handler -> handler.getClass().getAnnotation(Command.class))
.collect(Collectors.toList());
@Override
public void execute(GenshinPlayer player, List<String> args) {
if(args.size() < 1) { if(args.size() < 1) {
StringBuilder builder = new StringBuilder("Available commands:\n"); HashMap<String, CommandHandler> handlers = CommandMap.getInstance().getHandlers();
annotations.forEach(annotation -> builder.append(annotation.usage()).append("\n")); List<Command> annotations = new ArrayList<>();
CommandHandler.sendMessage(null, builder.toString()); for(String key : handlers.keySet()) {
Command annotation = handlers.get(key).getClass().getAnnotation(Command.class);
if(!Arrays.asList(annotation.aliases()).contains(key)) {
if(player != null && !Objects.equals(annotation.permission(), "") && !player.getAccount().hasPermission(annotation.permission())) continue;
annotations.add(annotation);
}
}
SendAllHelpMessage(player, annotations);
} else { } else {
String command = args.get(0); String command = args.get(0);
CommandHandler handler = CommandMap.getInstance().getHandler(command); CommandHandler handler = CommandMap.getInstance().getHandler(command);
StringBuilder builder = new StringBuilder(player == null ? "\nHelp - " : "Help - ").append(command).append(": \n");
if(handler == null) { if(handler == null) {
CommandHandler.sendMessage(null, "Command not found."); return; builder.append("No command found.");
} else {
Command annotation = handler.getClass().getAnnotation(Command.class);
builder.append(" ").append(annotation.description()).append("\n");
builder.append(" Usage: ").append(annotation.usage());
if(annotation.aliases().length >= 1) {
builder.append("\n").append(" Aliases: ");
for (String alias : annotation.aliases()) {
builder.append(alias).append(" ");
}
}
if(player != null && !Objects.equals(annotation.permission(), "") && !player.getAccount().hasPermission(annotation.permission())) {
builder.append("\n Warning: You do not have permission to run this command.");
}
} }
Command annotation = handler.getClass().getAnnotation(Command.class); CommandHandler.sendMessage(player, builder.toString());
CommandHandler.sendMessage(null, annotation.usage());
} }
} }
@Override void SendAllHelpMessage(GenshinPlayer player, List<Command> annotations) {
public void execute(GenshinPlayer player, List<String> args) { if(player == null) {
List<CommandHandler> handlers = CommandMap.getInstance().getHandlers(); StringBuilder builder = new StringBuilder("\nAvailable commands:\n");
List<Command> annotations = handlers.stream() annotations.forEach(annotation -> {
.map(handler -> handler.getClass().getAnnotation(Command.class)) if (annotation.execution() != Command.Execution.PLAYER) {
.collect(Collectors.toList()); builder.append(annotation.label()).append("\n");
builder.append(" ").append(annotation.description()).append("\n");
builder.append(" Usage: ").append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(" Aliases: ");
for (String alias : annotation.aliases()) {
builder.append(alias).append(" ");
}
}
if(args.size() < 1) { builder.append("\n");
annotations.forEach(annotation -> player.dropMessage(annotation.usage())); }
});
CommandHandler.sendMessage(null, builder.toString());
} else { } else {
String command = args.get(0); CommandHandler.sendMessage(player, "Available commands:");
CommandHandler handler = CommandMap.getInstance().getHandler(command); annotations.forEach(annotation -> {
if(handler == null) { if (annotation.execution() != Command.Execution.CONSOLE) {
CommandHandler.sendMessage(player, "Command not found."); return; StringBuilder builder = new StringBuilder(annotation.label()).append("\n");
builder.append(" ").append(annotation.description()).append("\n");
builder.append(" Usage: ").append(annotation.usage());
if (annotation.aliases().length >= 1) {
builder.append("\n").append(" Aliases: ");
for (String alias : annotation.aliases()) {
builder.append(alias).append(" ");
}
} }
Command annotation = handler.getClass().getAnnotation(Command.class); CommandHandler.sendMessage(player, builder.toString());
CommandHandler.sendMessage(player, annotation.usage()); }
});
} }
} }
} }
......
...@@ -197,7 +197,7 @@ public class ResourceLoader { ...@@ -197,7 +197,7 @@ public class ResourceLoader {
} else { } else {
Map<String, OpenConfigEntry> map = new TreeMap<>(); Map<String, OpenConfigEntry> map = new TreeMap<>();
java.lang.reflect.Type type = new TypeToken<Map<String, OpenConfigData[]>>() {}.getType(); java.lang.reflect.Type type = new TypeToken<Map<String, OpenConfigData[]>>() {}.getType();
String[] folderNames = {"BinOutput\\Talent\\EquipTalents\\", "BinOutput\\Talent\\AvatarTalents\\"}; String[] folderNames = {"BinOutput/Talent/EquipTalents/", "BinOutput/Talent/AvatarTalents/"};
for (String name : folderNames) { for (String name : folderNames) {
File folder = new File(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + name)); File folder = new File(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + name));
......
...@@ -106,6 +106,10 @@ public class Account { ...@@ -106,6 +106,10 @@ public class Account {
this.permissions.add(permission); return true; this.permissions.add(permission); return true;
} }
public boolean hasPermission(String permission) {
return this.permissions.contains(permission) || this.permissions.contains("*") ? true : false;
}
public boolean removePermission(String permission) { public boolean removePermission(String permission) {
return this.permissions.remove(permission); return this.permissions.remove(permission);
} }
......
...@@ -471,7 +471,7 @@ public class InventoryManager { ...@@ -471,7 +471,7 @@ public class InventoryManager {
} }
// Consume weapon // Consume weapon
player.getInventory().removeItem(feed); player.getInventory().removeItem(feed, 1);
// Get // Get
weapon.setRefinement(targetRefineLevel); weapon.setRefinement(targetRefineLevel);
...@@ -804,6 +804,12 @@ public class InventoryManager { ...@@ -804,6 +804,12 @@ public class InventoryManager {
// Get talent // Get talent
int currentTalentLevel = avatar.getCoreProudSkillLevel(); int currentTalentLevel = avatar.getCoreProudSkillLevel();
int nextTalentId = ((avatar.getAvatarId() % 10000000) * 10) + currentTalentLevel + 1; int nextTalentId = ((avatar.getAvatarId() % 10000000) * 10) + currentTalentLevel + 1;
if (avatar.getAvatarId() == 10000006) {
// Lisa is special in that her talentId starts with 4 instead of 6.
nextTalentId = 40 + currentTalentLevel + 1;
}
AvatarTalentData talentData = GenshinData.getAvatarTalentDataMap().get(nextTalentId); AvatarTalentData talentData = GenshinData.getAvatarTalentDataMap().get(nextTalentId);
if (talentData == null) { if (talentData == null) {
......
...@@ -389,6 +389,10 @@ public final class DispatchServer { ...@@ -389,6 +389,10 @@ public final class DispatchServer {
"/sdk/upload", "/sdk/upload",
new DispatchHttpJsonHandler("{\"code\":0}") new DispatchHttpJsonHandler("{\"code\":0}")
); );
server.createContext( // /perf/config/verify?device_id=xxx&platform=x&name=xxx
"/perf/config/verify",
new DispatchHttpJsonHandler("{\"code\":0}")
);
// Start server // Start server
server.start(); server.start();
Grasscutter.getLogger().info("Dispatch server started on port " + getAddress().getPort()); Grasscutter.getLogger().info("Dispatch server started on port " + getAddress().getPort());
......
...@@ -59,6 +59,7 @@ public class PacketPlayerEnterSceneNotify extends GenshinPacket { ...@@ -59,6 +59,7 @@ public class PacketPlayerEnterSceneNotify extends GenshinPacket {
.setEnterReason(reason.getValue()) .setEnterReason(reason.getValue())
.addSceneTagIdList(102) .addSceneTagIdList(102)
.addSceneTagIdList(107) .addSceneTagIdList(107)
.addSceneTagIdList(109)
.addSceneTagIdList(113) .addSceneTagIdList(113)
.addSceneTagIdList(117) .addSceneTagIdList(117)
.setUnk1(1) .setUnk1(1)
......
...@@ -21,6 +21,7 @@ import emu.grasscutter.data.def.AvatarData; ...@@ -21,6 +21,7 @@ import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.data.def.MonsterData; import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.data.def.SceneData; import emu.grasscutter.data.def.SceneData;
import emu.grasscutter.utils.Utils;
public final class Tools { public final class Tools {
...@@ -29,7 +30,7 @@ public final class Tools { ...@@ -29,7 +30,7 @@ public final class Tools {
ResourceLoader.loadResources(); ResourceLoader.loadResources();
Map<Long, String> map; Map<Long, String> map;
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMapEN.json")) { try (FileReader fileReader = new FileReader(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMap/TextMapEN.json"))) {
map = Grasscutter.getGsonFactory().fromJson(fileReader, new TypeToken<Map<Long, String>>() {}.getType()); map = Grasscutter.getGsonFactory().fromJson(fileReader, new TypeToken<Map<Long, String>>() {}.getType());
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment