stuff
This commit is contained in:
		
							parent
							
								
									48547a2c66
								
							
						
					
					
						commit
						dc1e189d38
					
				
					 25 changed files with 259 additions and 157 deletions
				
			
		|  | @ -2,6 +2,7 @@ package me.kawaiizenbo.moonlight; | |||
| 
 | ||||
| import java.io.File; | ||||
| import java.io.FileWriter; | ||||
| import java.io.IOException; | ||||
| import java.nio.file.Files; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | @ -13,16 +14,17 @@ import com.google.gson.Gson; | |||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.Setting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.StringSetting; | ||||
| import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| 
 | ||||
| public class Config  | ||||
| { | ||||
|     public static final Logger LOGGER = LoggerFactory.getLogger("mcfg"); | ||||
|     MinecraftClient mc = MinecraftClient.getInstance(); | ||||
|     public File configDir = new File(mc.runDirectory.getPath() + "/moonlight"); | ||||
|     public File configFile = new File(configDir, "config.json"); | ||||
|  | @ -43,13 +45,14 @@ public class Config | |||
|     { | ||||
|         ModuleManager.INSTANCE = new ModuleManager(); | ||||
|         Map<String, Object> mi = new HashMap<>(); | ||||
|         for (Module_ m : ModuleManager.INSTANCE.modules) | ||||
|         for (Module m : ModuleManager.INSTANCE.modules) | ||||
| 		{ | ||||
| 			Map<String, Object> mo = new HashMap<>(); | ||||
|             mo.put("enabled", m.enabled); | ||||
|             Map<String, Object> ms = new HashMap<>(); | ||||
| 			for (Setting s : m.settings) | ||||
| 			{ | ||||
|                 // sometimes i wish i were a nymphet instead of a massive nerd | ||||
|                 if (s instanceof BooleanSetting) | ||||
|                 { | ||||
|                     ms.put(s.name, ((BooleanSetting)s).value); | ||||
|  | @ -57,6 +60,14 @@ public class Config | |||
|                 else if (s instanceof DoubleSetting) | ||||
|                 { | ||||
|                     ms.put(s.name, ((DoubleSetting)s).value); | ||||
|                 } | ||||
|                 if (s instanceof StringSetting) | ||||
|                 { | ||||
|                     ms.put(s.name, ((StringSetting)s).value); | ||||
|                 } | ||||
|                 else if (s instanceof KeycodeSetting) | ||||
|                 { | ||||
|                     ms.put(s.name, ((KeycodeSetting)s).value); | ||||
|                 } | ||||
| 			} | ||||
|             mo.put("settings", ms); | ||||
|  | @ -84,7 +95,7 @@ public class Config | |||
|         ClickGUIScreen.INSTANCE = new ClickGUIScreen(); | ||||
|     } | ||||
| 
 | ||||
|     public void load() | ||||
|     public void load() throws IOException | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|  | @ -93,7 +104,7 @@ public class Config | |||
|         } | ||||
|         catch (Exception e) | ||||
|         { | ||||
|             e.printStackTrace(); | ||||
|             throw new IOException("Failed to load config file."); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,14 +4,16 @@ import net.fabricmc.api.ModInitializer; | |||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.Setting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.StringSetting; | ||||
| import me.kawaiizenbo.moonlight.ui.clickgui.CategoryPane; | ||||
|  | @ -37,44 +39,53 @@ public class Moonlight implements ModInitializer | |||
| 
 | ||||
| 	public void loadConfig() | ||||
| 	{ | ||||
| 		LOGGER.info("Loading config..."); | ||||
| 		if (CONFIG.doesConfigExist()) | ||||
| 		try | ||||
| 		{ | ||||
| 			LOGGER.info("Loading config..."); | ||||
| 			CONFIG.load(); | ||||
| 			for (Module m : ModuleManager.INSTANCE.modules) | ||||
| 			{ | ||||
| 				m.enabled = (boolean)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("enabled"); | ||||
| 				if (m.enabled) | ||||
| 				{ | ||||
| 					//m.onEnable(); | ||||
| 					// this doesnt work, will probably need to mixin to client server connection or something | ||||
| 				} | ||||
| 				for (Setting s : m.settings) | ||||
| 				{ | ||||
|                 	if (s instanceof BooleanSetting) | ||||
|                 	{ | ||||
|                     	((BooleanSetting)s).value = (boolean)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
|                 	} | ||||
|                 	else if (s instanceof DoubleSetting) | ||||
|                 	{ | ||||
|                     	((DoubleSetting)s).value = (Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
|                 	} | ||||
| 					else if (s instanceof StringSetting) | ||||
|                 	{ | ||||
|                     	((StringSetting)s).value = (String)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
|                 	} | ||||
| 					else if (s instanceof KeycodeSetting) | ||||
|                 	{ | ||||
|                 	    ((KeycodeSetting)s).value = ((Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name)).intValue(); | ||||
|                 	} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		catch(Exception e) | ||||
| 		{ | ||||
| 			LOGGER.warn("Config Error: " + e.getMessage()); | ||||
| 			LOGGER.info("Loading default config..."); | ||||
| 			CONFIG.loadDefaultConfig();  | ||||
| 			CONFIG.save(); | ||||
| 		} | ||||
| 		CONFIG.load(); | ||||
| 		for (Module_ m : ModuleManager.INSTANCE.modules) | ||||
| 		{ | ||||
| 			m.enabled = (boolean)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("enabled"); | ||||
| 			if (m.enabled) | ||||
| 			{ | ||||
| 				//m.onEnable(); | ||||
| 				/// brocken :( | ||||
| 			} | ||||
| 			for (Setting s : m.settings) | ||||
| 			{ | ||||
|                 if (s instanceof BooleanSetting) | ||||
|                 { | ||||
|                     ((BooleanSetting)s).value = (boolean)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
|                 } | ||||
|                 else if (s instanceof DoubleSetting) | ||||
|                 { | ||||
|                     ((DoubleSetting)s).value = (Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
|                 } | ||||
| 				else if (s instanceof StringSetting) | ||||
|                 { | ||||
|                     ((StringSetting)s).value = (String)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
|                 } | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	public void saveConfig() | ||||
| 	{ | ||||
| 		LOGGER.info("Saving config..."); | ||||
| 		Map<String, Object> mi = new HashMap<>(); | ||||
|         for (Module_ m : ModuleManager.INSTANCE.modules) | ||||
|         for (Module m : ModuleManager.INSTANCE.modules) | ||||
| 		{ | ||||
| 			Map<String, Object> mo = new HashMap<>(); | ||||
|             mo.put("enabled", m.enabled); | ||||
|  | @ -88,6 +99,14 @@ public class Moonlight implements ModInitializer | |||
|                 else if (s instanceof DoubleSetting) | ||||
|                 { | ||||
|                     ms.put(s.name, ((DoubleSetting)s).value); | ||||
|                 } | ||||
| 				if (s instanceof StringSetting) | ||||
|                 { | ||||
|                     ms.put(s.name, ((StringSetting)s).value); | ||||
|                 } | ||||
|                 else if (s instanceof KeycodeSetting) | ||||
|                 { | ||||
|                     ms.put(s.name, ((KeycodeSetting)s).value); | ||||
|                 } | ||||
| 			} | ||||
|             mo.put("settings", ms); | ||||
|  |  | |||
|  | @ -29,6 +29,7 @@ public class CommandManager | |||
|         add(new Help()); | ||||
|         add(new Toggle()); | ||||
|         add(new Teleport()); | ||||
|         add(new SettingCommand()); | ||||
|         commands.sort(Comparator.comparing(Command::getName)); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,63 +0,0 @@ | |||
| package me.kawaiizenbo.moonlight.command; | ||||
| 
 | ||||
| import java.util.Collection; | ||||
| import java.util.concurrent.CompletableFuture; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import com.mojang.brigadier.StringReader; | ||||
| import com.mojang.brigadier.arguments.ArgumentType; | ||||
| import com.mojang.brigadier.context.CommandContext; | ||||
| import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||||
| import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | ||||
| import com.mojang.brigadier.suggestion.Suggestions; | ||||
| import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import net.minecraft.command.CommandSource; | ||||
| import net.minecraft.text.Text; | ||||
| 
 | ||||
| public class ModuleArgumentType implements ArgumentType<Module_>  | ||||
| { | ||||
|     private static final Collection<String> EXAMPLES = ModuleManager.INSTANCE.modules | ||||
|             .stream() | ||||
|             .limit(3) | ||||
|             .map(module -> module.name) | ||||
|             .collect(Collectors.toList()); | ||||
| 
 | ||||
|     private static final DynamicCommandExceptionType NO_SUCH_MODULE = new DynamicCommandExceptionType(o -> | ||||
|             Text.literal("Module with name " + o + " doesn't exist.")); | ||||
| 
 | ||||
|     public static ModuleArgumentType module()  | ||||
|     { | ||||
|         return new ModuleArgumentType(); | ||||
|     } | ||||
| 
 | ||||
|     public static Module_ getModule(final CommandContext<?> context, final String name)  | ||||
|     { | ||||
|         return context.getArgument(name, Module_.class); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public Module_ parse(StringReader reader) throws CommandSyntaxException  | ||||
|     { | ||||
|         String argument = reader.readString(); | ||||
|         Module_ module = ModuleManager.INSTANCE.getModuleByName(argument); | ||||
| 
 | ||||
|         if (module == null) throw NO_SUCH_MODULE.create(argument); | ||||
| 
 | ||||
|         return module; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder)  | ||||
|     { | ||||
|         return CommandSource.suggestMatching(ModuleManager.INSTANCE.modules.stream().map(module -> module.name), builder); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public Collection<String> getExamples()  | ||||
|     { | ||||
|         return EXAMPLES; | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,72 @@ | |||
| package me.kawaiizenbo.moonlight.command.commands; | ||||
| 
 | ||||
| import com.mojang.brigadier.arguments.StringArgumentType; | ||||
| import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.command.Command; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.Setting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.StringSetting; | ||||
| import me.kawaiizenbo.moonlight.util.ChatUtils; | ||||
| import me.kawaiizenbo.moonlight.util.ColorUtils; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import net.minecraft.command.CommandSource; | ||||
| 
 | ||||
| public class SettingCommand extends Command | ||||
| { | ||||
|     public SettingCommand()  | ||||
|     { | ||||
|         super("setting", "Change a setting of a module."); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void build(LiteralArgumentBuilder<CommandSource> builder)  | ||||
|     { | ||||
|         builder | ||||
|         .then(argument("module", StringArgumentType.string()) | ||||
|         .then(argument("setting", StringArgumentType.string()) | ||||
|         .then(argument("value", StringArgumentType.string()) | ||||
|         .executes(context ->  | ||||
|         { | ||||
|             String m = context.getArgument("module", String.class); | ||||
|             String s = context.getArgument("setting", String.class); | ||||
|             String v = context.getArgument("value", String.class); | ||||
| 
 | ||||
|             Module module = ModuleManager.INSTANCE.getModuleByName(m); | ||||
|             if (module == null) | ||||
|             { | ||||
|                 ChatUtils.sendMsg(ColorUtils.red + "Invalid Module Name"); | ||||
|                 return 0; | ||||
|             } | ||||
|             Setting setting = module.getSettingByName(s); | ||||
|             if (setting == null) | ||||
|             { | ||||
|                 ChatUtils.sendMsg(ColorUtils.red + "Invalid Setting Name"); | ||||
|                 return 0; | ||||
|             } | ||||
| 
 | ||||
|             // you can break this really easily and i dont feel like fixing it :3 have fun | ||||
|             if (setting instanceof BooleanSetting) | ||||
|             { | ||||
|                 ((BooleanSetting)setting).value = Boolean.parseBoolean(v); | ||||
|             } | ||||
|             else if (setting instanceof DoubleSetting) | ||||
|             { | ||||
|                 ((DoubleSetting)setting).value = Double.parseDouble(v); | ||||
|             } | ||||
|             if (setting instanceof StringSetting) | ||||
|             { | ||||
|                 ((StringSetting)setting).value = v; | ||||
|             } | ||||
|             else if (setting instanceof KeycodeSetting) | ||||
|             { | ||||
|                 ((KeycodeSetting)setting).value = Integer.parseInt(v); | ||||
|             } | ||||
| 
 | ||||
|             return SINGLE_SUCCESS; | ||||
|         })))); | ||||
|     } | ||||
| } | ||||
|  | @ -1,11 +1,11 @@ | |||
| package me.kawaiizenbo.moonlight.command.commands; | ||||
| 
 | ||||
| import com.mojang.brigadier.arguments.StringArgumentType; | ||||
| import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.command.Command; | ||||
| import me.kawaiizenbo.moonlight.command.ModuleArgumentType; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import net.minecraft.client.network.ClientPlayerEntity; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import net.minecraft.command.CommandSource; | ||||
| 
 | ||||
| public class Toggle extends Command | ||||
|  | @ -19,13 +19,12 @@ public class Toggle extends Command | |||
|     @Override | ||||
|     public void build(LiteralArgumentBuilder<CommandSource> builder)  | ||||
|     { | ||||
|         builder.then(argument("module", new ModuleArgumentType()).executes(context ->  | ||||
|         builder.then(argument("module", StringArgumentType.string()) | ||||
|         .executes(context ->  | ||||
|         { | ||||
|             ClientPlayerEntity player = mc.player; | ||||
|             assert player != null; | ||||
| 
 | ||||
|             Module_ m = context.getArgument("module", Module_.class); | ||||
|             m.toggle(); | ||||
|             String m = context.getArgument("module", String.class); | ||||
|             Module module = ModuleManager.INSTANCE.getModuleByName(m); | ||||
|             module.toggle(); | ||||
| 
 | ||||
|             return SINGLE_SUCCESS; | ||||
|         })); | ||||
|  |  | |||
|  | @ -19,7 +19,6 @@ public class ClientConnectionMixin | |||
|     @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) | ||||
|     public void send(Packet<?> packet, CallbackInfo ci)  | ||||
|     { | ||||
|     	// Call commands if the prefix is sent | ||||
|     	if(packet instanceof ChatMessageC2SPacket && ((ChatMessageC2SPacket) packet).chatMessage().startsWith(CommandManager.get().getPrefix()))  | ||||
|         { | ||||
|     		try  | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.Inject; | |||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| import net.minecraft.client.network.ClientPlayerEntity; | ||||
| import net.minecraft.entity.MovementType; | ||||
|  | @ -18,7 +18,7 @@ public class ClientPlayerEntityMixin | |||
|     @Inject(method = "move", at = @At(value = "TAIL"), cancellable = true) | ||||
|     public void onMove(MovementType type, Vec3d movement, CallbackInfo ci)  | ||||
|     { | ||||
|         for (Module_ m : ModuleManager.INSTANCE.getEnabledModules()) | ||||
|         for (Module m : ModuleManager.INSTANCE.getEnabledModules()) | ||||
|         { | ||||
|             m.onMotion(type, movement); | ||||
|         } | ||||
|  | @ -27,7 +27,7 @@ public class ClientPlayerEntityMixin | |||
|     @Inject(method = "tick", at = @At(value = "HEAD"), cancellable = true) | ||||
|     public void onTick(CallbackInfo ci)  | ||||
|     { | ||||
|         for (Module_ m : ModuleManager.INSTANCE.getEnabledModules())  | ||||
|         for (Module m : ModuleManager.INSTANCE.getEnabledModules())  | ||||
|         { | ||||
| 			if (MinecraftClient.getInstance().player != null) m.tick(); | ||||
| 		} | ||||
|  | @ -36,7 +36,7 @@ public class ClientPlayerEntityMixin | |||
|     @Inject(method = "init", at = @At(value = "TAIL"), cancellable = true) | ||||
|     public void onInit(CallbackInfo ci)  | ||||
|     { | ||||
|         for (Module_ m : ModuleManager.INSTANCE.getEnabledModules())  | ||||
|         for (Module m : ModuleManager.INSTANCE.getEnabledModules())  | ||||
|         { | ||||
| 			m.onEnable(); | ||||
| 		} | ||||
|  |  | |||
|  | @ -8,6 +8,8 @@ import org.spongepowered.asm.mixin.injection.At; | |||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen; | ||||
| import net.minecraft.client.Keyboard; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
|  | @ -17,7 +19,18 @@ public abstract class KeyboardMixin { | |||
|     @Shadow @Final private MinecraftClient client; | ||||
| 
 | ||||
| 	@Inject(method = "onKey", at = @At("HEAD"), cancellable = true) | ||||
|     public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info) { | ||||
|     public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info)  | ||||
|     { | ||||
|         System.out.println("Keyboard event occured: " + java.awt.event.KeyEvent.getKeyText(key) + " (keycode "+key+")"); | ||||
|         if (key == GLFW.GLFW_KEY_RIGHT_ALT) MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE); | ||||
|         for (Module m : ModuleManager.INSTANCE.modules) | ||||
|         { | ||||
|             System.out.println("checking against module:" + m.name); | ||||
|             if (key == m.keybind.value) | ||||
|             { | ||||
|                 System.out.println("yup, we gotem :3"); | ||||
|                 m.toggle(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -10,7 +10,7 @@ import net.minecraft.client.MinecraftClient; | |||
| import net.minecraft.entity.MovementType; | ||||
| import net.minecraft.util.math.Vec3d; | ||||
| 
 | ||||
| public abstract class Module_  | ||||
| public abstract class Module  | ||||
| { | ||||
|     protected static MinecraftClient mc = MinecraftClient.getInstance(); | ||||
|     public String name; | ||||
|  | @ -22,7 +22,7 @@ public abstract class Module_ | |||
|     public BooleanSetting showInModulesList = new BooleanSetting("Show in Modules List", true); | ||||
|     public KeycodeSetting keybind = new KeycodeSetting("Keybind", 0); | ||||
| 
 | ||||
|     public Module_(String name, String description, Category category) | ||||
|     public Module(String name, String description, Category category) | ||||
|     { | ||||
|         this.name = name; | ||||
|         this.description = description; | ||||
|  | @ -46,4 +46,24 @@ public abstract class Module_ | |||
| 			onDisable(); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|     public Setting getSettingByName(String settingName) | ||||
|     { | ||||
|         for(Setting setting : settings)  | ||||
| 		{ | ||||
| 			if ((setting.name.trim().equalsIgnoreCase(settingName))) | ||||
| 			{ | ||||
| 				return setting; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
|     } | ||||
| 
 | ||||
|     protected void addSettings(Setting... settings) | ||||
|     { | ||||
|         for(Setting setting : settings) | ||||
|         { | ||||
|             this.settings.add(setting); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -7,7 +7,7 @@ import me.kawaiizenbo.moonlight.module.modules.*; | |||
| public class ModuleManager  | ||||
| { | ||||
|     public static ModuleManager INSTANCE = new ModuleManager(); | ||||
|     public ArrayList<Module_> modules = new ArrayList<>(); | ||||
|     public ArrayList<Module> modules = new ArrayList<>(); | ||||
| 
 | ||||
|     public ModuleManager() | ||||
|     { | ||||
|  | @ -18,25 +18,21 @@ public class ModuleManager | |||
| 			new Step(), | ||||
| 			new Fullbright(), | ||||
| 			new Speed(), | ||||
| 			new ModulesList() | ||||
| 			new ModulesList(), | ||||
| 			new TestModule() | ||||
| 		); | ||||
|     } | ||||
| 
 | ||||
|     public void registerModule(Module_ module)  | ||||
| 	{ | ||||
| 		modules.add(module); | ||||
| 	} | ||||
| 	 | ||||
| 	public void registerModules(Module_... modules)  | ||||
| 	private void registerModules(Module... modules)  | ||||
| 	{ | ||||
| 		for (Module_ module : modules) { | ||||
| 		for (Module module : modules) { | ||||
| 			this.modules.add(module); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|     public Module_ getModuleByName(String moduleName)  | ||||
|     public Module getModuleByName(String moduleName)  | ||||
| 	{ | ||||
| 		for(Module_ module : modules)  | ||||
| 		for(Module module : modules)  | ||||
| 		{ | ||||
| 			if ((module.name.trim().equalsIgnoreCase(moduleName))) | ||||
| 			{ | ||||
|  | @ -46,10 +42,10 @@ public class ModuleManager | |||
| 		return null; | ||||
| 	} | ||||
| 
 | ||||
| 	public ArrayList<Module_> getModulesByCategory(Category category) | ||||
| 	public ArrayList<Module> getModulesByCategory(Category category) | ||||
| 	{ | ||||
| 		ArrayList<Module_> returnedModules = new ArrayList<>(); | ||||
| 		for(Module_ module : modules)  | ||||
| 		ArrayList<Module> returnedModules = new ArrayList<>(); | ||||
| 		for(Module module : modules)  | ||||
| 		{ | ||||
| 			if (module.category == category)  | ||||
| 			{ | ||||
|  | @ -59,10 +55,10 @@ public class ModuleManager | |||
| 		return returnedModules; | ||||
| 	} | ||||
| 
 | ||||
| 	public ArrayList<Module_> getEnabledModules()  | ||||
| 	public ArrayList<Module> getEnabledModules()  | ||||
| 	{ | ||||
| 		ArrayList<Module_> enabledModules = new ArrayList<>(); | ||||
| 		for (Module_ module : modules)  | ||||
| 		ArrayList<Module> enabledModules = new ArrayList<>(); | ||||
| 		for (Module module : modules)  | ||||
| 		{ | ||||
| 			if (!module.enabled) | ||||
| 				continue; | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| package me.kawaiizenbo.moonlight.module.modules; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| 
 | ||||
| public class Fly extends Module_  | ||||
| public class Fly extends Module  | ||||
| { | ||||
| 
 | ||||
|     public Fly()  | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| package me.kawaiizenbo.moonlight.module.modules; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.util.ISimpleOption; | ||||
| 
 | ||||
| public class Fullbright extends Module_  | ||||
| public class Fullbright extends Module  | ||||
| { | ||||
|     public Fullbright() | ||||
|     { | ||||
|  |  | |||
|  | @ -2,13 +2,13 @@ package me.kawaiizenbo.moonlight.module.modules; | |||
| 
 | ||||
| import me.kawaiizenbo.moonlight.Moonlight; | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import me.kawaiizenbo.moonlight.ui.HUDOverlay; | ||||
| import me.kawaiizenbo.moonlight.util.ColorUtils; | ||||
| 
 | ||||
| public class HUDModule extends Module_  | ||||
| public class HUDModule extends Module  | ||||
| { | ||||
|     public BooleanSetting clientTag = new BooleanSetting("Client Tag", true); | ||||
|     public DoubleSetting r = new DoubleSetting("Red", 0x55, 0, 255, 0); | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| package me.kawaiizenbo.moonlight.module.modules; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| 
 | ||||
| public class ModulesList extends Module_  | ||||
| public class ModulesList extends Module  | ||||
| { | ||||
|     public ModulesList() | ||||
|     { | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| package me.kawaiizenbo.moonlight.module.modules; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; | ||||
| 
 | ||||
| public class NoFall extends Module_ | ||||
| public class NoFall extends Module | ||||
| { | ||||
|     public NoFall() | ||||
|     { | ||||
|  |  | |||
|  | @ -1,12 +1,12 @@ | |||
| package me.kawaiizenbo.moonlight.module.modules; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import net.minecraft.entity.MovementType; | ||||
| import net.minecraft.util.math.Vec3d; | ||||
| 
 | ||||
| public class Speed extends Module_  | ||||
| public class Speed extends Module  | ||||
| { | ||||
|     DoubleSetting speed = new DoubleSetting("Speed", 2, 0.1, 10, 1); | ||||
|     public Speed()  | ||||
|  | @ -17,6 +17,7 @@ public class Speed extends Module_ | |||
|     @Override | ||||
|     public void onMotion(MovementType type, Vec3d movement) | ||||
|     { | ||||
|         // ??? | ||||
|         mc.player.addVelocity(movement); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| package me.kawaiizenbo.moonlight.module.modules; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| 
 | ||||
| public class Step extends Module_ | ||||
| public class Step extends Module | ||||
| { | ||||
|     DoubleSetting stepHeight = new DoubleSetting("Height", 1, 1, 10, 0); | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,20 @@ | |||
| package me.kawaiizenbo.moonlight.module.modules; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.StringSetting; | ||||
| 
 | ||||
| public class TestModule extends Module  | ||||
| { | ||||
|     public BooleanSetting bs = new BooleanSetting("BooleanSetting", false); | ||||
|     public DoubleSetting ds = new DoubleSetting("DoubleSetting", 1, 0, 10, 10); | ||||
|     public StringSetting ss = new StringSetting("StringSetting", "string"); | ||||
| 
 | ||||
|     public TestModule() | ||||
|     { | ||||
|         super("Test Module", "Used for testing module features.", Category.WORLD); | ||||
|         addSettings(bs, ds, ss); | ||||
|     } | ||||
| } | ||||
|  | @ -1,5 +1,9 @@ | |||
| package me.kawaiizenbo.moonlight.module.settings; | ||||
| 
 | ||||
| import net.minecraft.client.font.TextRenderer; | ||||
| import net.minecraft.client.gui.DrawContext; | ||||
| import net.minecraft.text.Text; | ||||
| 
 | ||||
| public class StringSetting extends Setting | ||||
| { | ||||
|     public String value; | ||||
|  | @ -9,4 +13,14 @@ public class StringSetting extends Setting | |||
|         this.name = name; | ||||
|         this.value = value; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer)  | ||||
|     { | ||||
|         super.render(drawContext, x, y, mouseX, mouseY, textRenderer); | ||||
|         drawContext.drawTextWithShadow(textRenderer, Text.literal(name), x+2, y+4, 0xFFFFFF); | ||||
|         int twidth = textRenderer.getWidth(value); | ||||
|         drawContext.drawTextWithShadow(textRenderer, value, x+190-twidth, y+4, 0xFFFFFF); | ||||
|         drawContext.drawTextWithShadow(textRenderer, "WIP, please use the .setting command", x+2, y+14, 0xFFFFFF); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import java.util.ArrayList; | |||
| 
 | ||||
| import me.kawaiizenbo.moonlight.Moonlight; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| 
 | ||||
| import net.minecraft.client.gui.DrawContext; | ||||
|  | @ -13,7 +13,7 @@ public class ModulesListOverlay | |||
| { | ||||
|     public static ModulesListOverlay INSTANCE = new ModulesListOverlay(); | ||||
|     private MinecraftClient mc = MinecraftClient.getInstance(); | ||||
|     private ArrayList<Module_> enabledModules = ModuleManager.INSTANCE.getEnabledModules(); | ||||
|     private ArrayList<Module> enabledModules = ModuleManager.INSTANCE.getEnabledModules(); | ||||
| 
 | ||||
|     public void render(DrawContext drawContext, int scaledWidth, int scaledHeight) | ||||
|     { | ||||
|  | @ -21,7 +21,7 @@ public class ModulesListOverlay | |||
|         if (mc.getDebugHud().shouldShowDebugHud()) return; | ||||
|          | ||||
|         int yOffset = 0; | ||||
|         for (Module_ m : enabledModules) | ||||
|         for (Module m : enabledModules) | ||||
|         { | ||||
|             if (!m.showInModulesList.value) continue; | ||||
|             int nameWidth = mc.textRenderer.getWidth(m.name); | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import java.util.ArrayList; | |||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import net.minecraft.client.font.TextRenderer; | ||||
| import net.minecraft.client.gui.DrawContext; | ||||
| 
 | ||||
|  | @ -24,7 +24,7 @@ public class CategoryPane | |||
|         this.y = initialY; | ||||
|         this.collapsed = collapsed; | ||||
|         moduleButtons = new ArrayList<ModuleButton>(); | ||||
|         for (Module_ m : ModuleManager.INSTANCE.getModulesByCategory(category)) | ||||
|         for (Module m : ModuleManager.INSTANCE.getModulesByCategory(category)) | ||||
|         { | ||||
|             moduleButtons.add(new ModuleButton(m)); | ||||
|         } | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ public class KeybindScreen extends Screen | |||
| 	public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)  | ||||
| 	{ | ||||
| 		this.renderBackground(drawContext, mouseX, mouseY, delta); | ||||
|         drawContext.drawCenteredTextWithShadow(textRenderer, "Press any key", width/2, height/2, 0xFFFFFFFF); | ||||
|         drawContext.drawCenteredTextWithShadow(textRenderer, "Press any key (may not work, use .setting instead)", width/2, height/2, 0xFFFFFFFF); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|  |  | |||
|  | @ -1,17 +1,17 @@ | |||
| package me.kawaiizenbo.moonlight.ui.clickgui; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.Moonlight; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| import net.minecraft.client.font.TextRenderer; | ||||
| import net.minecraft.client.gui.DrawContext; | ||||
| 
 | ||||
| public class ModuleButton  | ||||
| { | ||||
|     public Module_ module; | ||||
|     public Module module; | ||||
| 	public int x, y, width, height = 0; | ||||
| 	 | ||||
| 	public ModuleButton(Module_ module)  | ||||
| 	public ModuleButton(Module module)  | ||||
|     { | ||||
| 		this.module = module; | ||||
| 		this.width = 92; | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| package me.kawaiizenbo.moonlight.ui.clickgui; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.Module; | ||||
| import me.kawaiizenbo.moonlight.module.settings.Setting; | ||||
| import me.kawaiizenbo.moonlight.ui.TextButton; | ||||
| import me.kawaiizenbo.moonlight.util.ColorUtils; | ||||
|  | @ -10,13 +10,13 @@ import net.minecraft.text.Text; | |||
| 
 | ||||
| public class SettingsScreen extends Screen  | ||||
| { | ||||
|     private Module_ module; | ||||
|     private Module module; | ||||
|     private TextButton backButton; | ||||
| 
 | ||||
|     boolean dragging = false; | ||||
|     int startX, startY, x = 4, y = 4, windowWidth = 224, windowHeight = 192; | ||||
| 
 | ||||
|     public SettingsScreen(Module_ module)  | ||||
|     public SettingsScreen(Module module)  | ||||
|     { | ||||
|         super(Text.literal("Settings")); | ||||
|         this.module = module; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 kawaiizenbo
						kawaiizenbo