From 95b26b5ba46628c06e727716002bf73f1d88e1dd Mon Sep 17 00:00:00 2001 From: Alexander Hartmann Date: Sat, 2 Nov 2024 07:08:03 +0100 Subject: [PATCH] [Refactoring] Removed now unused protobuff code from the buld scripts and project (#167) * [Refactoring] Remove all protobuff related code from the gradle script and project * [Refactoring] Removed now unused exlipse and intellij plugins * [Dependencies] Updated lombok version (1.18.24->1.18.34) --- build.gradle | 64 ++----------------- .../game/ability/AbilityManager.java | 14 ++-- .../ability/actions/ActionApplyModifier.java | 4 -- .../ability/mixins/AbilityMixinHandler.java | 2 - .../game/managers/energy/EnergyManager.java | 3 +- .../grasscutter/net/packet/BasePacket.java | 10 --- .../net/packet/BaseTypedPacket.java | 11 ---- .../server/http/dispatch/RegionHandler.java | 1 - 8 files changed, 11 insertions(+), 98 deletions(-) diff --git a/build.gradle b/build.gradle index 0fd2ced2..f7f817a1 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,6 @@ buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } - dependencies { - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' - } } plugins { @@ -26,15 +23,6 @@ plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' - // Apply the protobuf auto generator - id 'com.google.protobuf' version "0.8.18" - - // Eclipse Support - id 'eclipse' - - // IntelliJ Support - id 'idea' - // Maven id 'maven-publish' id 'signing' @@ -85,7 +73,6 @@ dependencies { implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.79.Final' implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0' - implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.18.2' implementation group: 'org.reflections', name: 'reflections', version: '0.10.2' @@ -114,12 +101,10 @@ dependencies { implementation group: 'io.javalin', name: 'javalin', version: '4.6.4' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.3' - protobuf files('proto/') - - compileOnly 'org.projectlombok:lombok:1.18.24' - annotationProcessor 'org.projectlombok:lombok:1.18.24' - testCompileOnly 'org.projectlombok:lombok:1.18.24' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.24' + compileOnly 'org.projectlombok:lombok:1.18.34' + annotationProcessor 'org.projectlombok:lombok:1.18.34' + testCompileOnly 'org.projectlombok:lombok:1.18.34' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.34' } configurations.all { @@ -132,7 +117,6 @@ application { } shadowJar { - exclude("*.proto") zip64 = true duplicatesStrategy = DuplicatesStrategy.INCLUDE mergeServiceFiles() @@ -146,8 +130,6 @@ shadowJar { } jar { - exclude '*.proto' - manifest { attributes 'Main-Class': 'emu.grasscutter.Grasscutter' } @@ -232,48 +214,14 @@ publishing { } } -clean { - delete protobuf.generatedFilesBaseDir -} - -protobuf { - protoc { - // The artifact spec for the Protobuf Compiler - artifact = 'com.google.protobuf:protoc:3.18.1' - } -// generatedFilesBaseDir = "$projectDir/src/main/java/emu/grasscutter/net/proto/" - generatedFilesBaseDir = "$projectDir/src/generated/" -} - sourceSets { main { - proto { - // In addition to the default 'src/main/proto' - srcDir 'src/generated' - } java { srcDir 'src/java' } } } -idea { - module { - // proto files and generated Java files are automatically added as - // source dirs. - // If you have additional sources, add them here: - sourceDirs += file("/proto/"); - } -} - -eclipse { - classpath { - file.whenMerged { cp -> - cp.entries.add( new org.gradle.plugins.ide.eclipse.model.SourceFolder('src/generated/main/java', null) ) - } - } -} - signing { if(!version.endsWith('-dev')) { sign publishing.publications.mavenJava @@ -306,8 +254,4 @@ public final class BuildConfig { } -processResources { - dependsOn "generateProto" -} - task generateActivityConditions(type: GenerateActivityConditions) diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index 95c0a282..bf834dbd 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -11,8 +11,6 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.Loggers; import emu.grasscutter.game.props.ElementReactionType; -import com.google.protobuf.InvalidProtocolBufferException; - import emu.grasscutter.data.GameData; import emu.grasscutter.data.binout.AbilityData; import emu.grasscutter.data.binout.AbilityMixinData; @@ -414,11 +412,11 @@ public final class AbilityManager extends BasePlayerManager { } } - private void handleMixinCostStamina(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException { + private void handleMixinCostStamina(AbilityInvokeEntry invoke) { } - private void handleGenerateElemBall(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException { + private void handleGenerateElemBall(AbilityInvokeEntry invoke) { } @@ -432,7 +430,7 @@ public final class AbilityManager extends BasePlayerManager { return null; } - private void handleGlobalFloatValue(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException { + private void handleGlobalFloatValue(AbilityInvokeEntry invoke) { var entity = this.player.getScene().getEntityById(invoke.getEntityId()); if(entity == null) return; @@ -465,11 +463,11 @@ public final class AbilityManager extends BasePlayerManager { } - private void handleModifierDurabilityChange(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException { + private void handleModifierDurabilityChange(AbilityInvokeEntry invoke) { } - private void handleAddNewAbility(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException { + private void handleAddNewAbility(AbilityInvokeEntry invoke) { var entity = this.player.getScene().getEntityById(invoke.getEntityId()); if(entity == null) { @@ -496,7 +494,7 @@ public final class AbilityManager extends BasePlayerManager { * Invoked when an entity triggered an elemental reaction. * @param invoke Holds information of elemental reaction, attacker and target. */ - private void handleTriggerElementReaction(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException { + private void handleTriggerElementReaction(AbilityInvokeEntry invoke) { if (getPlayer().getScene() == null) return; AbilityMetaTriggerElementReaction data = AbilityMetaTriggerElementReaction.parseBy(invoke.getAbilityData(), player.getSession().getVersion()); diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionApplyModifier.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionApplyModifier.java index 92c7c5ec..e368edb7 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionApplyModifier.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionApplyModifier.java @@ -1,12 +1,8 @@ package emu.grasscutter.game.ability.actions; -import com.google.protobuf.ByteString; - -import emu.grasscutter.Grasscutter; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; import emu.grasscutter.game.ability.Ability; -import emu.grasscutter.game.ability.AbilityModifierController; import emu.grasscutter.game.entity.GameEntity; @AbilityAction(AbilityModifierAction.Type.ApplyModifier) diff --git a/src/main/java/emu/grasscutter/game/ability/mixins/AbilityMixinHandler.java b/src/main/java/emu/grasscutter/game/ability/mixins/AbilityMixinHandler.java index fc46ec50..d6e3cf93 100644 --- a/src/main/java/emu/grasscutter/game/ability/mixins/AbilityMixinHandler.java +++ b/src/main/java/emu/grasscutter/game/ability/mixins/AbilityMixinHandler.java @@ -1,7 +1,5 @@ package emu.grasscutter.game.ability.mixins; -import com.google.protobuf.ByteString; - import emu.grasscutter.data.binout.AbilityMixinData; import emu.grasscutter.game.ability.Ability; diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java index 74936a5d..eeb0123b 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java @@ -1,6 +1,5 @@ package emu.grasscutter.game.managers.energy; -import com.google.protobuf.InvalidProtocolBufferException; import emu.grasscutter.Grasscutter; import emu.grasscutter.data.DataLoader; import emu.grasscutter.data.GameData; @@ -121,7 +120,7 @@ public class EnergyManager extends BasePlayerManager { }; } - public void handleGenerateElemBall(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException { + public void handleGenerateElemBall(AbilityInvokeEntry invoke) { // ToDo: // This is also called when a weapon like Favonius Warbow etc. creates energy through its passive. // We are not handling this correctly at the moment. diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index 6485e24c..4c1579e9 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -3,7 +3,6 @@ package emu.grasscutter.net.packet; import java.io.ByteArrayOutputStream; import java.io.IOException; -import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.utils.Crypto; import lombok.val; @@ -76,15 +75,6 @@ public class BasePacket { this.data = data; } - public void setData(GeneratedMessageV3 proto) { - this.data = proto.toByteArray(); - } - - @SuppressWarnings("rawtypes") - public void setData(GeneratedMessageV3.Builder proto) { - this.data = proto.build().toByteArray(); - } - public BasePacket buildHeader(int clientSequence) { if (this.getHeader() != null && clientSequence == 0) { return this; diff --git a/src/main/java/emu/grasscutter/net/packet/BaseTypedPacket.java b/src/main/java/emu/grasscutter/net/packet/BaseTypedPacket.java index 0e2cdf52..07718765 100644 --- a/src/main/java/emu/grasscutter/net/packet/BaseTypedPacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BaseTypedPacket.java @@ -1,6 +1,5 @@ package emu.grasscutter.net.packet; -import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.server.game.GameSession; import org.anime_game_servers.core.base.Version; import org.anime_game_servers.multi_proto.core.interfaces.ProtoModel; @@ -36,14 +35,4 @@ public abstract class BaseTypedPacket extends BasePac public void setData(byte[] data) { throw new UnsupportedOperationException("Not supported, why are you doing this."); } - @Deprecated - @Override - public void setData(GeneratedMessageV3 proto) { - setData((byte[])null); - } - - @Override @Deprecated - public void setData(GeneratedMessageV3.Builder proto) { - setData((byte[])null); - } } diff --git a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java index 03a33903..324526e7 100644 --- a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java +++ b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java @@ -1,6 +1,5 @@ package emu.grasscutter.server.http.dispatch; -import com.google.protobuf.ByteString; import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerRunMode; import emu.grasscutter.server.event.dispatch.QueryAllRegionsEvent;