Move username field from WorldHandler to GuiWorldHandler
This commit is contained in:
@@ -12,7 +12,6 @@ import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
@@ -57,6 +56,8 @@ public class GuiWorldHandler extends Container
|
||||
private GuiTextFieldTooltip syntaxField;
|
||||
private GuiTextFieldTooltip nameField;
|
||||
|
||||
private static String player = Minecraft.getInstance().getSession().getUsername();
|
||||
|
||||
private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
|
||||
|
||||
public GuiWorldHandler(Content content) throws Exception
|
||||
@@ -133,7 +134,7 @@ public class GuiWorldHandler extends Container
|
||||
this.nameField.setText(this.getPlayer());
|
||||
this.nameField.setResponder(text ->
|
||||
{
|
||||
WorldHandler.USERNAME = text;
|
||||
GuiWorldHandler.player = text;
|
||||
this.updateNameField();
|
||||
});
|
||||
this.updateNameField();
|
||||
@@ -282,7 +283,7 @@ public class GuiWorldHandler extends Container
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
if(WorldHandler.USERNAME.isEmpty())
|
||||
if(GuiWorldHandler.player.isEmpty())
|
||||
{
|
||||
int width = this.font.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
|
||||
this.nameField.setWidth(width);
|
||||
@@ -290,12 +291,12 @@ public class GuiWorldHandler extends Container
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = this.font.getStringWidth(WorldHandler.USERNAME) + 2;
|
||||
int width = this.font.getStringWidth(GuiWorldHandler.player) + 2;
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - width, backgroundY + 6);
|
||||
}
|
||||
|
||||
this.content.onPlayerNameChanged(WorldHandler.USERNAME);
|
||||
this.content.onPlayerNameChanged(GuiWorldHandler.player);
|
||||
}
|
||||
|
||||
private void defaultColor()
|
||||
@@ -499,7 +500,7 @@ public class GuiWorldHandler extends Container
|
||||
|
||||
//TITLE
|
||||
|
||||
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.font.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
|
||||
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.font.getStringWidth(GuiWorldHandler.player) - 2 - this.getWatchOffset() - 7;
|
||||
this.font.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.font), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor());
|
||||
|
||||
//HEADLINE
|
||||
@@ -519,7 +520,7 @@ public class GuiWorldHandler extends Container
|
||||
|
||||
//NAME FIELD
|
||||
|
||||
final String username = WorldHandler.USERNAME.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : WorldHandler.USERNAME;
|
||||
final String username = GuiWorldHandler.player.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : GuiWorldHandler.player;
|
||||
this.font.drawString(username, backgroundX + 232 - this.font.getStringWidth(username), backgroundY + 7, Config.getSkin().getLabelColor());
|
||||
|
||||
//WATCH
|
||||
@@ -664,7 +665,7 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public String getPlayer()
|
||||
{
|
||||
return WorldHandler.USERNAME;
|
||||
return GuiWorldHandler.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGeneric;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
@@ -40,7 +39,7 @@ public class ContentPlayer extends Content
|
||||
private GuiTextFieldTooltip xpField;
|
||||
|
||||
private final BuilderGeneric builderSetworldspawn = new BuilderGeneric("setworldspawn");
|
||||
private final BuilderSpawnpoint builderSpawnpoint = new BuilderSpawnpoint(WorldHandler.USERNAME);
|
||||
private final BuilderSpawnpoint builderSpawnpoint = new BuilderSpawnpoint();
|
||||
private final BuilderPlayer builderKill = new BuilderPlayer("kill");
|
||||
private final BuilderGeneric builderClear = new BuilderGeneric("clear");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user