From d6653f03a77f414e2089998ad0ee38d2758a467b Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Fri, 22 Apr 2022 20:42:55 -0400 Subject: [PATCH 01/15] Move manifest to resources --- src/main/{java => resources}/META-INF/MANIFEST.MF | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/{java => resources}/META-INF/MANIFEST.MF (100%) diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF similarity index 100% rename from src/main/java/META-INF/MANIFEST.MF rename to src/main/resources/META-INF/MANIFEST.MF From 6243c4e6e8d82eb8f9084c8324049685a05b762b Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Fri, 22 Apr 2022 21:45:44 -0400 Subject: [PATCH 02/15] Basic plugin manager --- src/main/java/emu/grasscutter/Config.java | 3 +- .../java/emu/grasscutter/Grasscutter.java | 11 +- .../java/emu/grasscutter/plugin/Plugin.java | 71 ++++++++++++ .../emu/grasscutter/plugin/PluginConfig.java | 18 ++++ .../grasscutter/plugin/PluginIdentifier.java | 29 +++++ .../emu/grasscutter/plugin/PluginManager.java | 102 ++++++++++++++++++ .../java/emu/grasscutter/utils/Utils.java | 9 ++ 7 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 src/main/java/emu/grasscutter/plugin/Plugin.java create mode 100644 src/main/java/emu/grasscutter/plugin/PluginConfig.java create mode 100644 src/main/java/emu/grasscutter/plugin/PluginIdentifier.java create mode 100644 src/main/java/emu/grasscutter/plugin/PluginManager.java diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index 4a6f71680..7da51f912 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -1,7 +1,5 @@ package emu.grasscutter; -import java.util.ArrayList; - public final class Config { public String DatabaseUrl = "mongodb://localhost:27017"; @@ -12,6 +10,7 @@ public final class Config { public String PACKETS_FOLDER = "./packets/"; public String DUMPS_FOLDER = "./dumps/"; public String KEY_FOLDER = "./keys/"; + public String PLUGINS_FOLDER = "./plugins/"; public String RunMode = "HYBRID"; // HYBRID, DISPATCH_ONLY, GAME_ONLY public GameServerOptions GameServer = new GameServerOptions(); diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index abcdc3557..de7025b12 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -8,6 +8,7 @@ import java.io.InputStreamReader; import java.net.InetSocketAddress; import emu.grasscutter.command.CommandMap; +import emu.grasscutter.plugin.PluginManager; import emu.grasscutter.utils.Utils; import org.reflections.Reflections; import org.slf4j.LoggerFactory; @@ -35,6 +36,7 @@ public final class Grasscutter { private static GameServer gameServer; public static final Reflections reflector = new Reflections(); + public static final PluginManager pluginManager; static { // Declare logback configuration. @@ -45,6 +47,9 @@ public final class Grasscutter { // Check server structure. Utils.startupCheck(); + + // Call plugin manager. + pluginManager = new PluginManager(); } public static void main(String[] args) throws Exception { @@ -91,8 +96,6 @@ public final class Grasscutter { getLogger().error("Shutting down..."); System.exit(1); } - - // Open console. startConsole(); @@ -161,4 +164,8 @@ public final class Grasscutter { public static GameServer getGameServer() { return gameServer; } + + public static PluginManager getPluginManager() { + return pluginManager; + } } diff --git a/src/main/java/emu/grasscutter/plugin/Plugin.java b/src/main/java/emu/grasscutter/plugin/Plugin.java new file mode 100644 index 000000000..145a06eb8 --- /dev/null +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -0,0 +1,71 @@ +package emu.grasscutter.plugin; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.server.game.GameServer; + +/** + * The base class for all plugins to extend. + */ +public abstract class Plugin { + private final PluginIdentifier identifier; + + /** + * Empty constructor for developers. + * Should not be called by users. + */ + public Plugin() { + this(new PluginIdentifier("", "", "", new String[]{})); + } + + /** + * Constructor for plugins. + * @param identifier The plugin's identifier. + */ + public Plugin(PluginIdentifier identifier) { + this.identifier = identifier; + } + + /** + * The plugin's identifier instance. + * @return An instance of {@link PluginIdentifier}. + */ + public final PluginIdentifier getIdentifier(){ + return this.identifier; + } + + /** + * Get the plugin's name. + */ + public final String getName() { + return this.identifier.name; + } + + /** + * Get the plugin's description. + */ + public final String getDescription() { + return this.identifier.description; + } + + /** + * Get the plugin's version. + */ + public final String getVersion() { + return this.identifier.version; + } + + /** + * Returns the server that initialized the plugin. + * @return A server instance. + */ + public final GameServer getServer() { + return Grasscutter.getGameServer(); + } + + /* Called when the plugin is first loaded. */ + public void onLoad() { } + /* Called after (most of) the server enables. */ + public void onEnable() { } + /* Called before the server disables. */ + public void onDisable() { } +} diff --git a/src/main/java/emu/grasscutter/plugin/PluginConfig.java b/src/main/java/emu/grasscutter/plugin/PluginConfig.java new file mode 100644 index 000000000..0fb07037c --- /dev/null +++ b/src/main/java/emu/grasscutter/plugin/PluginConfig.java @@ -0,0 +1,18 @@ +package emu.grasscutter.plugin; + +/** + * The data contained in the plugin's `plugin.json` file. + */ +public final class PluginConfig { + public String name, description, version; + public String mainClass; + public String[] authors; + + /** + * Attempts to validate this config instance. + * @return True if the config is valid, false otherwise. + */ + public boolean validate() { + return name != null && description != null && mainClass != null; + } +} diff --git a/src/main/java/emu/grasscutter/plugin/PluginIdentifier.java b/src/main/java/emu/grasscutter/plugin/PluginIdentifier.java new file mode 100644 index 000000000..a467e3949 --- /dev/null +++ b/src/main/java/emu/grasscutter/plugin/PluginIdentifier.java @@ -0,0 +1,29 @@ +package emu.grasscutter.plugin; + +// TODO: Potentially replace with Lombok? +public final class PluginIdentifier { + public final String name, description, version; + public final String[] authors; + + public PluginIdentifier( + String name, String description, String version, + String[] authors + ) { + this.name = name; + this.description = description; + this.version = version; + this.authors = authors; + } + + /** + * Converts a {@link PluginConfig} into a {@link PluginIdentifier}. + */ + public static PluginIdentifier fromPluginConfig(PluginConfig config) { + if(!config.validate()) + throw new IllegalArgumentException("A valid plugin config is required to convert into a plugin identifier."); + return new PluginIdentifier( + config.name, config.description, config.version, + config.authors + ); + } +} diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java new file mode 100644 index 000000000..3177bb291 --- /dev/null +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -0,0 +1,102 @@ +package emu.grasscutter.plugin; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.utils.Utils; + +import java.io.File; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Manages the server's plugins & the event system. + */ +public final class PluginManager { + private final Map plugins = new HashMap<>(); + + public PluginManager() { + this.loadPlugins(); // Load all plugins from the plugins directory. + } + + /** + * Loads plugins from the config-specified directory. + */ + private void loadPlugins() { + String directory = Grasscutter.getConfig().PLUGINS_FOLDER; + File pluginsDir = new File(Utils.toFilePath(directory)); + if(!pluginsDir.exists() && !pluginsDir.mkdirs()) { + Grasscutter.getLogger().error("Failed to create plugins directory: " + pluginsDir.getAbsolutePath()); + return; + } + + File[] files = pluginsDir.listFiles(); + if(files == null) { + // The directory is empty, there aren't any plugins to load. + return; + } + + List plugins = Arrays.stream(files) + .filter(file -> file.getName().endsWith(".jar")) + .collect(Collectors.toList()); + + plugins.forEach(plugin -> { + try { + URL url = plugin.toURI().toURL(); + try (URLClassLoader loader = new URLClassLoader(new URL[]{url})) { + URL configFile = loader.findResource("plugin.json"); + InputStreamReader fileReader = new InputStreamReader(configFile.openStream()); + + PluginConfig pluginConfig = Grasscutter.getGsonFactory().fromJson(fileReader, PluginConfig.class); + if(!pluginConfig.validate()) { + Utils.logObject(pluginConfig); + Grasscutter.getLogger().warn("Plugin " + plugin.getName() + " has an invalid config file."); + return; + } + + Class pluginClass = loader.loadClass(pluginConfig.mainClass); + Plugin pluginInstance = (Plugin) pluginClass.getDeclaredConstructor(PluginIdentifier.class) + .newInstance(PluginIdentifier.fromPluginConfig(pluginConfig)); + this.loadPlugin(pluginInstance); + + fileReader.close(); // Close the file reader. + } catch (ClassNotFoundException ignored) { + Grasscutter.getLogger().warn("Plugin " + plugin.getName() + " has an invalid main class."); + } + } catch (Exception exception) { + Grasscutter.getLogger().error("Failed to load plugin: " + plugin.getName(), exception); + } + }); + } + + /** + * Load the specified plugin. + * @param plugin The plugin instance. + */ + private void loadPlugin(Plugin plugin) { + Grasscutter.getLogger().info("Loading plugin: " + plugin.getName()); + + // Add the plugin to the list of loaded plugins. + this.plugins.put(plugin.getName(), plugin); + // Call the plugin's onLoad method. + plugin.onLoad(); + } + + /** + * Enables all registered plugins. + */ + public void enablePlugins() { + + } + + /** + * Disables all registered plugins. + */ + public void disablePlugins() { + + } +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/utils/Utils.java b/src/main/java/emu/grasscutter/utils/Utils.java index c481ffd07..5b7b8c439 100644 --- a/src/main/java/emu/grasscutter/utils/Utils.java +++ b/src/main/java/emu/grasscutter/utils/Utils.java @@ -137,6 +137,15 @@ public final class Utils { return nonNull != null ? nonNull : fallback; } + /** + * Logs an object to the console. + * @param object The object to log. + */ + public static void logObject(Object object) { + String asJson = Grasscutter.getGsonFactory().toJson(object); + Grasscutter.getLogger().info(asJson); + } + /** * Checks for required files and folders before startup. */ From ec6a54ebd738aebd7e03c490e04a52532c3e6727 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 23 Apr 2022 00:55:31 -0400 Subject: [PATCH 03/15] Merge `origin/development` into `plugin-system` --- README.md | 2 +- build.gradle | 11 +- keystore.p12 | Bin 2389 -> 2679 bytes src/main/java/emu/grasscutter/Config.java | 2 +- .../emu/grasscutter/command/CommandMap.java | 1 + .../command/commands/ClearWeaponsCommand.java | 29 + .../grasscutter/database/DatabaseCounter.java | 2 +- .../grasscutter/database/DatabaseHelper.java | 117 +-- .../grasscutter/database/DatabaseManager.java | 54 +- .../java/emu/grasscutter/game/Account.java | 30 +- .../emu/grasscutter/game/GenshinPlayer.java | 18 +- .../java/emu/grasscutter/game/TeamInfo.java | 2 + .../emu/grasscutter/game/TeamManager.java | 2 + .../game/avatar/AvatarProfileData.java | 3 + .../game/avatar/GenshinAvatar.java | 2 +- .../grasscutter/game/friends/Friendship.java | 2 +- .../game/friends/PlayerProfile.java | 1 + .../game/gacha/PlayerGachaBannerInfo.java | 3 + .../game/gacha/PlayerGachaInfo.java | 3 + .../game/inventory/GenshinItem.java | 2 +- .../game/player/PlayerBirthday.java | 68 ++ .../grasscutter/net/packet/PacketOpcodes.java | 3 +- .../net/proto/BirthdayOuterClass.java | 10 +- .../EvtAvatarSitDownNotifyOuterClass.java | 816 ++++++++++++++++++ .../proto/SetPlayerBirthdayReqOuterClass.java | 674 +++++++++++++++ .../proto/SetPlayerBirthdayRspOuterClass.java | 674 +++++++++++++++ .../net/proto/SitReqOuterClass.java | 744 ++++++++++++++++ .../net/proto/SitRspOuterClass.java | 815 +++++++++++++++++ .../recv/HandleEvtAvatarSitDownNotify.java | 21 + .../server/packet/recv/HandleSitReq.java | 24 + .../recv/HandlerSetPlayerBirthdayReq.java | 38 + .../send/PacketEvtAvatarSitDownNotify.java | 20 + .../send/PacketSetPlayerBirthdayRsp.java | 20 + .../server/packet/send/PacketSitRsp.java | 21 + .../java/emu/grasscutter/utils/Position.java | 2 + start.cmd | 4 + 36 files changed, 4102 insertions(+), 138 deletions(-) create mode 100644 src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java create mode 100644 src/main/java/emu/grasscutter/game/player/PlayerBirthday.java create mode 100644 src/main/java/emu/grasscutter/net/proto/EvtAvatarSitDownNotifyOuterClass.java create mode 100644 src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayReqOuterClass.java create mode 100644 src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayRspOuterClass.java create mode 100644 src/main/java/emu/grasscutter/net/proto/SitReqOuterClass.java create mode 100644 src/main/java/emu/grasscutter/net/proto/SitRspOuterClass.java create mode 100644 src/main/java/emu/grasscutter/server/packet/recv/HandleEvtAvatarSitDownNotify.java create mode 100644 src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java create mode 100644 src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java create mode 100644 src/main/java/emu/grasscutter/server/packet/send/PacketEvtAvatarSitDownNotify.java create mode 100644 src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java create mode 100644 src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java diff --git a/README.md b/README.md index 853c37ae3..e6843b116 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ A WIP server reimplementation for *some anime game* 2.3-2.6 * If you update from an older version, delete `config.json` for regeneration ### Prerequisites -* JDK-8u202 ([mirror link](https://mirrors.huaweicloud.com/java/jdk/8u202-b08/) since Oracle required an account to download old builds) +* Java 16 * Mongodb (recommended 4.0+) * Proxy daemon: mitmproxy (mitmdump, recommended), Fiddler Classic, etc. diff --git a/build.gradle b/build.gradle index 97477456a..dcc109d0e 100644 --- a/build.gradle +++ b/build.gradle @@ -14,17 +14,16 @@ plugins { id 'application' } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 16 +targetCompatibility = 16 repositories { mavenCentral() - jcenter() } dependencies { implementation fileTree(dir: 'lib', include: ['*.jar']) - + implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.32' implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.6' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.6' @@ -33,9 +32,9 @@ dependencies { implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.8' implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.18.1' - implementation group: 'org.reflections', name: 'reflections', version: '0.9.12' + implementation group: 'org.reflections', name: 'reflections', version: '0.10.2' - implementation group: 'dev.morphia.morphia', name: 'core', version: '1.6.1' + implementation group: 'dev.morphia.morphia', name: 'morphia-core', version: '2.2.6' implementation group: 'org.greenrobot', name: 'eventbus-java', version: '3.3.1' } diff --git a/keystore.p12 b/keystore.p12 index 9fa5cf19c6611eeada69c4d18df372578eef4845..5ea492e292dce655be2b7b8adaca0293427000d7 100644 GIT binary patch literal 2679 zcmY+EcQ_l27RD1ID$;?_Qc+4N@exGrRch2GV%3UWJ4UreD>O!}qDJi!BSuS&+Iy6i zpkh?*T~(Bt<+}H|_xqmv$9c{<@B5zf=MRa8cvAtXk$8w8m`;G8PT0Q)qy^^SA#e~L z!g?+6jcf*7CJ+W$&bjiW<>!JtIJHS-0K(Z^bHNL9691ZuX#L?PJ}!@YeIAMl)DbtrO}nV;Zp)NVB(>C)_R>* z4y~@nZ!L`PY#FNxkjtAM;liFK>R6BgdMLexsmgcOu#~x=Z|l(Uh5F*6fG>ae&30{B ziW5wt56EN-(gZ_k`dDF0<&_dSlIibux1cCka#ei{mgnt=n4@G^Y{RUrAKCy6Q0Ka>yn5Aa;#q{U#H{(RwA9?C*R#Qh=8J zchloI^d@*K&oe<#(c@9dhgKRUcvH%}*5bIRnaULCS;#H+vk2W3cUdV;q|H1()l^z*iew34!uVG4e|?-QkwE1K7OE9=5DC zxDQ3|2c}*PdD>YWN`;E{q#|4v>$12OtB$UuhaD{%=`PE^u?2(0)Rdp5+Hq^tZ?Y>m z?`OT04a8@6+?O9jKg?ZeL9zJx=R@3&|00qnRULk1(UDxYz9A;Zh>Pi4og?Oa+5&2i zzAFvW6oBcj%J7tB-FMimC;rqR$BmNiJtGt+IUb}h2oz{FeLnJiE3;uLeL|gaRE>w8 zG-qmU$KTct`wS+YVOw)=eZkXJea4vtuH{2xLY18m%$R2rd5^< zQ_k9lcRnTME1yxn=Mk86ieQxP4#uvGW8dZQ{xsUe@u5Fo_hjD0_}N?y&=o02gx3?zkB&3a?7tG{Hw27aN_{S+Ctb__0#~06 z8f8>U#A=l0?Z*o^jJN1n28>1B@7>nTjuF1q2v{o=rWwRA)Zlu}4Et{>V+9;EscZF7 z`Cj@Qgx;nWei&)GeL?&+K0&Rd#0t~ zpiN!F=%>(rPzK9#E`c2_W|-p|nYt9$ZrVHB{G>@~-U6@*tk^Rj)s*;cV9t02sp;vp z@SPz!T@@xQ=^%XZE<0wn14qK4gA@{G!R?Yej^pE^cl{A?;Z}_~L`HCyr(5y2`@{tP zKIP%YX^GnG)6dZ?dM!Gd&j(g6SF!e<1s}ra{5eFSa%!&!%DN1BJ3Da)vEXSP)czh8 zLjl2y1|yZ|A^ua@Cf8NkW5VamOK1(_CPT;ZqZz%Z(nL= zu4i0vJ3&0-m7~l=?0eAp#=d;y$xu0)1z+)uWKVfDO7>E(=>}Jm?az`8~ zE`^dniHIRl=P*tBJ46dU=j-!xDTE3LIB!q>ae)6vT=2h%tBz4}Gs8s!)h<{U^N*_3 z17m4N{zKenc#z@^{(#ny4t=8lW+qwfmqht8Q|L-=8?BkNa|!Q{kBUW4GGR*~?Y05? zi5ce_*S;GRLHXhuxetQY`*+=U@CAb5Hg)vl(i@)7b2WG}xGEBZmr4zt4JNE=gn8?# zzG+XEE!dOA^7E-DonRTZ)L!gw8gFJ5Kd| zh0(MN{LyOBFC6C*ns5J#XB(3t6wyB9B{DC560)qLnBf;; z{s-S}MpkEkJ;%CVl%+l~8DV`h$$b@Pz89S1CWR)i7x`+w{ zOu>5<^%I@A%%%BK_3Wlj3&zw1(Pex=UXyqWg*S3x6EdNH;WF%3j)_Q9sUt zJ6C-Iba@lmI^kRtzB)<4o}IX+pWmyaJ`Z&5rm$5v?2luXZf_)ju*c2;s>yX) z@!d&z*OzIvy~9GICzrK2PfU6;TA0_yKWbmS)8^q?D)=7qX;IDZaJsE;l%F*>vl5o( z$CSBnoZNZGbGl4!brNeYG(5QR;fV##i8ZJ|{Iu`uhLl&-^hu6>o1*QEPaS=q(z?a4 zBszxeFQ>V^cTPC8a_9)p$dN%VF9${N^)jIb(J$w9|SnUY8sg?8aRZ3!r3hqndzQTZ5STxvAZXJVw}}tz&$+%Ilb{ z!mn&6Qg>HL?|`B_LK#!&G>XO(MbA@sp)_M@0e3S=s8EQ>ue7<UAS++yKC*?ogVB|D12Lih$R-+ zWj(yZ&54vpav|x!G>A*oRBSW=5bWdj(E{tjZNniSzfjjxkz2;6ygMLRriLSPwC^qg UvYa-S?yWXMjOjjS5Rj1bFNHevzW@LL literal 2389 zcmY+Ec{~#iAIG=Z?1)XwnQ|ppn33YA%zfmJIm4WV+-Ht5+AkvaH8r9vk#gV5uLF%7 z<(T%9Smiz|w|VOIdYK%8B^*2QDBd1__3hZOO21A7plcKrp~f zB1dqxyxB_xowD1MWzWtL+#lKR#AdD?3=5Vl#dfnFc)9pI7t>iW!aXVhMWrE05v@ES zgDAjTA4DP}M(kXI(v{le9tT6xctP)j}}|yBz<{}HZ)XG<)Urhs+(Te zF=?HNFKbfb5-z@!2%QMK&`7Ax3%{ z>nsu>X_+#XC84}m0IR#K%t(mzcug!|0Mtr*2>n$@{l-|o~>K5dB0$}+@btW7+- z)B-@bD{GzPY89DxdR+;oI+)7*ioU7^_a=ZHFh);3-)eI5kZ$*Kjej>UrsCd}IDhK~ zh55$;s;ow&hu+6_Cqs0oa#a{b`nD7~3m0}vm19T1!)>(vn@5n7vT*`xl}mT??)U@6 zKN~4)7I>68S7*O8)}$$m z7tTc-3bsDGMC}0KI0!TeBlYg}AIK8Lw9Q`i$kw5Vq$d{RGufDu7e?;t95mh1$fd__sI9=tHL5kS<%%chpY!$P!(`8Bpld2v- zb$G7hWM_68emc4e{C<6T5CHM7X`@-3hFabgpW=2)*)t?XRTQJ#!qcl|p-Qr^ODNav zR3Fqe+9@gBHHdU8uc4|5`iLH1egLz{vvg6T z1Kz;GP6JDGA2Sz} z;&n)+K|sRJd0^I?!s=2RFKg$;y!QG{`_;iV%XCftpzfGIOWw*}j=c%95E^MjC=XVe zMB;n$4ZXA?VxW#<^vUXS)N%dm!pt&~ojIXyR$r2ZcI_c^jmwF<*s{%;*KJEXdYa>x zLWrqN(Lz=3eUVBEf5CS_nkO7ET9DQAq4bKEwOyP$l`7Q5qJ(eVpJ?AgjxZrl@iNYh zeknZN`-wqjyA^|GlKR_O24VaY^Or@0YB`a$L6NIhw)%(VY9wVSj81{0(7I>e`}q-) zm|gv!G8xNVQ1+|xA*+3!c#QAjH>2GYN#MEJc0Ivmb?jJLAW-btGfFE1R2DW*@^0ofpe#sDAfDe3~w|6n9z`XpKd)crV%7sS*x; z$R~nSMX9&ofZXsoz85RP*u^JmZ;b>H0Evdd_!!i^pm(@ z_Cx(^+eNt-?lfQJ^;4K}ji-|5Ugx}R%Pbk;GDp@vh*0p^47vr5rkLi=bTvZ3)$f~} zy>&jS;UU<2M#|&@#Mwne1wxy_W2j*3*=5Z}@p~kAkqW&CvNV;hG$;AS=YULJc|C01 z6K{1Ww$ota44>-g-aByQRQ1Ni-l_OYE!98MGubHlB`eU!4>ON-{mZ=JPC54l^$8PU z_A^BZ08XrHW0cyn#pz`e=C#GSzC_dMmG^6O0vx}gw_sWmJcdEvx@Q~J5!RP`_FysCx1CD1u9vyEE4Q!?!$Q+%eP4nz%zPDDW_UtS(wpWuv!sfjnN4=v- zM|g6_2p!${!W;hd)Z%HBzJNz+K<(5hFU4katWn>os}Y>OzVp-&#VpocwMOEGwErGW z8el5z=K2k5bTAJ|asnn7J(mk6`{Ec~$1 z-KeTHi zgke-L5*RoqL;=YG5`h4~Xt(}3K%|OqA`Acgr_%+A-sBE#C>SOj?p>dLp9T26lK%o^ C169fZ diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index 7da51f912..ee5fe65c8 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -28,7 +28,7 @@ public final class Config { public int Port = 443; public int PublicPort = 0; public String KeystorePath = "./keystore.p12"; - public String KeystorePassword = ""; + public String KeystorePassword = "123456"; public Boolean UseSSL = true; public Boolean FrontHTTPS = true; diff --git a/src/main/java/emu/grasscutter/command/CommandMap.java b/src/main/java/emu/grasscutter/command/CommandMap.java index 007fafe17..f735bc642 100644 --- a/src/main/java/emu/grasscutter/command/CommandMap.java +++ b/src/main/java/emu/grasscutter/command/CommandMap.java @@ -11,6 +11,7 @@ import java.util.*; public final class CommandMap { private final Map commands = new HashMap<>(); private final Map annotations = new HashMap<>(); + public CommandMap() { this(false); } diff --git a/src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java b/src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java new file mode 100644 index 000000000..8fab1768b --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java @@ -0,0 +1,29 @@ +package emu.grasscutter.command.commands; + +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.GenshinPlayer; +import emu.grasscutter.game.inventory.Inventory; +import emu.grasscutter.game.inventory.ItemType; + +import java.util.List; + +@Command(label = "clearweapons", usage = "clearweapons", + description = "Deletes all unequipped and unlocked weapons, including yellow rarity ones from your inventory", + aliases = {"clearwpns"}, permission = "player.clearweapons") +public final class ClearWeaponsCommand implements CommandHandler { + + @Override + public void execute(GenshinPlayer sender, List args) { + if (sender == null) { + CommandHandler.sendMessage(null, "Run this command in-game."); + return; // TODO: clear player's weapons from console or other players + } + + Inventory playerInventory = sender.getInventory(); + playerInventory.getItems().values().stream() + .filter(item -> item.getItemType() == ItemType.ITEM_WEAPON) + .filter(item -> !item.isLocked() && !item.isEquipped()) + .forEach(item -> playerInventory.removeItem(item, item.getCount())); + } +} diff --git a/src/main/java/emu/grasscutter/database/DatabaseCounter.java b/src/main/java/emu/grasscutter/database/DatabaseCounter.java index 37fa59d7c..a70fe518a 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseCounter.java +++ b/src/main/java/emu/grasscutter/database/DatabaseCounter.java @@ -3,7 +3,7 @@ package emu.grasscutter.database; import dev.morphia.annotations.Entity; import dev.morphia.annotations.Id; -@Entity(value = "counters", noClassnameStored = true) +@Entity(value = "counters", useDiscriminator = false) public class DatabaseCounter { @Id private String id; diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index ed092e976..fc24b70e6 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -2,41 +2,33 @@ package emu.grasscutter.database; import java.util.List; -import com.mongodb.WriteResult; - -import dev.morphia.query.FindOptions; -import dev.morphia.query.Query; -import dev.morphia.query.internal.MorphiaCursor; +import com.mongodb.client.result.DeleteResult; +import dev.morphia.query.experimental.filters.Filters; import emu.grasscutter.GenshinConstants; -import emu.grasscutter.Grasscutter; import emu.grasscutter.game.Account; import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.friends.Friendship; import emu.grasscutter.game.inventory.GenshinItem; -public class DatabaseHelper { - - protected static FindOptions FIND_ONE = new FindOptions().limit(1); - +public final class DatabaseHelper { public static Account createAccount(String username) { return createAccountWithId(username, 0); } - + public static Account createAccountWithId(String username, int reservedId) { // Unique names only Account exists = DatabaseHelper.getAccountByName(username); if (exists != null) { return null; } - + // Make sure there are no id collisions if (reservedId > 0) { // Cannot make account with the same uid as the server console if (reservedId == GenshinConstants.SERVER_CONSOLE_UID) { return null; } - exists = DatabaseHelper.getAccountByPlayerId(reservedId); if (exists != null) { return null; @@ -47,10 +39,10 @@ public class DatabaseHelper { Account account = new Account(); account.setUsername(username); account.setId(Integer.toString(DatabaseManager.getNextId(account))); - + if (reservedId > 0) { account.setPlayerId(reservedId); - } + } DatabaseHelper.saveAccount(account); return account; @@ -63,65 +55,52 @@ public class DatabaseHelper { if (exists != null) { return null; } - + // Account Account account = new Account(); account.setId(Integer.toString(DatabaseManager.getNextId(account))); account.setUsername(username); account.setPassword(password); - DatabaseHelper.saveAccount(account); + DatabaseHelper.saveAccount(account); return account; } public static void saveAccount(Account account) { DatabaseManager.getAccountDatastore().save(account); } - + public static Account getAccountByName(String username) { - MorphiaCursor cursor = DatabaseManager.getAccountDatastore().createQuery(Account.class).field("username").equalIgnoreCase(username).find(FIND_ONE); - if (!cursor.hasNext()) return null; - return cursor.next(); + return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("username", username)).first(); } - + public static Account getAccountByToken(String token) { - if (token == null) return null; - MorphiaCursor cursor = DatabaseManager.getAccountDatastore().createQuery(Account.class).field("token").equal(token).find(FIND_ONE); - if (!cursor.hasNext()) return null; - return cursor.next(); + if(token == null) return null; + return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("token", token)).first(); } - + public static Account getAccountById(String uid) { - MorphiaCursor cursor = DatabaseManager.getAccountDatastore().createQuery(Account.class).field("_id").equal(uid).find(FIND_ONE); - if (!cursor.hasNext()) return null; - return cursor.next(); + return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("_id", uid)).first(); } - + public static Account getAccountByPlayerId(int playerId) { - MorphiaCursor cursor = DatabaseManager.getAccountDatastore().createQuery(Account.class).field("playerId").equal(playerId).find(FIND_ONE); - if (!cursor.hasNext()) return null; - return cursor.next(); + return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("playerId", playerId)).first(); } - + public static boolean deleteAccount(String username) { - Query q = DatabaseManager.getAccountDatastore().createQuery(Account.class).field("username").equalIgnoreCase(username); - return DatabaseManager.getDatastore().findAndDelete(q) != null; + return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("username", username)).delete().getDeletedCount() > 0; } - + public static GenshinPlayer getPlayerById(int id) { - Query query = DatabaseManager.getDatastore().createQuery(GenshinPlayer.class).field("_id").equal(id); - MorphiaCursor cursor = query.find(FIND_ONE); - if (!cursor.hasNext()) return null; - return cursor.next(); + return DatabaseManager.getDatastore().find(GenshinPlayer.class).filter(Filters.eq("_id", id)).first(); } - + public static boolean checkPlayerExists(int id) { - MorphiaCursor query = DatabaseManager.getDatastore().createQuery(GenshinPlayer.class).field("_id").equal(id).find(FIND_ONE); - return query.hasNext(); + return DatabaseManager.getDatastore().find(GenshinPlayer.class).filter(Filters.eq("_id", id)).first() != null; } - + public static synchronized GenshinPlayer createPlayer(GenshinPlayer character, int reservedId) { // Check if reserved id - int id = 0; + int id; if (reservedId > 0 && !checkPlayerExists(reservedId)) { id = reservedId; character.setUid(id); @@ -136,10 +115,10 @@ public class DatabaseHelper { DatabaseManager.getDatastore().save(character); return character; } - + public static synchronized int getNextPlayerId(int reservedId) { // Check if reserved id - int id = 0; + int id; if (reservedId > 0 && !checkPlayerExists(reservedId)) { id = reservedId; } else { @@ -150,41 +129,37 @@ public class DatabaseHelper { } return id; } - + public static void savePlayer(GenshinPlayer character) { DatabaseManager.getDatastore().save(character); } - + public static void saveAvatar(GenshinAvatar avatar) { DatabaseManager.getDatastore().save(avatar); } - + public static List getAvatars(GenshinPlayer player) { - Query query = DatabaseManager.getDatastore().createQuery(GenshinAvatar.class).filter("ownerId", player.getUid()); - return query.find().toList(); + return DatabaseManager.getDatastore().find(GenshinAvatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); } - + public static void saveItem(GenshinItem item) { DatabaseManager.getDatastore().save(item); } - + public static boolean deleteItem(GenshinItem item) { - WriteResult result = DatabaseManager.getDatastore().delete(item); + DeleteResult result = DatabaseManager.getDatastore().delete(item); return result.wasAcknowledged(); } - + public static List getInventoryItems(GenshinPlayer player) { - Query query = DatabaseManager.getDatastore().createQuery(GenshinItem.class).filter("ownerId", player.getUid()); - return query.find().toList(); + return DatabaseManager.getDatastore().find(GenshinItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); } public static List getFriends(GenshinPlayer player) { - Query query = DatabaseManager.getDatastore().createQuery(Friendship.class).filter("ownerId", player.getUid()); - return query.find().toList(); + return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); } - + public static List getReverseFriends(GenshinPlayer player) { - Query query = DatabaseManager.getDatastore().createQuery(Friendship.class).filter("friendId", player.getUid()); - return query.find().toList(); + return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList(); } public static void saveFriendship(Friendship friendship) { @@ -196,13 +171,9 @@ public class DatabaseHelper { } public static Friendship getReverseFriendship(Friendship friendship) { - Query query = DatabaseManager.getDatastore().createQuery(Friendship.class); - query.and( - query.criteria("ownerId").equal(friendship.getFriendId()), - query.criteria("friendId").equal(friendship.getOwnerId()) - ); - MorphiaCursor reverseFriendship = query.find(FIND_ONE); - if (!reverseFriendship.hasNext()) return null; - return reverseFriendship.next(); + return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.and( + Filters.eq("ownerId", friendship.getFriendId()), + Filters.eq("friendId", friendship.getOwnerId()) + )).first(); } } diff --git a/src/main/java/emu/grasscutter/database/DatabaseManager.java b/src/main/java/emu/grasscutter/database/DatabaseManager.java index 46dad537d..9d64f9258 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseManager.java +++ b/src/main/java/emu/grasscutter/database/DatabaseManager.java @@ -1,13 +1,16 @@ package emu.grasscutter.database; -import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.MongoCommandException; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; import com.mongodb.client.MongoDatabase; import com.mongodb.client.MongoIterable; import dev.morphia.Datastore; import dev.morphia.Morphia; +import dev.morphia.mapping.MapperOptions; +import dev.morphia.query.experimental.filters.Filters; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.Account; import emu.grasscutter.game.GenshinPlayer; @@ -16,6 +19,7 @@ import emu.grasscutter.game.friends.Friendship; import emu.grasscutter.game.inventory.GenshinItem; public final class DatabaseManager { + private static MongoClient mongoClient; private static MongoClient dispatchMongoClient; @@ -26,15 +30,11 @@ public final class DatabaseManager { DatabaseCounter.class, Account.class, GenshinPlayer.class, GenshinAvatar.class, GenshinItem.class, Friendship.class }; - public static MongoClient getMongoClient() { - return mongoClient; + public static Datastore getDatastore() { + return datastore; } - - public static Datastore getDatastore() { - return datastore; - } - - public static MongoDatabase getDatabase() { + + public static MongoDatabase getDatabase() { return getDatastore().getDatabase(); } @@ -50,27 +50,23 @@ public final class DatabaseManager { public static void initialize() { // Initialize - mongoClient = new MongoClient(new MongoClientURI(Grasscutter.getConfig().DatabaseUrl)); - Morphia morphia = new Morphia(); + MongoClient mongoClient = MongoClients.create(Grasscutter.getConfig().DatabaseUrl); - // TODO Update when migrating to Morphia 2.0 - morphia.getMapper().getOptions().setStoreEmpties(true); - morphia.getMapper().getOptions().setStoreNulls(false); - morphia.getMapper().getOptions().setDisableEmbeddedIndexes(true); - - // Map - morphia.map(mappedClasses); - - // Build datastore - datastore = morphia.createDatastore(mongoClient, Grasscutter.getConfig().DatabaseCollection); + // Set mapper options. + MapperOptions mapperOptions = MapperOptions.builder() + .storeEmpties(true).storeNulls(false).build(); + // Create data store. + datastore = Morphia.createDatastore(mongoClient, Grasscutter.getConfig().DatabaseCollection, mapperOptions); + // Map classes. + datastore.getMapper().map(mappedClasses); // Ensure indexes try { datastore.ensureIndexes(); - } catch (MongoCommandException e) { - Grasscutter.getLogger().info("Mongo index error: ", e); + } catch (MongoCommandException exception) { + Grasscutter.getLogger().info("Mongo index error: ", exception); // Duplicate index error - if (e.getCode() == 85) { + if (exception.getCode() == 85) { // Drop all indexes and re add them MongoIterable collections = datastore.getDatabase().listCollectionNames(); for (String name : collections) { @@ -82,8 +78,8 @@ public final class DatabaseManager { } if(Grasscutter.getConfig().RunMode.equalsIgnoreCase("GAME_ONLY")) { - dispatchMongoClient = new MongoClient(new MongoClientURI(Grasscutter.getConfig().getGameServerOptions().DispatchServerDatabaseUrl)); - dispatchDatastore = morphia.createDatastore(dispatchMongoClient, Grasscutter.getConfig().getGameServerOptions().DispatchServerDatabaseCollection); + dispatchMongoClient = MongoClients.create(Grasscutter.getConfig().getGameServerOptions().DispatchServerDatabaseUrl); + dispatchDatastore = Morphia.createDatastore(dispatchMongoClient, Grasscutter.getConfig().getGameServerOptions().DispatchServerDatabaseCollection); // Ensure indexes for dispatch server try { @@ -103,9 +99,9 @@ public final class DatabaseManager { } } } - + public static synchronized int getNextId(Class c) { - DatabaseCounter counter = getDatastore().createQuery(DatabaseCounter.class).field("_id").equal(c.getSimpleName()).find().tryNext(); + DatabaseCounter counter = getDatastore().find(DatabaseCounter.class).filter(Filters.eq("_id", c.getName())).first(); if (counter == null) { counter = new DatabaseCounter(c.getSimpleName()); } @@ -115,7 +111,7 @@ public final class DatabaseManager { getDatastore().save(counter); } } - + public static synchronized int getNextId(Object o) { return getNextId(o.getClass()); } diff --git a/src/main/java/emu/grasscutter/game/Account.java b/src/main/java/emu/grasscutter/game/Account.java index dfb1e2829..dbd6ef854 100644 --- a/src/main/java/emu/grasscutter/game/Account.java +++ b/src/main/java/emu/grasscutter/game/Account.java @@ -1,22 +1,18 @@ package emu.grasscutter.game; -import dev.morphia.annotations.AlsoLoad; -import dev.morphia.annotations.Collation; -import dev.morphia.annotations.Entity; -import dev.morphia.annotations.Id; -import dev.morphia.annotations.Indexed; -import dev.morphia.annotations.PreLoad; +import dev.morphia.annotations.*; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.utils.Crypto; import emu.grasscutter.utils.Utils; -import dev.morphia.annotations.IndexOptions; import java.util.ArrayList; import java.util.List; +import org.bson.Document; + import com.mongodb.DBObject; -@Entity(value = "accounts", noClassnameStored = true) +@Entity(value = "accounts", useDiscriminator = false) public class Account { @Id private String id; @@ -31,7 +27,7 @@ public class Account { private String token; private String sessionKey; // Session token for dispatch server private List permissions; - + @Deprecated public Account() { this.permissions = new ArrayList<>(); @@ -122,15 +118,15 @@ public class Account { return this.token; } - @PreLoad - public void onLoad(DBObject dbObj) { - // Grant the superuser permissions to accounts created before the permissions update - if (!dbObj.containsField("permissions")) { - this.addPermission("*"); - } - } - public void save() { DatabaseHelper.saveAccount(this); } + + @PreLoad + public void onLoad(Document document) { + // Grant the superuser permissions to accounts created before the permissions update + if (!document.containsKey("permissions")) { + this.addPermission("*"); + } + } } diff --git a/src/main/java/emu/grasscutter/game/GenshinPlayer.java b/src/main/java/emu/grasscutter/game/GenshinPlayer.java index 44f960198..cdef5852e 100644 --- a/src/main/java/emu/grasscutter/game/GenshinPlayer.java +++ b/src/main/java/emu/grasscutter/game/GenshinPlayer.java @@ -18,6 +18,7 @@ import emu.grasscutter.game.friends.PlayerProfile; import emu.grasscutter.game.gacha.PlayerGachaInfo; import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.Inventory; +import emu.grasscutter.game.player.PlayerBirthday; import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.net.packet.GenshinPacket; @@ -61,7 +62,7 @@ import emu.grasscutter.utils.Position; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -@Entity(value = "players", noClassnameStored = true) +@Entity(value = "players", useDiscriminator = false) public class GenshinPlayer { @Id private int id; @Indexed(options = @IndexOptions(unique = true)) private String accountId; @@ -73,6 +74,7 @@ public class GenshinPlayer { private int nameCardId = 210001; private Position pos; private Position rotation; + private PlayerBirthday birthday; private Map properties; private Set nameCardList; @@ -139,6 +141,8 @@ public class GenshinPlayer { this.combatInvokeHandler = new InvokeHandler(PacketCombatInvocationsNotify.class); this.abilityInvokeHandler = new InvokeHandler(PacketAbilityInvocationsNotify.class); this.clientAbilityInitFinishHandler = new InvokeHandler(PacketClientAbilityInitFinishNotify.class); + + this.birthday = new PlayerBirthday(); } // On player creation @@ -150,6 +154,7 @@ public class GenshinPlayer { this.nickname = "Traveler"; this.signature = ""; this.teamManager = new TeamManager(this); + this.birthday = new PlayerBirthday(); this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, 1); this.setProperty(PlayerProperty.PROP_IS_SPRING_AUTO_USE, 1); this.setProperty(PlayerProperty.PROP_SPRING_AUTO_USE_PERCENT, 50); @@ -642,6 +647,15 @@ public class GenshinPlayer { return onlineInfo.build(); } + public PlayerBirthday getBirthday(){ + return this.birthday; + } + + public void setBirthday(int d, int m) { + this.birthday = new PlayerBirthday(d, m); + this.updateProfile(); + } + public SocialDetail.Builder getSocialDetail() { SocialDetail.Builder social = SocialDetail.newBuilder() .setUid(this.getUid()) @@ -649,7 +663,7 @@ public class GenshinPlayer { .setNickname(this.getNickname()) .setSignature(this.getSignature()) .setLevel(this.getLevel()) - .setBirthday(Birthday.newBuilder()) + .setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty()) .setWorldLevel(this.getWorldLevel()) .setUnk1(1) .setUnk3(1) diff --git a/src/main/java/emu/grasscutter/game/TeamInfo.java b/src/main/java/emu/grasscutter/game/TeamInfo.java index c60ce8cc0..efaf5ea1c 100644 --- a/src/main/java/emu/grasscutter/game/TeamInfo.java +++ b/src/main/java/emu/grasscutter/game/TeamInfo.java @@ -3,10 +3,12 @@ package emu.grasscutter.game; import java.util.ArrayList; import java.util.List; +import dev.morphia.annotations.Entity; import emu.grasscutter.GenshinConstants; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.avatar.GenshinAvatar; +@Entity public class TeamInfo { private String name; private List avatars; diff --git a/src/main/java/emu/grasscutter/game/TeamManager.java b/src/main/java/emu/grasscutter/game/TeamManager.java index 065c3bd28..6cd447d49 100644 --- a/src/main/java/emu/grasscutter/game/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/TeamManager.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import dev.morphia.annotations.Entity; import dev.morphia.annotations.Transient; import emu.grasscutter.GenshinConstants; import emu.grasscutter.Grasscutter; @@ -41,6 +42,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; +@Entity public class TeamManager { @Transient private GenshinPlayer player; diff --git a/src/main/java/emu/grasscutter/game/avatar/AvatarProfileData.java b/src/main/java/emu/grasscutter/game/avatar/AvatarProfileData.java index 5458c1752..d04c9d326 100644 --- a/src/main/java/emu/grasscutter/game/avatar/AvatarProfileData.java +++ b/src/main/java/emu/grasscutter/game/avatar/AvatarProfileData.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.avatar; +import dev.morphia.annotations.Entity; + +@Entity public class AvatarProfileData { private int avatarId; private int level; diff --git a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java index 6906d3896..b80b080d9 100644 --- a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java @@ -56,7 +56,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -@Entity(value = "avatars", noClassnameStored = true) +@Entity(value = "avatars", useDiscriminator = false) public class GenshinAvatar { @Id private ObjectId id; @Indexed private int ownerId; // Id of player that this avatar belongs to diff --git a/src/main/java/emu/grasscutter/game/friends/Friendship.java b/src/main/java/emu/grasscutter/game/friends/Friendship.java index 172d1bd43..28561dc39 100644 --- a/src/main/java/emu/grasscutter/game/friends/Friendship.java +++ b/src/main/java/emu/grasscutter/game/friends/Friendship.java @@ -9,7 +9,7 @@ import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief; import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState; import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage; -@Entity(value = "friendships", noClassnameStored = true) +@Entity(value = "friendships", useDiscriminator = false) public class Friendship { @Id private ObjectId id; diff --git a/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java b/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java index b9381c901..4af5f570e 100644 --- a/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java +++ b/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java @@ -4,6 +4,7 @@ import dev.morphia.annotations.*; import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.utils.Utils; +@Entity public class PlayerProfile { @Transient private GenshinPlayer player; diff --git a/src/main/java/emu/grasscutter/game/gacha/PlayerGachaBannerInfo.java b/src/main/java/emu/grasscutter/game/gacha/PlayerGachaBannerInfo.java index 2e144226e..b0c85d355 100644 --- a/src/main/java/emu/grasscutter/game/gacha/PlayerGachaBannerInfo.java +++ b/src/main/java/emu/grasscutter/game/gacha/PlayerGachaBannerInfo.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.gacha; +import dev.morphia.annotations.Entity; + +@Entity public class PlayerGachaBannerInfo { private int pity5 = 0; private int pity4 = 0; diff --git a/src/main/java/emu/grasscutter/game/gacha/PlayerGachaInfo.java b/src/main/java/emu/grasscutter/game/gacha/PlayerGachaInfo.java index c3aabcb76..8dd0e380e 100644 --- a/src/main/java/emu/grasscutter/game/gacha/PlayerGachaInfo.java +++ b/src/main/java/emu/grasscutter/game/gacha/PlayerGachaInfo.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.gacha; +import dev.morphia.annotations.Entity; + +@Entity public class PlayerGachaInfo { private PlayerGachaBannerInfo standardBanner; private PlayerGachaBannerInfo eventCharacterBanner; diff --git a/src/main/java/emu/grasscutter/game/inventory/GenshinItem.java b/src/main/java/emu/grasscutter/game/inventory/GenshinItem.java index 0b0db49c4..a395825da 100644 --- a/src/main/java/emu/grasscutter/game/inventory/GenshinItem.java +++ b/src/main/java/emu/grasscutter/game/inventory/GenshinItem.java @@ -34,7 +34,7 @@ import emu.grasscutter.net.proto.SceneWeaponInfoOuterClass.SceneWeaponInfo; import emu.grasscutter.net.proto.WeaponOuterClass.Weapon; import emu.grasscutter.utils.WeightedList; -@Entity(value = "items", noClassnameStored = true) +@Entity(value = "items", useDiscriminator = false) public class GenshinItem { @Id private ObjectId id; @Indexed private int ownerId; diff --git a/src/main/java/emu/grasscutter/game/player/PlayerBirthday.java b/src/main/java/emu/grasscutter/game/player/PlayerBirthday.java new file mode 100644 index 000000000..733f58ee5 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/player/PlayerBirthday.java @@ -0,0 +1,68 @@ +package emu.grasscutter.game.player; + +import emu.grasscutter.net.proto.BirthdayOuterClass.Birthday; + +public class PlayerBirthday { + private int day; + private int month; + + public PlayerBirthday(){ + this.day = 0; + this.month = 0; + } + + public PlayerBirthday(int day, int month){ + this.day = day; + this.month = month; + } + + public PlayerBirthday set(PlayerBirthday birth){ + this.day = birth.day; + this.month = birth.month; + + return this; + } + + public PlayerBirthday set(int d, int m){ + this.day = d; + this.month = m; + + return this; + } + + public PlayerBirthday setDay(int value){ + this.day = value; + return this; + } + + public PlayerBirthday setMonth(int value){ + this.month = value; + return this; + } + + public int getDay(){ + return this.day; + } + + public int getMonth(){ + return this.month; + } + + public Birthday toProto(){ + return Birthday.newBuilder() + .setDay(this.getDay()) + .setMonth(this.getMonth()) + .build(); + } + + public Birthday.Builder getFilledProtoWhenNotEmpty(){ + if(this.getDay() > 0) + { + return Birthday.newBuilder() + .setDay(this.getDay()) + .setMonth(this.getMonth()); + } + + return Birthday.newBuilder(); + } +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java index 418f16a4b..365055e26 100644 --- a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java +++ b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java @@ -1034,6 +1034,8 @@ public class PacketOpcodes { public static final int ShowTemplateReminderNotify = 3164; public static final int SignInInfoReq = 2510; public static final int SignInInfoRsp = 2515; + public static final int SitReq = 354; + public static final int SitRsp = 335; public static final int SocialDataNotify = 4063; public static final int SpringUseReq = 1720; public static final int SpringUseRsp = 1727; @@ -1208,5 +1210,4 @@ public class PacketOpcodes { public static final int WorldRoutineChangeNotify = 3548; public static final int WorldRoutineTypeCloseNotify = 3513; public static final int WorldRoutineTypeRefreshNotify = 3545; - } \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/net/proto/BirthdayOuterClass.java b/src/main/java/emu/grasscutter/net/proto/BirthdayOuterClass.java index d06d120f7..e3af15e27 100644 --- a/src/main/java/emu/grasscutter/net/proto/BirthdayOuterClass.java +++ b/src/main/java/emu/grasscutter/net/proto/BirthdayOuterClass.java @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Birthday.proto +// source: proto/Birthday.proto package emu.grasscutter.net.proto; @@ -96,6 +96,8 @@ public final class BirthdayOuterClass { } } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException( e).setUnfinishedMessage(this); @@ -586,9 +588,9 @@ public final class BirthdayOuterClass { descriptor; static { java.lang.String[] descriptorData = { - "\n\016Birthday.proto\"&\n\010Birthday\022\r\n\005month\030\001 " + - "\001(\r\022\013\n\003day\030\002 \001(\rB\033\n\031emu.grasscutter.net." + - "protob\006proto3" + "\n\024proto/Birthday.proto\"&\n\010Birthday\022\r\n\005mo" + + "nth\030\001 \001(\r\022\013\n\003day\030\002 \001(\rB\033\n\031emu.grasscutte" + + "r.net.protob\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, diff --git a/src/main/java/emu/grasscutter/net/proto/EvtAvatarSitDownNotifyOuterClass.java b/src/main/java/emu/grasscutter/net/proto/EvtAvatarSitDownNotifyOuterClass.java new file mode 100644 index 000000000..2bc0317b2 --- /dev/null +++ b/src/main/java/emu/grasscutter/net/proto/EvtAvatarSitDownNotifyOuterClass.java @@ -0,0 +1,816 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: EvtAvatarSitDownNotify.proto + +package emu.grasscutter.net.proto; + +public final class EvtAvatarSitDownNotifyOuterClass { + private EvtAvatarSitDownNotifyOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface EvtAvatarSitDownNotifyOrBuilder extends + // @@protoc_insertion_point(interface_extends:EvtAvatarSitDownNotify) + com.google.protobuf.MessageOrBuilder { + + /** + * uint32 entity_id = 1; + * @return The entityId. + */ + int getEntityId(); + + /** + * .Vector position = 2; + * @return Whether the position field is set. + */ + boolean hasPosition(); + /** + * .Vector position = 2; + * @return The position. + */ + emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition(); + /** + * .Vector position = 2; + */ + emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder(); + + /** + * uint64 chair_id = 3; + * @return The chairId. + */ + long getChairId(); + } + /** + * Protobuf type {@code EvtAvatarSitDownNotify} + */ + public static final class EvtAvatarSitDownNotify extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:EvtAvatarSitDownNotify) + EvtAvatarSitDownNotifyOrBuilder { + private static final long serialVersionUID = 0L; + // Use EvtAvatarSitDownNotify.newBuilder() to construct. + private EvtAvatarSitDownNotify(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EvtAvatarSitDownNotify() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new EvtAvatarSitDownNotify(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EvtAvatarSitDownNotify( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + entityId_ = input.readUInt32(); + break; + } + case 18: { + emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder subBuilder = null; + if (position_ != null) { + subBuilder = position_.toBuilder(); + } + position_ = input.readMessage(emu.grasscutter.net.proto.VectorOuterClass.Vector.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(position_); + position_ = subBuilder.buildPartial(); + } + + break; + } + case 24: { + + chairId_ = input.readUInt64(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.internal_static_EvtAvatarSitDownNotify_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.internal_static_EvtAvatarSitDownNotify_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify.class, emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify.Builder.class); + } + + public static final int ENTITY_ID_FIELD_NUMBER = 1; + private int entityId_; + /** + * uint32 entity_id = 1; + * @return The entityId. + */ + @java.lang.Override + public int getEntityId() { + return entityId_; + } + + public static final int POSITION_FIELD_NUMBER = 2; + private emu.grasscutter.net.proto.VectorOuterClass.Vector position_; + /** + * .Vector position = 2; + * @return Whether the position field is set. + */ + @java.lang.Override + public boolean hasPosition() { + return position_ != null; + } + /** + * .Vector position = 2; + * @return The position. + */ + @java.lang.Override + public emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition() { + return position_ == null ? emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } + /** + * .Vector position = 2; + */ + @java.lang.Override + public emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder() { + return getPosition(); + } + + public static final int CHAIR_ID_FIELD_NUMBER = 3; + private long chairId_; + /** + * uint64 chair_id = 3; + * @return The chairId. + */ + @java.lang.Override + public long getChairId() { + return chairId_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (entityId_ != 0) { + output.writeUInt32(1, entityId_); + } + if (position_ != null) { + output.writeMessage(2, getPosition()); + } + if (chairId_ != 0L) { + output.writeUInt64(3, chairId_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (entityId_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(1, entityId_); + } + if (position_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getPosition()); + } + if (chairId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(3, chairId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify)) { + return super.equals(obj); + } + emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify other = (emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify) obj; + + if (getEntityId() + != other.getEntityId()) return false; + if (hasPosition() != other.hasPosition()) return false; + if (hasPosition()) { + if (!getPosition() + .equals(other.getPosition())) return false; + } + if (getChairId() + != other.getChairId()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENTITY_ID_FIELD_NUMBER; + hash = (53 * hash) + getEntityId(); + if (hasPosition()) { + hash = (37 * hash) + POSITION_FIELD_NUMBER; + hash = (53 * hash) + getPosition().hashCode(); + } + hash = (37 * hash) + CHAIR_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getChairId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code EvtAvatarSitDownNotify} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:EvtAvatarSitDownNotify) + emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotifyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.internal_static_EvtAvatarSitDownNotify_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.internal_static_EvtAvatarSitDownNotify_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify.class, emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify.Builder.class); + } + + // Construct using emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + entityId_ = 0; + + if (positionBuilder_ == null) { + position_ = null; + } else { + position_ = null; + positionBuilder_ = null; + } + chairId_ = 0L; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.internal_static_EvtAvatarSitDownNotify_descriptor; + } + + @java.lang.Override + public emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify getDefaultInstanceForType() { + return emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify.getDefaultInstance(); + } + + @java.lang.Override + public emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify build() { + emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify buildPartial() { + emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify result = new emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify(this); + result.entityId_ = entityId_; + if (positionBuilder_ == null) { + result.position_ = position_; + } else { + result.position_ = positionBuilder_.build(); + } + result.chairId_ = chairId_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify) { + return mergeFrom((emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify other) { + if (other == emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify.getDefaultInstance()) return this; + if (other.getEntityId() != 0) { + setEntityId(other.getEntityId()); + } + if (other.hasPosition()) { + mergePosition(other.getPosition()); + } + if (other.getChairId() != 0L) { + setChairId(other.getChairId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int entityId_ ; + /** + * uint32 entity_id = 1; + * @return The entityId. + */ + @java.lang.Override + public int getEntityId() { + return entityId_; + } + /** + * uint32 entity_id = 1; + * @param value The entityId to set. + * @return This builder for chaining. + */ + public Builder setEntityId(int value) { + + entityId_ = value; + onChanged(); + return this; + } + /** + * uint32 entity_id = 1; + * @return This builder for chaining. + */ + public Builder clearEntityId() { + + entityId_ = 0; + onChanged(); + return this; + } + + private emu.grasscutter.net.proto.VectorOuterClass.Vector position_; + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder> positionBuilder_; + /** + * .Vector position = 2; + * @return Whether the position field is set. + */ + public boolean hasPosition() { + return positionBuilder_ != null || position_ != null; + } + /** + * .Vector position = 2; + * @return The position. + */ + public emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition() { + if (positionBuilder_ == null) { + return position_ == null ? emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } else { + return positionBuilder_.getMessage(); + } + } + /** + * .Vector position = 2; + */ + public Builder setPosition(emu.grasscutter.net.proto.VectorOuterClass.Vector value) { + if (positionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + position_ = value; + onChanged(); + } else { + positionBuilder_.setMessage(value); + } + + return this; + } + /** + * .Vector position = 2; + */ + public Builder setPosition( + emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder builderForValue) { + if (positionBuilder_ == null) { + position_ = builderForValue.build(); + onChanged(); + } else { + positionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .Vector position = 2; + */ + public Builder mergePosition(emu.grasscutter.net.proto.VectorOuterClass.Vector value) { + if (positionBuilder_ == null) { + if (position_ != null) { + position_ = + emu.grasscutter.net.proto.VectorOuterClass.Vector.newBuilder(position_).mergeFrom(value).buildPartial(); + } else { + position_ = value; + } + onChanged(); + } else { + positionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .Vector position = 2; + */ + public Builder clearPosition() { + if (positionBuilder_ == null) { + position_ = null; + onChanged(); + } else { + position_ = null; + positionBuilder_ = null; + } + + return this; + } + /** + * .Vector position = 2; + */ + public emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder getPositionBuilder() { + + onChanged(); + return getPositionFieldBuilder().getBuilder(); + } + /** + * .Vector position = 2; + */ + public emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder() { + if (positionBuilder_ != null) { + return positionBuilder_.getMessageOrBuilder(); + } else { + return position_ == null ? + emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } + } + /** + * .Vector position = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder> + getPositionFieldBuilder() { + if (positionBuilder_ == null) { + positionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder>( + getPosition(), + getParentForChildren(), + isClean()); + position_ = null; + } + return positionBuilder_; + } + + private long chairId_ ; + /** + * uint64 chair_id = 3; + * @return The chairId. + */ + @java.lang.Override + public long getChairId() { + return chairId_; + } + /** + * uint64 chair_id = 3; + * @param value The chairId to set. + * @return This builder for chaining. + */ + public Builder setChairId(long value) { + + chairId_ = value; + onChanged(); + return this; + } + /** + * uint64 chair_id = 3; + * @return This builder for chaining. + */ + public Builder clearChairId() { + + chairId_ = 0L; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:EvtAvatarSitDownNotify) + } + + // @@protoc_insertion_point(class_scope:EvtAvatarSitDownNotify) + private static final emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify(); + } + + public static emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public EvtAvatarSitDownNotify parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EvtAvatarSitDownNotify(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_EvtAvatarSitDownNotify_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_EvtAvatarSitDownNotify_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\034EvtAvatarSitDownNotify.proto\032\014Vector.p" + + "roto\"X\n\026EvtAvatarSitDownNotify\022\021\n\tentity" + + "_id\030\001 \001(\r\022\031\n\010position\030\002 \001(\0132\007.Vector\022\020\n\010" + + "chair_id\030\003 \001(\004B\033\n\031emu.grasscutter.net.pr" + + "otob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + emu.grasscutter.net.proto.VectorOuterClass.getDescriptor(), + }); + internal_static_EvtAvatarSitDownNotify_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_EvtAvatarSitDownNotify_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_EvtAvatarSitDownNotify_descriptor, + new java.lang.String[] { "EntityId", "Position", "ChairId", }); + emu.grasscutter.net.proto.VectorOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayReqOuterClass.java b/src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayReqOuterClass.java new file mode 100644 index 000000000..d49e0f983 --- /dev/null +++ b/src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayReqOuterClass.java @@ -0,0 +1,674 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: proto/SetPlayerBirthdayReq.proto + +package emu.grasscutter.net.proto; + +public final class SetPlayerBirthdayReqOuterClass { + private SetPlayerBirthdayReqOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SetPlayerBirthdayReqOrBuilder extends + // @@protoc_insertion_point(interface_extends:SetPlayerBirthdayReq) + com.google.protobuf.MessageOrBuilder { + + /** + * .Birthday birth = 1; + * @return Whether the birth field is set. + */ + boolean hasBirth(); + /** + * .Birthday birth = 1; + * @return The birth. + */ + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday getBirth(); + /** + * .Birthday birth = 1; + */ + emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder getBirthOrBuilder(); + } + /** + * Protobuf type {@code SetPlayerBirthdayReq} + */ + public static final class SetPlayerBirthdayReq extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SetPlayerBirthdayReq) + SetPlayerBirthdayReqOrBuilder { + private static final long serialVersionUID = 0L; + // Use SetPlayerBirthdayReq.newBuilder() to construct. + private SetPlayerBirthdayReq(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SetPlayerBirthdayReq() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SetPlayerBirthdayReq(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SetPlayerBirthdayReq( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder subBuilder = null; + if (birth_ != null) { + subBuilder = birth_.toBuilder(); + } + birth_ = input.readMessage(emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(birth_); + birth_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.internal_static_SetPlayerBirthdayReq_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.internal_static_SetPlayerBirthdayReq_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq.class, emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq.Builder.class); + } + + public static final int BIRTH_FIELD_NUMBER = 1; + private emu.grasscutter.net.proto.BirthdayOuterClass.Birthday birth_; + /** + * .Birthday birth = 1; + * @return Whether the birth field is set. + */ + @java.lang.Override + public boolean hasBirth() { + return birth_ != null; + } + /** + * .Birthday birth = 1; + * @return The birth. + */ + @java.lang.Override + public emu.grasscutter.net.proto.BirthdayOuterClass.Birthday getBirth() { + return birth_ == null ? emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.getDefaultInstance() : birth_; + } + /** + * .Birthday birth = 1; + */ + @java.lang.Override + public emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder getBirthOrBuilder() { + return getBirth(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (birth_ != null) { + output.writeMessage(1, getBirth()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (birth_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getBirth()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq)) { + return super.equals(obj); + } + emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq other = (emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq) obj; + + if (hasBirth() != other.hasBirth()) return false; + if (hasBirth()) { + if (!getBirth() + .equals(other.getBirth())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBirth()) { + hash = (37 * hash) + BIRTH_FIELD_NUMBER; + hash = (53 * hash) + getBirth().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code SetPlayerBirthdayReq} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SetPlayerBirthdayReq) + emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReqOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.internal_static_SetPlayerBirthdayReq_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.internal_static_SetPlayerBirthdayReq_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq.class, emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq.Builder.class); + } + + // Construct using emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (birthBuilder_ == null) { + birth_ = null; + } else { + birth_ = null; + birthBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.internal_static_SetPlayerBirthdayReq_descriptor; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq getDefaultInstanceForType() { + return emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq.getDefaultInstance(); + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq build() { + emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq buildPartial() { + emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq result = new emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq(this); + if (birthBuilder_ == null) { + result.birth_ = birth_; + } else { + result.birth_ = birthBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq) { + return mergeFrom((emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq other) { + if (other == emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq.getDefaultInstance()) return this; + if (other.hasBirth()) { + mergeBirth(other.getBirth()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private emu.grasscutter.net.proto.BirthdayOuterClass.Birthday birth_; + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday, emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder, emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder> birthBuilder_; + /** + * .Birthday birth = 1; + * @return Whether the birth field is set. + */ + public boolean hasBirth() { + return birthBuilder_ != null || birth_ != null; + } + /** + * .Birthday birth = 1; + * @return The birth. + */ + public emu.grasscutter.net.proto.BirthdayOuterClass.Birthday getBirth() { + if (birthBuilder_ == null) { + return birth_ == null ? emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.getDefaultInstance() : birth_; + } else { + return birthBuilder_.getMessage(); + } + } + /** + * .Birthday birth = 1; + */ + public Builder setBirth(emu.grasscutter.net.proto.BirthdayOuterClass.Birthday value) { + if (birthBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + birth_ = value; + onChanged(); + } else { + birthBuilder_.setMessage(value); + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public Builder setBirth( + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder builderForValue) { + if (birthBuilder_ == null) { + birth_ = builderForValue.build(); + onChanged(); + } else { + birthBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public Builder mergeBirth(emu.grasscutter.net.proto.BirthdayOuterClass.Birthday value) { + if (birthBuilder_ == null) { + if (birth_ != null) { + birth_ = + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.newBuilder(birth_).mergeFrom(value).buildPartial(); + } else { + birth_ = value; + } + onChanged(); + } else { + birthBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public Builder clearBirth() { + if (birthBuilder_ == null) { + birth_ = null; + onChanged(); + } else { + birth_ = null; + birthBuilder_ = null; + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder getBirthBuilder() { + + onChanged(); + return getBirthFieldBuilder().getBuilder(); + } + /** + * .Birthday birth = 1; + */ + public emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder getBirthOrBuilder() { + if (birthBuilder_ != null) { + return birthBuilder_.getMessageOrBuilder(); + } else { + return birth_ == null ? + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.getDefaultInstance() : birth_; + } + } + /** + * .Birthday birth = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday, emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder, emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder> + getBirthFieldBuilder() { + if (birthBuilder_ == null) { + birthBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday, emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder, emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder>( + getBirth(), + getParentForChildren(), + isClean()); + birth_ = null; + } + return birthBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SetPlayerBirthdayReq) + } + + // @@protoc_insertion_point(class_scope:SetPlayerBirthdayReq) + private static final emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq(); + } + + public static emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SetPlayerBirthdayReq parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SetPlayerBirthdayReq(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SetPlayerBirthdayReq_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SetPlayerBirthdayReq_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n proto/SetPlayerBirthdayReq.proto\032\024prot" + + "o/Birthday.proto\"0\n\024SetPlayerBirthdayReq" + + "\022\030\n\005birth\030\001 \001(\0132\t.BirthdayB\033\n\031emu.grassc" + + "utter.net.protob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + emu.grasscutter.net.proto.BirthdayOuterClass.getDescriptor(), + }); + internal_static_SetPlayerBirthdayReq_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SetPlayerBirthdayReq_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SetPlayerBirthdayReq_descriptor, + new java.lang.String[] { "Birth", }); + emu.grasscutter.net.proto.BirthdayOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayRspOuterClass.java b/src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayRspOuterClass.java new file mode 100644 index 000000000..acb24b8b2 --- /dev/null +++ b/src/main/java/emu/grasscutter/net/proto/SetPlayerBirthdayRspOuterClass.java @@ -0,0 +1,674 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: proto/SetPlayerBirthdayRsp.proto + +package emu.grasscutter.net.proto; + +public final class SetPlayerBirthdayRspOuterClass { + private SetPlayerBirthdayRspOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SetPlayerBirthdayRspOrBuilder extends + // @@protoc_insertion_point(interface_extends:SetPlayerBirthdayRsp) + com.google.protobuf.MessageOrBuilder { + + /** + * .Birthday birth = 1; + * @return Whether the birth field is set. + */ + boolean hasBirth(); + /** + * .Birthday birth = 1; + * @return The birth. + */ + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday getBirth(); + /** + * .Birthday birth = 1; + */ + emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder getBirthOrBuilder(); + } + /** + * Protobuf type {@code SetPlayerBirthdayRsp} + */ + public static final class SetPlayerBirthdayRsp extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SetPlayerBirthdayRsp) + SetPlayerBirthdayRspOrBuilder { + private static final long serialVersionUID = 0L; + // Use SetPlayerBirthdayRsp.newBuilder() to construct. + private SetPlayerBirthdayRsp(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SetPlayerBirthdayRsp() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SetPlayerBirthdayRsp(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SetPlayerBirthdayRsp( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder subBuilder = null; + if (birth_ != null) { + subBuilder = birth_.toBuilder(); + } + birth_ = input.readMessage(emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(birth_); + birth_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.internal_static_SetPlayerBirthdayRsp_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.internal_static_SetPlayerBirthdayRsp_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp.class, emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp.Builder.class); + } + + public static final int BIRTH_FIELD_NUMBER = 1; + private emu.grasscutter.net.proto.BirthdayOuterClass.Birthday birth_; + /** + * .Birthday birth = 1; + * @return Whether the birth field is set. + */ + @java.lang.Override + public boolean hasBirth() { + return birth_ != null; + } + /** + * .Birthday birth = 1; + * @return The birth. + */ + @java.lang.Override + public emu.grasscutter.net.proto.BirthdayOuterClass.Birthday getBirth() { + return birth_ == null ? emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.getDefaultInstance() : birth_; + } + /** + * .Birthday birth = 1; + */ + @java.lang.Override + public emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder getBirthOrBuilder() { + return getBirth(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (birth_ != null) { + output.writeMessage(1, getBirth()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (birth_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getBirth()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp)) { + return super.equals(obj); + } + emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp other = (emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp) obj; + + if (hasBirth() != other.hasBirth()) return false; + if (hasBirth()) { + if (!getBirth() + .equals(other.getBirth())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBirth()) { + hash = (37 * hash) + BIRTH_FIELD_NUMBER; + hash = (53 * hash) + getBirth().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code SetPlayerBirthdayRsp} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SetPlayerBirthdayRsp) + emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRspOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.internal_static_SetPlayerBirthdayRsp_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.internal_static_SetPlayerBirthdayRsp_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp.class, emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp.Builder.class); + } + + // Construct using emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (birthBuilder_ == null) { + birth_ = null; + } else { + birth_ = null; + birthBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.internal_static_SetPlayerBirthdayRsp_descriptor; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp getDefaultInstanceForType() { + return emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp.getDefaultInstance(); + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp build() { + emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp buildPartial() { + emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp result = new emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp(this); + if (birthBuilder_ == null) { + result.birth_ = birth_; + } else { + result.birth_ = birthBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp) { + return mergeFrom((emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp other) { + if (other == emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp.getDefaultInstance()) return this; + if (other.hasBirth()) { + mergeBirth(other.getBirth()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private emu.grasscutter.net.proto.BirthdayOuterClass.Birthday birth_; + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday, emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder, emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder> birthBuilder_; + /** + * .Birthday birth = 1; + * @return Whether the birth field is set. + */ + public boolean hasBirth() { + return birthBuilder_ != null || birth_ != null; + } + /** + * .Birthday birth = 1; + * @return The birth. + */ + public emu.grasscutter.net.proto.BirthdayOuterClass.Birthday getBirth() { + if (birthBuilder_ == null) { + return birth_ == null ? emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.getDefaultInstance() : birth_; + } else { + return birthBuilder_.getMessage(); + } + } + /** + * .Birthday birth = 1; + */ + public Builder setBirth(emu.grasscutter.net.proto.BirthdayOuterClass.Birthday value) { + if (birthBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + birth_ = value; + onChanged(); + } else { + birthBuilder_.setMessage(value); + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public Builder setBirth( + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder builderForValue) { + if (birthBuilder_ == null) { + birth_ = builderForValue.build(); + onChanged(); + } else { + birthBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public Builder mergeBirth(emu.grasscutter.net.proto.BirthdayOuterClass.Birthday value) { + if (birthBuilder_ == null) { + if (birth_ != null) { + birth_ = + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.newBuilder(birth_).mergeFrom(value).buildPartial(); + } else { + birth_ = value; + } + onChanged(); + } else { + birthBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public Builder clearBirth() { + if (birthBuilder_ == null) { + birth_ = null; + onChanged(); + } else { + birth_ = null; + birthBuilder_ = null; + } + + return this; + } + /** + * .Birthday birth = 1; + */ + public emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder getBirthBuilder() { + + onChanged(); + return getBirthFieldBuilder().getBuilder(); + } + /** + * .Birthday birth = 1; + */ + public emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder getBirthOrBuilder() { + if (birthBuilder_ != null) { + return birthBuilder_.getMessageOrBuilder(); + } else { + return birth_ == null ? + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.getDefaultInstance() : birth_; + } + } + /** + * .Birthday birth = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday, emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder, emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder> + getBirthFieldBuilder() { + if (birthBuilder_ == null) { + birthBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.BirthdayOuterClass.Birthday, emu.grasscutter.net.proto.BirthdayOuterClass.Birthday.Builder, emu.grasscutter.net.proto.BirthdayOuterClass.BirthdayOrBuilder>( + getBirth(), + getParentForChildren(), + isClean()); + birth_ = null; + } + return birthBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SetPlayerBirthdayRsp) + } + + // @@protoc_insertion_point(class_scope:SetPlayerBirthdayRsp) + private static final emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp(); + } + + public static emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SetPlayerBirthdayRsp parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SetPlayerBirthdayRsp(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SetPlayerBirthdayRsp_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SetPlayerBirthdayRsp_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n proto/SetPlayerBirthdayRsp.proto\032\024prot" + + "o/Birthday.proto\"0\n\024SetPlayerBirthdayRsp" + + "\022\030\n\005birth\030\001 \001(\0132\t.BirthdayB\033\n\031emu.grassc" + + "utter.net.protob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + emu.grasscutter.net.proto.BirthdayOuterClass.getDescriptor(), + }); + internal_static_SetPlayerBirthdayRsp_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SetPlayerBirthdayRsp_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SetPlayerBirthdayRsp_descriptor, + new java.lang.String[] { "Birth", }); + emu.grasscutter.net.proto.BirthdayOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/emu/grasscutter/net/proto/SitReqOuterClass.java b/src/main/java/emu/grasscutter/net/proto/SitReqOuterClass.java new file mode 100644 index 000000000..bf6d6f0d1 --- /dev/null +++ b/src/main/java/emu/grasscutter/net/proto/SitReqOuterClass.java @@ -0,0 +1,744 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: SitReq.proto + +package emu.grasscutter.net.proto; + +public final class SitReqOuterClass { + private SitReqOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SitReqOrBuilder extends + // @@protoc_insertion_point(interface_extends:SitReq) + com.google.protobuf.MessageOrBuilder { + + /** + * uint64 chair_id = 1; + * @return The chairId. + */ + long getChairId(); + + /** + * .Vector position = 2; + * @return Whether the position field is set. + */ + boolean hasPosition(); + /** + * .Vector position = 2; + * @return The position. + */ + emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition(); + /** + * .Vector position = 2; + */ + emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder(); + } + /** + * Protobuf type {@code SitReq} + */ + public static final class SitReq extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SitReq) + SitReqOrBuilder { + private static final long serialVersionUID = 0L; + // Use SitReq.newBuilder() to construct. + private SitReq(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SitReq() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SitReq(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SitReq( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + chairId_ = input.readUInt64(); + break; + } + case 18: { + emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder subBuilder = null; + if (position_ != null) { + subBuilder = position_.toBuilder(); + } + position_ = input.readMessage(emu.grasscutter.net.proto.VectorOuterClass.Vector.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(position_); + position_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SitReqOuterClass.internal_static_SitReq_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SitReqOuterClass.internal_static_SitReq_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SitReqOuterClass.SitReq.class, emu.grasscutter.net.proto.SitReqOuterClass.SitReq.Builder.class); + } + + public static final int CHAIR_ID_FIELD_NUMBER = 1; + private long chairId_; + /** + * uint64 chair_id = 1; + * @return The chairId. + */ + @java.lang.Override + public long getChairId() { + return chairId_; + } + + public static final int POSITION_FIELD_NUMBER = 2; + private emu.grasscutter.net.proto.VectorOuterClass.Vector position_; + /** + * .Vector position = 2; + * @return Whether the position field is set. + */ + @java.lang.Override + public boolean hasPosition() { + return position_ != null; + } + /** + * .Vector position = 2; + * @return The position. + */ + @java.lang.Override + public emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition() { + return position_ == null ? emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } + /** + * .Vector position = 2; + */ + @java.lang.Override + public emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder() { + return getPosition(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (chairId_ != 0L) { + output.writeUInt64(1, chairId_); + } + if (position_ != null) { + output.writeMessage(2, getPosition()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (chairId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, chairId_); + } + if (position_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getPosition()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof emu.grasscutter.net.proto.SitReqOuterClass.SitReq)) { + return super.equals(obj); + } + emu.grasscutter.net.proto.SitReqOuterClass.SitReq other = (emu.grasscutter.net.proto.SitReqOuterClass.SitReq) obj; + + if (getChairId() + != other.getChairId()) return false; + if (hasPosition() != other.hasPosition()) return false; + if (hasPosition()) { + if (!getPosition() + .equals(other.getPosition())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CHAIR_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getChairId()); + if (hasPosition()) { + hash = (37 * hash) + POSITION_FIELD_NUMBER; + hash = (53 * hash) + getPosition().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(emu.grasscutter.net.proto.SitReqOuterClass.SitReq prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code SitReq} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SitReq) + emu.grasscutter.net.proto.SitReqOuterClass.SitReqOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SitReqOuterClass.internal_static_SitReq_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SitReqOuterClass.internal_static_SitReq_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SitReqOuterClass.SitReq.class, emu.grasscutter.net.proto.SitReqOuterClass.SitReq.Builder.class); + } + + // Construct using emu.grasscutter.net.proto.SitReqOuterClass.SitReq.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + chairId_ = 0L; + + if (positionBuilder_ == null) { + position_ = null; + } else { + position_ = null; + positionBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return emu.grasscutter.net.proto.SitReqOuterClass.internal_static_SitReq_descriptor; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitReqOuterClass.SitReq getDefaultInstanceForType() { + return emu.grasscutter.net.proto.SitReqOuterClass.SitReq.getDefaultInstance(); + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitReqOuterClass.SitReq build() { + emu.grasscutter.net.proto.SitReqOuterClass.SitReq result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitReqOuterClass.SitReq buildPartial() { + emu.grasscutter.net.proto.SitReqOuterClass.SitReq result = new emu.grasscutter.net.proto.SitReqOuterClass.SitReq(this); + result.chairId_ = chairId_; + if (positionBuilder_ == null) { + result.position_ = position_; + } else { + result.position_ = positionBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof emu.grasscutter.net.proto.SitReqOuterClass.SitReq) { + return mergeFrom((emu.grasscutter.net.proto.SitReqOuterClass.SitReq)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(emu.grasscutter.net.proto.SitReqOuterClass.SitReq other) { + if (other == emu.grasscutter.net.proto.SitReqOuterClass.SitReq.getDefaultInstance()) return this; + if (other.getChairId() != 0L) { + setChairId(other.getChairId()); + } + if (other.hasPosition()) { + mergePosition(other.getPosition()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + emu.grasscutter.net.proto.SitReqOuterClass.SitReq parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (emu.grasscutter.net.proto.SitReqOuterClass.SitReq) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long chairId_ ; + /** + * uint64 chair_id = 1; + * @return The chairId. + */ + @java.lang.Override + public long getChairId() { + return chairId_; + } + /** + * uint64 chair_id = 1; + * @param value The chairId to set. + * @return This builder for chaining. + */ + public Builder setChairId(long value) { + + chairId_ = value; + onChanged(); + return this; + } + /** + * uint64 chair_id = 1; + * @return This builder for chaining. + */ + public Builder clearChairId() { + + chairId_ = 0L; + onChanged(); + return this; + } + + private emu.grasscutter.net.proto.VectorOuterClass.Vector position_; + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder> positionBuilder_; + /** + * .Vector position = 2; + * @return Whether the position field is set. + */ + public boolean hasPosition() { + return positionBuilder_ != null || position_ != null; + } + /** + * .Vector position = 2; + * @return The position. + */ + public emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition() { + if (positionBuilder_ == null) { + return position_ == null ? emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } else { + return positionBuilder_.getMessage(); + } + } + /** + * .Vector position = 2; + */ + public Builder setPosition(emu.grasscutter.net.proto.VectorOuterClass.Vector value) { + if (positionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + position_ = value; + onChanged(); + } else { + positionBuilder_.setMessage(value); + } + + return this; + } + /** + * .Vector position = 2; + */ + public Builder setPosition( + emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder builderForValue) { + if (positionBuilder_ == null) { + position_ = builderForValue.build(); + onChanged(); + } else { + positionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .Vector position = 2; + */ + public Builder mergePosition(emu.grasscutter.net.proto.VectorOuterClass.Vector value) { + if (positionBuilder_ == null) { + if (position_ != null) { + position_ = + emu.grasscutter.net.proto.VectorOuterClass.Vector.newBuilder(position_).mergeFrom(value).buildPartial(); + } else { + position_ = value; + } + onChanged(); + } else { + positionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .Vector position = 2; + */ + public Builder clearPosition() { + if (positionBuilder_ == null) { + position_ = null; + onChanged(); + } else { + position_ = null; + positionBuilder_ = null; + } + + return this; + } + /** + * .Vector position = 2; + */ + public emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder getPositionBuilder() { + + onChanged(); + return getPositionFieldBuilder().getBuilder(); + } + /** + * .Vector position = 2; + */ + public emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder() { + if (positionBuilder_ != null) { + return positionBuilder_.getMessageOrBuilder(); + } else { + return position_ == null ? + emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } + } + /** + * .Vector position = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder> + getPositionFieldBuilder() { + if (positionBuilder_ == null) { + positionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder>( + getPosition(), + getParentForChildren(), + isClean()); + position_ = null; + } + return positionBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SitReq) + } + + // @@protoc_insertion_point(class_scope:SitReq) + private static final emu.grasscutter.net.proto.SitReqOuterClass.SitReq DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new emu.grasscutter.net.proto.SitReqOuterClass.SitReq(); + } + + public static emu.grasscutter.net.proto.SitReqOuterClass.SitReq getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SitReq parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SitReq(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitReqOuterClass.SitReq getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SitReq_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SitReq_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014SitReq.proto\032\014Vector.proto\"5\n\006SitReq\022\020" + + "\n\010chair_id\030\001 \001(\004\022\031\n\010position\030\002 \001(\0132\007.Vec" + + "torB\033\n\031emu.grasscutter.net.protob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + emu.grasscutter.net.proto.VectorOuterClass.getDescriptor(), + }); + internal_static_SitReq_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SitReq_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SitReq_descriptor, + new java.lang.String[] { "ChairId", "Position", }); + emu.grasscutter.net.proto.VectorOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/emu/grasscutter/net/proto/SitRspOuterClass.java b/src/main/java/emu/grasscutter/net/proto/SitRspOuterClass.java new file mode 100644 index 000000000..eeed03216 --- /dev/null +++ b/src/main/java/emu/grasscutter/net/proto/SitRspOuterClass.java @@ -0,0 +1,815 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: SitRsp.proto + +package emu.grasscutter.net.proto; + +public final class SitRspOuterClass { + private SitRspOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SitRspOrBuilder extends + // @@protoc_insertion_point(interface_extends:SitRsp) + com.google.protobuf.MessageOrBuilder { + + /** + * uint32 entity_id = 2; + * @return The entityId. + */ + int getEntityId(); + + /** + * .Vector position = 3; + * @return Whether the position field is set. + */ + boolean hasPosition(); + /** + * .Vector position = 3; + * @return The position. + */ + emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition(); + /** + * .Vector position = 3; + */ + emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder(); + + /** + * uint64 chair_id = 4; + * @return The chairId. + */ + long getChairId(); + } + /** + * Protobuf type {@code SitRsp} + */ + public static final class SitRsp extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SitRsp) + SitRspOrBuilder { + private static final long serialVersionUID = 0L; + // Use SitRsp.newBuilder() to construct. + private SitRsp(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SitRsp() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SitRsp(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SitRsp( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 16: { + + entityId_ = input.readUInt32(); + break; + } + case 26: { + emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder subBuilder = null; + if (position_ != null) { + subBuilder = position_.toBuilder(); + } + position_ = input.readMessage(emu.grasscutter.net.proto.VectorOuterClass.Vector.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(position_); + position_ = subBuilder.buildPartial(); + } + + break; + } + case 32: { + + chairId_ = input.readUInt64(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SitRspOuterClass.internal_static_SitRsp_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SitRspOuterClass.internal_static_SitRsp_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SitRspOuterClass.SitRsp.class, emu.grasscutter.net.proto.SitRspOuterClass.SitRsp.Builder.class); + } + + public static final int ENTITY_ID_FIELD_NUMBER = 2; + private int entityId_; + /** + * uint32 entity_id = 2; + * @return The entityId. + */ + @java.lang.Override + public int getEntityId() { + return entityId_; + } + + public static final int POSITION_FIELD_NUMBER = 3; + private emu.grasscutter.net.proto.VectorOuterClass.Vector position_; + /** + * .Vector position = 3; + * @return Whether the position field is set. + */ + @java.lang.Override + public boolean hasPosition() { + return position_ != null; + } + /** + * .Vector position = 3; + * @return The position. + */ + @java.lang.Override + public emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition() { + return position_ == null ? emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } + /** + * .Vector position = 3; + */ + @java.lang.Override + public emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder() { + return getPosition(); + } + + public static final int CHAIR_ID_FIELD_NUMBER = 4; + private long chairId_; + /** + * uint64 chair_id = 4; + * @return The chairId. + */ + @java.lang.Override + public long getChairId() { + return chairId_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (entityId_ != 0) { + output.writeUInt32(2, entityId_); + } + if (position_ != null) { + output.writeMessage(3, getPosition()); + } + if (chairId_ != 0L) { + output.writeUInt64(4, chairId_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (entityId_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(2, entityId_); + } + if (position_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getPosition()); + } + if (chairId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(4, chairId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof emu.grasscutter.net.proto.SitRspOuterClass.SitRsp)) { + return super.equals(obj); + } + emu.grasscutter.net.proto.SitRspOuterClass.SitRsp other = (emu.grasscutter.net.proto.SitRspOuterClass.SitRsp) obj; + + if (getEntityId() + != other.getEntityId()) return false; + if (hasPosition() != other.hasPosition()) return false; + if (hasPosition()) { + if (!getPosition() + .equals(other.getPosition())) return false; + } + if (getChairId() + != other.getChairId()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENTITY_ID_FIELD_NUMBER; + hash = (53 * hash) + getEntityId(); + if (hasPosition()) { + hash = (37 * hash) + POSITION_FIELD_NUMBER; + hash = (53 * hash) + getPosition().hashCode(); + } + hash = (37 * hash) + CHAIR_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getChairId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(emu.grasscutter.net.proto.SitRspOuterClass.SitRsp prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code SitRsp} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SitRsp) + emu.grasscutter.net.proto.SitRspOuterClass.SitRspOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SitRspOuterClass.internal_static_SitRsp_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SitRspOuterClass.internal_static_SitRsp_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SitRspOuterClass.SitRsp.class, emu.grasscutter.net.proto.SitRspOuterClass.SitRsp.Builder.class); + } + + // Construct using emu.grasscutter.net.proto.SitRspOuterClass.SitRsp.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + entityId_ = 0; + + if (positionBuilder_ == null) { + position_ = null; + } else { + position_ = null; + positionBuilder_ = null; + } + chairId_ = 0L; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return emu.grasscutter.net.proto.SitRspOuterClass.internal_static_SitRsp_descriptor; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitRspOuterClass.SitRsp getDefaultInstanceForType() { + return emu.grasscutter.net.proto.SitRspOuterClass.SitRsp.getDefaultInstance(); + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitRspOuterClass.SitRsp build() { + emu.grasscutter.net.proto.SitRspOuterClass.SitRsp result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitRspOuterClass.SitRsp buildPartial() { + emu.grasscutter.net.proto.SitRspOuterClass.SitRsp result = new emu.grasscutter.net.proto.SitRspOuterClass.SitRsp(this); + result.entityId_ = entityId_; + if (positionBuilder_ == null) { + result.position_ = position_; + } else { + result.position_ = positionBuilder_.build(); + } + result.chairId_ = chairId_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof emu.grasscutter.net.proto.SitRspOuterClass.SitRsp) { + return mergeFrom((emu.grasscutter.net.proto.SitRspOuterClass.SitRsp)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(emu.grasscutter.net.proto.SitRspOuterClass.SitRsp other) { + if (other == emu.grasscutter.net.proto.SitRspOuterClass.SitRsp.getDefaultInstance()) return this; + if (other.getEntityId() != 0) { + setEntityId(other.getEntityId()); + } + if (other.hasPosition()) { + mergePosition(other.getPosition()); + } + if (other.getChairId() != 0L) { + setChairId(other.getChairId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + emu.grasscutter.net.proto.SitRspOuterClass.SitRsp parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (emu.grasscutter.net.proto.SitRspOuterClass.SitRsp) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int entityId_ ; + /** + * uint32 entity_id = 2; + * @return The entityId. + */ + @java.lang.Override + public int getEntityId() { + return entityId_; + } + /** + * uint32 entity_id = 2; + * @param value The entityId to set. + * @return This builder for chaining. + */ + public Builder setEntityId(int value) { + + entityId_ = value; + onChanged(); + return this; + } + /** + * uint32 entity_id = 2; + * @return This builder for chaining. + */ + public Builder clearEntityId() { + + entityId_ = 0; + onChanged(); + return this; + } + + private emu.grasscutter.net.proto.VectorOuterClass.Vector position_; + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder> positionBuilder_; + /** + * .Vector position = 3; + * @return Whether the position field is set. + */ + public boolean hasPosition() { + return positionBuilder_ != null || position_ != null; + } + /** + * .Vector position = 3; + * @return The position. + */ + public emu.grasscutter.net.proto.VectorOuterClass.Vector getPosition() { + if (positionBuilder_ == null) { + return position_ == null ? emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } else { + return positionBuilder_.getMessage(); + } + } + /** + * .Vector position = 3; + */ + public Builder setPosition(emu.grasscutter.net.proto.VectorOuterClass.Vector value) { + if (positionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + position_ = value; + onChanged(); + } else { + positionBuilder_.setMessage(value); + } + + return this; + } + /** + * .Vector position = 3; + */ + public Builder setPosition( + emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder builderForValue) { + if (positionBuilder_ == null) { + position_ = builderForValue.build(); + onChanged(); + } else { + positionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .Vector position = 3; + */ + public Builder mergePosition(emu.grasscutter.net.proto.VectorOuterClass.Vector value) { + if (positionBuilder_ == null) { + if (position_ != null) { + position_ = + emu.grasscutter.net.proto.VectorOuterClass.Vector.newBuilder(position_).mergeFrom(value).buildPartial(); + } else { + position_ = value; + } + onChanged(); + } else { + positionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .Vector position = 3; + */ + public Builder clearPosition() { + if (positionBuilder_ == null) { + position_ = null; + onChanged(); + } else { + position_ = null; + positionBuilder_ = null; + } + + return this; + } + /** + * .Vector position = 3; + */ + public emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder getPositionBuilder() { + + onChanged(); + return getPositionFieldBuilder().getBuilder(); + } + /** + * .Vector position = 3; + */ + public emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder getPositionOrBuilder() { + if (positionBuilder_ != null) { + return positionBuilder_.getMessageOrBuilder(); + } else { + return position_ == null ? + emu.grasscutter.net.proto.VectorOuterClass.Vector.getDefaultInstance() : position_; + } + } + /** + * .Vector position = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder> + getPositionFieldBuilder() { + if (positionBuilder_ == null) { + positionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + emu.grasscutter.net.proto.VectorOuterClass.Vector, emu.grasscutter.net.proto.VectorOuterClass.Vector.Builder, emu.grasscutter.net.proto.VectorOuterClass.VectorOrBuilder>( + getPosition(), + getParentForChildren(), + isClean()); + position_ = null; + } + return positionBuilder_; + } + + private long chairId_ ; + /** + * uint64 chair_id = 4; + * @return The chairId. + */ + @java.lang.Override + public long getChairId() { + return chairId_; + } + /** + * uint64 chair_id = 4; + * @param value The chairId to set. + * @return This builder for chaining. + */ + public Builder setChairId(long value) { + + chairId_ = value; + onChanged(); + return this; + } + /** + * uint64 chair_id = 4; + * @return This builder for chaining. + */ + public Builder clearChairId() { + + chairId_ = 0L; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SitRsp) + } + + // @@protoc_insertion_point(class_scope:SitRsp) + private static final emu.grasscutter.net.proto.SitRspOuterClass.SitRsp DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new emu.grasscutter.net.proto.SitRspOuterClass.SitRsp(); + } + + public static emu.grasscutter.net.proto.SitRspOuterClass.SitRsp getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SitRsp parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SitRsp(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SitRspOuterClass.SitRsp getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SitRsp_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SitRsp_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014SitRsp.proto\032\014Vector.proto\"H\n\006SitRsp\022\021" + + "\n\tentity_id\030\002 \001(\r\022\031\n\010position\030\003 \001(\0132\007.Ve" + + "ctor\022\020\n\010chair_id\030\004 \001(\004B\033\n\031emu.grasscutte" + + "r.net.protob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + emu.grasscutter.net.proto.VectorOuterClass.getDescriptor(), + }); + internal_static_SitRsp_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SitRsp_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SitRsp_descriptor, + new java.lang.String[] { "EntityId", "Position", "ChairId", }); + emu.grasscutter.net.proto.VectorOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandleEvtAvatarSitDownNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandleEvtAvatarSitDownNotify.java new file mode 100644 index 000000000..8f653dde9 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandleEvtAvatarSitDownNotify.java @@ -0,0 +1,21 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketEvtAvatarSitDownNotify; + +@Opcodes(PacketOpcodes.EvtAvatarSitDownNotify) +public class HandleEvtAvatarSitDownNotify extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + EvtAvatarSitDownNotify notify = EvtAvatarSitDownNotify.parseFrom(payload); + + session.send(new PacketEvtAvatarSitDownNotify(notify)); + } + +} + diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java new file mode 100644 index 000000000..418d99eef --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java @@ -0,0 +1,24 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.SitReqOuterClass; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketSitRsp; +import emu.grasscutter.utils.Position; + +@Opcodes(PacketOpcodes.SitReq) +public class HandleSitReq extends PacketHandler { + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + SitReqOuterClass.SitReq req = SitReqOuterClass.SitReq.parseFrom(payload); + + float x = req.getPosition().getX(); + float y = req.getPosition().getY(); + float z = req.getPosition().getZ(); + + session.send(new PacketSitRsp(req.getChairId(), new Position(x, y, z), session.getPlayer().getTeamManager().getCurrentAvatarEntity().getId())); + } + +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java new file mode 100644 index 000000000..0edb08f73 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java @@ -0,0 +1,38 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketGetPlayerSocialDetailRsp; +import emu.grasscutter.server.packet.send.PacketSetPlayerBirthdayRsp; + +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.packet.PacketHandler; + +import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; +import emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq; + +import com.google.gson.Gson; + +@Opcodes(PacketOpcodes.SetPlayerBirthdayReq) +public class HandlerSetPlayerBirthdayReq extends PacketHandler { + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + SetPlayerBirthdayReq req = SetPlayerBirthdayReq.parseFrom(payload); + + if(req.getBirth() != null && req.getBirth().getDay() > 0 && req.getBirth().getMonth() > 0) + { + int day = req.getBirth().getDay(); + int month = req.getBirth().getMonth(); + + // Update birthday value + session.getPlayer().setBirthday(day, month); + + // Save birthday month and day + session.getPlayer().save(); + SocialDetail.Builder detail = session.getPlayer().getSocialDetail(); + + session.send(new PacketSetPlayerBirthdayRsp(session.getPlayer())); + session.send(new PacketGetPlayerSocialDetailRsp(detail)); + } + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketEvtAvatarSitDownNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketEvtAvatarSitDownNotify.java new file mode 100644 index 000000000..6a051024a --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketEvtAvatarSitDownNotify.java @@ -0,0 +1,20 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify; + +public class PacketEvtAvatarSitDownNotify extends GenshinPacket { + + public PacketEvtAvatarSitDownNotify(EvtAvatarSitDownNotify notify) { + super(PacketOpcodes.EvtAvatarSitDownNotify); + + EvtAvatarSitDownNotify proto = EvtAvatarSitDownNotify.newBuilder() + .setEntityId(notify.getEntityId()) + .setPosition(notify.getPosition()) + .setChairId(notify.getChairId()) + .build(); + + this.setData(proto); + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java new file mode 100644 index 000000000..9b73b6b13 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java @@ -0,0 +1,20 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.game.GenshinPlayer; +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp; +import emu.grasscutter.net.proto.BirthdayOuterClass.Birthday; + +public class PacketSetPlayerBirthdayRsp extends GenshinPacket { + public PacketSetPlayerBirthdayRsp(GenshinPlayer player) { + super(PacketOpcodes.SetPlayerBirthdayRsp); + + SetPlayerBirthdayRsp proto = SetPlayerBirthdayRsp.newBuilder() + .setBirth(player.getBirthday().toProto()) + .build(); + + this.setData(proto); + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java new file mode 100644 index 000000000..70893965b --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java @@ -0,0 +1,21 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.SitRspOuterClass.SitRsp; +import emu.grasscutter.utils.Position; + +public class PacketSitRsp extends GenshinPacket { + + public PacketSitRsp(long chairId, Position pos, int EntityId) { + super(PacketOpcodes.SitRsp); + + SitRsp proto = SitRsp.newBuilder() + .setEntityId(EntityId) + .setPosition(pos.toProto()) + .setChairId(chairId) + .build(); + + this.setData(proto); + } +} diff --git a/src/main/java/emu/grasscutter/utils/Position.java b/src/main/java/emu/grasscutter/utils/Position.java index 6a02dacba..f2ecb6915 100644 --- a/src/main/java/emu/grasscutter/utils/Position.java +++ b/src/main/java/emu/grasscutter/utils/Position.java @@ -2,8 +2,10 @@ package emu.grasscutter.utils; import java.io.Serializable; +import dev.morphia.annotations.Entity; import emu.grasscutter.net.proto.VectorOuterClass.Vector; +@Entity public class Position implements Serializable { private static final long serialVersionUID = -2001232313615923575L; diff --git a/start.cmd b/start.cmd index 8c89f359e..8c525dfc8 100644 --- a/start.cmd +++ b/start.cmd @@ -74,7 +74,9 @@ for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVe @rem TODO: External proxy when ORIG_PROXY_ENABLE == 0x1 echo set ws = createobject("wscript.shell") > "%temp%\proxy.vbs" +if not "%MITMDUMP_PATH%" == "" ( echo ws.currentdirectory = "%MITMDUMP_PATH%" >> "%temp%\proxy.vbs" +) echo ws.run "cmd /c mitmdump.exe -s "^&chr(34)^&"%PROXY_SCRIPT_NAME%"^&chr(34)^&" -k",0 >> "%temp%\proxy.vbs" "%temp%\proxy.vbs" del /f /q "%temp%\proxy.vbs" >nul 2>nul @@ -117,7 +119,9 @@ set DATABASE=true mkdir "%DATABASE_STORAGE_PATH%" >nul 2>nul echo set ws = createobject("wscript.shell") > "%temp%\db.vbs" +if not "%MONGODB_PATH%" == "" ( echo ws.currentdirectory = "%MONGODB_PATH%" >> "%temp%\db.vbs" +) echo ws.run "cmd /c mongod.exe --dbpath "^&chr(34)^&"%DATABASE_STORAGE_PATH%"^&chr(34)^&"",0 >> "%temp%\db.vbs" "%temp%\db.vbs" del /f /q "%temp%\db.vbs" >nul 2>nul From 2a6984229eaf4e7e58dbb4ac2df4e58f138fe07c Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 23 Apr 2022 01:17:35 -0400 Subject: [PATCH 04/15] Plugin enabling & disabling --- .../java/emu/grasscutter/Grasscutter.java | 59 ++++++++++++------- .../java/emu/grasscutter/plugin/Plugin.java | 20 +++---- .../emu/grasscutter/plugin/PluginManager.java | 34 +++++++---- 3 files changed, 69 insertions(+), 44 deletions(-) diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index abcdc3557..8f64f0e51 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -8,6 +8,7 @@ import java.io.InputStreamReader; import java.net.InetSocketAddress; import emu.grasscutter.command.CommandMap; +import emu.grasscutter.plugin.PluginManager; import emu.grasscutter.utils.Utils; import org.reflections.Reflections; import org.slf4j.LoggerFactory; @@ -33,6 +34,7 @@ public final class Grasscutter { public static RunMode MODE = RunMode.BOTH; private static DispatchServer dispatchServer; private static GameServer gameServer; + private static PluginManager pluginManager; public static final Reflections reflector = new Reflections(); @@ -52,15 +54,11 @@ public final class Grasscutter { for (String arg : args) { switch (arg.toLowerCase()) { - case "-auth": - MODE = RunMode.AUTH; - break; - case "-game": - MODE = RunMode.GAME; - break; - case "-handbook": - Tools.createGmHandbook(); - return; + case "-auth" -> MODE = RunMode.AUTH; + case "-game" -> MODE = RunMode.GAME; + case "-handbook" -> { + Tools.createGmHandbook(); return; + } } } @@ -71,19 +69,21 @@ public final class Grasscutter { ResourceLoader.loadAll(); // Database DatabaseManager.initialize(); + + // Create server instances. + dispatchServer = new DispatchServer(); + gameServer = new GameServer(new InetSocketAddress(getConfig().getGameServerOptions().Ip, getConfig().getGameServerOptions().Port)); + + // Create plugin manager instance. + pluginManager = new PluginManager(); // Start servers. if(getConfig().RunMode.equalsIgnoreCase("HYBRID")) { - dispatchServer = new DispatchServer(); dispatchServer.start(); - - gameServer = new GameServer(new InetSocketAddress(getConfig().getGameServerOptions().Ip, getConfig().getGameServerOptions().Port)); gameServer.start(); - } else if(getConfig().RunMode.equalsIgnoreCase("DISPATCH_ONLY")) { - dispatchServer = new DispatchServer(); + } else if (getConfig().RunMode.equalsIgnoreCase("DISPATCH_ONLY")) { dispatchServer.start(); - } else if(getConfig().RunMode.equalsIgnoreCase("GAME_ONLY")) { - gameServer = new GameServer(new InetSocketAddress(getConfig().getGameServerOptions().Ip, getConfig().getGameServerOptions().Port)); + } else if (getConfig().RunMode.equalsIgnoreCase("GAME_ONLY")) { gameServer.start(); } else { getLogger().error("Invalid server run mode. " + getConfig().RunMode); @@ -91,12 +91,23 @@ public final class Grasscutter { getLogger().error("Shutting down..."); System.exit(1); } - - + + // Enable all plugins. + pluginManager.enablePlugins(); // Open console. startConsole(); + // Hook into shutdown event. + Runtime.getRuntime().addShutdownHook(new Thread(Grasscutter::onShutdown)); } + + /** + * Server shutdown event. + */ + private static void onShutdown() { + // Disable all plugins. + pluginManager.disablePlugins(); + } public static void loadConfig() { try (FileReader file = new FileReader(configFile)) { @@ -112,7 +123,7 @@ public final class Grasscutter { try (FileWriter file = new FileWriter(configFile)) { file.write(gson.toJson(config)); } catch (Exception e) { - Grasscutter.getLogger().error("Config save error"); + Grasscutter.getLogger().error("Unable to save config file."); } } @@ -122,13 +133,13 @@ public final class Grasscutter { while ((input = br.readLine()) != null) { try { if(getConfig().RunMode.equalsIgnoreCase("DISPATCH_ONLY")) { - getLogger().error("Commands are not supported in dispatch only mode"); + getLogger().error("Commands are not supported in dispatch only mode."); return; } + CommandMap.getInstance().invoke(null, input); } catch (Exception e) { - Grasscutter.getLogger().error("Command error: "); - e.printStackTrace(); + Grasscutter.getLogger().error("Command error:", e); } } } catch (Exception e) { @@ -161,4 +172,8 @@ public final class Grasscutter { public static GameServer getGameServer() { return gameServer; } + + public static PluginManager getPluginManager() { + return pluginManager; + } } diff --git a/src/main/java/emu/grasscutter/plugin/Plugin.java b/src/main/java/emu/grasscutter/plugin/Plugin.java index 145a06eb8..a3160d7c7 100644 --- a/src/main/java/emu/grasscutter/plugin/Plugin.java +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -7,22 +7,18 @@ import emu.grasscutter.server.game.GameServer; * The base class for all plugins to extend. */ public abstract class Plugin { - private final PluginIdentifier identifier; + private PluginIdentifier identifier; /** - * Empty constructor for developers. - * Should not be called by users. - */ - public Plugin() { - this(new PluginIdentifier("", "", "", new String[]{})); - } - - /** - * Constructor for plugins. + * This method is reflected into. + * + * Set plugin variables. * @param identifier The plugin's identifier. */ - public Plugin(PluginIdentifier identifier) { - this.identifier = identifier; + private void initializePlugin(PluginIdentifier identifier) { + if(this.identifier == null) + this.identifier = identifier; + else Grasscutter.getLogger().warn(this.identifier.name + " had a reinitialization attempt."); } /** diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java index 3177bb291..3e55e4ad8 100644 --- a/src/main/java/emu/grasscutter/plugin/PluginManager.java +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -5,13 +5,13 @@ import emu.grasscutter.utils.Utils; import java.io.File; import java.io.InputStreamReader; +import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * Manages the server's plugins & the event system. @@ -42,7 +42,7 @@ public final class PluginManager { List plugins = Arrays.stream(files) .filter(file -> file.getName().endsWith(".jar")) - .collect(Collectors.toList()); + .toList(); plugins.forEach(plugin -> { try { @@ -59,9 +59,8 @@ public final class PluginManager { } Class pluginClass = loader.loadClass(pluginConfig.mainClass); - Plugin pluginInstance = (Plugin) pluginClass.getDeclaredConstructor(PluginIdentifier.class) - .newInstance(PluginIdentifier.fromPluginConfig(pluginConfig)); - this.loadPlugin(pluginInstance); + Plugin pluginInstance = (Plugin) pluginClass.getDeclaredConstructor().newInstance(); + this.loadPlugin(pluginInstance, PluginIdentifier.fromPluginConfig(pluginConfig)); fileReader.close(); // Close the file reader. } catch (ClassNotFoundException ignored) { @@ -77,11 +76,20 @@ public final class PluginManager { * Load the specified plugin. * @param plugin The plugin instance. */ - private void loadPlugin(Plugin plugin) { - Grasscutter.getLogger().info("Loading plugin: " + plugin.getName()); + private void loadPlugin(Plugin plugin, PluginIdentifier identifier) { + Grasscutter.getLogger().info("Loading plugin: " + identifier.name); + + // Add the plugin's identifier. + try { + Class pluginClass = Plugin.class; + Method method = pluginClass.getDeclaredMethod("initializePlugin", PluginIdentifier.class); + method.setAccessible(true); method.invoke(plugin, identifier); method.setAccessible(false); + } catch (Exception ignored) { + Grasscutter.getLogger().warn("Failed to add plugin identifier: " + identifier.name); + } // Add the plugin to the list of loaded plugins. - this.plugins.put(plugin.getName(), plugin); + this.plugins.put(identifier.name, plugin); // Call the plugin's onLoad method. plugin.onLoad(); } @@ -90,13 +98,19 @@ public final class PluginManager { * Enables all registered plugins. */ public void enablePlugins() { - + this.plugins.forEach((name, plugin) -> { + Grasscutter.getLogger().info("Enabling plugin: " + name); + plugin.onEnable(); + }); } /** * Disables all registered plugins. */ public void disablePlugins() { - + this.plugins.forEach((name, plugin) -> { + Grasscutter.getLogger().info("Disabling plugin: " + name); + plugin.onDisable(); + }); } } \ No newline at end of file From 8b34222cebb8c67a39a66be2dd53d7784e7ce271 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 23 Apr 2022 01:58:37 -0400 Subject: [PATCH 05/15] Implement an event handler --- .../emu/grasscutter/plugin/PluginManager.java | 44 +++++++++++++++++-- .../grasscutter/server/event/Cancellable.java | 8 ++++ .../emu/grasscutter/server/event/Event.java | 33 ++++++++++++++ .../server/event/EventHandler.java | 11 +++++ .../grasscutter/server/event/Listener.java | 7 +++ .../grasscutter/server/event/ServerEvent.java | 17 +++++++ 6 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 src/main/java/emu/grasscutter/server/event/Cancellable.java create mode 100644 src/main/java/emu/grasscutter/server/event/Event.java create mode 100644 src/main/java/emu/grasscutter/server/event/EventHandler.java create mode 100644 src/main/java/emu/grasscutter/server/event/Listener.java create mode 100644 src/main/java/emu/grasscutter/server/event/ServerEvent.java diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java index 3e55e4ad8..7b54f460f 100644 --- a/src/main/java/emu/grasscutter/plugin/PluginManager.java +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -1,23 +1,25 @@ package emu.grasscutter.plugin; import emu.grasscutter.Grasscutter; +import emu.grasscutter.server.event.Event; +import emu.grasscutter.server.event.EventHandler; +import emu.grasscutter.server.event.Listener; import emu.grasscutter.utils.Utils; +import org.reflections.Reflections; import java.io.File; import java.io.InputStreamReader; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * Manages the server's plugins & the event system. */ public final class PluginManager { private final Map plugins = new HashMap<>(); + private final Map> listeners = new HashMap<>(); public PluginManager() { this.loadPlugins(); // Load all plugins from the plugins directory. @@ -113,4 +115,38 @@ public final class PluginManager { plugin.onDisable(); }); } + + /** + * Registers a plugin's event listener. + * @param plugin The plugin instance. + * @param listener The event listener. + */ + public void registerListener(Plugin plugin, Listener listener) { + this.listeners.computeIfAbsent(plugin, k -> new ArrayList<>()).add(listener); + } + + /** + * Invoke the provided event on all registered event listeners. + * @param event The event to invoke. + */ + public void invokeEvent(Event event) { + this.listeners.values().stream() + .flatMap(Collection::stream) + .forEach(listener -> this.invokeOnListener(listener, event)); + } + + /** + * Attempts to invoke the event on the provided listener. + */ + private void invokeOnListener(Listener listener, Event event) { + try { + Class listenerClass = listener.getClass(); + Method[] methods = listenerClass.getMethods(); + for (Method method : methods) { + if(!method.isAnnotationPresent(EventHandler.class)) return; + if(!method.getParameterTypes()[0].isAssignableFrom(event.getClass())) return; + method.invoke(listener, event); + } + } catch (Exception ignored) { } + } } \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/event/Cancellable.java b/src/main/java/emu/grasscutter/server/event/Cancellable.java new file mode 100644 index 000000000..0296f0b36 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/Cancellable.java @@ -0,0 +1,8 @@ +package emu.grasscutter.server.event; + +/** + * Implementing this interface marks an event as cancellable. + */ +public interface Cancellable { + void cancel(); +} diff --git a/src/main/java/emu/grasscutter/server/event/Event.java b/src/main/java/emu/grasscutter/server/event/Event.java new file mode 100644 index 000000000..7dd67b84d --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/Event.java @@ -0,0 +1,33 @@ +package emu.grasscutter.server.event; + +import emu.grasscutter.Grasscutter; + +/** + * A generic server event. + */ +public abstract class Event { + private boolean cancelled = false; + + /** + * Return the cancelled state of the event. + */ + public boolean isCanceled() { + return this.cancelled; + } + + /** + * Cancels the event if possible. + */ + public void cancel() throws IllegalAccessException { + if(!(this instanceof Cancellable)) + throw new IllegalAccessException("Event is not cancellable."); + this.cancelled = true; + } + + /** + * Pushes this event to all listeners. + */ + public void call() { + Grasscutter.getPluginManager().invokeEvent(this); + } +} diff --git a/src/main/java/emu/grasscutter/server/event/EventHandler.java b/src/main/java/emu/grasscutter/server/event/EventHandler.java new file mode 100644 index 000000000..d924933f2 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/EventHandler.java @@ -0,0 +1,11 @@ +package emu.grasscutter.server.event; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Declares a class as an event listener/handler. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface EventHandler { +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/event/Listener.java b/src/main/java/emu/grasscutter/server/event/Listener.java new file mode 100644 index 000000000..2949cfe4a --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/Listener.java @@ -0,0 +1,7 @@ +package emu.grasscutter.server.event; + +/** + * Implementing this interface declares a class as an event listener. + */ +public interface Listener { +} diff --git a/src/main/java/emu/grasscutter/server/event/ServerEvent.java b/src/main/java/emu/grasscutter/server/event/ServerEvent.java new file mode 100644 index 000000000..e87abae0d --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/ServerEvent.java @@ -0,0 +1,17 @@ +package emu.grasscutter.server.event; + +/** + * An event that is related to the internals of the server. + */ +public abstract class ServerEvent extends Event { + protected final Type type; + + public ServerEvent(Type type) { + this.type = type; + } + + public enum Type { + DISPATCH, + GAME + } +} From c676bb9f08954bf7cb387a289a79699aedbaadd9 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 23 Apr 2022 01:59:06 -0400 Subject: [PATCH 06/15] Implement region events --- .../server/dispatch/DispatchServer.java | 22 ++++++++++++++----- .../event/dispatch/QueryAllRegionsEvent.java | 21 ++++++++++++++++++ .../dispatch/QueryCurrentRegionEvent.java | 21 ++++++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java create mode 100644 src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 7c7915675..ba280fb3e 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -18,6 +18,8 @@ import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo; import emu.grasscutter.net.proto.RegionSimpleInfoOuterClass.RegionSimpleInfo; import emu.grasscutter.server.dispatch.json.*; import emu.grasscutter.server.dispatch.json.ComboTokenReqJson.LoginTokenData; +import emu.grasscutter.server.event.dispatch.QueryAllRegionsEvent; +import emu.grasscutter.server.event.dispatch.QueryCurrentRegionEvent; import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.Utils; @@ -189,24 +191,32 @@ public final class DispatchServer { // Dispatch server.createContext("/query_region_list", t -> { - // Log + // Log incoming request. Grasscutter.getLogger().info(String.format("[Dispatch] Client %s request: query_region_list", t.getRemoteAddress())); - - responseHTML(t, regionListBase64); + + // Invoke event. + QueryAllRegionsEvent event = new QueryAllRegionsEvent(this.regionListBase64); event.call(); + // Respond with event result. + responseHTML(t, event.getRegionList()); }); for (String regionName : regions.keySet()) { server.createContext("/query_cur_region_" + regionName, t -> { String regionCurrentBase64 = regions.get(regionName).Base64; - // Log + // Log incoming request. Grasscutter.getLogger().info(String.format("Client %s request: query_cur_region_%s", t.getRemoteAddress(), regionName)); - // Create a response form the request query parameters + + // Create a response from the request query parameters. URI uri = t.getRequestURI(); String response = "CAESGE5vdCBGb3VuZCB2ZXJzaW9uIGNvbmZpZw=="; if (uri.getQuery() != null && uri.getQuery().length() > 0) { response = regionCurrentBase64; } - responseHTML(t, response); + + // Invoke event. + QueryCurrentRegionEvent event = new QueryCurrentRegionEvent(response); event.call(); + // Respond with event result. + responseHTML(t, event.getRegionInfo()); }); } diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java new file mode 100644 index 000000000..8595f6221 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java @@ -0,0 +1,21 @@ +package emu.grasscutter.server.event.dispatch; + +import emu.grasscutter.server.event.ServerEvent; + +public final class QueryAllRegionsEvent extends ServerEvent { + private String regionList; + + public QueryAllRegionsEvent(String regionList) { + super(Type.DISPATCH); + + this.regionList = regionList; + } + + public void setRegionList(String regionList) { + this.regionList = regionList; + } + + public String getRegionList() { + return this.regionList; + } +} diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java new file mode 100644 index 000000000..d6a20b2df --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java @@ -0,0 +1,21 @@ +package emu.grasscutter.server.event.dispatch; + +import emu.grasscutter.server.event.ServerEvent; + +public final class QueryCurrentRegionEvent extends ServerEvent { + private String regionInfo; + + public QueryCurrentRegionEvent(String regionInfo) { + super(Type.DISPATCH); + + this.regionInfo = regionInfo; + } + + public void setRegionInfo(String regionInfo) { + this.regionInfo = regionInfo; + } + + public String getRegionInfo() { + return this.regionInfo; + } +} From c31312416ad27d9eb7b77996c4e4bf612c23df23 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 23 Apr 2022 02:08:31 -0400 Subject: [PATCH 07/15] Implement packet send/receive events --- .../emu/grasscutter/server/event/Event.java | 7 ++-- .../server/event/game/ReceivePacketEvent.java | 35 +++++++++++++++++++ .../server/event/game/SendPacketEvent.java | 30 ++++++++++++++++ .../server/game/GameServerPacketHandler.java | 11 +++--- .../grasscutter/server/game/GameSession.java | 12 +++---- 5 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java create mode 100644 src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java diff --git a/src/main/java/emu/grasscutter/server/event/Event.java b/src/main/java/emu/grasscutter/server/event/Event.java index 7dd67b84d..bea7dd66f 100644 --- a/src/main/java/emu/grasscutter/server/event/Event.java +++ b/src/main/java/emu/grasscutter/server/event/Event.java @@ -18,10 +18,9 @@ public abstract class Event { /** * Cancels the event if possible. */ - public void cancel() throws IllegalAccessException { - if(!(this instanceof Cancellable)) - throw new IllegalAccessException("Event is not cancellable."); - this.cancelled = true; + public void cancel() { + if(this instanceof Cancellable) + this.cancelled = true; } /** diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java new file mode 100644 index 000000000..51109c720 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java @@ -0,0 +1,35 @@ +package emu.grasscutter.server.event.game; + +import emu.grasscutter.server.event.Cancellable; +import emu.grasscutter.server.event.ServerEvent; +import emu.grasscutter.server.game.GameSession; + +public final class ReceivePacketEvent extends ServerEvent implements Cancellable { + private final GameSession gameSession; + private final int packetId; + private byte[] packetData; + + public ReceivePacketEvent(GameSession gameSession, int packetId, byte[] packetData) { + super(Type.GAME); + + this.gameSession = gameSession; + this.packetId = packetId; + this.packetData = packetData; + } + + public GameSession getGameSession() { + return this.gameSession; + } + + public int getPacketId() { + return this.packetId; + } + + public void setPacketData(byte[] packetData) { + this.packetData = packetData; + } + + public byte[] getPacketData() { + return this.packetData; + } +} diff --git a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java new file mode 100644 index 000000000..7a25b4e10 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java @@ -0,0 +1,30 @@ +package emu.grasscutter.server.event.game; + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.server.event.Cancellable; +import emu.grasscutter.server.event.ServerEvent; +import emu.grasscutter.server.game.GameSession; + +public final class SendPacketEvent extends ServerEvent implements Cancellable { + private final GameSession gameSession; + private GenshinPacket packet; + + public SendPacketEvent(GameSession gameSession, GenshinPacket packet) { + super(Type.GAME); + + this.gameSession = gameSession; + this.packet = packet; + } + + public GameSession getGameSession() { + return this.gameSession; + } + + public void setPacket(GenshinPacket packet) { + this.packet = packet; + } + + public GenshinPacket getPacket() { + return this.packet; + } +} diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index 62a57df91..50d508bed 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -2,6 +2,7 @@ package emu.grasscutter.server.game; import java.util.Set; +import emu.grasscutter.server.event.game.ReceivePacketEvent; import org.reflections.Reflections; import emu.grasscutter.Grasscutter; @@ -48,9 +49,7 @@ public class GameServerPacketHandler { } public void handle(GameSession session, int opcode, byte[] header, byte[] payload) { - PacketHandler handler = null; - - handler = this.handlers.get(opcode); + PacketHandler handler = this.handlers.get(opcode); if (handler != null) { try { @@ -77,8 +76,10 @@ public class GameServerPacketHandler { } } - // Handle - handler.handle(session, header, payload); + // Invoke event. + ReceivePacketEvent event = new ReceivePacketEvent(session, opcode, payload); event.call(); + if(!event.isCanceled()) // If event is not canceled, continue. + handler.handle(session, header, event.getPacketData()); } catch (Exception ex) { // TODO Remove this when no more needed ex.printStackTrace(); diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index ebd66dc20..53b4f32cc 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -10,6 +10,7 @@ import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodesUtil; import emu.grasscutter.netty.MihoyoKcpChannel; +import emu.grasscutter.server.event.game.SendPacketEvent; import emu.grasscutter.utils.Crypto; import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.Utils; @@ -161,16 +162,15 @@ public class GameSession extends MihoyoKcpChannel { genshinPacket.buildHeader(this.getNextClientSequence()); } - // Build packet - byte[] data = genshinPacket.build(); - // Log if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) { logPacket(genshinPacket); } - - // Send - send(data); + + // Invoke event. + SendPacketEvent event = new SendPacketEvent(this, genshinPacket); event.call(); + if(!event.isCanceled()) // If event is not cancelled, continue. + this.send(event.getPacket().build()); } private void logPacket(int opcode) { From c592891c744432bac6e40e741c48ab47940f11fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9C=9F=E5=BF=83?= Date: Mon, 25 Apr 2022 16:55:21 +0800 Subject: [PATCH 08/15] Update Java to 17 --- README.md | 4 ++-- README_zh-CN.md | 4 ++-- build.gradle | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5bcec2715..fdd0b1e27 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ EN | [中文](README_zh-CN.md) ### Requirements -* Java SE - 16 ([mirror link](https://github.com/adoptium/temurin16-binaries/releases/tag/jdk-16.0.2+7) since Oracle required an account to download old builds) +* Java SE - 17 ([mirror link](https://github.com/adoptium/temurin17-binaries/releases/tag/jdk-17.0.3+7) since Oracle required an account to download old builds) **Note:** If you just want to **run it**, then **jre** is fine @@ -142,7 +142,7 @@ character falling from a very high destination, exact location that you marked. # Quick Troubleshooting -* If compiling wasn't successful, please check your JDK installation (JDK 16 and validated JDK's bin PATH variable) +* If compiling wasn't successful, please check your JDK installation (JDK 17 and validated JDK's bin PATH variable) * My client doesn't connect, doesn't login, 4206, etc... - Mostly your proxy daemon setup is *the issue*, if using Fiddler make sure it running on another port except 8888 * Startup sequence: Mongodb > Grasscutter > Proxy daemon (mitmdump, fiddler, etc.) > Client diff --git a/README_zh-CN.md b/README_zh-CN.md index 075bc11a1..17f7e70f0 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -24,7 +24,7 @@ ### 环境需求 -* Java SE - 16 (当您没有Oracle账户,可以使用[镜像](https://github.com/adoptium/temurin16-binaries/releases/tag/jdk-16.0.2+7)) +* Java SE - 17 (当您没有Oracle账户,可以使用[镜像](https://mirrors.tuna.tsinghua.edu.cn/Adoptium/17/jdk/)) **注:** 如果您仅仅想要简单地**运行服务端**, 那么使用 **jre** 便足够了 @@ -142,6 +142,6 @@ chmod +x gradlew # 快速排除问题 -* 如果编译未能成功,请检查您的jdk安装 (JDK 16并确认jdk处于环境变量`PATH`中 +* 如果编译未能成功,请检查您的jdk安装 (JDK 17并确认jdk处于环境变量`PATH`中 * 我的客户端无法登录/连接, 4206, 其它... - 大部分情况下这是因为您的代理存在问题.如果使用Fiddler请确认Fiddler监听端口不是`8888` * 启动顺序: MongoDB > Grasscutter > 代理程序 (mitmdump, fiddler等.) > 客户端 diff --git a/build.gradle b/build.gradle index c32d56e1f..bf839316a 100644 --- a/build.gradle +++ b/build.gradle @@ -14,8 +14,8 @@ plugins { id 'application' } -sourceCompatibility = 16 -targetCompatibility = 16 +sourceCompatibility = 17 +targetCompatibility = 17 repositories { mavenCentral() From 8007b2ee9f3868bf6ab8306cabe9392bb3a5c2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9C=9F=E5=BF=83?= Date: Mon, 25 Apr 2022 16:57:46 +0800 Subject: [PATCH 09/15] Update Java to 17 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc0193c1a..8d6d6aaf0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: temurin - java-version: '16' + java-version: '17' - name: Run Gradle run: ./gradlew && ./gradlew jar - name: Upload build From 0ecde3d82f299ad8343550e31f2eb1f310b20eac Mon Sep 17 00:00:00 2001 From: alt3ri <95161279+alt3ri@users.noreply.github.com> Date: Tue, 26 Apr 2022 00:13:16 +0700 Subject: [PATCH 10/15] Delete ClearWeaponsCommand.java --- .../command/commands/ClearWeaponsCommand.java | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java diff --git a/src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java b/src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java deleted file mode 100644 index fbe72db87..000000000 --- a/src/main/java/emu/grasscutter/command/commands/ClearWeaponsCommand.java +++ /dev/null @@ -1,51 +0,0 @@ -package emu.grasscutter.command.commands; - -import emu.grasscutter.Grasscutter; -import emu.grasscutter.command.Command; -import emu.grasscutter.command.CommandHandler; -import emu.grasscutter.game.GenshinPlayer; -import emu.grasscutter.game.inventory.Inventory; -import emu.grasscutter.game.inventory.ItemType; - -import java.util.List; - -@Command(label = "clearweapons", usage = "clearweapons", - description = "Deletes all unequipped and unlocked weapons, including yellow rarity ones from your inventory", - aliases = {"clearwp"}, permission = "player.clearweapons") -public final class ClearWeaponsCommand implements CommandHandler { - - @Override - public void execute(GenshinPlayer sender, List args) { - if (sender == null) { - CommandHandler.sendMessage(null, "Run this command in-game."); - return; - } - - int target; - if (args.size() == 1) { - try { - target = Integer.parseInt(args.get(0)); - if (Grasscutter.getGameServer().getPlayerByUid(target) == null) { - target = sender.getUid(); - } - } catch (NumberFormatException e) { - CommandHandler.sendMessage(sender, "Invalid player id."); - return; - } - } else { - target = sender.getUid(); - } - GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); - if (targetPlayer == null) { - CommandHandler.sendMessage(sender, "Player not found."); - return; - } - - Inventory playerInventory = targetPlayer.getInventory(); - playerInventory.getItems().values().stream() - .filter(item -> item.getItemType() == ItemType.ITEM_WEAPON) - .filter(item -> !item.isLocked() && !item.isEquipped()) - .forEach(item -> playerInventory.removeItem(item, item.getCount())); - sender.dropMessage("Cleared weapons for " + targetPlayer.getNickname() + " ."); - } -} From dbca694a782cb883d0100bf61969123c56aa81d8 Mon Sep 17 00:00:00 2001 From: alt3ri <95161279+alt3ri@users.noreply.github.com> Date: Tue, 26 Apr 2022 00:13:26 +0700 Subject: [PATCH 11/15] Delete ClearArtifactsCommand.java --- .../commands/ClearArtifactsCommand.java | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/main/java/emu/grasscutter/command/commands/ClearArtifactsCommand.java diff --git a/src/main/java/emu/grasscutter/command/commands/ClearArtifactsCommand.java b/src/main/java/emu/grasscutter/command/commands/ClearArtifactsCommand.java deleted file mode 100644 index 258e1e1d5..000000000 --- a/src/main/java/emu/grasscutter/command/commands/ClearArtifactsCommand.java +++ /dev/null @@ -1,30 +0,0 @@ -package emu.grasscutter.command.commands; - -import emu.grasscutter.command.Command; -import emu.grasscutter.command.CommandHandler; -import emu.grasscutter.game.GenshinPlayer; -import emu.grasscutter.game.inventory.Inventory; -import emu.grasscutter.game.inventory.ItemType; - -import java.util.List; - -@Command(label = "clearartifacts", usage = "clearartifacts", - description = "Deletes all unequipped and unlocked level 0 artifacts, including yellow rarity ones from your inventory", - aliases = {"clearart"}, permission = "player.clearartifacts") -public final class ClearArtifactsCommand implements CommandHandler { - - @Override - public void execute(GenshinPlayer sender, List args) { - if (sender == null) { - CommandHandler.sendMessage(null, "Run this command in-game."); - return; // TODO: clear player's artifacts from console or other players - } - - Inventory playerInventory = sender.getInventory(); - playerInventory.getItems().values().stream() - .filter(item -> item.getItemType() == ItemType.ITEM_RELIQUARY) - .filter(item -> item.getLevel() == 1 && item.getExp() == 0) - .filter(item -> !item.isLocked() && !item.isEquipped()) - .forEach(item -> playerInventory.removeItem(item, item.getCount())); - } -} From 37b875717f08a0072809ed198a20586452668bb1 Mon Sep 17 00:00:00 2001 From: alt3ri <95161279+alt3ri@users.noreply.github.com> Date: Tue, 26 Apr 2022 00:18:48 +0700 Subject: [PATCH 12/15] Merged /clearartifacts and /clearweapons I merged ClearArtifactsCommand and ClearWeaponsCommand to ClearCommand with UID parameter. Still no send from console cuz I forgor :skull: Usage: /clear [uid] --- .../command/commands/ClearCommand.java | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/main/java/emu/grasscutter/command/commands/ClearCommand.java diff --git a/src/main/java/emu/grasscutter/command/commands/ClearCommand.java b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java new file mode 100644 index 000000000..8d16e58c1 --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java @@ -0,0 +1,106 @@ +package emu.grasscutter.command.commands; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.data.GenshinData; +import emu.grasscutter.data.def.ItemData; +import emu.grasscutter.game.GenshinPlayer; +import emu.grasscutter.game.inventory.GenshinItem; +import emu.grasscutter.game.inventory.Inventory; +import emu.grasscutter.game.inventory.ItemType; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +@Command(label = "clear", usage = "clear ", //Merged /clearartifacts and /clearweapons to /clear [uid] + description = "Deletes unequipped unlocked items, including yellow rarity ones from your inventory", + aliases = {"clear"}, permission = "player.clearinv") + +public final class ClearCommand implements CommandHandler { + + @Override + public void execute(GenshinPlayer sender, List args) { + int target; + if (sender == null) { + CommandHandler.sendMessage(null, "Run this command in-game."); + return; + } + String cmdSwitch = args.get(1); + + Inventory playerInventory = sender.getInventory(); + try { + target = Integer.parseInt(args.get(0)); + GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); + if (targetPlayer == null && sender != null) { + target = sender.getUid(); + } else { + switch (cmdSwitch){ + case "wp": + playerInventory.getItems().values().stream() + .filter(item -> item.getItemType() == ItemType.ITEM_WEAPON) + .filter(item -> !item.isLocked() && !item.isEquipped()) + .forEach(item -> playerInventory.removeItem(item, item.getCount())); + sender.dropMessage("Cleared weapons for " + targetPlayer.getNickname() + " ."); + break; + case "art": + playerInventory.getItems().values().stream() + .filter(item -> item.getItemType() == ItemType.ITEM_RELIQUARY) + .filter(item -> item.getLevel() == 1 && item.getExp() == 0) + .filter(item -> !item.isLocked() && !item.isEquipped()) + .forEach(item -> playerInventory.removeItem(item, item.getCount())); + sender.dropMessage("Cleared artifacts for " + targetPlayer.getNickname() + " ."); + break; + case "mat": + playerInventory.getItems().values().stream() + .filter(item -> item.getItemType() == ItemType.ITEM_MATERIAL) + .filter(item -> item.getLevel() == 1 && item.getExp() == 0) + .filter(item -> !item.isLocked() && !item.isEquipped()) + .forEach(item -> playerInventory.removeItem(item, item.getCount())); + sender.dropMessage("Cleared artifacts for " + targetPlayer.getNickname() + " ."); + break; + case "all": + playerInventory.getItems().values().stream() + .filter(item1 -> item1.getItemType() == ItemType.ITEM_RELIQUARY) + .filter(item1 -> item1.getLevel() == 1 && item1.getExp() == 0) + .filter(item1 -> !item1.isLocked() && !item1.isEquipped()) + .forEach(item1 -> playerInventory.removeItem(item1, item1.getCount())); + playerInventory.getItems().values().stream() + .filter(item2 -> item2.getItemType() == ItemType.ITEM_MATERIAL) + .filter(item2 -> !item2.isLocked() && !item2.isEquipped()) + .forEach(item2 -> playerInventory.removeItem(item2, item2.getCount())); + playerInventory.getItems().values().stream() + .filter(item3 -> item3.getItemType() == ItemType.ITEM_WEAPON) + .filter(item3 -> item3.getLevel() == 1 && item3.getExp() == 0) + .filter(item3 -> !item3.isLocked() && !item3.isEquipped()) + .forEach(item3 -> playerInventory.removeItem(item3, item3.getCount())); + playerInventory.getItems().values().stream() + .filter(item4 -> item4.getItemType() == ItemType.ITEM_FURNITURE) + .filter(item4 -> !item4.isLocked() && !item4.isEquipped()) + .forEach(item4 -> playerInventory.removeItem(item4, item4.getCount())); + playerInventory.getItems().values().stream() + .filter(item5 -> item5.getItemType() == ItemType.ITEM_DISPLAY) + .filter(item5 -> !item5.isLocked() && !item5.isEquipped()) + .forEach(item5 -> playerInventory.removeItem(item5, item5.getCount())); + playerInventory.getItems().values().stream() + .filter(item6 -> item6.getItemType() == ItemType.ITEM_VIRTUAL) + .filter(item6 -> !item6.isLocked() && !item6.isEquipped()) + .forEach(item6 -> playerInventory.removeItem(item6, item6.getCount())); + sender.dropMessage("Cleared everything for " + targetPlayer.getNickname() + " ."); + break; + } + } + } catch (NumberFormatException ignored) { + // TODO: Parse from item name using GM Handbook. + CommandHandler.sendMessage(sender, "Invalid playerId."); + return; + } + + GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); + if (targetPlayer == null) { + CommandHandler.sendMessage(sender, "Player not found."); + return; + } + } +} From f3240fc53fe0d8147a1b74a87061780f82aa8a18 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 25 Apr 2022 21:07:34 +0800 Subject: [PATCH 13/15] Add killcharacter command --- .../commands/KillCharacterCommand.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java diff --git a/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java b/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java new file mode 100644 index 000000000..b396fdaa1 --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java @@ -0,0 +1,57 @@ +package emu.grasscutter.command.commands; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.GenshinPlayer; +import emu.grasscutter.game.entity.EntityAvatar; +import emu.grasscutter.game.props.FightProperty; +import emu.grasscutter.game.props.LifeState; +import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; +import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify; + +import java.util.List; + +@Command(label = "killcharacter", usage = "killcharacter [playerId]", aliases = {"suicide"}, + description = "Directly kill a player's current active character", permission = "player.killcharacter") +public final class KillCharacterCommand implements CommandHandler { + + @Override + public void execute(GenshinPlayer sender, List args) { + if (sender == null) { + CommandHandler.sendMessage(null, "Run this command in-game."); + return; // TODO: kill a player's current active character from console + } + + int target; + if (args.size() == 1) { + try { + target = Integer.parseInt(args.get(0)); + if (Grasscutter.getGameServer().getPlayerByUid(target) == null) { + target = sender.getUid(); + } + } catch (NumberFormatException e) { + CommandHandler.sendMessage(sender, "Invalid player id."); + return; + } + } else { + target = sender.getUid(); + } + GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); + if (targetPlayer == null) { + CommandHandler.sendMessage(sender, "Player not found or offline."); + return; + } + + EntityAvatar entity = targetPlayer.getTeamManager().getCurrentAvatarEntity(); + entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0f); + // Packets + entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_HP)); + entity.getWorld().broadcastPacket(new PacketLifeStateChangeNotify(0, entity, LifeState.LIFE_DEAD)); + // remove + targetPlayer.getScene().removeEntity(entity); + entity.onDeath(0); + + sender.dropMessage("Killed " + targetPlayer.getNickname() + "'s current active character."); + } +} From 76e2fa59d8a710dd6b079b34b0dcde53f7d2ee8d Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 25 Apr 2022 21:22:33 +0800 Subject: [PATCH 14/15] Add a new alias to the command `killcharacter` --- .../emu/grasscutter/command/commands/KillCharacterCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java b/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java index b396fdaa1..f877c64df 100644 --- a/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java @@ -12,7 +12,7 @@ import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify; import java.util.List; -@Command(label = "killcharacter", usage = "killcharacter [playerId]", aliases = {"suicide"}, +@Command(label = "killcharacter", usage = "killcharacter [playerId]", aliases = {"suicide", "kill"}, description = "Directly kill a player's current active character", permission = "player.killcharacter") public final class KillCharacterCommand implements CommandHandler { From dbb7350f6f20adb7f63a3e3853e50b1a7785eca7 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 25 Apr 2022 21:56:12 +0800 Subject: [PATCH 15/15] Support kill from console --- .../commands/KillCharacterCommand.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java b/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java index f877c64df..beaa4f959 100644 --- a/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/KillCharacterCommand.java @@ -13,30 +13,41 @@ import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify; import java.util.List; @Command(label = "killcharacter", usage = "killcharacter [playerId]", aliases = {"suicide", "kill"}, - description = "Directly kill a player's current active character", permission = "player.killcharacter") + description = "Kills the players current character", permission = "player.killcharacter") public final class KillCharacterCommand implements CommandHandler { @Override public void execute(GenshinPlayer sender, List args) { - if (sender == null) { - CommandHandler.sendMessage(null, "Run this command in-game."); - return; // TODO: kill a player's current active character from console - } - int target; - if (args.size() == 1) { - try { - target = Integer.parseInt(args.get(0)); - if (Grasscutter.getGameServer().getPlayerByUid(target) == null) { - target = sender.getUid(); + if (sender == null) { + // from console + if (args.size() == 1) { + try { + target = Integer.parseInt(args.get(0)); + } catch (NumberFormatException e) { + CommandHandler.sendMessage(null, "Invalid player id."); + return; } - } catch (NumberFormatException e) { - CommandHandler.sendMessage(sender, "Invalid player id."); + } else { + CommandHandler.sendMessage(null, "Usage: /killcharacter [playerId]"); return; } } else { - target = sender.getUid(); + if (args.size() == 1) { + try { + target = Integer.parseInt(args.get(0)); + if (Grasscutter.getGameServer().getPlayerByUid(target) == null) { + target = sender.getUid(); + } + } catch (NumberFormatException e) { + CommandHandler.sendMessage(sender, "Invalid player id."); + return; + } + } else { + target = sender.getUid(); + } } + GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); if (targetPlayer == null) { CommandHandler.sendMessage(sender, "Player not found or offline."); @@ -52,6 +63,6 @@ public final class KillCharacterCommand implements CommandHandler { targetPlayer.getScene().removeEntity(entity); entity.onDeath(0); - sender.dropMessage("Killed " + targetPlayer.getNickname() + "'s current active character."); + CommandHandler.sendMessage(sender, "Killed " + targetPlayer.getNickname() + " current character."); } }