Added basic (and functional!) Login screen
Metadata now ignores the Forge part of the Minecraft version String
This commit is contained in:
@@ -11,10 +11,11 @@ import net.minecraftforge.fml.common.Mod.Instance;
|
|||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import eu.crushedpixel.replaymod.authentication.AuthenticationHandler;
|
import eu.crushedpixel.replaymod.api.client.ApiClient;
|
||||||
import eu.crushedpixel.replaymod.events.GuiEventHandler;
|
import eu.crushedpixel.replaymod.events.GuiEventHandler;
|
||||||
import eu.crushedpixel.replaymod.events.GuiReplayOverlay;
|
import eu.crushedpixel.replaymod.events.GuiReplayOverlay;
|
||||||
import eu.crushedpixel.replaymod.events.RecordingHandler;
|
import eu.crushedpixel.replaymod.events.RecordingHandler;
|
||||||
|
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||||
import eu.crushedpixel.replaymod.renderer.SafeEntityRenderer;
|
import eu.crushedpixel.replaymod.renderer.SafeEntityRenderer;
|
||||||
@@ -49,6 +50,8 @@ public class ReplayMod
|
|||||||
|
|
||||||
public static int TP_DISTANCE_LIMIT = 128;
|
public static int TP_DISTANCE_LIMIT = 128;
|
||||||
|
|
||||||
|
public static final ApiClient apiClient = new ApiClient();
|
||||||
|
|
||||||
// The instance of your mod that Forge uses.
|
// The instance of your mod that Forge uses.
|
||||||
@Instance(value = "ReplayModID")
|
@Instance(value = "ReplayModID")
|
||||||
public static ReplayMod instance;
|
public static ReplayMod instance;
|
||||||
@@ -87,8 +90,6 @@ public class ReplayMod
|
|||||||
FMLCommonHandler.instance().bus().register(overlay);
|
FMLCommonHandler.instance().bus().register(overlay);
|
||||||
MinecraftForge.EVENT_BUS.register(overlay);
|
MinecraftForge.EVENT_BUS.register(overlay);
|
||||||
|
|
||||||
AuthenticationHandler.authenticate();
|
|
||||||
|
|
||||||
KeybindRegistry.initialize();
|
KeybindRegistry.initialize();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -20,11 +20,14 @@ import net.minecraftforge.client.event.GuiOpenEvent;
|
|||||||
import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import eu.crushedpixel.replaymod.authentication.AuthenticationHandler;
|
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||||
import eu.crushedpixel.replaymod.gui.GuiReplaySaving;
|
import eu.crushedpixel.replaymod.gui.GuiReplaySaving;
|
||||||
import eu.crushedpixel.replaymod.gui.GuiReplaySettings;
|
import eu.crushedpixel.replaymod.gui.GuiReplaySettings;
|
||||||
|
import eu.crushedpixel.replaymod.gui.online.GuiLoginPrompt;
|
||||||
|
import eu.crushedpixel.replaymod.gui.online.GuiReplayCenter;
|
||||||
import eu.crushedpixel.replaymod.gui.replaymanager.GuiReplayManager;
|
import eu.crushedpixel.replaymod.gui.replaymanager.GuiReplayManager;
|
||||||
import eu.crushedpixel.replaymod.gui.replaymanager.ResourceHelper;
|
import eu.crushedpixel.replaymod.gui.replaymanager.ResourceHelper;
|
||||||
|
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||||
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
||||||
import eu.crushedpixel.replaymod.renderer.SafeEntityRenderer;
|
import eu.crushedpixel.replaymod.renderer.SafeEntityRenderer;
|
||||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
@@ -64,9 +67,6 @@ public class GuiEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int REPLAY_MANAGER_ID = 9001;
|
|
||||||
private static final int REPLAY_OPTIONS_ID = 9001;
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onInit(InitGuiEvent event) {
|
public void onInit(InitGuiEvent event) {
|
||||||
if(event.gui instanceof GuiIngameMenu && ReplayHandler.replayActive()) {
|
if(event.gui instanceof GuiIngameMenu && ReplayHandler.replayActive()) {
|
||||||
@@ -89,9 +89,15 @@ public class GuiEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton rm = new GuiButton(REPLAY_MANAGER_ID, event.gui.width / 2 - 100, i1 + 2*24, I18n.format("Replay Manager", new Object[0]));
|
GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2*24, I18n.format("Replay Manager", new Object[0]));
|
||||||
|
rm.width = rm.width/2 - 2;
|
||||||
rm.enabled = AuthenticationHandler.isAuthenticated();
|
rm.enabled = AuthenticationHandler.isAuthenticated();
|
||||||
event.buttonList.add(rm);
|
event.buttonList.add(rm);
|
||||||
|
|
||||||
|
GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2*24, I18n.format("Replay Center", new Object[0]));
|
||||||
|
rc.width = rc.width/2 - 2;
|
||||||
|
rc.enabled = true;
|
||||||
|
event.buttonList.add(rc);
|
||||||
} else if(event.gui instanceof GuiOptions) {
|
} else if(event.gui instanceof GuiOptions) {
|
||||||
event.buttonList.add(new GuiButton(9001, event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, "Replay Mod Settings..."));
|
event.buttonList.add(new GuiButton(9001, event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, "Replay Mod Settings..."));
|
||||||
}
|
}
|
||||||
@@ -99,10 +105,14 @@ public class GuiEventHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(ActionPerformedEvent event) {
|
public void onButton(ActionPerformedEvent event) {
|
||||||
if(!AuthenticationHandler.isAuthenticated()) return;
|
if(!event.button.enabled) return;
|
||||||
if(event.gui instanceof GuiMainMenu && event.button.id == REPLAY_MANAGER_ID) {
|
if(event.gui instanceof GuiMainMenu) {
|
||||||
mc.displayGuiScreen(new GuiReplayManager());
|
if(event.button.id == GuiConstants.REPLAY_MANAGER_BUTTON_ID) {
|
||||||
} else if(event.gui instanceof GuiOptions && event.button.id == REPLAY_OPTIONS_ID) {
|
mc.displayGuiScreen(new GuiReplayManager());
|
||||||
|
} else if(event.button.id == GuiConstants.REPLAY_CENTER_BUTTON_ID) {
|
||||||
|
mc.displayGuiScreen(new GuiLoginPrompt(event.gui, new GuiReplayCenter()));
|
||||||
|
}
|
||||||
|
} else if(event.gui instanceof GuiOptions && event.button.id == GuiConstants.REPLAY_OPTIONS_BUTTON_ID) {
|
||||||
mc.displayGuiScreen(new GuiReplaySettings(event.gui));
|
mc.displayGuiScreen(new GuiReplaySettings(event.gui));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,8 +121,6 @@ public class GuiEventHandler {
|
|||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//mc.displayGuiScreen(new GuiReplaySaving(new GuiMainMenu()));
|
|
||||||
|
|
||||||
ReplayHandler.setSpeed(1f);
|
ReplayHandler.setSpeed(1f);
|
||||||
ReplayHandler.endReplay();
|
ReplayHandler.endReplay();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package eu.crushedpixel.replaymod.gui;
|
||||||
|
|
||||||
|
public class GuiConstants {
|
||||||
|
|
||||||
|
public static final int REPLAY_OPTIONS_BUTTON_ID = 8000;
|
||||||
|
|
||||||
|
public static final int REPLAY_MANAGER_BUTTON_ID = 9001;
|
||||||
|
|
||||||
|
public static final int REPLAY_CENTER_BUTTON_ID = 1000;
|
||||||
|
public static final int REPLAY_CENTER_LOGIN_TEXT_ID = 1001;
|
||||||
|
public static final int REPLAY_CENTER_PASSWORD_TEXT_ID = 1002;
|
||||||
|
|
||||||
|
public static final int LOGIN_OKAY_BUTTON = 1100;
|
||||||
|
public static final int LOGIN_CANCEL_BUTTON = 1101;
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package eu.crushedpixel.replaymod.gui;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
|
||||||
|
public class PasswordTextField extends GuiTextField {
|
||||||
|
|
||||||
|
private static Field text;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
text = GuiTextField.class.getDeclaredField(MCPNames.field("field_146216_j"));
|
||||||
|
text.setAccessible(true);
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PasswordTextField(int p_i45542_1_, FontRenderer p_i45542_2_,
|
||||||
|
int p_i45542_3_, int p_i45542_4_, int p_i45542_5_, int p_i45542_6_) {
|
||||||
|
super(p_i45542_1_, p_i45542_2_, p_i45542_3_, p_i45542_4_, p_i45542_5_,
|
||||||
|
p_i45542_6_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawTextBox() {
|
||||||
|
String prev = getText();
|
||||||
|
|
||||||
|
String pw = "";
|
||||||
|
for(int i=0; i<prev.length(); i++) {
|
||||||
|
pw += "*";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
text.set(this, pw);
|
||||||
|
super.drawTextBox();
|
||||||
|
text.set(this, prev);
|
||||||
|
} catch(Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
package eu.crushedpixel.replaymod.gui.online;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||||
|
import eu.crushedpixel.replaymod.gui.PasswordTextField;
|
||||||
|
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||||
|
|
||||||
|
public class GuiLoginPrompt extends GuiScreen {
|
||||||
|
|
||||||
|
private static final int EMPTY = 0;
|
||||||
|
private static final int LOGGING_IN = 1;
|
||||||
|
private static final int INVALID_LOGIN = 2;
|
||||||
|
private static final int NO_CONNECTION = 3;
|
||||||
|
|
||||||
|
private GuiScreen parent, successScreen;
|
||||||
|
|
||||||
|
private int textState = 0;
|
||||||
|
|
||||||
|
private static Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
private GuiTextField username;
|
||||||
|
private PasswordTextField password;
|
||||||
|
private GuiButton loginButton;
|
||||||
|
private GuiButton cancelButton;
|
||||||
|
|
||||||
|
public GuiLoginPrompt(GuiScreen parent, GuiScreen successScreen) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.successScreen = successScreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
Keyboard.enableRepeatEvents(true);
|
||||||
|
|
||||||
|
username = new GuiTextField(GuiConstants.REPLAY_CENTER_LOGIN_TEXT_ID, fontRendererObj, this.width/2 - 45, 30, 145, 20);
|
||||||
|
username.setEnabled(true);
|
||||||
|
username.setFocused(true);
|
||||||
|
|
||||||
|
password = new PasswordTextField(GuiConstants.REPLAY_CENTER_PASSWORD_TEXT_ID, fontRendererObj, this.width/2 - 45, 60, 145, 20);
|
||||||
|
password.setEnabled(true);
|
||||||
|
password.setFocused(false);
|
||||||
|
|
||||||
|
loginButton = new GuiButton(GuiConstants.LOGIN_OKAY_BUTTON, this.width/2 - 150 - 2, 110, "Login");
|
||||||
|
loginButton.width = 150;
|
||||||
|
loginButton.enabled = false;
|
||||||
|
buttonList.add(loginButton);
|
||||||
|
|
||||||
|
cancelButton = new GuiButton(GuiConstants.LOGIN_CANCEL_BUTTON, this.width/2 + 2, 110, "Cancel");
|
||||||
|
cancelButton.width = 150;
|
||||||
|
buttonList.add(cancelButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
if(button.id == GuiConstants.LOGIN_OKAY_BUTTON) {
|
||||||
|
if(button.enabled) {
|
||||||
|
//Authenticate
|
||||||
|
textState = LOGGING_IN;
|
||||||
|
|
||||||
|
Thread loginThread = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
switch(AuthenticationHandler.authenticate(username.getText(), password.getText())) {
|
||||||
|
case AuthenticationHandler.SUCCESS:
|
||||||
|
textState = EMPTY;
|
||||||
|
mc.displayGuiScreen(successScreen);
|
||||||
|
break;
|
||||||
|
case AuthenticationHandler.INVALID:
|
||||||
|
textState = INVALID_LOGIN;
|
||||||
|
break;
|
||||||
|
case AuthenticationHandler.NO_CONNECTION:
|
||||||
|
textState = NO_CONNECTION;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loginThread.start();
|
||||||
|
}
|
||||||
|
} else if(button.id == GuiConstants.LOGIN_CANCEL_BUTTON) {
|
||||||
|
mc.displayGuiScreen(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int lastMouseX, lastMouseY;
|
||||||
|
private float lastPartialTicks;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
lastMouseX = mouseX;
|
||||||
|
lastMouseY = mouseY;
|
||||||
|
lastPartialTicks = partialTicks;
|
||||||
|
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
drawCenteredString(fontRendererObj, "Login to ReplayMod.com", this.width/2, 10, Color.WHITE.getRGB());
|
||||||
|
|
||||||
|
drawString(fontRendererObj, "Username", this.width/2 - 100, 37, Color.WHITE.getRGB());
|
||||||
|
username.drawTextBox();
|
||||||
|
|
||||||
|
drawString(fontRendererObj, "Password", this.width/2 - 100, 67, Color.WHITE.getRGB());
|
||||||
|
password.drawTextBox();
|
||||||
|
|
||||||
|
switch(textState) {
|
||||||
|
case INVALID_LOGIN:
|
||||||
|
drawCenteredString(fontRendererObj, "Incorrect username or password.", this.width/2, 92, Color.RED.getRGB());
|
||||||
|
break;
|
||||||
|
case LOGGING_IN:
|
||||||
|
drawCenteredString(fontRendererObj, "Logging in...", this.width/2, 92, Color.WHITE.getRGB());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
username.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
password.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen() {
|
||||||
|
username.updateCursorCounter();
|
||||||
|
password.updateCursorCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed() {
|
||||||
|
Keyboard.enableRepeatEvents(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||||
|
if(keyCode == Keyboard.KEY_TAB) {
|
||||||
|
if(password.isFocused()) {
|
||||||
|
password.setFocused(false);
|
||||||
|
username.setFocused(true);
|
||||||
|
} else {
|
||||||
|
username.setFocused(false);
|
||||||
|
password.setFocused(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(keyCode == 28) { //Enter key
|
||||||
|
actionPerformed(loginButton);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(username.isFocused()) {
|
||||||
|
username.textboxKeyTyped(typedChar, keyCode);
|
||||||
|
} else if(password.isFocused()) {
|
||||||
|
password.textboxKeyTyped(typedChar, keyCode);
|
||||||
|
}
|
||||||
|
loginButton.enabled = username.getText().length() > 0 && password.getText().length() > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package eu.crushedpixel.replaymod.gui.online;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
|
||||||
|
public class GuiReplayCenter extends GuiScreen {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -89,15 +89,7 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
|
|||||||
BufferedImage bimg = ImageIO.read(is);
|
BufferedImage bimg = ImageIO.read(is);
|
||||||
if(bimg != null) {
|
if(bimg != null) {
|
||||||
img = ImageUtils.scaleImage(bimg, new Dimension(1280, 720));
|
img = ImageUtils.scaleImage(bimg, new Dimension(1280, 720));
|
||||||
}
|
|
||||||
|
|
||||||
/* Old way of reading thumbnail
|
|
||||||
else {
|
|
||||||
is = archive.getInputStream(image);
|
|
||||||
bimg = ImageIO.read(is);
|
|
||||||
img = ImageUtils.scaleImage(bimg, new Dimension(1280, 720));
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream is = archive.getInputStream(metadata);
|
InputStream is = archive.getInputStream(metadata);
|
||||||
@@ -136,8 +128,8 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initGui()
|
@Override
|
||||||
{
|
public void initGui() {
|
||||||
replayGuiList = new GuiReplayListExtended(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
|
replayGuiList = new GuiReplayListExtended(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
|
||||||
Keyboard.enableRepeatEvents(true);
|
Keyboard.enableRepeatEvents(true);
|
||||||
this.buttonList.clear();
|
this.buttonList.clear();
|
||||||
|
|||||||
@@ -1,23 +1,37 @@
|
|||||||
package eu.crushedpixel.replaymod.authentication;
|
package eu.crushedpixel.replaymod.online.authentication;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
|
import eu.crushedpixel.replaymod.api.client.ApiException;
|
||||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||||
|
|
||||||
public class AuthenticationHandler {
|
public class AuthenticationHandler {
|
||||||
|
|
||||||
|
public static final int SUCCESS = 1;
|
||||||
|
public static final int INVALID = 2;
|
||||||
|
public static final int NO_CONNECTION = 3;
|
||||||
|
|
||||||
private static Minecraft mc = Minecraft.getMinecraft();
|
private static Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
private static boolean auth = false;
|
private static String authkey = null;
|
||||||
|
|
||||||
public static boolean isAuthenticated() {
|
public static boolean isAuthenticated() {
|
||||||
return auth;
|
return authkey != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void authenticate() {
|
public static int authenticate(String username, String password) {
|
||||||
auth = isPremiumUsername(Minecraft.getMinecraft().getSession().getUsername());
|
try {
|
||||||
|
authkey = ReplayMod.apiClient.getLogin(username, password).getAuthkey();
|
||||||
|
return SUCCESS;
|
||||||
|
} catch(ApiException e) {
|
||||||
|
return INVALID;
|
||||||
|
} catch(Exception e) {
|
||||||
|
return NO_CONNECTION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<String> PREMIUM_USERS = new ArrayList<String>() {
|
private static final List<String> PREMIUM_USERS = new ArrayList<String>() {
|
||||||
@@ -20,6 +20,7 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@@ -146,8 +147,13 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
GuiReplaySaving.replaySaving = true;
|
GuiReplaySaving.replaySaving = true;
|
||||||
|
|
||||||
String mcversion = Minecraft.getMinecraft().getVersion();
|
String mcversion = Minecraft.getMinecraft().getVersion();
|
||||||
|
String[] split = mcversion.split("-");
|
||||||
|
if(split.length > 0) {
|
||||||
|
mcversion = split[0];
|
||||||
|
}
|
||||||
|
|
||||||
String[] pl = players.toArray(new String[players.size()]);
|
String[] pl = players.toArray(new String[players.size()]);
|
||||||
|
|
||||||
ReplayMetaData metaData = new ReplayMetaData(singleplayer, worldName, (int) lastSentPacket, startTime, pl, mcversion);
|
ReplayMetaData metaData = new ReplayMetaData(singleplayer, worldName, (int) lastSentPacket, startTime, pl, mcversion);
|
||||||
|
|||||||
Reference in New Issue
Block a user