Skip to content

Commit

Permalink
Clean up + Resize Button
Browse files Browse the repository at this point in the history
Deleted a bunch of unused files and cleaned up OpenToLanScreenMixin
  • Loading branch information
Flooflez committed Apr 2, 2022
1 parent 1be9599 commit a3df50b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 196 deletions.

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/alujjdnd/ngrok/lan/mixin/ExampleMixin.java

This file was deleted.

144 changes: 0 additions & 144 deletions src/main/java/alujjdnd/ngrok/lan/mixin/NgrokLaunch.java

This file was deleted.

38 changes: 11 additions & 27 deletions src/main/java/alujjdnd/ngrok/lan/mixin/OpenToLanScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,22 @@ protected OpenToLanScreenMixin(Text title) {
@Inject(method = "init", at = @At("HEAD"))
private void initWidgets(CallbackInfo info) {

if (config.enabledCheckBox == true) { //TODO: check mod enabled
this.addDrawableChild(new ButtonWidget(this.width / 2 + 104, this.height / 4 + 120 + -16, 20, 20, new TranslatableText("text.autoconfig.ngroklan.LanButton"), (button) -> {
if (config.enabledCheckBox) { //if mod enabled in mod menu
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, this.height - 58, 150, 20, new TranslatableText("text.autoconfig.ngroklan.LanButton"), (button) -> {

this.client.setScreen((Screen) null);
this.client.setScreen(null);
int i = NetworkUtils.findLocalPort();
TranslatableText text;
if (this.client.getServer().openToLan(this.gameMode, this.allowCommands, i)) {

switch (config.regionSelect) {
case US:
ngrokInit(i, Region.US);
break;
case EU:
ngrokInit(i, Region.EU);
break;
case AP:
ngrokInit(i, Region.AP);
break;
case AU:
ngrokInit(i, Region.AU);
break;
case SA:
ngrokInit(i, Region.SA);
break;
case JP:
ngrokInit(i, Region.JP);
break;
case IN:
ngrokInit(i, Region.IN);
break;
case US -> ngrokInit(i, Region.US);
case EU -> ngrokInit(i, Region.EU);
case AP -> ngrokInit(i, Region.AP);
case AU -> ngrokInit(i, Region.AU);
case SA -> ngrokInit(i, Region.SA);
case JP -> ngrokInit(i, Region.JP);
case IN -> ngrokInit(i, Region.IN);
}

text = new TranslatableText("commands.publish.started", new Object[]{i});
Expand All @@ -92,8 +78,7 @@ private void ngrokInit(int port, Region region) {
//Defines a new threaded function to oepn the Ngrok tunnel, so that the "Open to LAN" button does not hitch - this thread runs in a seperate process from the main game loop
Thread thread = new Thread(() ->
{
// Check if mod is enabled in the ModMenu
if (config.authToken == "AuthToken") {
if (config.authToken.equals("AuthToken")) {
// Check if authToken field has actually been changed, if not, print this text in chat
mc.inGameHud.getChatHud().addMessage(new LiteralText("\u00a7cPlease set your Ngrok AuthToken! Do this in your menu > Mods > Ngrok LAN > Sliders Icon > Auth Token"));
} else {
Expand All @@ -119,7 +104,6 @@ private void ngrokInit(int port, Region region) {

final Tunnel tunnel = ngrokClient.connect(createTunnel);


NgrokLan.LOGGER.info(tunnel.getPublicUrl());

var ngrok_url = tunnel.getPublicUrl().substring(6);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/ngroklan.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

],
"client": [
"ExampleMixin",
"OpenToLanScreenMixin"
],
"injectors": {
Expand Down

0 comments on commit a3df50b

Please sign in to comment.