Skip to content

Commit

Permalink
Delete integration package, inline methods
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 2, 2023
1 parent adddcca commit 07a0001
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import de.florianmichael.classic4j.model.classicube.CCAuthenticationResponse;
import de.florianmichael.classic4j.model.classicube.CCError;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand All @@ -29,6 +29,14 @@ public class MixinCCAuthenticationResponse {

@Redirect(method = "getErrorDisplay", at = @At(value = "FIELD", target = "Lde/florianmichael/classic4j/model/classicube/CCError;description:Ljava/lang/String;"))
public String mapTranslations(CCError instance) {
return Classic4JImpl.fromError(instance).getString();
switch (instance) {
case TOKEN -> Text.translatable("classicube.viafabricplus.error.token").getString();
case USERNAME -> Text.translatable("classicube.viafabricplus.error.username").getString();
case PASSWORD -> Text.translatable("classicube.viafabricplus.error.password").getString();
case VERIFICATION -> Text.translatable("classicube.viafabricplus.error.verification").getString();
case LOGIN_CODE -> Text.translatable("classicube.viafabricplus.error.logincode").getString();
}

return instance.description;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
*/
package de.florianmichael.viafabricplus.protocolhack.provider.vialegacy;

import com.mojang.authlib.exceptions.AuthenticationException;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.classic4j.BetaCraftHandler;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import de.florianmichael.viafabricplus.settings.impl.AuthenticationSettings;
import net.minecraft.client.MinecraftClient;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage;

Expand All @@ -35,12 +36,20 @@ public String getMpPass(UserConnection user) {
}

if (AuthenticationSettings.INSTANCE.useBetaCraftAuthentication.getValue()) {
final HandshakeStorage handshakeStorage = user.get(HandshakeStorage.class);
final var handshakeStorage = user.get(HandshakeStorage.class);
if (handshakeStorage == null) {
return super.getMpPass(user);
}
return BetaCraftHandler.requestMPPass(user.getProtocolInfo().getUsername(), handshakeStorage.getHostname(), handshakeStorage.getPort(), Classic4JImpl.JOIN_SERVER_CALL, throwable ->
ViaFabricPlus.LOGGER.error("Error occurred while requesting the MP-Pass to verify session", throwable));

return BetaCraftHandler.requestMPPass(user.getProtocolInfo().getUsername(), handshakeStorage.getHostname(), handshakeStorage.getPort(), serverId -> {
final var mc = MinecraftClient.getInstance();

try {
mc.getSessionService().joinServer(mc.getSession().getUuidOrNull(), mc.getSession().getAccessToken(), serverId);
} catch (AuthenticationException e) {
ViaFabricPlus.LOGGER.error("Error occurred while verifying session", e);
}
}, throwable -> ViaFabricPlus.LOGGER.error("Error occurred while requesting the MP-Pass to verify session", throwable));
} else {
return super.getMpPass(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.classic4j.ClassiCubeHandler;
import de.florianmichael.classic4j.api.LoginProcessHandler;
import de.florianmichael.classic4j.model.classicube.CCError;
import de.florianmichael.classic4j.model.classicube.account.CCAccount;
import de.florianmichael.viafabricplus.screen.VFPScreen;
import de.florianmichael.viafabricplus.definition.account.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import de.florianmichael.viafabricplus.screen.common.ProtocolSelectionScreen;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
Expand All @@ -41,7 +39,7 @@ public ClassiCubeMFAScreen() {

@Override
public void open(Screen prevScreen) {
this.setupSubtitle(Classic4JImpl.fromError(CCError.LOGIN_CODE));
this.setupSubtitle(Text.translatable("classicube.viafabricplus.error.logincode"));
super.open(prevScreen);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.integration;
package de.florianmichael.viafabricplus.screen.settings;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;

public class ModMenuImpl implements ModMenuApi {

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"environment": "client",
"entrypoints": {
"modmenu": [
"de.florianmichael.viafabricplus.integration.ModMenuImpl"
"de.florianmichael.viafabricplus.screen.settings.ModMenuImpl"
]
},
"mixins": [
Expand Down

0 comments on commit 07a0001

Please sign in to comment.