mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 01:12:13 +02:00
Merge branch 'master' into pr/17
This commit is contained in:
commit
94afb72e23
@ -28,6 +28,7 @@ import net.minecraft.client.font.TextRenderer;
|
||||
import net.wurstclient.Category;
|
||||
import net.wurstclient.Feature;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.components.FeatureButton;
|
||||
import net.wurstclient.hacks.ClickGuiHack;
|
||||
import net.wurstclient.settings.Setting;
|
||||
import net.wurstclient.util.json.JsonUtils;
|
||||
|
@ -13,7 +13,7 @@ import net.minecraft.client.font.TextRenderer;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.settings.EnumSetting;
|
||||
|
||||
class ComboBoxPopup<T extends Enum> extends Popup
|
||||
public final class ComboBoxPopup<T extends Enum> extends Popup
|
||||
{
|
||||
private final ClickGui gui = WurstClient.INSTANCE.getGui();
|
||||
private final TextRenderer tr = WurstClient.MC.textRenderer;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@ -17,6 +17,9 @@ import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.render.GuiLighting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.screens.EditBlockScreen;
|
||||
import net.wurstclient.settings.BlockSetting;
|
||||
|
||||
public final class BlockComponent extends Component
|
@ -5,12 +5,15 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.screens.EditBlockListScreen;
|
||||
import net.wurstclient.settings.BlockListSetting;
|
||||
|
||||
public final class BlockListEditButton extends Component
|
@ -5,12 +5,15 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.Window;
|
||||
import net.wurstclient.settings.CheckboxSetting;
|
||||
|
||||
public final class CheckboxComponent extends Component
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
@ -15,6 +15,10 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.ComboBoxPopup;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.Window;
|
||||
import net.wurstclient.settings.EnumSetting;
|
||||
|
||||
public final class ComboBoxComponent<T extends Enum> extends Component
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -15,6 +15,10 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.wurstclient.Feature;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.SettingsWindow;
|
||||
import net.wurstclient.clickgui.Window;
|
||||
|
||||
public final class FeatureButton extends Component
|
||||
{
|
@ -5,12 +5,15 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.screens.SelectFileScreen;
|
||||
import net.wurstclient.settings.FileSetting;
|
||||
|
||||
public final class FileComponent extends Component
|
||||
@ -23,7 +26,7 @@ public final class FileComponent extends Component
|
||||
this.setting = setting;
|
||||
|
||||
TextRenderer fr = WurstClient.MC.textRenderer;
|
||||
buttonWidth = fr.getStringWidth("Edit...");
|
||||
buttonWidth = fr.getStringWidth(setting.getSelectedFileName());
|
||||
|
||||
setWidth(getDefaultWidth());
|
||||
setHeight(getDefaultHeight());
|
||||
@ -38,7 +41,8 @@ public final class FileComponent extends Component
|
||||
if(mouseX < getX() + getWidth() - buttonWidth - 4)
|
||||
return;
|
||||
|
||||
// TODO
|
||||
WurstClient.MC.openScreen(
|
||||
new SelectFileScreen(WurstClient.MC.currentScreen, setting));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,6 +70,11 @@ public final class FileComponent extends Component
|
||||
// tooltip
|
||||
if(hText)
|
||||
gui.setTooltip(setting.getDescription());
|
||||
else if(hBox)
|
||||
{
|
||||
String tooltip = "\u00a7e[left-click]\u00a7r to select file";
|
||||
gui.setTooltip(tooltip);
|
||||
}
|
||||
|
||||
// background
|
||||
GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
|
||||
@ -97,9 +106,9 @@ public final class FileComponent extends Component
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
TextRenderer fr = WurstClient.MC.textRenderer;
|
||||
String text = setting.getName() + ": " + setting.getSelectedFileName();
|
||||
String text = setting.getName() + ": ";
|
||||
fr.draw(text, x1, y1 + 2, 0xf0f0f0);
|
||||
fr.draw("Edit...", x3 + 2, y1 + 2, 0xf0f0f0);
|
||||
fr.draw(setting.getSelectedFileName(), x3 + 2, y1 + 2, 0xf0f0f0);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
@ -107,7 +116,7 @@ public final class FileComponent extends Component
|
||||
public int getDefaultWidth()
|
||||
{
|
||||
TextRenderer fr = WurstClient.MC.textRenderer;
|
||||
String text = setting.getName() + ": " + setting.getSelectedFileName();
|
||||
String text = setting.getName() + ": ";
|
||||
return fr.getStringWidth(text) + buttonWidth + 6;
|
||||
}
|
||||
|
@ -5,12 +5,15 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.screens.EditItemListScreen;
|
||||
import net.wurstclient.settings.ItemListSetting;
|
||||
|
||||
public final class ItemListEditButton extends Component
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.components;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@ -13,6 +13,10 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.Window;
|
||||
import net.wurstclient.clickgui.screens.EditSliderScreen;
|
||||
import net.wurstclient.settings.SliderSetting;
|
||||
|
||||
public final class SliderComponent extends Component
|
@ -5,10 +5,11 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.screens;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
|
||||
public final class ClickGuiScreen extends Screen
|
||||
{
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.screens;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.screens;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.screens;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui;
|
||||
package net.wurstclient.clickgui.screens;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (C) 2014 - 2019 | Wurst-Imperium | All rights reserved.
|
||||
*
|
||||
* This source code is subject to the terms of the GNU General Public
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.clickgui.screens;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.screen.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ListWidget;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.wurstclient.settings.FileSetting;
|
||||
|
||||
public final class SelectFileScreen extends Screen
|
||||
{
|
||||
private final Screen prevScreen;
|
||||
private final FileSetting setting;
|
||||
|
||||
private ListGui listGui;
|
||||
private ButtonWidget doneButton;
|
||||
|
||||
public SelectFileScreen(Screen prevScreen, FileSetting blockList)
|
||||
{
|
||||
super(new LiteralText(""));
|
||||
this.prevScreen = prevScreen;
|
||||
setting = blockList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
listGui = new ListGui(minecraft, this, setting.listFiles());
|
||||
|
||||
addButton(new ButtonWidget(width - 108, 8, 100, 20, "Reset to Defaults",
|
||||
b -> askToConfirmReset()));
|
||||
|
||||
doneButton = addButton(new ButtonWidget(width / 2 - 102, height - 28,
|
||||
100, 20, "Done", b -> done()));
|
||||
addButton(new ButtonWidget(width / 2 + 2, height - 28, 100, 20,
|
||||
"Cancel", b -> openPrevScreen()));
|
||||
}
|
||||
|
||||
private void openPrevScreen()
|
||||
{
|
||||
minecraft.openScreen(prevScreen);
|
||||
}
|
||||
|
||||
private void done()
|
||||
{
|
||||
if(listGui.selected >= 0 && listGui.selected < listGui.list.size())
|
||||
{
|
||||
Path path = listGui.list.get(listGui.selected);
|
||||
String fileName = "" + path.getFileName();
|
||||
setting.setSelectedFile(fileName);
|
||||
}
|
||||
|
||||
openPrevScreen();
|
||||
}
|
||||
|
||||
private void askToConfirmReset()
|
||||
{
|
||||
LiteralText title = new LiteralText("Reset Folder");
|
||||
|
||||
LiteralText message = new LiteralText(
|
||||
"This will empty the '" + setting.getFolder().getFileName()
|
||||
+ "' folder and then re-generate the default files.\n"
|
||||
+ "Are you sure you want to do this?");
|
||||
|
||||
minecraft.openScreen(
|
||||
new ConfirmScreen(c -> confirmReset(c), title, message));
|
||||
}
|
||||
|
||||
private void confirmReset(boolean confirmed)
|
||||
{
|
||||
if(confirmed)
|
||||
setting.resetFolder();
|
||||
|
||||
minecraft.openScreen(SelectFileScreen.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton)
|
||||
{
|
||||
boolean childClicked = super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
listGui.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
if(!childClicked && (mouseX < (width - 220) / 2
|
||||
|| mouseX > width / 2 + 129 || mouseY < 32 || mouseY > height - 64))
|
||||
listGui.selected = -1;
|
||||
|
||||
return childClicked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(double double_1, double double_2, int int_1,
|
||||
double double_3, double double_4)
|
||||
{
|
||||
listGui.mouseDragged(double_1, double_2, int_1, double_3, double_4);
|
||||
return super.mouseDragged(double_1, double_2, int_1, double_3,
|
||||
double_4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double double_1, double double_2, int int_1)
|
||||
{
|
||||
listGui.mouseReleased(double_1, double_2, int_1);
|
||||
return super.mouseReleased(double_1, double_2, int_1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double double_1, double double_2,
|
||||
double double_3)
|
||||
{
|
||||
listGui.mouseScrolled(double_1, double_2, double_3);
|
||||
return super.mouseScrolled(double_1, double_2, double_3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int int_3)
|
||||
{
|
||||
if(keyCode == GLFW.GLFW_KEY_ENTER)
|
||||
done();
|
||||
else if(keyCode == GLFW.GLFW_KEY_ESCAPE)
|
||||
openPrevScreen();
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, int_3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
doneButton.active =
|
||||
listGui.selected >= 0 && listGui.selected < listGui.list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
renderBackground();
|
||||
listGui.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
drawCenteredString(minecraft.textRenderer, setting.getName(), width / 2,
|
||||
12, 0xffffff);
|
||||
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
if(doneButton.isHovered() && !doneButton.active)
|
||||
renderTooltip("You must first select a file.", mouseX, mouseY);
|
||||
}
|
||||
|
||||
private static class ListGui extends ListWidget
|
||||
{
|
||||
private final MinecraftClient mc;
|
||||
private final List<Path> list;
|
||||
private int selected = -1;
|
||||
|
||||
public ListGui(MinecraftClient mc, SelectFileScreen screen,
|
||||
ArrayList<Path> list)
|
||||
{
|
||||
super(mc, screen.width, screen.height, 32, screen.height - 64, 20);
|
||||
this.mc = mc;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getItemCount()
|
||||
{
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean selectItem(int index, int int_2, double var3,
|
||||
double var4)
|
||||
{
|
||||
if(index >= 0 && index < list.size())
|
||||
selected = index;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSelectedItem(int index)
|
||||
{
|
||||
return index == selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBackground()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderItem(int index, int x, int y, int var4, int var5,
|
||||
int var6, float partialTicks)
|
||||
{
|
||||
TextRenderer fr = mc.textRenderer;
|
||||
|
||||
Path path = list.get(index);
|
||||
fr.draw("" + path.getFileName(), x + 28, y, 0xf0f0f0);
|
||||
fr.draw("" + minecraft.runDirectory.toPath().relativize(path),
|
||||
x + 28, y + 9, 0xa0a0a0);
|
||||
}
|
||||
}
|
||||
}
|
@ -18,8 +18,9 @@ import net.wurstclient.settings.FileSetting;
|
||||
|
||||
public final class AutoBuildHack extends Hack implements UpdateListener
|
||||
{
|
||||
private final FileSetting template = new FileSetting("Template", "",
|
||||
"autobuild", folder -> createDefaultTemplates(folder));
|
||||
private final FileSetting template =
|
||||
new FileSetting("Template", "Determines what to build.", "autobuild",
|
||||
folder -> createDefaultTemplates(folder));
|
||||
|
||||
public AutoBuildHack()
|
||||
{
|
||||
@ -50,7 +51,7 @@ public final class AutoBuildHack extends Hack implements UpdateListener
|
||||
{
|
||||
try
|
||||
{
|
||||
Files.createFile(folder.resolve("test.txt"));
|
||||
Files.createFile(folder.resolve("test.json"));
|
||||
|
||||
}catch(IOException e)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
package net.wurstclient.hacks;
|
||||
|
||||
import net.wurstclient.SearchTags;
|
||||
import net.wurstclient.clickgui.ClickGuiScreen;
|
||||
import net.wurstclient.clickgui.screens.ClickGuiScreen;
|
||||
import net.wurstclient.hack.DontSaveState;
|
||||
import net.wurstclient.hack.Hack;
|
||||
import net.wurstclient.settings.SliderSetting;
|
||||
|
@ -14,7 +14,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.wurstclient.Category;
|
||||
import net.wurstclient.SearchTags;
|
||||
import net.wurstclient.clickgui.EditBlockListScreen;
|
||||
import net.wurstclient.clickgui.screens.EditBlockListScreen;
|
||||
import net.wurstclient.events.GetAmbientOcclusionLightLevelListener;
|
||||
import net.wurstclient.events.RenderBlockEntityListener;
|
||||
import net.wurstclient.events.SetOpaqueCubeListener;
|
||||
|
@ -11,7 +11,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.ClickGuiScreen;
|
||||
import net.wurstclient.clickgui.screens.ClickGuiScreen;
|
||||
import net.wurstclient.events.GUIRenderListener;
|
||||
|
||||
public final class IngameHUD implements GUIRenderListener
|
||||
|
@ -12,7 +12,7 @@ import org.lwjgl.glfw.GLFW;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGuiScreen;
|
||||
import net.wurstclient.clickgui.screens.ClickGuiScreen;
|
||||
import net.wurstclient.command.CmdProcessor;
|
||||
import net.wurstclient.events.KeyPressListener;
|
||||
import net.wurstclient.hack.Hack;
|
||||
|
@ -22,8 +22,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.BlockListEditButton;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.components.BlockListEditButton;
|
||||
import net.wurstclient.keybinds.PossibleKeybind;
|
||||
import net.wurstclient.util.BlockUtils;
|
||||
import net.wurstclient.util.json.JsonException;
|
||||
|
@ -17,8 +17,8 @@ import com.google.gson.JsonPrimitive;
|
||||
import net.minecraft.block.AirBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.BlockComponent;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.components.BlockComponent;
|
||||
import net.wurstclient.keybinds.PossibleKeybind;
|
||||
import net.wurstclient.util.BlockUtils;
|
||||
import net.wurstclient.util.json.JsonException;
|
||||
|
@ -14,8 +14,8 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.CheckboxComponent;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.components.CheckboxComponent;
|
||||
import net.wurstclient.keybinds.PossibleKeybind;
|
||||
import net.wurstclient.util.json.JsonUtils;
|
||||
|
||||
|
@ -14,8 +14,8 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ComboBoxComponent;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.components.ComboBoxComponent;
|
||||
import net.wurstclient.keybinds.PossibleKeybind;
|
||||
import net.wurstclient.util.json.JsonUtils;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.google.gson.JsonPrimitive;
|
||||
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.FileComponent;
|
||||
import net.wurstclient.clickgui.components.FileComponent;
|
||||
import net.wurstclient.keybinds.PossibleKeybind;
|
||||
import net.wurstclient.util.json.JsonException;
|
||||
import net.wurstclient.util.json.JsonUtils;
|
||||
@ -68,9 +68,25 @@ public final class FileSetting extends Setting
|
||||
WurstClient.INSTANCE.saveSettings();
|
||||
}
|
||||
|
||||
private void resetToDefault()
|
||||
public void resetFolder()
|
||||
{
|
||||
createFolder();
|
||||
for(Path path : listFiles())
|
||||
try
|
||||
{
|
||||
Files.delete(path);
|
||||
|
||||
}catch(IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
generateDefaultFiles();
|
||||
WurstClient.INSTANCE.saveSettings();
|
||||
}
|
||||
|
||||
private void generateDefaultFiles()
|
||||
{
|
||||
createFolderIfNeeded();
|
||||
ArrayList<Path> files = listFiles();
|
||||
|
||||
if(files.isEmpty())
|
||||
@ -86,7 +102,7 @@ public final class FileSetting extends Setting
|
||||
selectedFile = "" + files.get(0).getFileName();
|
||||
}
|
||||
|
||||
private void createFolder()
|
||||
private void createFolderIfNeeded()
|
||||
{
|
||||
if(Files.isDirectory(folder))
|
||||
return;
|
||||
@ -102,11 +118,11 @@ public final class FileSetting extends Setting
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Path> listFiles()
|
||||
public ArrayList<Path> listFiles()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Files.list(folder)
|
||||
return Files.list(folder).filter(Files::isRegularFile)
|
||||
.collect(Collectors.toCollection(() -> new ArrayList<>()));
|
||||
|
||||
}catch(IOException e)
|
||||
@ -136,7 +152,7 @@ public final class FileSetting extends Setting
|
||||
}catch(JsonException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
resetToDefault();
|
||||
generateDefaultFiles();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.ItemListEditButton;
|
||||
import net.wurstclient.clickgui.components.ItemListEditButton;
|
||||
import net.wurstclient.keybinds.PossibleKeybind;
|
||||
import net.wurstclient.util.json.JsonException;
|
||||
import net.wurstclient.util.json.JsonUtils;
|
||||
|
@ -14,7 +14,7 @@ import com.google.gson.JsonPrimitive;
|
||||
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.SliderComponent;
|
||||
import net.wurstclient.clickgui.components.SliderComponent;
|
||||
import net.wurstclient.keybinds.PossibleKeybind;
|
||||
import net.wurstclient.util.MathUtils;
|
||||
import net.wurstclient.util.json.JsonUtils;
|
||||
|
Loading…
Reference in New Issue
Block a user